From 3534f09da2ce29e2d58de3aceefc77fc854721be Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 4 Oct 2025 01:14:40 -0400 Subject: [PATCH] change: moved value group editors to Editor folder --- Assets/Scripts/Core/Editor.meta | 8 + .../Scripts/Core/Editor/ValueGroupEditors.cs | 480 +++++++++++++++++ .../{ => Editor}/ValueGroupEditors.cs.meta | 0 Assets/Scripts/Core/ValueGroupEditors.cs | 483 ------------------ 4 files changed, 488 insertions(+), 483 deletions(-) create mode 100644 Assets/Scripts/Core/Editor.meta create mode 100644 Assets/Scripts/Core/Editor/ValueGroupEditors.cs rename Assets/Scripts/Core/{ => Editor}/ValueGroupEditors.cs.meta (100%) delete mode 100644 Assets/Scripts/Core/ValueGroupEditors.cs diff --git a/Assets/Scripts/Core/Editor.meta b/Assets/Scripts/Core/Editor.meta new file mode 100644 index 0000000..ece7efb --- /dev/null +++ b/Assets/Scripts/Core/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07ef2a4305e0a06408bd8ebe1a7b41f3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Core/Editor/ValueGroupEditors.cs b/Assets/Scripts/Core/Editor/ValueGroupEditors.cs new file mode 100644 index 0000000..f15dc88 --- /dev/null +++ b/Assets/Scripts/Core/Editor/ValueGroupEditors.cs @@ -0,0 +1,480 @@ +using NodeCanvas.Editor; +using ParadoxNotion.Design; +using Reset.Core; +using UnityEditor; +using UnityEngine; + +public class BoolValueGroupDrawer : ObjectDrawer { + public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(80.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); + + // Create the value/disabled information field + if (_instance.changeValue.value == ValueChangeAction.NewValue){ + _instance.value = EditorGUILayout.Toggle(_instance.value.value, floatOptions); + } else if (_instance.changeValue.value == ValueChangeAction.RelativeValue){ + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField("Not Available", floatOptions); + EditorGUI.EndDisabledGroup(); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + + + +public class CurveValueGroupDrawer : ObjectDrawer { + public override CurveValueGroup OnGUI(GUIContent _content, CurveValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(80.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); + + // Create the value/disabled information field + if (_instance.changeValue.value == ValueChangeAction.NewValue){ + BBParameterEditor.ParameterField("", _instance.value); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + +public class EnumValueGroupDrawer : ObjectDrawer{ + public override EnumValueGroup OnGUI(GUIContent _content, EnumValueGroup _instance){ + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(200.0f), + GUILayout.MinWidth(100.0f), + GUILayout.ExpandWidth(true), + }; + + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); + + // Create the value/disabled information field + if (_instance.changeValue.value == ValueChangeAction.NewValue){ + _instance.value.value = EditorGUILayout.EnumPopup("", instance.value.value, floatOptions); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField((ValueChangeAction)_instance.value.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } + + +} + +public class FloatValueGroupDrawer : ObjectDrawer { + public override FloatValueGroup OnGUI(GUIContent _content, FloatValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Start the label + GUILayout.BeginHorizontal(); + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(80.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + + // End the label + GUILayout.EndHorizontal(); + + // Start the variables + GUILayout.BeginHorizontal(); + + // Create the x settings enum + // _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); + BBParameterEditor.ParameterField("", _instance.changeValue); + + // Create the value/disabled information field + if (_instance.changeValue.value == ValueChangeAction.NewValue || _instance.changeValue.value == ValueChangeAction.RelativeValue){ + BBParameterEditor.ParameterField("", _instance.value); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up with the variables + GUILayout.EndHorizontal(); + + ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + +public class Vector3ValueGroupDrawer : ObjectDrawer { + public override Vector3ValueGroup OnGUI(GUIContent _content, Vector3ValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 20; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(300.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value); + + // Create the value/disabled information field + if (_instance.changeX.value== ValueChangeAction.NewValue) { + var value = _instance.value.value; + value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions); + _instance.value.value = value; + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the y settings enum + _instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value); + + // Create the value/disabled information field + if (_instance.changeY.value == ValueChangeAction.NewValue) { + var value = _instance.value.value; + value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions); + _instance.value.value = value; + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the y settings enum + _instance.changeZ.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeZ.value); + + // Create the value/disabled information field + if (_instance.changeZ.value == ValueChangeAction.NewValue) { + var value = _instance.value.value; + value.z = EditorGUILayout.FloatField(_instance.value.value.z, floatOptions); + _instance.value.value = value; + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeZ.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + + ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); + + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + +public class Vector2ValueGroupDrawer : ObjectDrawer { + public override Vector2ValueGroup OnGUI(GUIContent _content, Vector2ValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 50; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(300.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options + GUILayout.BeginVertical(); + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + GUILayout.BeginHorizontal(); + + // Create the x settings enum + _instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value); + + // Create the value/disabled information field + if (_instance.changeX.value == ValueChangeAction.NewValue) { + var value = _instance.value.value; + value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions); + _instance.value.value = value; + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // It do what it do. + GUILayout.Space(5); + + // Create the y settings enum + _instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value); + + // Create the value/disabled information field + if (_instance.changeY.value == ValueChangeAction.NewValue) { + var value = _instance.value.value; + value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions); + _instance.value.value = value; + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close this line up + GUILayout.EndHorizontal(); + + ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); + + GUILayout.EndVertical(); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + +// Custom editor for each orbital follow ring setting +public class OrbitalFollowValueGroupDrawer : ObjectDrawer{ + public override OrbitalFollowValueGroup OnGUI(GUIContent _content, OrbitalFollowValueGroup _instance){ + // Remove label for floats + EditorGUIUtility.labelWidth = 1; + + // Set layout options for the label and the float fields + GUILayoutOption[] floatOptions = new GUILayoutOption[] { + // GUILayout.Width(300.0f), + // GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + // Add the label + GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); + + // Start the smoothing and easing section + GUILayout.BeginHorizontal(); + + GUIStyle smallText= new GUIStyle{ + fontSize = 10, + padding = new RectOffset(8, 0, 0,0), + normal ={ + textColor = Color.gray + Color.gray / 2f + } + }; + + // Start the left side for height + GUILayout.BeginVertical(); + + // Draw the label + GUILayout.BeginHorizontal(); + GUILayout.Label("Height", smallText); + GUILayout.EndHorizontal(); + + // Height + BBParameterEditor.ParameterField("", _instance.changeHeight); + + if (_instance.changeHeight.value == ValueChangeAction.NewValue || _instance.changeHeight.value == ValueChangeAction.RelativeValue){ + // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); + BBParameterEditor.ParameterField("", _instance.height); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeHeight.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close height + GUILayout.EndVertical(); + + // Start the right for radius + GUILayout.BeginVertical(); + + // Draw the label + GUILayout.BeginHorizontal(); + GUILayout.Label("Radius", smallText); + GUILayout.EndHorizontal(); + + // Radius + BBParameterEditor.ParameterField("", _instance.changeRadius); + + if (_instance.changeRadius.value == ValueChangeAction.NewValue || _instance.changeRadius.value == ValueChangeAction.RelativeValue){ + // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); + BBParameterEditor.ParameterField("", _instance.radius); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeRadius.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close easing + GUILayout.EndVertical(); + + GUILayout.Space(8); + + GUILayout.EndHorizontal(); + + ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); + + // Reset to default so the rest of things don't get messed up + EditorGUIUtility.labelWidth = 0; + return _instance; + } +} + +public static class ValueGroupEditorUtilities{ + public static void DrawEasingAndSmoothingSection(ValueGroup.ISmoothable _instance){ + // Start the smoothing and easing section + GUILayout.BeginHorizontal(); + + GUIStyle smallText= new GUIStyle{ + fontSize = 10, + padding = new RectOffset(8, 0, 0,0), + normal ={ + textColor = Color.gray + } + }; + + // Start the left side for easing + GUILayout.BeginVertical(); + + // Draw the label + GUILayout.BeginHorizontal(); + GUILayout.Label("Easing", smallText); + GUILayout.EndHorizontal(); + + // Easing + // _instance.changeEasing.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeEasing.value); + BBParameterEditor.ParameterField("", _instance.changeEasing); + + if (_instance.changeEasing.value == ValueChangeAction.NewValue){ + // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); + BBParameterEditor.ParameterField("", _instance.Easing); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeEasing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close easing + GUILayout.EndVertical(); + + // Start the right for smoothing + GUILayout.BeginVertical(); + + // Draw the label + GUILayout.BeginHorizontal(); + GUILayout.Label("Smoothing", smallText); + GUILayout.EndHorizontal(); + + // Smoothing + BBParameterEditor.ParameterField("", _instance.changeSmoothing); + + if (_instance.changeSmoothing.value == ValueChangeAction.NewValue){ + // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); + BBParameterEditor.ParameterField("", _instance.Smoothing); + } else { + EditorGUI.BeginDisabledGroup(true); + EditorGUILayout.TextField(_instance.changeSmoothing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); + EditorGUI.EndDisabledGroup(); + } + + // Close easing + GUILayout.EndVertical(); + + GUILayout.Space(8); + + GUILayout.EndHorizontal(); + } + + static GUILayoutOption[] floatOptions = new GUILayoutOption[] { + GUILayout.Width(300.0f), + GUILayout.MinWidth(20.0f), + GUILayout.ExpandWidth(true), + }; + + public static GUIStyle titleText = new GUIStyle{ + fontSize = 12, + fontStyle = FontStyle.Bold, + padding = new RectOffset(8, 0, 3,0), + normal ={ + textColor = Color.white + } + }; +} \ No newline at end of file diff --git a/Assets/Scripts/Core/ValueGroupEditors.cs.meta b/Assets/Scripts/Core/Editor/ValueGroupEditors.cs.meta similarity index 100% rename from Assets/Scripts/Core/ValueGroupEditors.cs.meta rename to Assets/Scripts/Core/Editor/ValueGroupEditors.cs.meta diff --git a/Assets/Scripts/Core/ValueGroupEditors.cs b/Assets/Scripts/Core/ValueGroupEditors.cs deleted file mode 100644 index e20ea5b..0000000 --- a/Assets/Scripts/Core/ValueGroupEditors.cs +++ /dev/null @@ -1,483 +0,0 @@ -#if UNITY_EDITOR -using NodeCanvas.Editor; -using ParadoxNotion.Design; -using Reset.Core; -using UnityEditor; -using UnityEngine; - - - public class BoolValueGroupDrawer : ObjectDrawer { - public override BoolValueGroup OnGUI(GUIContent _content, BoolValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 50; - - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(80.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.BeginVertical(); - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - GUILayout.BeginHorizontal(); - - // Create the x settings enum - _instance.changeValue = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); - - // Create the value/disabled information field - if (_instance.changeValue.value == ValueChangeAction.NewValue){ - _instance.value = EditorGUILayout.Toggle(_instance.value.value, floatOptions); - } else if (_instance.changeValue.value == ValueChangeAction.RelativeValue){ - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField("Not Available", floatOptions); - EditorGUI.EndDisabledGroup(); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up - GUILayout.EndHorizontal(); - GUILayout.EndVertical(); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - - - public class CurveValueGroupDrawer : ObjectDrawer { - public override CurveValueGroup OnGUI(GUIContent _content, CurveValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 50; - - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(80.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.BeginVertical(); - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - GUILayout.BeginHorizontal(); - - // Create the x settings enum - _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); - - // Create the value/disabled information field - if (_instance.changeValue.value == ValueChangeAction.NewValue){ - BBParameterEditor.ParameterField("", _instance.value); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up - GUILayout.EndHorizontal(); - GUILayout.EndVertical(); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - public class EnumValueGroupDrawer : ObjectDrawer{ - public override EnumValueGroup OnGUI(GUIContent _content, EnumValueGroup _instance){ - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(200.0f), - GUILayout.MinWidth(100.0f), - GUILayout.ExpandWidth(true), - }; - - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.BeginVertical(); - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - GUILayout.BeginHorizontal(); - - // Create the x settings enum - _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); - - // Create the value/disabled information field - if (_instance.changeValue.value == ValueChangeAction.NewValue){ - _instance.value.value = EditorGUILayout.EnumPopup("", instance.value.value, floatOptions); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField((ValueChangeAction)_instance.value.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up - GUILayout.EndHorizontal(); - GUILayout.EndVertical(); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - - - } - - public class FloatValueGroupDrawer : ObjectDrawer { - public override FloatValueGroup OnGUI(GUIContent _content, FloatValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 50; - - // Start the label - GUILayout.BeginHorizontal(); - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(80.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - - // End the label - GUILayout.EndHorizontal(); - - // Start the variables - GUILayout.BeginHorizontal(); - - // Create the x settings enum - // _instance.changeValue.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeValue.value); - BBParameterEditor.ParameterField("", _instance.changeValue); - - // Create the value/disabled information field - if (_instance.changeValue.value == ValueChangeAction.NewValue || _instance.changeValue.value == ValueChangeAction.RelativeValue){ - BBParameterEditor.ParameterField("", _instance.value); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeValue.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up with the variables - GUILayout.EndHorizontal(); - - ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - public class Vector3ValueGroupDrawer : ObjectDrawer { - public override Vector3ValueGroup OnGUI(GUIContent _content, Vector3ValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 20; - - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(300.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.BeginVertical(); - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - GUILayout.BeginHorizontal(); - - // Create the x settings enum - _instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value); - - // Create the value/disabled information field - if (_instance.changeX.value== ValueChangeAction.NewValue) { - var value = _instance.value.value; - value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions); - _instance.value.value = value; - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // It do what it do. - GUILayout.Space(5); - - // Create the y settings enum - _instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value); - - // Create the value/disabled information field - if (_instance.changeY.value == ValueChangeAction.NewValue) { - var value = _instance.value.value; - value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions); - _instance.value.value = value; - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // It do what it do. - GUILayout.Space(5); - - // Create the y settings enum - _instance.changeZ.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeZ.value); - - // Create the value/disabled information field - if (_instance.changeZ.value == ValueChangeAction.NewValue) { - var value = _instance.value.value; - value.z = EditorGUILayout.FloatField(_instance.value.value.z, floatOptions); - _instance.value.value = value; - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeZ.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up - GUILayout.EndHorizontal(); - - ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); - - GUILayout.EndVertical(); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - public class Vector2ValueGroupDrawer : ObjectDrawer { - public override Vector2ValueGroup OnGUI(GUIContent _content, Vector2ValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 50; - - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(300.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options - GUILayout.BeginVertical(); - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - GUILayout.BeginHorizontal(); - - // Create the x settings enum - _instance.changeX.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeX.value); - - // Create the value/disabled information field - if (_instance.changeX.value == ValueChangeAction.NewValue) { - var value = _instance.value.value; - value.x = EditorGUILayout.FloatField(_instance.value.value.x, floatOptions); - _instance.value.value = value; - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeX.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // It do what it do. - GUILayout.Space(5); - - // Create the y settings enum - _instance.changeY.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeY.value); - - // Create the value/disabled information field - if (_instance.changeY.value == ValueChangeAction.NewValue) { - var value = _instance.value.value; - value.y = EditorGUILayout.FloatField(_instance.value.value.y, floatOptions); - _instance.value.value = value; - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeY.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close this line up - GUILayout.EndHorizontal(); - - ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); - - GUILayout.EndVertical(); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - // Custom editor for each orbital follow ring setting - public class OrbitalFollowValueGroupDrawer : ObjectDrawer{ - public override OrbitalFollowValueGroup OnGUI(GUIContent _content, OrbitalFollowValueGroup _instance){ - // Remove label for floats - EditorGUIUtility.labelWidth = 1; - - // Set layout options for the label and the float fields - GUILayoutOption[] floatOptions = new GUILayoutOption[] { - // GUILayout.Width(300.0f), - // GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - // Add the label - GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText); - - // Start the smoothing and easing section - GUILayout.BeginHorizontal(); - - GUIStyle smallText= new GUIStyle{ - fontSize = 10, - padding = new RectOffset(8, 0, 0,0), - normal ={ - textColor = Color.gray + Color.gray / 2f - } - }; - - // Start the left side for height - GUILayout.BeginVertical(); - - // Draw the label - GUILayout.BeginHorizontal(); - GUILayout.Label("Height", smallText); - GUILayout.EndHorizontal(); - - // Height - BBParameterEditor.ParameterField("", _instance.changeHeight); - - if (_instance.changeHeight.value == ValueChangeAction.NewValue || _instance.changeHeight.value == ValueChangeAction.RelativeValue){ - // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); - BBParameterEditor.ParameterField("", _instance.height); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeHeight.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close height - GUILayout.EndVertical(); - - // Start the right for radius - GUILayout.BeginVertical(); - - // Draw the label - GUILayout.BeginHorizontal(); - GUILayout.Label("Radius", smallText); - GUILayout.EndHorizontal(); - - // Radius - BBParameterEditor.ParameterField("", _instance.changeRadius); - - if (_instance.changeRadius.value == ValueChangeAction.NewValue || _instance.changeRadius.value == ValueChangeAction.RelativeValue){ - // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); - BBParameterEditor.ParameterField("", _instance.radius); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeRadius.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close easing - GUILayout.EndVertical(); - - GUILayout.Space(8); - - GUILayout.EndHorizontal(); - - ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance); - - // Reset to default so the rest of things don't get messed up - EditorGUIUtility.labelWidth = 0; - return _instance; - } - } - - public static class ValueGroupEditorUtilities{ - public static void DrawEasingAndSmoothingSection(ValueGroup.ISmoothable _instance){ - // Start the smoothing and easing section - GUILayout.BeginHorizontal(); - - GUIStyle smallText= new GUIStyle{ - fontSize = 10, - padding = new RectOffset(8, 0, 0,0), - normal ={ - textColor = Color.gray - } - }; - - // Start the left side for easing - GUILayout.BeginVertical(); - - // Draw the label - GUILayout.BeginHorizontal(); - GUILayout.Label("Easing", smallText); - GUILayout.EndHorizontal(); - - // Easing - // _instance.changeEasing.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", instance.changeEasing.value); - BBParameterEditor.ParameterField("", _instance.changeEasing); - - if (_instance.changeEasing.value == ValueChangeAction.NewValue){ - // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); - BBParameterEditor.ParameterField("", _instance.Easing); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeEasing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close easing - GUILayout.EndVertical(); - - // Start the right for smoothing - GUILayout.BeginVertical(); - - // Draw the label - GUILayout.BeginHorizontal(); - GUILayout.Label("Smoothing", smallText); - GUILayout.EndHorizontal(); - - // Smoothing - BBParameterEditor.ParameterField("", _instance.changeSmoothing); - - if (_instance.changeSmoothing.value == ValueChangeAction.NewValue){ - // _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions); - BBParameterEditor.ParameterField("", _instance.Smoothing); - } else { - EditorGUI.BeginDisabledGroup(true); - EditorGUILayout.TextField(_instance.changeSmoothing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions); - EditorGUI.EndDisabledGroup(); - } - - // Close easing - GUILayout.EndVertical(); - - GUILayout.Space(8); - - GUILayout.EndHorizontal(); - } - - static GUILayoutOption[] floatOptions = new GUILayoutOption[] { - GUILayout.Width(300.0f), - GUILayout.MinWidth(20.0f), - GUILayout.ExpandWidth(true), - }; - - public static GUIStyle titleText = new GUIStyle{ - fontSize = 12, - fontStyle = FontStyle.Bold, - padding = new RectOffset(8, 0, 3,0), - normal ={ - textColor = Color.white - } - }; - } -#endif