예제 #1
0
        /// <summary>
        /// On enable, grabs our serialized properties
        /// </summary>
        protected virtual void OnEnable()
        {
            FloatController myTarget = (FloatController)target;

            _TargetObject = serializedObject.FindProperty("TargetObject");

            _Curve    = serializedObject.FindProperty("Curve");
            _MinValue = serializedObject.FindProperty("MinValue");
            _MaxValue = serializedObject.FindProperty("MaxValue");
            _Duration = serializedObject.FindProperty("Duration");

            _Amplitude = serializedObject.FindProperty("Amplitude");
            _Frequency = serializedObject.FindProperty("Frequency");
            _Shift     = serializedObject.FindProperty("Shift");

            _OneTimeDuration  = serializedObject.FindProperty("OneTimeDuration");
            _OneTimeAmplitude = serializedObject.FindProperty("OneTimeAmplitude");
            _OneTimeCurve     = serializedObject.FindProperty("OneTimeCurve");
            _OneTimeButton    = serializedObject.FindProperty("OneTimeButton");

            _InitialValue = serializedObject.FindProperty("InitialValue");
            _CurrentValue = serializedObject.FindProperty("CurrentValue");

            _ChoiceIndex  = serializedObject.FindProperty("ChoiceIndex");
            _PropertyName = serializedObject.FindProperty("PropertyName");

            _AudioAnalyzer           = serializedObject.FindProperty("AudioAnalyzer");
            _BeatID                  = serializedObject.FindProperty("BeatID");
            _AudioAnalyzerMultiplier = serializedObject.FindProperty("AudioAnalyzerMultiplier");

            VerifyChosenIndex();
            AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload;
        }
예제 #2
0
        /// <summary>
        /// Draws a custom conditional inspector
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Undo.RecordObject(target, "Modified FloatController");

            FloatController myTarget = (FloatController)target;

            EditorGUILayout.PropertyField(_TargetObject);
            if (myTarget.AttributeNames != null)
            {
                if (myTarget.AttributeNames.Length > 0)
                {
                    // draws a dropdown with all our properties
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Property");

                    _ChoiceIndex.intValue = EditorGUILayout.Popup(myTarget.ChoiceIndex, myTarget.AttributeNames);
                    BindPropertyName();
                    EditorGUILayout.EndHorizontal();

                    Editor.DrawPropertiesExcluding(serializedObject, new string[] { "m_Script", "TargetObject", "Curve", "MinValue", "MaxValue", "Duration", "Amplitude",
                                                                                    "Frequency", "Shift", "InitialValue", "CurrentValue",
                                                                                    "OneTimeDuration", "OneTimeAmplitude", "OneTimeCurve", "OneTimeButton",
                                                                                    "AudioAnalyzer", "BeatID", "AudioAnalyzerMultiplier" });

                    if (myTarget.ControlMode == FloatController.ControlModes.PingPong)
                    {
                        EditorGUILayout.PropertyField(_Curve);
                        EditorGUILayout.PropertyField(_MinValue);
                        EditorGUILayout.PropertyField(_MaxValue);
                        EditorGUILayout.PropertyField(_Duration);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.Random)
                    {
                        EditorGUILayout.PropertyField(_Amplitude);
                        EditorGUILayout.PropertyField(_Frequency);
                        EditorGUILayout.PropertyField(_Shift);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.OneTime)
                    {
                        EditorGUILayout.PropertyField(_OneTimeDuration);
                        EditorGUILayout.PropertyField(_OneTimeAmplitude);
                        EditorGUILayout.PropertyField(_OneTimeCurve);
                        EditorGUILayout.PropertyField(_OneTimeButton);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.AudioAnalyzer)
                    {
                        EditorGUILayout.PropertyField(_AudioAnalyzer);
                        EditorGUILayout.PropertyField(_BeatID);
                        EditorGUILayout.PropertyField(_AudioAnalyzerMultiplier);
                    }

                    EditorGUILayout.PropertyField(_InitialValue);
                    EditorGUILayout.PropertyField(_CurrentValue);
                }
            }


            serializedObject.ApplyModifiedProperties();
        }
