示例#1
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            EditorGUILayout.BeginVertical(MalbersEditor.StyleBlue);
            EditorGUILayout.HelpBox("The Combat Mode is managed here", MessageType.None);
            EditorGUILayout.EndVertical();

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
            {
                EditorGUI.BeginDisabledGroup(true);
                script = (MonoScript)EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false);
                EditorGUI.EndDisabledGroup();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.PropertyField(HitMask, new GUIContent("Hit Mask", "What to Hit"));
                    M.Target = (Transform)EditorGUILayout.ObjectField(new GUIContent("Target", "If the Rider has a Target"), M.Target, typeof(Transform), true);
                    M.AimDot = (RectTransform)EditorGUILayout.ObjectField(new GUIContent("Aim Dot", "UI for Aiming"), M.AimDot, typeof(RectTransform), true);

                    M.StrafeOnTarget = EditorGUILayout.Toggle(new GUIContent("Strafe on Target", "If is there a Target change the mount Input to Camera Input "), M.StrafeOnTarget);
                }
                EditorGUILayout.EndVertical();


                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUI.indentLevel++;
                    M.Editor_ShowEquipPoints = EditorGUILayout.Foldout(M.Editor_ShowEquipPoints, "Weapon Equip Points");

                    if (M.Editor_ShowEquipPoints)
                    {
                        M.LeftHandEquipPoint  = (Transform)EditorGUILayout.ObjectField("Left Hand", M.LeftHandEquipPoint, typeof(Transform), true);
                        M.RightHandEquipPoint = (Transform)EditorGUILayout.ObjectField("Right Hand", M.RightHandEquipPoint, typeof(Transform), true);
                    }

                    Animator rideranimator = M.GetComponent <Animator>();
                    if (rideranimator)
                    {
                        if (!M.LeftHandEquipPoint)
                        {
                            M.LeftHandEquipPoint = rideranimator.GetBoneTransform(HumanBodyBones.LeftHand);
                        }

                        if (!M.RightHandEquipPoint)
                        {
                            M.RightHandEquipPoint = rideranimator.GetBoneTransform(HumanBodyBones.RightHand);
                        }
                    }
                    EditorGUI.indentLevel--;
                }
                EditorGUILayout.EndVertical();


                //INPUTS
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUI.indentLevel++;
                    M.Editor_ShowInputs = EditorGUILayout.Foldout(M.Editor_ShowInputs, "Inputs");

                    if (M.Editor_ShowInputs)
                    {
                        EditorGUILayout.PropertyField(InputAttack1, new GUIContent("Attack1", "Attack Right Side "));
                        MalbersInputEditor.DrawInputEvents(InputAttack1, InputAttack1.FindPropertyRelative("ShowEvents").boolValue);

                        EditorGUILayout.PropertyField(InputAttack2, new GUIContent("Attack2", "Attack Left Side "));
                        MalbersInputEditor.DrawInputEvents(InputAttack2, InputAttack2.FindPropertyRelative("ShowEvents").boolValue);

                        EditorGUILayout.PropertyField(InputAim, new GUIContent("Aim Mode", "Enable Aim mode for Ranged Weapons"));
                        MalbersInputEditor.DrawInputEvents(InputAim, InputAim.FindPropertyRelative("ShowEvents").boolValue);

                        EditorGUILayout.PropertyField(Reload, new GUIContent("Reload", "To Reload Guns"));
                        MalbersInputEditor.DrawInputEvents(Reload, Reload.FindPropertyRelative("ShowEvents").boolValue);
                    }
                    EditorGUI.indentLevel--;
                }

                EditorGUILayout.EndVertical();
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                M.ActiveHolderSide = (WeaponHolder)EditorGUILayout.EnumPopup(new GUIContent("Active Holder Side", "Holder to draw weapons from, When weapons dont have specific holder"), M.ActiveHolderSide);
                EditorGUILayout.EndVertical();

                if (EditorGUI.EndChangeCheck())
                {
                    M.SetActiveHolder(M.ActiveHolderSide);
                }
                EditorGUI.indentLevel++;

                ///──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                //Inventory and Holders
                EditorGUILayout.BeginHorizontal();

                M.UseInventory = GUILayout.Toggle(M.UseInventory, new GUIContent("Use Inventory", "Get the Weapons from an Inventory"), EditorStyles.toolbarButton);

                if (M.UseInventory)
                {
                    M.UseHolders = false;
                }
                else
                {
                    M.UseHolders = true;
                }


                M.UseHolders = GUILayout.Toggle(M.UseHolders, new GUIContent("Use Holders", "The Weapons are child of the Holders Transform"), EditorStyles.toolbarButton);

                if (M.UseHolders)
                {
                    M.UseInventory = false;
                }
                else
                {
                    M.UseInventory = true;
                }

                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel--;

                if (M.UseInventory)
                {
                    EditorGUILayout.BeginVertical(MalbersEditor.StyleGreen);
                    EditorGUILayout.HelpBox("The weapons gameobjects are received by the method 'SetWeaponByInventory(GameObject)'", MessageType.None);
                    EditorGUILayout.EndVertical();
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    M.AlreadyInstantiated = EditorGUILayout.ToggleLeft(new GUIContent("Already Instantiated", "The weapon is already instantiated before entering 'GetWeaponByInventory'"), M.AlreadyInstantiated);
                    EditorGUILayout.EndVertical();

                    //if (MyRiderCombat.GetComponent<MInventory>())
                    //{
                    //    MyRiderCombat.GetComponent<MInventory>().enabled = true;
                    //}
                }

                //Holder Stufss
                if (M.UseHolders)
                {
                    EditorGUILayout.BeginVertical(MalbersEditor.StyleGreen);
                    EditorGUILayout.HelpBox("The weapons are child of the Holders", MessageType.None);
                    EditorGUILayout.EndVertical();

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    {
                        EditorGUI.indentLevel++;

                        M.Editor_ShowHolders = EditorGUILayout.Foldout(M.Editor_ShowHolders, "Holders");
                        if (M.Editor_ShowHolders)
                        {
                            EditorGUILayout.PropertyField(HolderLeft, new GUIContent("Holder Left", "The Tranform that has the weapons on the Left  Side"));
                            EditorGUILayout.PropertyField(HolderRight, new GUIContent("Holder Right", "The Tranform that has the weapons on the Right Side"));
                            EditorGUILayout.PropertyField(HolderBack, new GUIContent("Holder Back", "The Tranform that has the weapons on the Back  Side"));

                            M.Editor_ShowHoldersInput = GUILayout.Toggle(M.Editor_ShowHoldersInput, "Holders Input", EditorStyles.toolbarButton);
                            {
                                if (M.Editor_ShowHoldersInput)
                                {
                                    EditorGUILayout.PropertyField(InputWeapon, new GUIContent("Input Weapon", "Draw/Store the Last Weapon"));
                                    MalbersInputEditor.DrawInputEvents(InputWeapon, InputWeapon.FindPropertyRelative("ShowEvents").boolValue);

                                    EditorGUILayout.PropertyField(HLeft, new GUIContent("Left", "Input to get Weapons from the Left Holder"));
                                    MalbersInputEditor.DrawInputEvents(HLeft, HLeft.FindPropertyRelative("ShowEvents").boolValue);

                                    EditorGUILayout.PropertyField(HRight, new GUIContent("Right", "Input to get Weapons from the Right Holder"));
                                    MalbersInputEditor.DrawInputEvents(HRight, HRight.FindPropertyRelative("ShowEvents").boolValue);

                                    EditorGUILayout.PropertyField(HBack, new GUIContent("Back", "Input to get Weapons from the Back Holder"));
                                    MalbersInputEditor.DrawInputEvents(HBack, HBack.FindPropertyRelative("ShowEvents").boolValue);
                                }
                            }
                        }

                        EditorGUI.indentLevel--;
                    }
                    EditorGUILayout.EndVertical();

                    if (M.GetComponent <MInventory>())
                    {
                        M.GetComponent <MInventory>().enabled = false;
                    }
                }
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUI.indentLevel++;
            EditorGUILayout.PropertyField(CombatAbilities, new GUIContent("Rider Combat Abilities", ""), true);
            EditorGUI.indentLevel--;
            EditorGUILayout.EndVertical();


            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUI.indentLevel++;
            M.Editor_ShowAbilities = EditorGUILayout.Foldout(M.Editor_ShowAbilities, "Abilities Properties");
            EditorGUI.indentLevel--;

            if (M.Editor_ShowAbilities)
            {
                if (M.CombatAbilities != null)
                {
                    foreach (var combatAbility in M.CombatAbilities)
                    {
                        if (combatAbility != null)
                        {
                            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                            EditorGUILayout.LabelField(combatAbility.name, EditorStyles.toolbarButton);
                            //EditorGUILayout.Separator();
                            DrawAbility(combatAbility);
                            EditorGUILayout.EndVertical();
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUI.indentLevel++;
            DrawEvents();

            EditorGUILayout.PropertyField(debug, new GUIContent("Debug", ""));

            Animator anim = M.GetComponent <Animator>();

            UnityEditor.Animations.AnimatorController controller = null;
            if (anim)
            {
                controller = (UnityEditor.Animations.AnimatorController)anim.runtimeAnimatorController;
            }

            if (controller)
            {
                List <UnityEditor.Animations.AnimatorControllerLayer> layers = controller.layers.ToList();

                if (layers.Find(layer => layer.name == "Mounted") == null)
                //if (anim.GetLayerIndex("Mounted") == -1)
                {
                    EditorGUILayout.HelpBox("No Mounted Layer Found, Add it the Mounted Layer using the Rider 3rd Person Script", MessageType.Warning);
                }
                else
                {
                    if (layers.Find(layer => layer.name == "Rider Combat") == null)
                    //if (anim.GetLayerIndex("Rider Combat") == -1)
                    {
                        if (GUILayout.Button(new GUIContent("Add Rider Combat Layers", "Used for adding the parameters and Layer from the Mounted Animator to your custom character controller animator ")))
                        {
                            AddLayerMountedCombat(controller);
                        }
                    }
                }
            }
            EditorGUILayout.EndVertical();

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Rider Combat Change");
            }

            EditorUtility.SetDirty(target);
            serializedObject.ApplyModifiedProperties();
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            MalbersEditor.DrawDescription("The Combat while Riding is controlled here");

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.BeginVertical(MalbersEditor.StyleGray);
                {
                    MalbersEditor.DrawScript(script);


                    Editor_Tabs1.intValue = GUILayout.Toolbar(Editor_Tabs1.intValue, new string[] { "General", "Holders", "Abilities" /*,"References" */ });

                    if (Editor_Tabs1.intValue != 4)
                    {
                        Editor_Tabs2.intValue = 4;
                    }

                    Editor_Tabs2.intValue = GUILayout.Toolbar(Editor_Tabs2.intValue, new string[] { "Advanced", "Animator", "Events", "Debug" });

                    if (Editor_Tabs2.intValue != 4)
                    {
                        Editor_Tabs1.intValue = 4;
                    }

                    //First Tabs
                    int Selection = Editor_Tabs1.intValue;

                    if (Selection == 0)
                    {
                        DrawGeneral();
                    }
                    else if (Selection == 1)
                    {
                        ShowHolders();
                    }
                    else if (Selection == 2)
                    {
                        ShowAbilities();
                    }
                    //  else if (Selection == 1) DrawReferences();


                    //2nd Tabs
                    Selection = Editor_Tabs2.intValue;

                    if (Selection == 0)
                    {
                        DrawAdvanced();
                    }
                    else if (Selection == 1)
                    {
                        DrawAnimator();
                    }
                    else if (Selection == 2)
                    {
                        DrawEvents();
                    }
                    else if (Selection == 3)
                    {
                        DrawDebug();
                    }
                }


                Animator anim = M.GetComponent <Animator>();

                UnityEditor.Animations.AnimatorController controller = null;
                if (anim)
                {
                    controller = (UnityEditor.Animations.AnimatorController)anim.runtimeAnimatorController;
                }

                if (controller)
                {
                    List <UnityEditor.Animations.AnimatorControllerLayer> layers = controller.layers.ToList();

                    if (layers.Find(layer => layer.name == "Mounted") == null)
                    {
                        EditorGUILayout.HelpBox("No Mounted Layer Found, Add it the Mounted Layer using the Rider 3rd Person Script", MessageType.Warning);
                    }
                    else
                    {
                        if (layers.Find(layer => layer.name == M.CombatLayerName) == null)
                        //if (anim.GetLayerIndex("Rider Combat") == -1)
                        {
                            if (GUILayout.Button(new GUIContent("Add Rider Combat Layers", "Used for adding the parameters and Layer from the Mounted Animator to your custom character controller animator ")))
                            {
                                AddLayerMountedCombat(controller);
                            }
                        }
                    }
                }
                EditorGUILayout.EndVertical();
            }
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(target, "Rider Combat Change");
                //EditorUtility.SetDirty(target);
            }


            serializedObject.ApplyModifiedProperties();
        }