_OnUpdate() public method

public _OnUpdate ( float delta ) : void
delta float
return void
Ejemplo n.º 1
0
 void _OnUpdate()
 {
     if (bPlay)
     {
         DateTime _now  = DateTime.Now;
         float    delta = (float)(_now - last).TotalSeconds;
         last = _now;
         con._OnUpdate(delta);
         // Repaint();
     }
 }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if (con == null)
        {
            EditorApplication.update += this._OnUpdate;
        }

        con = target as FB.PosePlus.AniPlayer;

        if (con == null)
        {
            return;
        }
        if (con.Clips == null)
        {
            con.Clips = new List <FB.PosePlus.AniClip>();
        }


        GUILayout.BeginHorizontal();
        if (GUILayout.Button("向左"))
        {
            con.SetDir(-1);
        }

        GUILayout.Space(10);
        if (GUILayout.Button("向右"))

        {
            con.SetDir(1);
        }

        GUILayout.EndHorizontal();
        {
            foreach (var c in con.Clips)
            {
                if (c == null)
                {
                    continue;
                }
                GUILayout.BeginHorizontal();
                if (c.frames == null)
                {
                    continue;
                }
                GUILayout.Label(c.name + "(" + (c.loop ? "loop" : "") + c.frames.Count + ")");
                if (GUILayout.Button("play", GUILayout.Width(150)))
                {
                    con.Play(c.name);
                    //con.Play();
                    bPlay = true;
                    //return;
                    //CloneAni(c);
                }

                if (GUILayout.Button("cross 0.2", GUILayout.Width(150)))
                {
                    con.Play(c.name);

                    bPlay = true;
                }


                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Space(40);
                GUILayout.BeginVertical();
                foreach (var sub in c.subclips)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(sub.name + (sub.loop ? "[Loop]" : "") + "(" + (sub.endframe - sub.startframe + 1) +
                                    ")");
                    if (GUILayout.Button("play", GUILayout.Width(100)))
                    {
                        con.Play(c.name, sub.name);
                        bPlay = true;
                    }

                    if (GUILayout.Button("cross 0.2", GUILayout.Width(100)))
                    {
                        con.Play(c.name, sub.name);

                        bPlay = true;
                    }

                    GUILayout.EndHorizontal();
                }

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        }
        {
            //动画控制
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("stopAni", GUILayout.Width(150)))
            {
                bPlay = false;
                //con.Stop();
            }

            if (GUILayout.Button("AddTime", GUILayout.Width(150)))
            {
                con._OnUpdate(0.04f);
            }

            GUILayout.EndHorizontal();
        }
        {
            if (GUILayout.Button("显示/隐藏Box"))
            {
                var ani = target as FB.PosePlus.AniPlayer;
                ani.isShowBoxLine = !ani.isShowBoxLine;

                var trans = con.transform.Find("_boxes");
                if (trans == null)
                {
                    Debug.LogError("没有找到_boxes");
                }
                foreach (Transform t in trans)
                {
                    var o = t.gameObject;

                    if (ani.isShowBoxLine)
                    {
                        if (!o.GetComponent <Collider_Vis>())
                        {
                            o.AddComponent <Collider_Vis>();
                        }
                        if (!o.GetComponent <LineRenderer>())
                        {
                            o.AddComponent <LineRenderer>();
                        }
                        if (!o.GetComponent <MeshRenderer>())
                        {
                            o.AddComponent <MeshRenderer>();
                        }
                        ani.SetBoxColor(o);

                        //o.GetComponent<Collider_Vis>().updateColl();
                    }
                    else
                    {
                        if (o.GetComponent <Collider_Vis>())
                        {
                            DestroyImmediate(o.GetComponent <Collider_Vis>());
                        }
                        if (o.GetComponent <LineRenderer>())
                        {
                            DestroyImmediate(o.GetComponent <LineRenderer>());
                        }
                        if (o.GetComponent <MeshRenderer>())
                        {
                            DestroyImmediate(o.GetComponent <MeshRenderer>());
                        }
                    }
                }

                var _trans = con.transform.Find("_dotes");
                if (trans == null)
                {
                    Debug.LogError("没有找到_dotes");
                }
                foreach (Transform t in _trans)
                {
                    var o = t.gameObject;

                    if (ani.isShowBoxLine)
                    {
/*                        if (!o.GetComponent<LineRenderer>())*/
                        o.GetComponent <LineRenderer>().enabled = true;
                    }
                    else
                    {
/*                        if (o.GetComponent<LineRenderer>())*/
                        o.GetComponent <LineRenderer>().enabled = false;
                    }
                }
            }

            if (GUILayout.Button("匹配所有动画的骨骼"))
            {
                var win = EditorWindow.GetWindow <EditorWindow_FBAniCheck>("动作检测");
                win.Show(target as AniPlayer);
            }

            GUI.color = Color.red;
            if (GUILayout.Button("寻找丢失动画"))
            {
                FindLoseAni();
            }

            GUI.color = GUI.contentColor;
        }
    }