public override void OnInspectorGUI() { Level level = (Level)target; float linearizedFrequency = level.linearizedFrequency; linearizedFrequency = SpectrumGUILayout.SpectrumField(level.spectrumFilter, level.linearizedFrequency, level.levelBeat); foreach (Level lvl in targets) { lvl.linearizedFrequency = Frequency.UnlinearizeFrequency(linearizedFrequency, Frequency.LowestAudibleFrequency, Frequency.HighestAudibleFrequency); } serializedObject.Update(); EditorGUILayout.PropertyField(spectrumFilterProp, new GUIContent("SpectrumFilter", "SpectrumFilter to grab spectrum data from. If this is set to None, then it'll try to find a SpectrumFilter at runtime by looking up through the hierarchy.")); EditorGUILayout.PropertyField(linearizedFrequencyProp, new GUIContent("Frequency (Hz)", "Frequency to track. Set the frequency directly here, or click in the frequency window above.")); EditorGUILayout.PropertyField(inheritableProp, new GUIContent("Inheritable", "Tells a PropertyDriver if it can inherit this Level or not, unless the PropertyDriver is sharing the same GameObject as the Level, in which the Level will automatically be inherited.")); serializedObject.ApplyModifiedProperties(); foreach (Level lvl in targets) { lvl.linearizedFrequency = Mathf.Clamp(lvl.linearizedFrequency, Frequency.LowestAudibleFrequency, Frequency.HighestAudibleFrequency); lvl.linearizedFrequency = Frequency.LinearizeFrequency(lvl.linearizedFrequency); Undo.RecordObject(lvl, "Level"); } if (Application.isPlaying || GUI.changed) { Repaint(); } }
public override void OnInspectorGUI() { serializedObject.Update(); SpectrumFilter spectrumFilter = (SpectrumFilter)target; SpectrumGUILayout.SpectrumField(spectrumFilter, 2.0f, -1.0f); EditorGUILayout.PropertyField(spectrumSource, new GUIContent("SpectrumSource", "The SpectrumSource to filter. If this is set to None, then it'll try to find a SpectrumSource at runtime by looking up through the hierarchy.")); EditorGUILayout.PropertyField(eq, new GUIContent("EQ", "Allows the user to make finer adjustments to the spectrum.")); EditorGUILayout.PropertyField(interpolationType, new GUIContent("Interpolation", "Sets whether the values in between levels ease in and out or are straight lines.")); EditorGUILayout.PropertyField(scale, new GUIContent("Scale", "Scales all magnitudes equally for the given SpectrumSource")); EditorGUILayout.PropertyField(fallSpeed, new GUIContent("Fall Speed", "The time in seconds a level at maximum height will reach its minimum height.")); EditorGUILayout.PropertyField(beatSensitivity, new GUIContent("Beat Sensitivity", "The percentage threshold that a level has to move to trigger a beat. 1 equals 100%")); // Update frequently while it's playing. if (EditorApplication.isPlaying || GUI.changed) { Repaint(); } serializedObject.ApplyModifiedProperties(); }