public override void OnInspectorGUI() { //base.OnInspectorGUI(); serializedObject.Update(); ToolBoxEditorGUILayout.BeginBox("Change Basic Settings"); SerializedProperty speed = serializedObject.FindProperty("speed"); EditorGUILayout.PropertyField(speed); SerializedProperty radius = serializedObject.FindProperty("_radius"); EditorGUILayout.PropertyField(radius); ToolBoxEditorGUILayout.EndBox(); ToolBoxEditorGUILayout.BeginBox("Debug GUI"); SerializedProperty guiDebug = serializedObject.FindProperty("guiDebug"); EditorGUILayout.PropertyField(guiDebug); if (guiDebug.boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("guiDebugTextColor")); EditorGUILayout.PropertyField(serializedObject.FindProperty("guiDebugTextSize")); } ToolBoxEditorGUILayout.EndBox(); ToolBoxEditorGUILayout.BeginBox("Debug Gizmos"); SerializedProperty gizmoDebug = serializedObject.FindProperty("gizmoDebug"); EditorGUILayout.PropertyField(gizmoDebug); if (gizmoDebug.boolValue) { EditorGUILayout.PropertyField(serializedObject.FindProperty("gizmosCenterColor")); EditorGUILayout.PropertyField(serializedObject.FindProperty("gizmosPositionColor")); EditorGUILayout.PropertyField(serializedObject.FindProperty("gizmosLineColor")); } ToolBoxEditorGUILayout.EndBox(); serializedObject.ApplyModifiedProperties(); }
private void OnGUI() { //FIND THE ANIMATOR ToolBoxEditorGUILayout.BeginBox("Selections"); if (null == _animatorComponentsArr) { _animatorComponentsArr = _FindAnimatorComponentsInScene(); } if (null == _animatorGameObjectsNames) { _animatorGameObjectsNames = _FindAnimatorsGameObjectsNames(); } _currentAnimatorIndex = EditorGUILayout.Popup("Animator", _currentAnimatorIndex, _animatorGameObjectsNames); //Verification to destroy highlighter if (_currentAnimator != _animatorComponentsArr[_currentAnimatorIndex] && null != _currentAnimator) { StopAnim(); try { DestroyImmediate(_currentAnimator.gameObject.GetComponent <HierarchyHighlighter>()); } catch { } } _currentAnimator = _animatorComponentsArr[_currentAnimatorIndex]; //FIND THE ANIMATION if (_currentAnimator != null) { if (null == _clipsOfCurrentAnimator) { _clipsOfCurrentAnimator = _FindAnimClips(_currentAnimator); } if (null == _clipsNamesOfCurrentAnimator) { _clipsNamesOfCurrentAnimator = _FindAnimNames(_clipsOfCurrentAnimator); } } GUILayout.Space(10f); _currentClipIndex = EditorGUILayout.Popup("Animation", _currentClipIndex, _clipsNamesOfCurrentAnimator); ToolBoxEditorGUILayout.EndBox(); //GIVE THE INFOMRATIONS OF THE ANIMATION ToolBoxEditorGUILayout.BeginBox("Informations"); GUILayout.Label("Length : " + _clipsOfCurrentAnimator[_currentClipIndex].length); if (!_useSlider) { if (_isPlaying && !_stop) { GUILayout.Label("Actual Time : " + (Time.realtimeSinceStartup - _editorLastTime) * _speed % _clipsOfCurrentAnimator[_currentClipIndex].length); } else { GUILayout.Label("Actual Time : 0"); } } else { GUILayout.Label("Actual Time : " + _valueOfSlider); } GUILayout.Label("Looping : " + _clipsOfCurrentAnimator[_currentClipIndex].isLooping); ToolBoxEditorGUILayout.EndBox(); //MODE OF PLAY ToolBoxEditorGUILayout.BeginBox("Playing Mode"); _useSlider = GUILayout.Toggle(_useSlider, "Use a slider"); if (!_useSlider) { _speed = EditorGUILayout.Slider("Speed", _speed, 0f, 40f); _delay = EditorGUILayout.FloatField("Delay between loops", _delay); } else { _valueOfSlider = EditorGUILayout.Slider("Time of Animation", _valueOfSlider, 0f, _clipsOfCurrentAnimator[_currentClipIndex].length); if (!_isPlaying) { EditorGUILayout.HelpBox("You have to play to show the animation", MessageType.Warning); } } ToolBoxEditorGUILayout.EndBox(); //BUTTONS GUILayout.Space(30f); if (!Application.isPlaying) { if (_isPlaying) { if (GUILayout.Button("Stop")) { StopAnim(); } } else if (GUILayout.Button("Play")) { PlayAnim(); } } //Stop the animation if playing else { if (_isPlaying) { StopAnim(); } } if (GUILayout.Button("Select in scene")) { Selection.activeGameObject = _currentAnimator.gameObject; _currentAnimator.gameObject.AddComponent <HierarchyHighlighter>(); SceneView.lastActiveSceneView.FrameSelected(); EditorGUIUtility.PingObject(_currentAnimator.gameObject); } }