private void DisplayAnimGroups(bool playerExists)
        {
            m_scrollViewPos = GUILayout.BeginScrollView(m_scrollViewPos, GUILayout.MinHeight(m_minScrollViewHeight), GUILayout.MaxHeight(m_maxScrollViewHeight));

            float elementHeight = 25;

            foreach (var pair in Importing.Animation.AnimationGroup.AllLoadedGroups)
            {
                GUILayout.Space(5);
                GUILayout.Label("Name: " + pair.Key);

                foreach (var pair2 in pair.Value)
                {
                    if (!m_displayWalkcycleAnims && pair2.Key == AnimGroup.WalkCycle)
                    {
                        continue;
                    }

                    GUILayout.Label("Type: " + pair2.Key);

                    var animGroup = pair2.Value;

                    for (int i = 0; i < animGroup.Animations.Length; i++)
                    {
                        string animName = animGroup.Animations[i];

                        if (playerExists)
                        {
                            // display button which will play the anim
                            if (GUILayout.Button(animName, GUILayout.Height(elementHeight)))
                            {
                                this.PlayAnim(new AnimId(animGroup.Type, AnimIndexUtil.Get(i)));
                            }
                        }
                        else
                        {
                            GUILayout.Label(animName, GUILayout.Height(elementHeight));
                        }
                    }
                }
            }

            GUILayout.EndScrollView();
        }
Beispiel #2
0
        protected override void OnWindowGUI()
        {
//			if (null == Player.Instance) {
//				GUILayout.Label ("Player object not found");
//				return;
//			}


            bool playerExists = Player.Instance != null;


            float headerHeight = m_displayAnimStats ? 200 : 60;

            GUILayout.BeginArea(new Rect(0, 0, this.windowRect.width, headerHeight));

            if (playerExists)
            {
                Player.Instance.shouldPlayAnims = !GUILayout.Toggle(!Player.Instance.shouldPlayAnims, "Override player anims");
            }

            m_displayWalkcycleAnims = GUILayout.Toggle(m_displayWalkcycleAnims, "Display walkcycle anims");

            m_displayAnimStats = GUILayout.Toggle(m_displayAnimStats, "Display anim stats");

            // display anim stats
            if (m_displayAnimStats && playerExists)
            {
                DisplayAnimStats();
            }

            GUILayout.EndArea();


            // display anim groups and their anims

            Rect scrollViewRect = this.windowRect;

            m_scrollViewPos = GUI.BeginScrollView(new Rect(new Vector2(0, headerHeight), scrollViewRect.size), m_scrollViewPos,
                                                  new Rect(Vector2.zero, new Vector2(scrollViewRect.width, m_lastContentHeight)));

            float labelWidth  = 150;
            float labelHeight = 20;
            Rect  rect        = new Rect(new Vector2(0, headerHeight), new Vector2(labelWidth, labelHeight));

            //	m_lastContentHeight = 0;


            foreach (var pair in Importing.Animation.AnimationGroup.AllLoadedGroups)
            {
                //	rect.xMin = 0;
                //	rect.yMin += labelHeight;
                rect.position = new Vector2(0, rect.position.y + labelHeight);
                GUI.Label(rect, "Name: " + pair.Key);

                foreach (var pair2 in pair.Value)
                {
                    if (!m_displayWalkcycleAnims && pair2.Key == AnimGroup.WalkCycle)
                    {
                        continue;
                    }

                    //	rect.xMin = labelWidth;
                    //	rect.yMin += labelHeight;
                    rect.position = new Vector2(labelWidth, rect.position.y + labelHeight);
                    GUI.Label(rect, "Type: " + pair2.Key);

                    var animGroup = pair2.Value;

                    rect.position = new Vector2(labelWidth * 2, rect.position.y);
                    for (int i = 0; i < animGroup.Animations.Length; i++)
                    {
                        string animName = animGroup.Animations[i];

                        rect.position = new Vector2(rect.position.x, rect.position.y + labelHeight);

                        if (playerExists)
                        {
                            // display button which will play the anim
                            if (GUI.Button(rect, animName))
                            {
                                Player.Instance.PlayerModel.ResetModelState();
                                Player.Instance.PlayerModel.PlayAnim(animGroup.Type, AnimIndexUtil.Get(i));
                            }
                        }
                        else
                        {
                            GUI.Label(rect, animName);
                        }
                    }
                }
            }

            GUI.EndScrollView();

            m_lastContentHeight = rect.yMax;
        }