public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            rect.height = height;
            mExpanded   = EditorGUI.Foldout(rect, mExpanded, label, true);
            if (mExpanded)
            {
                ++EditorGUI.indentLevel;

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_LimitMode));
                if (IsAxisLimit(property))
                {
                    rect.y += height + vSpace;
                    EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_RemoveLimitMode));
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(
                        rect, null,
                        new[] { property.FindPropertyRelative(() => def.m_LookTarget),
                                property.FindPropertyRelative(() => def.m_Camera) },
                        new[] { GUIContent.none, null });
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(
                        rect, null,
                        new[] { property.FindPropertyRelative(() => def.m_AxisVector),
                                property.FindPropertyRelative(() => def.m_LimitRange) },
                        new[] { GUIContent.none, null });
                }
                --EditorGUI.indentLevel;
            }
        }
Exemple #2
0
 public override void OnInspectorGUI()
 {
     BeginInspector();
     DrawRemainingPropertiesInInspector();
     InspectorUtility.MultiPropertyOnLine(
         EditorGUILayout.GetControlRect(), mRepeatLabel,
         mRepeatProperties, mRepeatSubLabels);
     mEnterExpanded = DrawActionSettings(FindProperty(x => x.m_EnterAction), mEnterExpanded);
     mExitExpanded  = DrawActionSettings(FindProperty(x => x.m_ExitAction), mExitExpanded);
 }
        AxisState def    = new AxisState(); // to access name strings

        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            rect.height = height;
            mExpanded   = EditorGUI.Foldout(rect, mExpanded, label);
            if (mExpanded)
            {
                ++EditorGUI.indentLevel;

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.Value));

                if (!ValueRangeIsLocked(property))
                {
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(rect, new GUIContent("Value Range"),
                                                         new [] { property.FindPropertyRelative(() => def.m_MinValue),
                                                                  property.FindPropertyRelative(() => def.m_MaxValue),
                                                                  property.FindPropertyRelative(() => def.m_Wrap) },
                                                         new [] { GUIContent.none, new GUIContent("to "), null });
                }

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_MaxSpeed));

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_AccelTime));

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_DecelTime));

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.m_InputAxisName));

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(rect, null,
                                                     new [] { property.FindPropertyRelative(() => def.m_InputAxisValue),
                                                              property.FindPropertyRelative(() => def.m_InvertInput) },
                                                     new [] { GUIContent.none, new GUIContent("Invert") });

                --EditorGUI.indentLevel;
            }
        }
