Esempio n. 1
0
    public void PlayAnimation(string animationName, AnimationOrTween.Direction type, UnityAction action = null)
    {
        ActiveAnimation activeAnimation = ActiveAnimation.Play(panelAnimation, animationName, type);

        m_Action = action;
        EventDelegate.Add(activeAnimation.onFinished, () => OnAnimation(activeAnimation), true);
    }
Esempio n. 2
0
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(120f);
        UIPlayAnimation pa = target as UIPlayAnimation;

        GUILayout.Space(6f);

        GUI.changed = false;

        EditorGUI.BeginDisabledGroup(pa.target);
        Animator animator = (Animator)EditorGUILayout.ObjectField("Animator", pa.animator, typeof(Animator), true);

        EditorGUI.EndDisabledGroup();
        EditorGUI.BeginDisabledGroup(pa.animator);
        Animation anim = (Animation)EditorGUILayout.ObjectField("Animation", pa.target, typeof(Animation), true);

        EditorGUI.EndDisabledGroup();
        EditorGUI.BeginDisabledGroup(anim == null && animator == null);
        string clipName = EditorGUILayout.TextField("State Name", pa.clipName);

        AnimationOrTween.Trigger trigger =
            (AnimationOrTween.Trigger)EditorGUILayout.EnumPopup("Trigger condition", pa.trigger);

        EditorGUI.BeginDisabledGroup(animator != null && !string.IsNullOrEmpty(clipName));
        AnimationOrTween.Direction dir =
            (AnimationOrTween.Direction)EditorGUILayout.EnumPopup("Play direction", pa.playDirection);
        EditorGUI.EndDisabledGroup();

        SelectedObject so    = pa.clearSelection ? SelectedObject.SetToNothing : SelectedObject.KeepCurrent;
        bool           clear = (SelectedObject)EditorGUILayout.EnumPopup("Selected object", so) == SelectedObject.SetToNothing;

        AnimationOrTween.EnableCondition enab =
            (AnimationOrTween.EnableCondition)EditorGUILayout.EnumPopup("If disabled on start", pa.ifDisabledOnPlay);
        ResetOnPlay rs    = pa.resetOnPlay ? ResetOnPlay.RestartAnimation : ResetOnPlay.ContinueFromCurrent;
        bool        reset = (ResetOnPlay)EditorGUILayout.EnumPopup("On activation", rs) == ResetOnPlay.RestartAnimation;

        AnimationOrTween.DisableCondition dis =
            (AnimationOrTween.DisableCondition)EditorGUILayout.EnumPopup("When finished", pa.disableWhenFinished);
        EditorGUI.EndDisabledGroup();

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("PlayAnimation Change", pa);
            pa.target              = anim;
            pa.animator            = animator;
            pa.clipName            = clipName;
            pa.trigger             = trigger;
            pa.playDirection       = dir;
            pa.clearSelection      = clear;
            pa.ifDisabledOnPlay    = enab;
            pa.resetOnPlay         = reset;
            pa.disableWhenFinished = dis;
            NGUITools.SetDirty(pa);
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawEvents("On Finished", pa, pa.onFinished);
    }
