public override void OnInspectorGUI() { EMOpenCloseMotion t = (EMOpenCloseMotion)target; EditorGUILayout.Space(); t.motionName = EditorGUILayout.TextField("Motion name", t.motionName); EditorGUILayout.Space(); t.OpenAtStart = EMGuiTools.Toggle("Open at start", t.OpenAtStart, true); EditorGUILayout.Space(); t.alpha = EditorGUILayout.Slider("Alpha", t.alpha, 0f, 1f); EditorGUILayout.Space(); // open effect t.showOpenInspector = EMGuiTools.BeginFoldOut("Open motion", t.showOpenInspector); if (t.showOpenInspector) { EMGuiTools.BeginGroup(); { UIEffectInspector(t.openProp, t.rectTransform(), ref inRecOpen); } EMGuiTools.EndGroup(); } // Close Effect t.showCloseInspector = EMGuiTools.BeginFoldOut("Close motion", t.showCloseInspector); if (t.showCloseInspector) { EMGuiTools.BeginGroup(); { UIEffectInspector(t.closeProp, t.rectTransform(), ref inRecClose); } EMGuiTools.EndGroup(); } // Events t.showEventInspector = EMGuiTools.BeginFoldOut("Events", t.showEventInspector); if (t.showEventInspector) { EMGuiTools.BeginGroup(); { serializedObject.Update(); SerializedProperty openStart = serializedObject.FindProperty("onOpenStart"); EditorGUILayout.PropertyField(openStart, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty openEnd = serializedObject.FindProperty("onOpenEnd"); EditorGUILayout.PropertyField(openEnd, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty closeStart = serializedObject.FindProperty("onCloseStart"); EditorGUILayout.PropertyField(closeStart, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty closeend = serializedObject.FindProperty("onCloseEnd"); EditorGUILayout.PropertyField(closeend, true, null); serializedObject.ApplyModifiedProperties(); } EMGuiTools.EndGroup(); } }
public override void OnInspectorGUI() { EMSimpleMotion t = (EMSimpleMotion)target; EditorGUILayout.Space(); t.motionName = EditorGUILayout.TextField("Motion name", t.motionName); EditorGUILayout.Space(); t.simpleProp.sound = (AudioClip)EditorGUILayout.ObjectField("Sound", t.simpleProp.sound, typeof(AudioClip), false); t.simpleProp.volume = EditorGUILayout.Slider("Volume", t.simpleProp.volume, 0f, 1f); t.playSoundRewind = EMGuiTools.Toggle("Play sound at rewind", t.playSoundRewind, true); #region Motion t.showMotionInspector = EMGuiTools.BeginFoldOut("Motion", t.showMotionInspector); if (t.showMotionInspector) { EMGuiTools.BeginGroup(); { MotionInspector(t); } EMGuiTools.EndGroup(); } #endregion #region Events t.showEventInspector = EMGuiTools.BeginFoldOut("Events", t.showEventInspector); if (t.showEventInspector) { EMGuiTools.BeginGroup(); { serializedObject.Update(); SerializedProperty openStart = serializedObject.FindProperty("onPlayStart"); EditorGUILayout.PropertyField(openStart, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty openEnd = serializedObject.FindProperty("onPlayEnd"); EditorGUILayout.PropertyField(openEnd, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty closeStart = serializedObject.FindProperty("onRewindStart"); EditorGUILayout.PropertyField(closeStart, true, null); serializedObject.ApplyModifiedProperties(); serializedObject.Update(); SerializedProperty closeend = serializedObject.FindProperty("onRewindEnd"); EditorGUILayout.PropertyField(closeend, true, null); serializedObject.ApplyModifiedProperties(); } EMGuiTools.EndGroup(); } #endregion }
public static bool BeginToogleGroup(string text, bool value, int indent = 0) { if (value) { GUI.backgroundColor = Color.green; } else { GUI.backgroundColor = Color.red; } value = EditorGUILayout.BeginToggleGroup(text, value); GUI.backgroundColor = Color.white; if (value) { EMGuiTools.BeginGroup(indent); } return(value); }
private void MotionInspector(EMSimpleMotion simpleMotion) { Record(simpleMotion); EMMotionProperties motion = simpleMotion.simpleProp; #region Move EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowMove = EMGuiTools.BeginFoldOut("Move effect", motion.inspectorShowMove); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowMove) { EMGuiTools.BeginGroup(6); { motion.isMove = EMGuiTools.Toggle("Enable move effect", motion.isMove, true); if (motion.isMove) { motion.moveDirection = (EMMotionProperties.MotionDirection)EditorGUILayout.EnumPopup("To", motion.moveDirection); if (motion.moveDirection == EMMotionProperties.MotionDirection.UserDefined) { if (inRec) { motion.transform.position = simpleMotion.rectTransform().anchoredPosition; motion.transform.anchorMin = simpleMotion.rectTransform().anchorMin; motion.transform.anchorMax = simpleMotion.rectTransform().anchorMax; } EditorGUILayout.Vector3Field("Position", motion.transform.position); } UIEaseInspector(motion.moveEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Rotate EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowRotate = EMGuiTools.BeginFoldOut("Rotation effect", motion.inspectorShowRotate); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowRotate) { EMGuiTools.BeginGroup(6); { motion.isRotate = EMGuiTools.Toggle("Enable rotation effect", motion.isRotate, true); if (motion.isRotate) { if (inRec) { motion.transform.rotation = simpleMotion.rectTransform().localRotation.eulerAngles; } motion.transform.rotation = EditorGUILayout.Vector3Field("Rotation", motion.transform.rotation); UIEaseInspector(motion.rotateEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Scale EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowScale = EMGuiTools.BeginFoldOut("Scale effect", motion.inspectorShowScale); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowScale) { EMGuiTools.BeginGroup(6); { motion.isScale = EMGuiTools.Toggle("Enable scale effect", motion.isScale, true); if (motion.isScale) { if (inRec) { motion.transform.scale = simpleMotion.rectTransform().localScale; } motion.transform.scale = EditorGUILayout.Vector3Field("Scale", motion.transform.scale); UIEaseInspector(motion.scaleEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Alpha EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowColor = EMGuiTools.BeginFoldOut("alpha effect", motion.inspectorShowColor); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowColor) { EMGuiTools.BeginGroup(6); { motion.isAlpha = EMGuiTools.Toggle("Enable alpha effect", motion.isAlpha, true); if (motion.isAlpha) { if (inRec) { simpleMotion.rectTransform().GetComponentInParent <CanvasGroup>().alpha = motion.transform.alpha; } motion.transform.alpha = EditorGUILayout.Slider("Alpha", motion.transform.alpha, 0f, 1f); UIEaseInspector(motion.alphaEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion }
private void UIEffectInspector(EMMotionProperties motion, RectTransform rect, ref bool inRec) { motion.sound = (AudioClip)EditorGUILayout.ObjectField("Sound", motion.sound, typeof(AudioClip), false); motion.volume = EditorGUILayout.Slider("Volume", motion.volume, 0f, 1f); EditorGUILayout.Space(); if (motion.motionType == EMMotionProperties.MotionType.Open) { motion.autoClose = EMGuiTools.Toggle("Auto close", motion.autoClose, true); if (motion.autoClose) { EditorGUI.indentLevel++; motion.autoCloseDelayTime = EditorGUILayout.FloatField("After (in second)", motion.autoCloseDelayTime); EditorGUI.indentLevel--; } } EditorGUILayout.Space(); #region Move EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowMove = EMGuiTools.BeginFoldOut("Move effect", motion.inspectorShowMove); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowMove) { EMGuiTools.BeginGroup(6); { motion.isMove = EMGuiTools.Toggle("Enable move effect", motion.isMove, true); if (motion.isMove) { string label = "From"; if (motion.motionType == EMMotionProperties.MotionType.Close) { label = "To"; } motion.moveDirection = (EMMotionProperties.MotionDirection)EditorGUILayout.EnumPopup(label, motion.moveDirection); if (motion.moveDirection == EMMotionProperties.MotionDirection.UserDefined) { UserDefinedStartPosition(motion, rect, ref inRec); } UIEaseInspector(motion.moveEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Rotate EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowRotate = EMGuiTools.BeginFoldOut("Rotation effect", motion.inspectorShowRotate); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowRotate) { EMGuiTools.BeginGroup(6); { motion.isRotate = EMGuiTools.Toggle("Enable rotation effect", motion.isRotate, true); if (motion.isRotate) { motion.transform.rotation = EditorGUILayout.Vector3Field("Rotation", motion.transform.rotation); UIEaseInspector(motion.rotateEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Scale EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowScale = EMGuiTools.BeginFoldOut("Scale effect", motion.inspectorShowScale); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowScale) { EMGuiTools.BeginGroup(6); { motion.isScale = EMGuiTools.Toggle("Enable scale effect", motion.isScale, true); if (motion.isScale) { motion.transform.scale = EditorGUILayout.Vector3Field("Scale", motion.transform.scale); UIEaseInspector(motion.scaleEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion #region Alpha EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); motion.inspectorShowColor = EMGuiTools.BeginFoldOut("alpha effect", motion.inspectorShowColor); EditorGUILayout.EndHorizontal(); if (motion.inspectorShowColor) { EMGuiTools.BeginGroup(6); { motion.isAlpha = EMGuiTools.Toggle("Enable alpha effect", motion.isAlpha, true); if (motion.isAlpha) { motion.transform.alpha = EditorGUILayout.Slider("Alpha", motion.transform.alpha, 0f, 1f); UIEaseInspector(motion.alphaEasing); } } EMGuiTools.EndGroup(); } else { EditorGUILayout.Space(); } EditorGUI.indentLevel--; #endregion }