So then, the safest thing to do is to not write your own InternalAPIBridge, but rather “borrow” the one from the 2D Commons package.
Create an Assembly Definition Reference inside a folder called InternalBridge (or anything really, but do it inside a specific folder for safety). Now, reference the InternalBridgeDef under Packages > 2D Common > Runtime / Editor > InternalBridge,
Add a script called AssemblyInfo containing the following:
using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("My.Cool.Assembly")]
And a script called InternalEngineBridge in which you safely expose the internals you require. NOTE: you HAVE to put it under a namespace to avoid naming conflicts! You could also use a different name but that could break if Unity adds scripts themselves, so using a namespace is safest.
using UnityEngine;
namespace UnityClock
{
internal static class InternalEngineBridge
{
// Note how NumericFieldDraggerUtility is an internal Unity class.
public static float NiceDelta(Vector2 deviceDelta, float acceleration) =>
NumericFieldDraggerUtility.NiceDelta(deviceDelta, acceleration);
}
}
Now all that’s left is to reference the InternalBridgeDef from the 2D Commons package inside the assembly where you want to use it.
And presto!
public override void ApplyInputDeviceDelta(Vector3 delta, DeltaSpeed speed, TimeSpan startValue)
{
InternalEngineBridge.NiceDelta(delta, 0f);
}
This is completely safe, since you can just keep adding Assembly Definition References! You also make sure that you expose to the things that need it, and nothing else. As the magicians say, “you finish clean”. The only thing you need is to have the 2D Commons package installed - dumb, but I’ll take it!