Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.34k stars 351 forks source link

Can onStart in Tween be public? #624

Open bmielnicki opened 1 year ago

bmielnicki commented 1 year ago

Can onStart in Tween be public? Is there good reason why this is not the case? It would seem consistent this way with other tween callbacks. Currently line with public field of onStart in tween.cs is commented (and in ABSSequentiable field is not public) : // public TweenCallback onStart; // (in ABSSequentiable) When the tween is set in a PLAY state the first time, AFTER any eventual delay While it would be nice to have this it is not absolutely necessary as I've managed to work around this in a bit hacky way:

public static TweenCallback GetOnStart(this Tween tween)
    {
        return GetInstanceField(typeof(Tween), tween, "onStart") as TweenCallback;
    }
internal static object GetInstanceField(Type type, object instance, string fieldName)
    {
        BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
            | BindingFlags.Static;
        FieldInfo field = type.GetField(fieldName, bindFlags);
        return field.GetValue(instance);
    }
yasirkula commented 11 months ago

+1