public override void OnInspectorGUI() { OnInspectorGUIPRO(() => { EditorGUILayout.PropertyField(FindProperty("space")); EditorGUILayout.Space(); EditorGUILayout.LabelField("Direction", EditorStyles.boldLabel); if (target.space == Space.Self) { //target.parent = (Transform)EditorGUILayout.ObjectField("Parent", target.parent, typeof(Transform), true); EditorGUILayout.PropertyField(FindProperty("_parent")); } target.value = EditorGUILayout.Vector3Field("Value", target.value); target.gravity = EditorGUILayout.FloatField("Force", target.gravity); target.gravityScale = EditorGUILayout.FloatField("Gravity Scale", target.gravityScale); EditorGUILayout.Space(); //Local if (target.space == Space.Self) { EditorGUILayout.LabelField("Local", EditorStyles.boldLabel); EditorGUILayout.PropertyField(FindProperty("offset")); EditorGUILayout.Space(); } target.showContextInfo = EditorGUILayout.Foldout(target.showContextInfo, "Info", true, EditorStyles.foldout.clone().richText()); if (target.showContextInfo) { GUI.enabled = false; //local and global directions EditorGUILayout.Vector3Field("Direction", target.direction); if (target.space == Space.Self) { EditorGUILayout.Vector3Field("Local Direction", target.localDirection); } if (target.space == Space.Self) { EditorGUILayout.Space(); EditorGUILayout.Vector3Field("Direction Raw", target.directionRaw); if (target.space == Space.Self) { EditorGUILayout.Vector3Field("Local Direction Raw", target.localDirectionRaw); } } if (target.space == Space.Self) { EditorGUILayout.Space(); } //local and global velocity EditorGUILayout.Vector3Field("Velocity", target.velocity); if (target.space == Space.Self) { EditorGUILayout.Vector3Field("Local Velocity", target.localVelocity); } GUI.enabled = true; EditorGUILayout.Space(); } //Editor methods! //Line(); if (EditorApplication.isPaused || !EditorApplication.isPlaying) { target.showMethods = EditorGUILayout.Foldout(target.showMethods, "Methods", true, EditorStyles.foldout.clone().richText()); if (target.showMethods) { Function("Switch", () => { target.Switch(P_Switch_Space, P_Switch_Link); }, new Action[] { () => P_Switch_Space = (Space)EditorGUILayout.EnumPopup(GUIContent.none, P_Switch_Space), () => P_Switch_Link = (Link)EditorGUILayout.EnumPopup(GUIContent.none, P_Switch_Link) }, "Switched CustomGravity Space and/or Link", target.gameObject); //Function("Switch Parent", () => //{ // target.SwitchParent(P_SwitchParent_Parent); //}, new Action[] { // () => P_SwitchParent_Parent = (Transform)EditorGUILayout.ObjectField(GUIContent.none, P_SwitchParent_Parent, typeof(Transform), true) // }, "Switched CustomGravity Parent", target.gameObject); Function("Remove Offset", () => { if (EditorUtility.DisplayDialog( "Remove Offset?", "Are you sure you want to remove the offset of \"CustomGravity?\"", "Yes", "Cancel")) { Undo.RecordObject(target.gameObject, "Removed CustomGravity Offset"); target.RemoveOffset(); } }, new Action[] { }); Function("Set Context", () => { if (P_SetContext_Type == LinkSpace.World) { target.direction = P_SetContext_New; } else if (P_SetContext_Type == LinkSpace.Self) { target.localDirection = P_SetContext_New; } else if (P_SetContext_Type == LinkSpace.WorldRaw) { target.directionRaw = P_SetContext_New; } else if (P_SetContext_Type == LinkSpace.SelfRaw) { target.localDirectionRaw = P_SetContext_New; } }, new Action[] { () => { EditorGUI.BeginChangeCheck(); P_SetContext_Type = (LinkSpace)EditorGUILayout.EnumPopup("Type", P_SetContext_Type); if (EditorGUI.EndChangeCheck()) { if (P_SetContext_Type == LinkSpace.World) { P_SetContext_New = target.direction; } else if (P_SetContext_Type == LinkSpace.Self) { P_SetContext_New = target.localDirection; } else if (P_SetContext_Type == LinkSpace.WorldRaw) { P_SetContext_New = target.directionRaw; } else if (P_SetContext_Type == LinkSpace.SelfRaw) { P_SetContext_New = target.localDirectionRaw; } } }, () => P_SetContext_New = EditorGUILayout.Vector3Field(GUIContent.none, P_SetContext_New) }, "Changed Context Value of CustomGravity", target.gameObject); // Function("Set Velocity", () => { if (P_SetVelocity_Type == Space.World) { target.velocity = P_SetVelocity_New; } else if (P_SetVelocity_Type == Space.Self) { target.localVelocity = P_SetVelocity_New; } }, new Action[] { () => { EditorGUI.BeginChangeCheck(); P_SetVelocity_Type = (Space)EditorGUILayout.EnumPopup("Type", P_SetVelocity_Type); if (EditorGUI.EndChangeCheck()) { if (P_SetVelocity_Type == Space.World) { P_SetVelocity_New = target.velocity; } else if (P_SetVelocity_Type == Space.Self) { P_SetVelocity_New = target.localVelocity; } } }, () => P_SetVelocity_New = EditorGUILayout.Vector3Field(GUIContent.none, P_SetVelocity_New) }, "Changed Rigidbody Velocity from CustomGravity", target.gameObject); } } }); }
public override void OnInspectorGUI() { OnInspectorGUIPRO(() => { EditorGUILayout.PropertyField(FindProperty("space")); EditorGUILayout.Space(); EditorGUILayout.LabelField("Rotation", EditorStyles.boldLabel); if (target.space == Space.Self) { //target.parent = (Transform)EditorGUILayout.ObjectField("Parent", target.parent, typeof(Transform), true); EditorGUILayout.PropertyField(FindProperty("_parent")); } if (!(target.space == Space.Self && target.link == Link.Match)) { //target.value = Quaternion.Euler(EditorGUILayout.Vector3Field("Value", target.value.eulerAngles)); EditorGUILayout.PropertyField(FindProperty("value")); } EditorGUILayout.Space(); if (target.space == Space.Self) { EditorGUILayout.LabelField("Local", EditorStyles.boldLabel); EditorGUILayout.PropertyField(FindProperty("link")); if (target.link == Link.Offset) { EditorGUILayout.PropertyField(FindProperty("offset")); } EditorGUILayout.Space(); } if (target.space == Space.Self && target.link == Link.Offset) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Transition", EditorStyles.boldLabel); target.follow = EditorGUILayout.Toggle(string.Empty, target.follow); EditorGUILayout.EndHorizontal(); if (target.follow) { EditorGUILayout.PropertyField(FindProperty("transition")); } EditorGUILayout.Space(); } target.showContextInfo = EditorGUILayout.Foldout(target.showContextInfo, "Info", true, EditorStyles.foldout.clone().richText()); if (target.showContextInfo) { GUI.enabled = false; EditorGUILayout.Vector3Field("Euler Angles", target.eulerAngles); if (target.space == Space.Self) { EditorGUILayout.Vector3Field("Local Euler Angles", target.localEulerAngles); } if (target.space == Space.Self && target.link == Link.Offset) { EditorGUILayout.Space(); EditorGUILayout.Vector3Field("Euler Angles Raw", target.eulerAnglesRaw); if (target.space == Space.Self) { EditorGUILayout.Vector3Field("Local Euler Angles Raw", target.localEulerAnglesRaw); } } GUI.enabled = true; EditorGUILayout.Space(); } if (EditorApplication.isPaused || !EditorApplication.isPlaying) { //Line(); target.showMethods = EditorGUILayout.Foldout(target.showMethods, "Methods", true, EditorStyles.foldout.clone().richText()); if (target.showMethods) { if (target.applyInEditor) { GUI.enabled = false; } if (GUILayout.Button("Target to Current")) { Undo.RecordObject(target.gameObject, "Re-Oriented CustomRotation"); target.TargetToCurrent(); } Function("Switch", () => { target.Switch(P_Switch_Space, P_Switch_Link); }, new Action[] { () => P_Switch_Space = (Space)EditorGUILayout.EnumPopup(GUIContent.none, P_Switch_Space), () => P_Switch_Link = (Link)EditorGUILayout.EnumPopup(GUIContent.none, P_Switch_Link) }, "Switched CustomRotation Space and/or Link", target.gameObject); Function("Switch Parent", () => { target.Switch(P_Switch_Space, P_Switch_Link); }, new Action[] { () => EditorGUILayout.PropertyField(FindPropertyEditor("P_SwitchParent_Parent"), GUIContent.none) }, "Switched CustomRotation Parent", target.gameObject); Function("Remove Offset", () => { if (EditorUtility.DisplayDialog( "Remove Offset?", "Are you sure you want to remove the offset of \"CustomRotation?\"", "Yes", "Cancel")) { Undo.RecordObject(target.gameObject, "Removed CustomRotation Offset"); target.RemoveOffset(); } }, new Action[] { }); GUI.enabled = true; if (!target.applyInEditor) { GUI.enabled = false; } //setContext Function Function("Set Property", () => { if (P_SetContext_Type == LinkSpace.World) { target.rotation = Quaternion.Euler(P_SetContext_New); } else if (P_SetContext_Type == LinkSpace.Self) { target.localRotation = Quaternion.Euler(P_SetContext_New); } else if (P_SetContext_Type == LinkSpace.WorldRaw) { target.rotationRaw = Quaternion.Euler(P_SetContext_New); } else if (P_SetContext_Type == LinkSpace.SelfRaw) { target.localRotationRaw = Quaternion.Euler(P_SetContext_New); } }, new Action[] { () => { EditorGUI.BeginChangeCheck(); P_SetContext_Type = (LinkSpace)EditorGUILayout.EnumPopup("Type", P_SetContext_Type); if (EditorGUI.EndChangeCheck()) { if (P_SetContext_Type == LinkSpace.World) { P_SetContext_New = target.rotation.eulerAngles; } else if (P_SetContext_Type == LinkSpace.Self) { P_SetContext_New = target.localRotation.eulerAngles; } else if (P_SetContext_Type == LinkSpace.WorldRaw) { P_SetContext_New = target.rotationRaw.eulerAngles; } else if (P_SetContext_Type == LinkSpace.SelfRaw) { P_SetContext_New = target.localRotationRaw.eulerAngles; } } }, () => P_SetContext_New = EditorGUILayout.Vector3Field(GUIContent.none, P_SetContext_New) }, "Changed Context Value of CustomRotation", target.gameObject); GUI.enabled = true; } EditorGUILayout.Space(); //Apply button if (!target.applyInEditor) { if (EditorApplication.isPaused) { target.EditorApplyCheck(); } if (GUILayout.Button( "Apply in Editor".bold(), EditorStyles.miniButton.clone().richText().fixedHeight(EditorGUIUtility.singleLineHeight * 1.5f) )) { Undo.RecordObject(target.gameObject, "Applied CustomRotation Values in Editor"); target.applyInEditor = true; //NEW STUFF //CustomTransformHandlesWindow.ShowWindow(); target.EditorApplyCheck(); } } else { if (GUILayout.Button( "Don't Apply in Editor".colour(Color.red).bold(), EditorStyles.miniButton.clone().richText().fixedHeight(EditorGUIUtility.singleLineHeight * 1.5f) )) { target.applyInEditor = false; target.EditorApplyCheck(); } } } }); }