diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 1997540..c508ce8 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,13 +1,13 @@
-# These are supported funding model platforms
-
-github: omegaleo
-patreon: # Replace with a single Patreon username
-open_collective: # Replace with a single Open Collective username
-ko_fi: omegaleo
-tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
-community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-liberapay: # Replace with a single Liberapay username
-issuehunt: # Replace with a single IssueHunt username
-otechie: # Replace with a single Otechie username
-lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
-custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+# These are supported funding model platforms
+
+github: omegaleo
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: omegaleo
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.gitignore b/.gitignore
index 8af868e..9cb74ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,60 +1,60 @@
-# This .gitignore file should be placed at the root of your Unity project directory
-#
-# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
-#
-/[Ll]ibrary/
-/[Tt]emp/
-/[Oo]bj/
-/[Bb]uild/
-/[Bb]uilds/
-/[Ll]ogs/
-/[Mm]emoryCaptures/
-
-# Asset meta data should only be ignored when the corresponding asset is also ignored
-!/[Aa]ssets/**/*.meta
-
-# Uncomment this line if you wish to ignore the asset store tools plugin
-# /[Aa]ssets/AssetStoreTools*
-
-# Autogenerated Jetbrains Rider plugin
-[Aa]ssets/Plugins/Editor/JetBrains*
-
-# Visual Studio cache directory
-.vs/
-
-# Gradle cache directory
-.gradle/
-
-# Autogenerated VS/MD/Consulo solution and project files
-ExportedObj/
-.consulo/
-*.csproj
-*.unityproj
-*.sln
-*.suo
-*.tmp
-*.user
-*.userprefs
-*.pidb
-*.booproj
-*.svd
-*.pdb
-*.mdb
-*.opendb
-*.VC.db
-
-# Unity3D generated meta files
-*.pidb.meta
-*.pdb.meta
-*.mdb.meta
-
-# Unity3D generated file on crash reports
-sysinfo.txt
-
-# Builds
-*.apk
-*.unitypackage
-
-# Crashlytics generated file
-crashlytics-build.properties
-
+# This .gitignore file should be placed at the root of your Unity project directory
+#
+# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
+#
+/[Ll]ibrary/
+/[Tt]emp/
+/[Oo]bj/
+/[Bb]uild/
+/[Bb]uilds/
+/[Ll]ogs/
+/[Mm]emoryCaptures/
+
+# Asset meta data should only be ignored when the corresponding asset is also ignored
+!/[Aa]ssets/**/*.meta
+
+# Uncomment this line if you wish to ignore the asset store tools plugin
+# /[Aa]ssets/AssetStoreTools*
+
+# Autogenerated Jetbrains Rider plugin
+[Aa]ssets/Plugins/Editor/JetBrains*
+
+# Visual Studio cache directory
+.vs/
+
+# Gradle cache directory
+.gradle/
+
+# Autogenerated VS/MD/Consulo solution and project files
+ExportedObj/
+.consulo/
+*.csproj
+*.unityproj
+*.sln
+*.suo
+*.tmp
+*.user
+*.userprefs
+*.pidb
+*.booproj
+*.svd
+*.pdb
+*.mdb
+*.opendb
+*.VC.db
+
+# Unity3D generated meta files
+*.pidb.meta
+*.pdb.meta
+*.mdb.meta
+
+# Unity3D generated file on crash reports
+sysinfo.txt
+
+# Builds
+*.apk
+*.unitypackage
+
+# Crashlytics generated file
+crashlytics-build.properties
+
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 3b66410..ca6fe06 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,3 +1,3 @@
-{
- "git.ignoreLimitWarning": true
+{
+ "git.ignoreLimitWarning": true
}
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 451ad6a..cd22657 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,26 +1,26 @@
-## Contributing
-
-[Based on MarcDiethelm's Contributing guide](https://gist.github.com/MarcDiethelm/7303312)
-
-If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.
-
-### How to make a clean pull request
-
-- Create a personal fork of the project on Github.
-- Clone the fork on your local machine. Your remote repo on Github is called `origin`.
-- Add the original repository as a remote called `upstream`.
-- If you created your fork a while ago be sure to pull upstream changes into your local repository.
-- Create a new branch to work on! Branch from `development` if it exists, else from `main`.
-- Implement/fix your feature, comment your code.
-- Follow the code style of the project, including indentation.
-- If the project has tests run them!
-- Write or adapt tests as needed.
-- Add or change the documentation as needed.
-- Squash your commits into a single commit with git's [interactive rebase](https://help.github.com/articles/interactive-rebase). Create a new branch if necessary.
-- Push your branch to your fork on Github, the remote `origin`.
-- From your fork open a pull request in the correct branch. Target the project's `development` branch if there is one, else go for `main`!
-- ...
-- Once the pull request is approved and merged you can pull the changes from `upstream` to your local repo and delete
-your extra branch(es).
-
-And last but not least: Always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code – not what you did to the code.
+## Contributing
+
+[Based on MarcDiethelm's Contributing guide](https://gist.github.com/MarcDiethelm/7303312)
+
+If you want to contribute to a project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request.
+
+### How to make a clean pull request
+
+- Create a personal fork of the project on Github.
+- Clone the fork on your local machine. Your remote repo on Github is called `origin`.
+- Add the original repository as a remote called `upstream`.
+- If you created your fork a while ago be sure to pull upstream changes into your local repository.
+- Create a new branch to work on! Branch from `development` if it exists, else from `main`.
+- Implement/fix your feature, comment your code.
+- Follow the code style of the project, including indentation.
+- If the project has tests run them!
+- Write or adapt tests as needed.
+- Add or change the documentation as needed.
+- Squash your commits into a single commit with git's [interactive rebase](https://help.github.com/articles/interactive-rebase). Create a new branch if necessary.
+- Push your branch to your fork on Github, the remote `origin`.
+- From your fork open a pull request in the correct branch. Target the project's `development` branch if there is one, else go for `main`!
+- ...
+- Once the pull request is approved and merged you can pull the changes from `upstream` to your local repo and delete
+your extra branch(es).
+
+And last but not least: Always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code – not what you did to the code.
diff --git a/Editor/Drawers/ColoredHeaderDrawer.cs b/Editor/Drawers/ColoredHeaderDrawer.cs
index db97218..b638f53 100644
--- a/Editor/Drawers/ColoredHeaderDrawer.cs
+++ b/Editor/Drawers/ColoredHeaderDrawer.cs
@@ -1,31 +1,31 @@
-using OmegaLeo.Toolbox.Attributes;
-using OmegaLeo.Toolbox.Editor.Helpers;
-using UnityEditor;
-using UnityEngine;
-
-namespace Omega_Leo_Toolbox.Editor.Drawers
-{
- [CustomPropertyDrawer(typeof(ColoredHeaderAttribute))]
- public class ColoredHeaderDrawer : DecoratorDrawer
- {
- public override float GetHeight()
- {
- var attr = attribute as ColoredHeaderAttribute;
- return EditorStylesHelper.HeaderStyle().CalcHeight(new GUIContent(attr.Title), Screen.width) + Mathf.Max(attr.Padding, attr.Thickness);
- }
-
- public override void OnGUI(Rect position)
- {
- var attr = attribute as ColoredHeaderAttribute;
-
- position.y += attr.Padding * .5f;
- position.height = EditorStylesHelper.HeaderStyle().CalcHeight(new GUIContent(attr.Title), Screen.width);
- position.height += attr.Thickness;
- position.y += attr.Padding * .5f;
-
- EditorGUI.DrawRect(position, attr.BackgroundColor);
- EditorGUI.LabelField(position, attr.Title, EditorStylesHelper.HeaderStyle(attr.TextColor));
-
- }
- }
+using OmegaLeo.Toolbox.Attributes;
+using OmegaLeo.Toolbox.Editor.Helpers;
+using UnityEditor;
+using UnityEngine;
+
+namespace Omega_Leo_Toolbox.Editor.Drawers
+{
+ [CustomPropertyDrawer(typeof(ColoredHeaderAttribute))]
+ public class ColoredHeaderDrawer : DecoratorDrawer
+ {
+ public override float GetHeight()
+ {
+ var attr = attribute as ColoredHeaderAttribute;
+ return EditorStylesHelper.HeaderStyle().CalcHeight(new GUIContent(attr.Title), Screen.width) + Mathf.Max(attr.Padding, attr.Thickness);
+ }
+
+ public override void OnGUI(Rect position)
+ {
+ var attr = attribute as ColoredHeaderAttribute;
+
+ position.y += attr.Padding * .5f;
+ position.height = EditorStylesHelper.HeaderStyle().CalcHeight(new GUIContent(attr.Title), Screen.width);
+ position.height += attr.Thickness;
+ position.y += attr.Padding * .5f;
+
+ EditorGUI.DrawRect(position, attr.BackgroundColor);
+ EditorGUI.LabelField(position, attr.Title, EditorStylesHelper.HeaderStyle(attr.TextColor));
+
+ }
+ }
}
\ No newline at end of file
diff --git a/Editor/Drawers/ConditionalFieldPropertyDrawer.cs b/Editor/Drawers/ConditionalFieldPropertyDrawer.cs
new file mode 100644
index 0000000..c1303bf
--- /dev/null
+++ b/Editor/Drawers/ConditionalFieldPropertyDrawer.cs
@@ -0,0 +1,94 @@
+using System;
+using OmegaLeo.Toolbox.Attributes;
+using UnityEditor;
+using UnityEngine;
+
+namespace OmegaLeo.Toolbox.Editor.Drawers
+{
+ [CustomPropertyDrawer(typeof(ConditionalFieldAttribute))]
+ public class ConditionalFieldPropertyDrawer : PropertyDrawer
+ {
+ public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
+ {
+ var condHAtt = (ConditionalFieldAttribute)attribute;
+ bool enabled = GetConditionalFieldAttributeResult(condHAtt, property);
+
+ bool wasEnabled = GUI.enabled;
+ GUI.enabled = enabled;
+ if (enabled)
+ {
+ EditorGUI.PropertyField(position, property, label, true);
+ }
+
+ GUI.enabled = wasEnabled;
+ }
+
+ public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
+ {
+ var condHAtt = (ConditionalFieldAttribute)attribute;
+ bool enabled = GetConditionalFieldAttributeResult(condHAtt, property);
+
+ if (enabled)
+ {
+ return EditorGUI.GetPropertyHeight(property, label);
+ }
+
+ // We return a height of 0 when the property is hidden
+ return 0f;
+ }
+
+ private bool GetConditionalFieldAttributeResult(ConditionalFieldAttribute condField, SerializedProperty property)
+ {
+ SerializedProperty sourcePropertyValue = property.serializedObject.FindProperty(condField.ConditionalSourceField);
+
+ if (sourcePropertyValue != null)
+ {
+ (var sourceType, var sourceValue) = GetPropertyValue(sourcePropertyValue, condField.ConditionalSourceField);
+
+ return AreValuesEqual(sourceValue, sourceType, condField.Value, condField.ValueType);
+ }
+
+ return true;
+ }
+
+ private bool AreValuesEqual(object sourceValue, Type sourceType, object condFieldValue, Type condFieldValueType)
+ {
+ if (sourceType == condFieldValueType || sourceType == typeof(Enum))
+ {
+ return sourceValue.ToString().Equals(condFieldValue.ToString(), StringComparison.OrdinalIgnoreCase);
+ }
+
+ return false;
+ }
+
+ private (Type, object) GetPropertyValue(SerializedProperty property, string propertyName)
+ {
+ SerializedProperty prop = property.serializedObject.FindProperty(propertyName);
+ if (prop != null)
+ {
+ switch (prop.propertyType)
+ {
+ case SerializedPropertyType.Boolean:
+ return (typeof(bool), prop.boolValue);
+ case SerializedPropertyType.Integer:
+ return (typeof(int), prop.intValue);
+ case SerializedPropertyType.Float:
+ return (typeof(float), prop.floatValue);
+ case SerializedPropertyType.String:
+ return (typeof(string), prop.stringValue);
+ case SerializedPropertyType.Enum:
+ return (typeof(Enum), prop.enumNames[prop.enumValueIndex]);
+ default:
+ Debug.LogWarning("ConditionalFieldAttribute: Property type not supported.");
+ break;
+ }
+ }
+ else
+ {
+ Debug.LogWarning("ConditionalFieldAttribute: Property not found.");
+ }
+
+ return (null, null);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Editor/Drawers/ConditionalFieldPropertyDrawer.cs.meta b/Editor/Drawers/ConditionalFieldPropertyDrawer.cs.meta
new file mode 100644
index 0000000..486a3bf
--- /dev/null
+++ b/Editor/Drawers/ConditionalFieldPropertyDrawer.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 1f161b6d9d0d4dd9a3d40f9026796a1b
+timeCreated: 1708086931
\ No newline at end of file
diff --git a/Editor/Editors/MonoBehaviourCustomEditor.cs b/Editor/Editors/MonoBehaviourCustomEditor.cs
index 9207b66..35bf22d 100644
--- a/Editor/Editors/MonoBehaviourCustomEditor.cs
+++ b/Editor/Editors/MonoBehaviourCustomEditor.cs
@@ -1,47 +1,47 @@
-using System;
-using System.Linq;
-using System.Reflection;
-using OmegaLeo.Toolbox.Attributes;
-using UnityEditor;
-using UnityEngine;
-using UnityEngine.Tilemaps;
-using Object = UnityEngine.Object;
-
-namespace OmegaLeo.Toolbox.Editor.Omega_Leo_Toolbox.Editor.Editors
-{
- [CustomEditor(typeof(MonoBehaviour), true), CanEditMultipleObjects] // Target all MonoBehaviours and descendants
-public class MonoBehaviourCustomEditor : UnityEditor.Editor
-{
- public override void OnInspectorGUI()
- {
- DrawDefaultInspector(); // Draw the normal inspector
-
- // Get the type descriptor for the MonoBehaviour we are drawing
- var type = target.GetType();
-
- HandleMethods(type);
- }
-
- private void HandleMethods(Type type)
- {
- // Iterate over each private or public instance method (no static methods atm)
- foreach (var method in type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |
- BindingFlags.FlattenHierarchy))
- {
- // make sure it is decorated by our custom attribute
- var attributes = method.GetCustomAttributes(typeof(MethodButtonAttribute), true);
- if (attributes.Length > 0)
- {
- var attribute = attributes.Select(x => x as MethodButtonAttribute)
- .FirstOrDefault(x => x.methodName == method.Name);
- if (GUILayout.Button(attribute.buttonName))
- {
- // If the user clicks the button, invoke the method immediately.
- // There are many ways to do this but I chose to use Invoke which only works in Play Mode.
- method.Invoke(target, null);
- }
- }
- }
- }
-}
+using System;
+using System.Linq;
+using System.Reflection;
+using OmegaLeo.Toolbox.Attributes;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Tilemaps;
+using Object = UnityEngine.Object;
+
+namespace OmegaLeo.Toolbox.Editor.Omega_Leo_Toolbox.Editor.Editors
+{
+ [CustomEditor(typeof(MonoBehaviour), true), CanEditMultipleObjects] // Target all MonoBehaviours and descendants
+public class MonoBehaviourCustomEditor : UnityEditor.Editor
+{
+ public override void OnInspectorGUI()
+ {
+ DrawDefaultInspector(); // Draw the normal inspector
+
+ // Get the type descriptor for the MonoBehaviour we are drawing
+ var type = target.GetType();
+
+ HandleMethods(type);
+ }
+
+ private void HandleMethods(Type type)
+ {
+ // Iterate over each private or public instance method (no static methods atm)
+ foreach (var method in type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance |
+ BindingFlags.FlattenHierarchy))
+ {
+ // make sure it is decorated by our custom attribute
+ var attributes = method.GetCustomAttributes(typeof(MethodButtonAttribute), true);
+ if (attributes.Length > 0)
+ {
+ var attribute = attributes.Select(x => x as MethodButtonAttribute)
+ .FirstOrDefault(x => x.methodName == method.Name);
+ if (GUILayout.Button(attribute.buttonName))
+ {
+ // If the user clicks the button, invoke the method immediately.
+ // There are many ways to do this but I chose to use Invoke which only works in Play Mode.
+ method.Invoke(target, null);
+ }
+ }
+ }
+ }
+}
}
\ No newline at end of file
diff --git a/Editor/Extensions/ExtractComponentToChildTool.cs b/Editor/Extensions/ExtractComponentToChildTool.cs
index f4e9752..85a4f0d 100644
--- a/Editor/Extensions/ExtractComponentToChildTool.cs
+++ b/Editor/Extensions/ExtractComponentToChildTool.cs
@@ -1,88 +1,88 @@
-
-using System;
-using System.Reflection;
-using UnityEditor;
-using UnityEditor.Events;
-using UnityEditorInternal;
-using UnityEngine;
-using UnityEngine.Events;
-using UnityEngine.UI;
-using UnityFlow.DocumentationHelper.Library.Documentation;
-using Object = UnityEngine.Object;
-
-namespace OmegaLeo.Toolbox.Editor.Extensions
-{
- [Documentation(nameof(ExtractComponentToChildTool), "Extension to the component menu that allows the extraction of the component to a child of the game object and associates all button onclick events that mentioned the old component to the new component that was extracted. Based on a video by Warped Imagination")]
- public static class ExtractComponentToChildTool
- {
- [MenuItem("CONTEXT/Component/Extract", priority = 504)]
- public static void ExtractMenuOption(MenuCommand command)
- {
- var sourceComponent = command.context as Component;
-
- if (sourceComponent != null)
- {
- int undoGroupIndex = Undo.GetCurrentGroup();
- Undo.IncrementCurrentGroup();
-
- var child = new GameObject(sourceComponent.GetType().Name);
- child.transform.parent = sourceComponent.transform;
- child.transform.localScale = Vector3.zero;
- child.transform.localPosition = Vector3.zero;
- child.transform.localRotation = Quaternion.identity;
-
- Undo.RegisterCreatedObjectUndo(child, "Created child object");
-
- if (ComponentUtility.CopyComponent(sourceComponent) && ComponentUtility.PasteComponentAsNew(child))
- {
- var newComponent = child.GetComponent(sourceComponent.GetType());
-
- // Check for any association to the old source component and point them to new component
- var buttons = Object.FindObjectsOfType