예제 #3
0
        protected virtual void OnAfterAssemblyReload()
        {
            FloatController myTarget = (FloatController)target;

            myTarget.FillDropDownList();
            VerifyChosenIndex();
            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        /// On enable, grabs our serialized properties
        /// </summary>
        protected virtual void OnEnable()
        {
            FloatController myTarget = (FloatController)target;

            _TargetObject = serializedObject.FindProperty("TargetObject");

            _Curve    = serializedObject.FindProperty("Curve");
            _MinValue = serializedObject.FindProperty("MinValue");
            _MaxValue = serializedObject.FindProperty("MaxValue");
            _Duration = serializedObject.FindProperty("Duration");
            _PingPongPauseDuration = serializedObject.FindProperty("PingPongPauseDuration");

            _Amplitude        = serializedObject.FindProperty("Amplitude");
            _Frequency        = serializedObject.FindProperty("Frequency");
            _Shift            = serializedObject.FindProperty("Shift");
            _RemapNoiseValues = serializedObject.FindProperty("RemapNoiseValues");
            _RemapNoiseZero   = serializedObject.FindProperty("RemapNoiseZero");
            _RemapNoiseOne    = serializedObject.FindProperty("RemapNoiseOne");

            _OneTimeDuration               = serializedObject.FindProperty("OneTimeDuration");
            _OneTimeAmplitude              = serializedObject.FindProperty("OneTimeAmplitude");
            _OneTimeRemapMin               = serializedObject.FindProperty("OneTimeRemapMin");
            _OneTimeRemapMax               = serializedObject.FindProperty("OneTimeRemapMax");
            _OneTimeCurve                  = serializedObject.FindProperty("OneTimeCurve");
            _DisableAfterOneTime           = serializedObject.FindProperty("DisableAfterOneTime");
            _DisableGameObjectAfterOneTime = serializedObject.FindProperty("DisableGameObjectAfterOneTime");
            _OneTimeButton                 = serializedObject.FindProperty("OneTimeButton");

            _DrivenLevel = serializedObject.FindProperty("DrivenLevel");

            _ToDestinationValue        = serializedObject.FindProperty("ToDestinationValue");
            _ToDestinationDuration     = serializedObject.FindProperty("ToDestinationDuration");
            _ToDestinationCurve        = serializedObject.FindProperty("ToDestinationCurve");
            _DisableAfterToDestination = serializedObject.FindProperty("DisableAfterToDestination");
            _ToDestinationButton       = serializedObject.FindProperty("ToDestinationButton");

            _InitialValue           = serializedObject.FindProperty("InitialValue");
            _CurrentValue           = serializedObject.FindProperty("CurrentValue");
            _CurrentValueNormalized = serializedObject.FindProperty("CurrentValueNormalized");

            _ChoiceIndex  = serializedObject.FindProperty("ChoiceIndex");
            _PropertyName = serializedObject.FindProperty("PropertyName");

            _AudioAnalyzer           = serializedObject.FindProperty("AudioAnalyzer");
            _AudioAnalyzerMode       = serializedObject.FindProperty("AudioAnalyzerMode");
            _NormalizedLevelID       = serializedObject.FindProperty("NormalizedLevelID");
            _BeatID                  = serializedObject.FindProperty("BeatID");
            _AudioAnalyzerMultiplier = serializedObject.FindProperty("AudioAnalyzerMultiplier");

            VerifyChosenIndex();
            AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload;
        }
예제 #5
0
        protected virtual void BindPropertyName()
        {
            FloatController myTarget = (FloatController)target;

            if (myTarget.ChoiceIndex > myTarget.AttributeNames.Length - 1)
            {
                _ChoiceIndex.intValue     = 0;
                _PropertyName.stringValue = FloatController._undefinedString;
            }
            else
            {
                _PropertyName.stringValue = myTarget.AttributeNames[myTarget.ChoiceIndex];
                serializedObject.ApplyModifiedProperties();
            }
        }
예제 #6
0
        protected virtual void VerifyChosenIndex()
        {
            FloatController myTarget = (FloatController)target;

            // determine choice index
            int  index = 0;
            bool found = false;

            foreach (string attName in myTarget.AttributeNames)
            {
                if (attName == myTarget.PropertyName)
                {
                    _ChoiceIndex.intValue = index;
                    found = true;
                }
                index++;
            }
            if (!found)
            {
                _ChoiceIndex.intValue     = 0;
                _PropertyName.stringValue = FloatController._undefinedString;
            }
            serializedObject.ApplyModifiedProperties();
        }
        /// <summary>
        /// Draws a custom conditional inspector
        /// </summary>
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            Undo.RecordObject(target, "Modified FloatController");

            FloatController myTarget = (FloatController)target;

            EditorGUILayout.PropertyField(_TargetObject);
            if (myTarget.AttributeNames != null)
            {
                if (myTarget.AttributeNames.Length > 0)
                {
                    // draws a dropdown with all our properties
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Property");

                    _ChoiceIndex.intValue = EditorGUILayout.Popup(myTarget.ChoiceIndex, myTarget.AttributeNames);
                    BindPropertyName();
                    EditorGUILayout.EndHorizontal();

                    Editor.DrawPropertiesExcluding(serializedObject, new string[] { "m_Script", "TargetObject", "Curve", "MinValue", "MaxValue", "Duration", "Amplitude",
                                                                                    "RemapNoiseValues", "RemapNoiseZero", "RemapNoiseOne",
                                                                                    "Frequency", "Shift", "InitialValue", "CurrentValue", "CurrentValueNormalized", "PingPongPauseDuration",
                                                                                    "OneTimeDuration", "OneTimeAmplitude", "OneTimeRemapMin", "OneTimeRemapMax",
                                                                                    "OneTimeCurve", "OneTimeButton", "DisableAfterOneTime", "DisableGameObjectAfterOneTime",
                                                                                    "AudioAnalyzer", "BeatID", "AudioAnalyzerMultiplier", "DisableAfterToDestination", "DrivenLevel",
                                                                                    "ToDestinationDuration", "ToDestinationValue", "ToDestinationCurve", "ToDestinationButton" });

                    if (myTarget.ControlMode == FloatController.ControlModes.PingPong)
                    {
                        EditorGUILayout.PropertyField(_Curve);
                        EditorGUILayout.PropertyField(_MinValue);
                        EditorGUILayout.PropertyField(_MaxValue);
                        EditorGUILayout.PropertyField(_Duration);
                        EditorGUILayout.PropertyField(_PingPongPauseDuration);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.Random)
                    {
                        EditorGUILayout.PropertyField(_Amplitude);
                        EditorGUILayout.PropertyField(_Frequency);
                        EditorGUILayout.PropertyField(_Shift);
                        EditorGUILayout.PropertyField(_RemapNoiseValues);
                        EditorGUILayout.PropertyField(_RemapNoiseZero);
                        EditorGUILayout.PropertyField(_RemapNoiseOne);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.Driven)
                    {
                        EditorGUILayout.PropertyField(_DrivenLevel);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.OneTime)
                    {
                        EditorGUILayout.PropertyField(_OneTimeDuration);
                        EditorGUILayout.PropertyField(_OneTimeAmplitude);
                        EditorGUILayout.PropertyField(_OneTimeRemapMin);
                        EditorGUILayout.PropertyField(_OneTimeRemapMax);
                        EditorGUILayout.PropertyField(_OneTimeCurve);
                        EditorGUILayout.PropertyField(_DisableAfterOneTime);
                        EditorGUILayout.PropertyField(_DisableGameObjectAfterOneTime);
                        EditorGUILayout.PropertyField(_OneTimeButton);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.AudioAnalyzer)
                    {
                        EditorGUILayout.PropertyField(_AudioAnalyzer);
                        EditorGUILayout.PropertyField(_AudioAnalyzerMode);
                        if (myTarget.AudioAnalyzerMode == FloatController.AudioAnalyzerModes.Beat)
                        {
                            EditorGUILayout.PropertyField(_BeatID);
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(_NormalizedLevelID);
                        }
                        EditorGUILayout.PropertyField(_AudioAnalyzerMultiplier);
                    }
                    else if (myTarget.ControlMode == FloatController.ControlModes.ToDestination)
                    {
                        EditorGUILayout.PropertyField(_ToDestinationDuration);
                        EditorGUILayout.PropertyField(_ToDestinationValue);
                        EditorGUILayout.PropertyField(_ToDestinationCurve);
                        EditorGUILayout.PropertyField(_DisableAfterToDestination);
                        EditorGUILayout.PropertyField(_ToDestinationButton);
                    }

                    EditorGUILayout.PropertyField(_InitialValue);
                    EditorGUILayout.PropertyField(_CurrentValue);
                    EditorGUILayout.PropertyField(_CurrentValueNormalized);
                }
            }


            serializedObject.ApplyModifiedProperties();

            if (Application.isPlaying)
            {
                _barRect = EditorGUILayout.GetControlRect();
                DrawLevelProgressBar(_barRect, myTarget.CurrentValueNormalized, _mmYellow, _mmRed);
            }
        }