Exemple #4
0
            = new CinemachineImpulseManager.EnvelopeDefinition(); // to access name strings

        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            rect.height = height;
            mExpanded   = EditorGUI.Foldout(rect, mExpanded, label, true);
            if (mExpanded)
            {
                const float indentAmount = 15;
                rect.width -= indentAmount; rect.x += indentAmount;
                float oldWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth -= indentAmount;

                rect.y += EditorGUIUtility.singleLineHeight + vSpace;
                DrawCurveTimeProperty(
                    rect, new GUIContent("Attack", "The custom shape of the attack curve.  Leave it blank for a default shape"),
                    property.FindPropertyRelative(() => myClass.m_AttackShape),
                    property.FindPropertyRelative(() => myClass.m_AttackTime));

                rect.y += EditorGUIUtility.singleLineHeight + vSpace;
#if false // with "forever" button... dangerous because signal never goes away!
                var holdProp = property.FindPropertyRelative(() => myClass.m_SustainTime);
                InspectorUtility.MultiPropertyOnLine(
                    rect, new GUIContent(holdProp.displayName, holdProp.tooltip),
                    new SerializedProperty[] { holdProp, property.FindPropertyRelative(() => myClass.m_HoldForever) },
                    new GUIContent[] { GUIContent.none, new GUIContent("forever") });
#else
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => myClass.m_SustainTime));
#endif
                rect.y += EditorGUIUtility.singleLineHeight + vSpace;
                DrawCurveTimeProperty(
                    rect, new GUIContent("Decay", "The custom shape of the decay curve.  Leave it blank for a default shape"),
                    property.FindPropertyRelative(() => myClass.m_DecayShape),
                    property.FindPropertyRelative(() => myClass.m_DecayTime));

                rect.y += EditorGUIUtility.singleLineHeight + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => myClass.m_ScaleWithImpact));

                EditorGUIUtility.labelWidth = oldWidth;
            }
        }
        bool DrawActionSettings(SerializedProperty property, bool expanded)
        {
            if (mFoldoutStyle == null)
            {
                mFoldoutStyle = new GUIStyle(EditorStyles.foldout)
                {
                    fontStyle = FontStyle.Bold
                }
            }
            ;

            Rect r = EditorGUILayout.GetControlRect();

            expanded = EditorGUI.Foldout(r, expanded, property.displayName, true, mFoldoutStyle);
            if (expanded)
            {
                SerializedProperty actionProp = property.FindPropertyRelative(() => def.m_Action);
                EditorGUILayout.PropertyField(actionProp);

                SerializedProperty targetProp = property.FindPropertyRelative(() => def.m_Target);
                bool isCustom = (actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Custom);
                if (!isCustom)
                {
                    EditorGUILayout.PropertyField(targetProp);
                }

                bool isBoost = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.PriorityBoost;
                if (isBoost)
                {
                    EditorGUILayout.PropertyField(property.FindPropertyRelative(() => def.m_BoostAmount));
                }

#if CINEMACHINE_TIMELINE
                bool isPlay = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Play;
                if (isPlay)
                {
                    SerializedProperty[] props = new SerializedProperty[2]
                    {
                        property.FindPropertyRelative(() => def.m_StartTime),
                        property.FindPropertyRelative(() => def.m_Mode)
                    };
                    GUIContent[] sublabels = new GUIContent[2]
                    {
                        GUIContent.none, new GUIContent("s", props[1].tooltip)
                    };
                    InspectorUtility.MultiPropertyOnLine(
                        EditorGUILayout.GetControlRect(), null, props, sublabels);
                }
#endif
                if (actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Custom)
                {
                    EditorGUILayout.HelpBox("Use the Event() list below to call custom methods", MessageType.Info);
                }

                if (isBoost)
                {
                    if (GetTargetComponent <CinemachineVirtualCameraBase>(targetProp.objectReferenceValue) == null)
                    {
                        EditorGUILayout.HelpBox("Target must be a CinemachineVirtualCameraBase in order to boost priority", MessageType.Warning);
                    }
                }

                bool isEnableDisable = (actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Enable ||
                                        actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Disable);
                if (isEnableDisable)
                {
                    var value = targetProp.objectReferenceValue;
                    if (value != null && (value as Behaviour) == null)
                    {
                        EditorGUILayout.HelpBox("Target must be a Behaviour in order to Enable/Disable", MessageType.Warning);
                    }
                }
#if CINEMACHINE_TIMELINE
                bool isPlayStop = isPlay ||
                                  actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Stop;
                if (isPlayStop)
                {
                    if (GetTargetComponent <Animator>(targetProp.objectReferenceValue) == null &&
                        GetTargetComponent <PlayableDirector>(targetProp.objectReferenceValue) == null)
                    {
                        EditorGUILayout.HelpBox("Target must have a PlayableDirector or Animator in order to Play/Stop", MessageType.Warning);
                    }
                }
#endif
                if (!isCustom && targetProp.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("No action will be taken because target is not valid", MessageType.Info);
                }

                EditorGUILayout.Space();
                EditorGUILayout.LabelField("This event will be invoked.  Add calls to custom methods here:");
                EditorGUILayout.PropertyField(property.FindPropertyRelative(() => def.m_Event));
            }
            property.serializedObject.ApplyModifiedProperties();
            return(expanded);
        }

        T GetTargetComponent <T>(UnityEngine.Object obj) where T : Behaviour
        {
            UnityEngine.Object currentTarget = obj;
            if (currentTarget != null)
            {
                GameObject targetGameObject = currentTarget as GameObject;
                Behaviour  targetBehaviour  = currentTarget as Behaviour;
                if (targetBehaviour != null)
                {
                    targetGameObject = targetBehaviour.gameObject;
                }
                if (targetBehaviour is T)
                {
                    return(targetBehaviour as T);
                }
                if (targetGameObject != null)
                {
                    return(targetGameObject.GetComponent <T>());
                }
            }
            return(null);
        }
    }
