Пример #1
0
        //执行
        public void End()
        {
            if (CurHandle != null)
            {
                CurHandle.OnStart(this);

                //直接设置到结束的,并且需要用当前值作开始值的,这里得计算下当前值,不然下面的Update()计算出来的值可能不正确
                if (m_isUseNowStart && !m_isCatchUseNowStart)
                {
                    if (!ingore)
                    {
                        CurHandle.OnUseNowStart(this);
                    }
                    m_isCatchUseNowStart = true;
                }
                if (!ingore)
                {
                    CurHandle.Update(this, m_animationCurve.Evaluate(1f), false);
                }
                EditorUtil.SetDirty(m_go);
            }

            Clear();
            if (m_onEnd != null)
            {
                m_onEnd();
            }
        }
Пример #2
0
        //开始,如果结束那么返回true
        public void Start()
        {
            Clear();
            m_beginTime = Now;

            HandleSequence seqHandle = null;

            if (CurHandle != null)
            {
                if (_type == Type.sequence)
                {
                    seqHandle = CurHandle as HandleSequence;
                    seqHandle.Start(this);
                }
                else
                {
                    CurHandle.OnStart(this);
                }
            }

            if (CurHandle != null && m_isUseNowStart)
            {
                if (!ingore)
                {
                    CurHandle.OnUseNowStart(this);
                }
                m_isCatchUseNowStart = true;
            }

            if (IsEnd)
            {
                End();
            }
        }
Пример #3
0
        //设置到某一帧
        public void SetTime(float time, bool ingoreDelay = false, bool stopIfPlay = false, bool endIfOverEnd = false)
        {
            if (ingoreDelay == false && time < m_delay)//还在delay中的话不用做
            {
                return;
            }
            bool isPlaying = IsPlaying;

            CurTime = ingoreDelay ? time + m_delay : time;
            bool isOverEnd = IsOverEnd;

            if (endIfOverEnd && isOverEnd)//已经结束的话,看是不是需要设置为结束
            {
                if (!ingore)
                {
                    CurHandle.Update(this, m_animationCurve.Evaluate(1f), stopIfPlay);
                }
                EditorUtil.SetDirty(m_go);                                  //编辑器下没有运行的时候可能不会刷新,这里手动调用下
            }
            else if (!isOverEnd && CurTime >= m_delay && CurHandle != null) //没有结束而且超过延迟
            {
                if (!ingore)
                {
                    CurHandle.Update(this, m_animationCurve.Evaluate(CurFactor), stopIfPlay);
                }
                EditorUtil.SetDirty(m_go);//编辑器下没有运行的时候可能不会刷新,这里手动调用下
            }


            if (!isPlaying || stopIfPlay)
            {
                Clear();
            }
        }
Пример #4
0
        public void SetType(Type type)
        {
            m_type = type;
#if UNITY_EDITOR
            if (CurHandle != null && Application.isEditor && !UnityEditor.EditorApplication.isPlaying)
            {
                CurHandle.OnReset(this);
            }
#endif
        }
Пример #5
0
    public void SetFollow(Transform follow, bool reset = false)
    {
        if (follow == null)
        {
            Debuger.LogError("不能设一个空的跟随者进来");
            return;
        }

        m_follow = follow;

        //重置下镜头和渐变速度
        if (reset && CurHandle != null)
        {
            CurHandle.Reset();
            ResetVelocity();
        }
    }
Пример #6
0
        //设置到某一比例,注意如果这里是循环或者乒乓的话可能会使次数减少,最好用SetTime替代
        public void SetFactor(float factor, bool stopIfPlay = false)
        {
            bool isPlaying = IsPlaying;

            CurFactor = factor;
            if (CurHandle != null)
            {
                if (!ingore)
                {
                    CurHandle.Update(this, m_animationCurve.Evaluate(factor), stopIfPlay);
                }
            }

            if (!isPlaying || stopIfPlay)
            {
                Clear();
            }
        }
Пример #7
0
        //绘制ui
        public void OnGUI(Component comp, System.Action <WndType, object> onOpenWnd, bool setGoWhenChangeType = true)
        {
            //类型
            GUI.changed = false;
            int type = UnityEditor.EditorGUILayout.Popup("类型", (int)m_type, TypeName);

            if (GUI.changed)
            {
                EditorUtil.RegisterUndo("Handle Change", comp);
                if (m_go == null && setGoWhenChangeType)
                {
                    m_go = comp.gameObject;
                }
                SetType((Type)type);
                EditorUtil.SetDirty(comp);
            }

            //具体内容
            if (CurHandle != null)
            {
                CurHandle.OnDrawGo(comp, this);
                CurHandle.OnDraw(comp, this, onOpenWnd);
            }
        }
Пример #8
0
        //更新
        public void Update()
        {
            if (!IsPlaying)
            {
                return;
            }

            //Debuger.LogError(string.Format("now:{0} curTime:{1}",Now,CurTime));
            if (IsEnd)
            {
                End();
            }
            else
            {
                if (CurTime >= m_delay && CurHandle != null)
                {
                    if (!ingore)
                    {
                        CurHandle.Update(this, m_animationCurve.Evaluate(CurFactor), false);
                    }
                    EditorUtil.SetDirty(m_go);
                }
            }
        }