Esempio n. 3
0
 /// <summary>
 /// 播放动画
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="forward"></param>
 public void PlayTween(AnimationOrTween.Direction direction, bool forward = true)
 {
     UIPlayTween[] tweens = CacheTransform.GetComponents <UIPlayTween>();
     if (null != tweens)
     {
         foreach (UIPlayTween tween in tweens)
         {
             tween.playDirection = direction;
             tween.Play(forward);
         }
     }
 }
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(120f);
        UIPlayTween tw = target as UIPlayTween;

        GUILayout.Space(6f);

        GUI.changed = false;
        GameObject tt = (GameObject)EditorGUILayout.ObjectField("Tween Target", tw.tweenTarget, typeof(GameObject), true);

        var ss       = tw.startState;
        var inc      = EditorGUILayout.Toggle("Include Children", tw.includeChildren);
        var setState = EditorGUILayout.Toggle("Start State", tw.setState);

        if (setState)
        {
            ss = EditorGUILayout.FloatField("   value", ss);
        }
        var group = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(160f));

        AnimationOrTween.Trigger         trigger = (AnimationOrTween.Trigger)EditorGUILayout.EnumPopup("Trigger condition", tw.trigger);
        AnimationOrTween.Direction       dir     = (AnimationOrTween.Direction)EditorGUILayout.EnumPopup("Play direction", tw.playDirection);
        AnimationOrTween.EnableCondition enab    = (AnimationOrTween.EnableCondition)EditorGUILayout.EnumPopup("If target is disabled", tw.ifDisabledOnPlay);
        ResetOnPlay rs    = tw.resetOnPlay ? ResetOnPlay.RestartTween : (tw.resetIfDisabled ? ResetOnPlay.RestartIfNotPlaying : ResetOnPlay.ContinueFromCurrent);
        ResetOnPlay reset = (ResetOnPlay)EditorGUILayout.EnumPopup("On activation", rs);

        AnimationOrTween.DisableCondition dis = (AnimationOrTween.DisableCondition)EditorGUILayout.EnumPopup("When finished", tw.disableWhenFinished);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Tween Change", tw);
            tw.tweenTarget         = tt;
            tw.tweenGroup          = group;
            tw.setState            = setState;
            tw.startState          = ss;
            tw.includeChildren     = inc;
            tw.trigger             = trigger;
            tw.playDirection       = dir;
            tw.ifDisabledOnPlay    = enab;
            tw.resetOnPlay         = (reset == ResetOnPlay.RestartTween);
            tw.resetIfDisabled     = (reset == ResetOnPlay.RestartIfNotPlaying);
            tw.disableWhenFinished = dis;
            NGUITools.SetDirty(tw);
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
    }
Esempio n. 5
0
    static int get_direction(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UITweener obj = (UITweener)o;
            AnimationOrTween.Direction ret = obj.direction;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index direction on a nil value" : e.Message));
        }
    }
Esempio n. 6
0
    static int set_playDirection(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIPlayTween obj = (UIPlayTween)o;
            AnimationOrTween.Direction arg0 = (AnimationOrTween.Direction)ToLua.CheckObject(L, 2, typeof(AnimationOrTween.Direction));
            obj.playDirection = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index playDirection on a nil value"));
        }
    }
Esempio n. 7
0
    static int get_playDirection(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UIPlayTween obj = (UIPlayTween)o;
            AnimationOrTween.Direction ret = obj.playDirection;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index playDirection on a nil value"));
        }
    }
Esempio n. 8
0
 /// <summary>
 /// 播放动画
 /// </summary>
 /// <param name="direction"></param>
 /// <param name="forward"></param>
 public void PlayTween(AnimationOrTween.Direction direction, bool forward = true)
 {
     UIPlayTween[] tweens = CacheTransform.GetComponents <UIPlayTween>();
     if (null != tweens)
     {
         Vector3 pos = CacheTransform.transform.localPosition;
         foreach (UIPlayTween tween in tweens)
         {
             tween.playDirection = direction;
             if (tween.onFinished.Count <= 0)
             {
                 tween.onFinished.Add(new EventDelegate(() =>
                 {
                     CacheTransform.localPosition = pos;
                 }));
             }
             tween.Play(forward);
         }
     }
 }