Exemple #6
0
        bool DrawActionSettings(SerializedProperty property, bool expanded)
        {
            Rect r = EditorGUILayout.GetControlRect();

            expanded = EditorGUI.Foldout(r, expanded, property.displayName);
            if (expanded)
            {
                SerializedProperty actionProp = property.FindPropertyRelative(() => def.m_Action);
                EditorGUILayout.PropertyField(actionProp);

                SerializedProperty targetProp = property.FindPropertyRelative(() => def.m_Target);
                EditorGUILayout.PropertyField(targetProp);

                bool isBoost = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.PriorityBoost;
                if (isBoost)
                {
                    EditorGUILayout.PropertyField(property.FindPropertyRelative(() => def.m_BoostAmount));
                }

                bool isPlay = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Play;
                if (isPlay)
                {
                    SerializedProperty[] props = new SerializedProperty[2]
                    {
                        property.FindPropertyRelative(() => def.m_StartTime),
                        property.FindPropertyRelative(() => def.m_Mode)
                    };
                    GUIContent[] sublabels = new GUIContent[2]
                    {
                        GUIContent.none, new GUIContent("s", props[1].tooltip)
                    };
                    InspectorUtility.MultiPropertyOnLine(
                        EditorGUILayout.GetControlRect(), null, props, sublabels);
                }

                SerializedProperty methodProp = property.FindPropertyRelative(() => def.m_MethodName);
                bool isBroadcast = actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Broadcast;
                if (isBroadcast)
                {
                    EditorGUILayout.PropertyField(methodProp);
                    string value = methodProp.stringValue.Trim();
                    if (value.Length == 0)
                    {
                        EditorGUILayout.HelpBox("Supply the name of a method to call. The method will be called in the target object, if it exists", MessageType.Info);
                    }
                }

                if (isBoost)
                {
                    if (GetTargetComponent <CinemachineVirtualCameraBase>(targetProp.objectReferenceValue) == null)
                    {
                        EditorGUILayout.HelpBox("Target must be a CinemachineVirtualCameraBase in order to boost priority", MessageType.Warning);
                    }
                }

                bool isEnableDisable = (actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Enable ||
                                        actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Disable);
                if (isEnableDisable)
                {
                    var value = targetProp.objectReferenceValue;
                    if (value != null && (value as Behaviour) == null)
                    {
                        EditorGUILayout.HelpBox("Target must be a Behaviour in order to Enable/Disable", MessageType.Warning);
                    }
                }

                bool isPlayStop = isPlay ||
                                  actionProp.intValue == (int)CinemachineTriggerAction.ActionSettings.Mode.Stop;
                if (isPlayStop)
                {
                    if (GetTargetComponent <Animator>(targetProp.objectReferenceValue) == null &&
                        GetTargetComponent <PlayableDirector>(targetProp.objectReferenceValue) == null)
                    {
                        EditorGUILayout.HelpBox("Target must have a PlayableDirector or Animator in order to Play/Stop", MessageType.Warning);
                    }
                }

                if (targetProp.objectReferenceValue == null)
                {
                    EditorGUILayout.HelpBox("No action will be taken because target is not valid", MessageType.Info);
                }

                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(property.FindPropertyRelative(() => def.m_Event));
            }
            property.serializedObject.ApplyModifiedProperties();
            return(expanded);
        }
Exemple #7
0
        AxisState def    = new AxisState(); // to access name strings

        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            float height = EditorGUIUtility.singleLineHeight;

            rect.height = height;
            mExpanded   = EditorGUI.Foldout(rect, mExpanded, EditorGUI.BeginProperty(rect, label, property), true);
            if (mExpanded)
            {
                ++EditorGUI.indentLevel;

                rect.y += height + vSpace;
                EditorGUI.PropertyField(rect, property.FindPropertyRelative(() => def.Value));

                if (!ValueRangeIsLocked(property))
                {
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(rect, new GUIContent("Value Range"),
                                                         new [] { property.FindPropertyRelative(() => def.m_MinValue),
                                                                  property.FindPropertyRelative(() => def.m_MaxValue),
                                                                  property.FindPropertyRelative(() => def.m_Wrap) },
                                                         new [] { GUIContent.none, new GUIContent("to "), null });
                }

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(rect, new GUIContent("Speed"),
                                                     new [] { property.FindPropertyRelative(() => def.m_MaxSpeed),
                                                              property.FindPropertyRelative(() => def.m_SpeedMode) },
                                                     new [] { GUIContent.none, new GUIContent("as") });

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(
                    rect, null,
                    new [] { property.FindPropertyRelative(() => def.m_AccelTime),
                             property.FindPropertyRelative(() => def.m_DecelTime) },
                    new [] { GUIContent.none, null });

                if (HasRecentering(property))
                {
                    var rDef        = new AxisState.Recentering();
                    var recentering = property.FindPropertyRelative(() => def.m_Recentering);
                    rect.y += height + vSpace;
                    InspectorUtility.MultiPropertyOnLine(
                        rect, new GUIContent(recentering.displayName, recentering.tooltip),
                        new [] {
                        recentering.FindPropertyRelative(() => rDef.m_enabled),
                        recentering.FindPropertyRelative(() => rDef.m_WaitTime),
                        recentering.FindPropertyRelative(() => rDef.m_RecenteringTime)
                    },
                        new [] { new GUIContent(""),
                                 new GUIContent("Wait"),
                                 new GUIContent("Time") });
                }

                if (!HasInputProvider(property))
                {
                    rect.y += height + vSpace;
                    EditorGUI.PropertyField(
                        rect, property.FindPropertyRelative(() => def.m_InputAxisName));
                }

                rect.y += height + vSpace;
                InspectorUtility.MultiPropertyOnLine(rect, null,
                                                     new [] { property.FindPropertyRelative(() => def.m_InputAxisValue),
                                                              property.FindPropertyRelative(() => def.m_InvertInput) },
                                                     new [] { GUIContent.none, new GUIContent("Invert") });

                --EditorGUI.indentLevel;
            }
        }