Tanoda
TransitionBehaviourEditor.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9using System.Collections;
10using System.Collections.Generic;
11using UnityEngine;
12using UnityEditor;
13
14namespace Leap.Unity.Recording {
15
16 [CanEditMultipleObjects]
17 [CustomEditor(typeof(TransitionBehaviour), editorForChildClasses: true, isFallback = true)]
18 public class TransitionBehaviourEditor : CustomEditorBase<TransitionBehaviour> {
19
20 protected override void OnEnable() {
21 base.OnEnable();
22
23 specifyCustomDrawer("transitionState", drawIndentedTransitionState);
24 }
25
26 private void drawIndentedTransitionState(SerializedProperty prop) {
27 EditorGUI.indentLevel++;
28
29 if (prop.objectReferenceValue == null) {
30 GUI.contentColor = new Color(0.7f, 0.7f, 0.7f, 1);
31 }
32
33 EditorGUILayout.PropertyField(prop);
34 EditorGUI.indentLevel--;
35 GUI.contentColor = Color.white;
36
37 EditorGUILayout.Space();
38 }
39
40 public override void OnInspectorGUI() {
41 base.OnInspectorGUI();
42
43 if (targets.Length == 1 && Application.isPlaying) {
44 if (GUILayout.Button("Execute Transition")) {
45 target.Transition();
46 }
47 }
48 }
49 }
50}
UnityEngine.Color Color
Definition: TestScript.cs:32
void specifyCustomDrawer(string propertyName, Action< SerializedProperty > propertyDrawer)
Specify a callback to be used to draw a specific named property. Should be called in OnEnable.