public virtual void SetOnInspectorGUI() { EditorGUILayout.BeginVertical(MalbersEditor.StyleBlue); EditorGUILayout.HelpBox("Controls the behaviour when is riding the animal ", MessageType.None); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(MalbersEditor.StyleGray); { #if REWIRED EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.PropertyField(serializedObject.FindProperty("PlayerID"), new GUIContent("Player ID", "Rewired Player ID")); EditorGUILayout.EndVertical(); #endif EditorGUI.indentLevel++; EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUI.indentLevel--; EditorGUILayout.BeginHorizontal(); { M.StartMounted = EditorGUILayout.ToggleLeft(new GUIContent(" Start Mounted", "Set an animal to star mounted on it "), M.StartMounted, GUILayout.MaxWidth(110)); M.AnimalStored = (Mountable)EditorGUILayout.ObjectField(M.AnimalStored, typeof(Mountable), true); } EditorGUILayout.EndHorizontal(); if (M.StartMounted && M.AnimalStored == null) { EditorGUILayout.HelpBox("Select a Animal with 'IMount' interface from the scene if you want to start mounted on it", MessageType.Warning); } var Parent = serializedObject.FindProperty("Parent"); Parent.boolValue = EditorGUILayout.ToggleLeft(new GUIContent("Parent to Mount Point", "Parent the Rider to the Mount Point on the Mountable Animal"), Parent.boolValue); EditorGUI.indentLevel++; } EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUILayout.BeginHorizontal(); M.CreateColliderMounted = EditorGUILayout.ToggleLeft("", M.CreateColliderMounted, GUILayout.MaxWidth(10)); EditorGUILayout.LabelField(new GUIContent("Create Capsule Collider while Mounted", "This collider is for hit the Rider while mounted")); EditorGUILayout.EndHorizontal(); if (M.CreateColliderMounted) { EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Center Y", GUILayout.MinWidth(40)); EditorGUILayout.LabelField("Height", GUILayout.MinWidth(40)); EditorGUILayout.LabelField("Radius", GUILayout.MinWidth(40)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); M.Col_Center = EditorGUILayout.FloatField(M.Col_Center); M.Col_height = EditorGUILayout.FloatField(M.Col_height); M.Col_radius = EditorGUILayout.FloatField(M.Col_radius); EditorGUILayout.EndHorizontal(); M.Col_Trigger = EditorGUILayout.Toggle("Is Trigger", M.Col_Trigger); EditorGUI.indentLevel--; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); M.DisableComponents = EditorGUILayout.ToggleLeft(new GUIContent("Disable Components", "If some of the scripts are breaking the Rider Script: disable them"), M.DisableComponents); EditorGUI.indentLevel++; if (M.DisableComponents) { EditorGUILayout.PropertyField(serializedObject.FindProperty("DisableList"), new GUIContent("Disable List", "Monobehaviours that will be disabled while mounted"), true); if (M.DisableList.Length == 0) { EditorGUILayout.HelpBox("If 'Disable List' is empty , it will disable all Monovehaviours while riding", MessageType.Info); } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; EditorGUILayout.BeginVertical(EditorStyles.helpBox); { EditorGUI.indentLevel++; M.Editor_Inputs = EditorGUILayout.Foldout(M.Editor_Inputs, "Inputs"); EditorGUI.indentLevel--; if (M.Editor_Inputs) { var mountInput = serializedObject.FindProperty("MountInput"); EditorGUILayout.PropertyField(mountInput, new GUIContent("Mount", "Key or Input to Mount"), true); MalbersInputEditor.DrawInputEvents(mountInput, mountInput.FindPropertyRelative("ShowEvents").boolValue); var DismountInput = serializedObject.FindProperty("DismountInput"); EditorGUILayout.PropertyField(DismountInput, new GUIContent("Dismount", "Key or Input to Dismount"), true); MalbersInputEditor.DrawInputEvents(DismountInput, DismountInput.FindPropertyRelative("ShowEvents").boolValue); var CallAnimalInput = serializedObject.FindProperty("CallAnimalInput"); EditorGUILayout.PropertyField(CallAnimalInput, new GUIContent("Call Animal", "Key or Input to Call the Animal"), true); MalbersInputEditor.DrawInputEvents(CallAnimalInput, CallAnimalInput.FindPropertyRelative("ShowEvents").boolValue); } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; M.Editor_RiderCallAnimal = EditorGUILayout.Foldout(M.Editor_RiderCallAnimal, "Call Animal Audio"); CallHelp = GUILayout.Toggle(CallHelp, "?", EditorStyles.miniButton, GUILayout.Width(18)); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; if (M.Editor_RiderCallAnimal) { if (CallHelp) { EditorGUILayout.HelpBox("To call an animal, the animal needs to have MointAI(Script) and a NavMeshAgent.\nRemember to bake a NavMesh... See Poly Art Horse as an example", MessageType.None); } EditorGUILayout.PropertyField(serializedObject.FindProperty("CallAnimalA"), new GUIContent("Call Animal", "Sound to call the Stored Animal")); EditorGUILayout.PropertyField(serializedObject.FindProperty("StopAnimalA"), new GUIContent("Stop Animal", "Sound to stop calling the Stored Animal")); EditorGUILayout.PropertyField(serializedObject.FindProperty("RiderAudio"), new GUIContent("Audio Source", "The reference for the audio source")); } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.PropertyField(serializedObject.FindProperty("LinkUpdate"), new GUIContent("Link Update", "Type of Update to link manually the rider to the Animal without Parenting it to the Mount Point ")); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.BeginHorizontal(); EditorGUI.indentLevel++; M.Editor_Events = EditorGUILayout.Foldout(M.Editor_Events, "Events"); EventHelp = GUILayout.Toggle(EventHelp, "?", EditorStyles.miniButton, GUILayout.Width(18)); EditorGUI.indentLevel--; EditorGUILayout.EndHorizontal(); if (M.Editor_Events) { if (EventHelp) { EditorGUILayout.HelpBox(CustomEventsHelp() + "\n\nOn Find Mount: Invoked when the rider founds something to mount.", MessageType.None); } DrawCustomEvents(); EditorGUILayout.PropertyField(serializedObject.FindProperty("OnFindMount"), new GUIContent("On Find Mount")); if (M.StartMounted) { EditorGUILayout.PropertyField(serializedObject.FindProperty("OnAlreadyMounted"), new GUIContent("On Already Mounted")); } } EditorGUILayout.EndVertical(); EditorGUI.indentLevel--; } EditorGUILayout.EndVertical(); EditorUtility.SetDirty(target); }
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(); }