dotween icon indicating copy to clipboard operation
dotween copied to clipboard

Can onStart in Tween be public?

Open bmielnicki opened this issue 2 years ago • 1 comments

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);
    }

bmielnicki avatar Feb 19 '23 20:02 bmielnicki

+1

yasirkula avatar Nov 06 '23 15:11 yasirkula