Esempio n. 9
0
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(120f);
        UIPlayAnimation pa = target as UIPlayAnimation;

        GUILayout.Space(6f);

        GUI.changed = false;
        Animation anim = (Animation)EditorGUILayout.ObjectField("Target", pa.target, typeof(Animation), true);

        string clipName = EditorGUILayout.TextField("Clip Name", pa.clipName);

        AnimationOrTween.Trigger   trigger = (AnimationOrTween.Trigger)EditorGUILayout.EnumPopup("Trigger condition", pa.trigger);
        AnimationOrTween.Direction dir     = (AnimationOrTween.Direction)EditorGUILayout.EnumPopup("Play direction", pa.playDirection);
        SelectedObject             so      = pa.clearSelection ? SelectedObject.SetToNothing : SelectedObject.KeepCurrent;
        bool clear = (SelectedObject)EditorGUILayout.EnumPopup("Selected object", so) == SelectedObject.SetToNothing;

        AnimationOrTween.EnableCondition enab = (AnimationOrTween.EnableCondition)EditorGUILayout.EnumPopup("If disabled on start", pa.ifDisabledOnPlay);
        ResetOnPlay rs    = pa.resetOnPlay ? ResetOnPlay.StartFromBeginning : ResetOnPlay.Continue;
        bool        reset = (ResetOnPlay)EditorGUILayout.EnumPopup("If already playing", rs) == ResetOnPlay.StartFromBeginning;

        AnimationOrTween.DisableCondition dis = (AnimationOrTween.DisableCondition)EditorGUILayout.EnumPopup("When finished", pa.disableWhenFinished);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("PlayAnimation Change", pa);
            pa.target              = anim;
            pa.clipName            = clipName;
            pa.trigger             = trigger;
            pa.playDirection       = dir;
            pa.clearSelection      = clear;
            pa.ifDisabledOnPlay    = enab;
            pa.resetOnPlay         = reset;
            pa.disableWhenFinished = dis;
            UnityEditor.EditorUtility.SetDirty(pa);
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawEvents("On Finished", pa, pa.onFinished);
    }
Esempio n. 10
0
    /// <summary>
    /// 播放动画片段
    /// </summary>
    /// <param name="anim"></param>
    /// <param name="name"></param>
    /// <param name="dir"></param>
    /// <returns></returns>
    public static AnimationState PlayAnimation(Animation anim, string name, AnimationOrTween.Direction dir)
    {
        var state = anim[name];

        if (state)
        {
            float speed = Mathf.Abs(state.speed);
            state.speed = speed * (int)dir;
            if (dir == AnimationOrTween.Direction.Reverse && state.time == 0f)
            {
                state.time = state.length;
            }
            else if (dir == AnimationOrTween.Direction.Forward && state.time == state.length)
            {
                state.time = 0f;
            }
            //Debug.Log(string.Format(" speed {0},dir ={1},time = {2},length={3}",state.speed,dir,state.time,state.length));
            anim.Play(name);
            anim.Sample();
        }
        return(state);
    }
Esempio n. 11
0
    public override void OnInspectorGUI()
    {
        NGUIEditorTools.SetLabelWidth(120f);
        UIPlayTween tw = target as UIPlayTween;

        GUILayout.Space(6f);

        GUI.changed = false;
        GameObject tt = (GameObject)EditorGUILayout.ObjectField("Tween Target", tw.tweenTarget, typeof(GameObject), true);

        bool inc   = EditorGUILayout.Toggle("Include Children", tw.includeChildren);
        int  group = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(160f));

        AnimationOrTween.Trigger         trigger = (AnimationOrTween.Trigger)EditorGUILayout.EnumPopup("Trigger condition", tw.trigger);
        AnimationOrTween.Direction       dir     = (AnimationOrTween.Direction)EditorGUILayout.EnumPopup("Play direction", tw.playDirection);
        AnimationOrTween.EnableCondition enab    = (AnimationOrTween.EnableCondition)EditorGUILayout.EnumPopup("If disabled on start", tw.ifDisabledOnPlay);
        ResetOnPlay rs    = tw.resetOnPlay ? ResetOnPlay.StartFromBeginning : ResetOnPlay.Continue;
        bool        reset = (ResetOnPlay)EditorGUILayout.EnumPopup("If already playing", rs) == ResetOnPlay.StartFromBeginning;

        AnimationOrTween.DisableCondition dis = (AnimationOrTween.DisableCondition)EditorGUILayout.EnumPopup("When finished", tw.disableWhenFinished);

        if (GUI.changed)
        {
            NGUIEditorTools.RegisterUndo("Tween Change", tw);
            tw.tweenTarget         = tt;
            tw.tweenGroup          = group;
            tw.includeChildren     = inc;
            tw.trigger             = trigger;
            tw.playDirection       = dir;
            tw.ifDisabledOnPlay    = enab;
            tw.resetOnPlay         = reset;
            tw.disableWhenFinished = dis;
            UnityEditor.EditorUtility.SetDirty(tw);
        }

        NGUIEditorTools.SetLabelWidth(80f);
        NGUIEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
    }