예제 #1
0
        public static void Open()
        {
            StatsWindow w = GetWindow <StatsWindow>("Stats & Effects Editor", typeof(SceneView));

            w.titleContent   = new GUIContent("Stats & Effects Editor", StatsIcon);
            w.wantsMouseMove = true;
        }
예제 #2
0
        public override void OnInspectorGUI()
        {
            displayFlags = (DisplayFlags)serializedObject.FindProperty("z_display_flags").intValue;
            MainContainerBeginSlim();

            GUILayout.BeginVertical();
            GUILayout.Space(6);
            GUILayout.EndVertical();

            if (GUILayout.Button("Stats & Effects Editor", GUILayout.MinHeight(32)))
            {
                StatsWindow.Open();
            }

            GUILayout.BeginVertical();
            GUILayout.Space(6);
            GUILayout.EndVertical();


            if (Application.isPlaying)
            {
                if (SectionToggle((int)displayFlags, (int)DisplayFlags.Debug, "Debug", DebugIcon))
                {
                    DrawDebug();
                }
            }

            if (SectionDropToggle((int)displayFlags, (int)DisplayFlags.Stats, "Stats", StatsIcon, "stats", typeof(StatValue)))
            {
                statSP = SimpleList("stats", statSP, 120, 1);
            }

            if (SectionToggle((int)displayFlags, (int)DisplayFlags.Effects, "Effects", EffectsIcon))
            {
                DrawEffects();
            }

            if (SectionToggle((int)displayFlags, (int)DisplayFlags.Combat, "Combat", CombatIcon))
            {
                DrawCombat();
            }

            if (SectionToggle((int)displayFlags, (int)DisplayFlags.DamageDealers, "Damage Dealers", DealersIcon))
            {
                DamageDealer[] dealers = myTarget.GetComponentsInChildren <DamageDealer>();
                foreach (DamageDealer dealer in dealers)
                {
                    EditorGUILayout.ObjectField(dealer, typeof(DamageDealer), true);
                }
                if (dealers.Length == 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(24);
                    GUILayout.Label("{None}", Skin.GetStyle("SubHeader"));
                    GUILayout.EndHorizontal();
                }

                Animator anim = myTarget.GetComponentInChildren <Animator>();
                if (anim != null && anim.isHuman)
                {
                    SubHeader("Dynamic Creation");
                    boneIndex1 = EditorGUILayout.Popup("Add to Bone", boneIndex1, bones, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Add"))
                    {
                        Transform target = anim.GetBoneTransform((HumanBodyBones)boneIndex1);
                        if (target == null)
                        {
                            EditorUtility.DisplayDialog("Stats Cog", "The requested bone '" + bones[boneIndex1] + "' could not be found on the selected rig.", "OK");
                        }
                        else
                        {
                            GameObject newDD = new GameObject();
                            newDD.name = "DamageDealer_" + bones[boneIndex1];
                            newDD.AddComponent <SphereCollider>().isTrigger = true;
                            newDD.AddComponent <DamageDealer>();
                            newDD.transform.SetParent(target);
                            newDD.transform.localPosition = Vector3.zero;
                            Selection.activeGameObject    = newDD;
                        }
                    }
                }
            }

            if (SectionToggle((int)displayFlags, (int)DisplayFlags.DamageReceivers, "Damage Receivers", ReceiversIcon))
            {
                DamageReceiver[] receivers = myTarget.GetComponentsInChildren <DamageReceiver>();
                foreach (DamageReceiver Receiver in receivers)
                {
                    EditorGUILayout.ObjectField(Receiver, typeof(DamageReceiver), true);
                }
                if (receivers.Length == 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(24);
                    GUILayout.Label("{None}", Skin.GetStyle("SubHeader"));
                    GUILayout.EndHorizontal();
                }

                Animator anim = myTarget.GetComponentInChildren <Animator>();
                if (anim != null && anim.isHuman)
                {
                    SubHeader("Dynamic Creation");
                    boneIndex2 = EditorGUILayout.Popup("Add to Bone", boneIndex2, bones, GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Add"))
                    {
                        Transform target = anim.GetBoneTransform((HumanBodyBones)boneIndex2);
                        if (target == null)
                        {
                            EditorUtility.DisplayDialog("Stats Cog", "The requested bone '" + bones[boneIndex2] + "' could not be found on the selected rig.", "OK");
                        }
                        else
                        {
                            GameObject newDD = new GameObject();
                            newDD.name = "DamageReceiver_" + bones[boneIndex2];
                            newDD.AddComponent <CapsuleCollider>().isTrigger = true;
                            newDD.AddComponent <DamageReceiver>();
                            newDD.transform.SetParent(target);
                            newDD.transform.localPosition = Vector3.zero;
                            Selection.activeGameObject    = newDD;
                        }
                    }
                }
            }

            if (SectionToggle((int)displayFlags, (int)DisplayFlags.Events, "Events", EventsIcon))
            {
                DrawEvents();
            }

            MainContainerEnd();
        }