From 755a1e7c775a10db8e5166fcef5d58835389493f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Fri, 26 Apr 2024 17:01:46 +0200 Subject: [PATCH 01/19] Remove stateful/instantiable classes from helpers folder --- Runtime/{Helpers => }/EnumDictionary.cs | 0 Runtime/{Helpers => }/EnumDictionary.cs.meta | 0 Runtime/{Helpers => }/GyroscopeHelper.cs | 0 Runtime/{Helpers => }/GyroscopeHelper.cs.meta | 0 Runtime/{Helpers => }/NetworkStatusChecker.cs | 0 Runtime/{Helpers => }/NetworkStatusChecker.cs.meta | 0 Runtime/{Helpers => }/Optional.cs | 0 Runtime/{Helpers => }/Optional.cs.meta | 0 Runtime/{Helpers => }/Singleton.cs | 0 Runtime/{Helpers => }/Singleton.cs.meta | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename Runtime/{Helpers => }/EnumDictionary.cs (100%) rename Runtime/{Helpers => }/EnumDictionary.cs.meta (100%) rename Runtime/{Helpers => }/GyroscopeHelper.cs (100%) rename Runtime/{Helpers => }/GyroscopeHelper.cs.meta (100%) rename Runtime/{Helpers => }/NetworkStatusChecker.cs (100%) rename Runtime/{Helpers => }/NetworkStatusChecker.cs.meta (100%) rename Runtime/{Helpers => }/Optional.cs (100%) rename Runtime/{Helpers => }/Optional.cs.meta (100%) rename Runtime/{Helpers => }/Singleton.cs (100%) rename Runtime/{Helpers => }/Singleton.cs.meta (100%) diff --git a/Runtime/Helpers/EnumDictionary.cs b/Runtime/EnumDictionary.cs similarity index 100% rename from Runtime/Helpers/EnumDictionary.cs rename to Runtime/EnumDictionary.cs diff --git a/Runtime/Helpers/EnumDictionary.cs.meta b/Runtime/EnumDictionary.cs.meta similarity index 100% rename from Runtime/Helpers/EnumDictionary.cs.meta rename to Runtime/EnumDictionary.cs.meta diff --git a/Runtime/Helpers/GyroscopeHelper.cs b/Runtime/GyroscopeHelper.cs similarity index 100% rename from Runtime/Helpers/GyroscopeHelper.cs rename to Runtime/GyroscopeHelper.cs diff --git a/Runtime/Helpers/GyroscopeHelper.cs.meta b/Runtime/GyroscopeHelper.cs.meta similarity index 100% rename from Runtime/Helpers/GyroscopeHelper.cs.meta rename to Runtime/GyroscopeHelper.cs.meta diff --git a/Runtime/Helpers/NetworkStatusChecker.cs b/Runtime/NetworkStatusChecker.cs similarity index 100% rename from Runtime/Helpers/NetworkStatusChecker.cs rename to Runtime/NetworkStatusChecker.cs diff --git a/Runtime/Helpers/NetworkStatusChecker.cs.meta b/Runtime/NetworkStatusChecker.cs.meta similarity index 100% rename from Runtime/Helpers/NetworkStatusChecker.cs.meta rename to Runtime/NetworkStatusChecker.cs.meta diff --git a/Runtime/Helpers/Optional.cs b/Runtime/Optional.cs similarity index 100% rename from Runtime/Helpers/Optional.cs rename to Runtime/Optional.cs diff --git a/Runtime/Helpers/Optional.cs.meta b/Runtime/Optional.cs.meta similarity index 100% rename from Runtime/Helpers/Optional.cs.meta rename to Runtime/Optional.cs.meta diff --git a/Runtime/Helpers/Singleton.cs b/Runtime/Singleton.cs similarity index 100% rename from Runtime/Helpers/Singleton.cs rename to Runtime/Singleton.cs diff --git a/Runtime/Helpers/Singleton.cs.meta b/Runtime/Singleton.cs.meta similarity index 100% rename from Runtime/Helpers/Singleton.cs.meta rename to Runtime/Singleton.cs.meta From bcc1598468331a58afdca4aa2f7d02ae7ca2a50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Fri, 26 Apr 2024 17:05:29 +0200 Subject: [PATCH 02/19] Move string helpers in extensions --- Runtime/Extensions/StringExtensions.cs | 48 ++++++++++++++++++++++++-- Runtime/Helpers/StringHelper.cs | 44 ----------------------- Runtime/Helpers/StringHelper.cs.meta | 12 ------- 3 files changed, 45 insertions(+), 59 deletions(-) delete mode 100644 Runtime/Helpers/StringHelper.cs delete mode 100644 Runtime/Helpers/StringHelper.cs.meta diff --git a/Runtime/Extensions/StringExtensions.cs b/Runtime/Extensions/StringExtensions.cs index 3698cde..2d95638 100644 --- a/Runtime/Extensions/StringExtensions.cs +++ b/Runtime/Extensions/StringExtensions.cs @@ -7,9 +7,9 @@ public static int CountOccurence( this string main, string pattern ) int count = 0; int previous_index = 0; - if ( !string.IsNullOrEmpty( pattern ) ) + if( !string.IsNullOrEmpty( pattern ) ) { - while ( ( previous_index = main.IndexOf( pattern, previous_index ) ) != -1 ) + while( ( previous_index = main.IndexOf( pattern, previous_index ) ) != -1 ) { ++previous_index; ++count; @@ -18,5 +18,47 @@ public static int CountOccurence( this string main, string pattern ) return count; } -} + public static string Capitalize( this string str ) + { + if( string.IsNullOrEmpty( str ) ) + { + return null; + } + + if( str.Length > 1 ) + { + return char.ToUpper( str[ 0 ] ) + str.Substring( 1 ); + } + + return str.ToUpper(); + } + + public static string SafeFormat( this string format, params object[] args ) + { + if( !string.IsNullOrEmpty( format ) ) + { + return string.Format( format, args ); + } + + string result = string.Empty; + bool first_arg = true; + + foreach( var arg in args ) + { + if( !first_arg ) + { + result += " - "; + } + + if( arg != null ) + { + result += arg.ToString(); + } + + first_arg = false; + } + + return result; + } +} diff --git a/Runtime/Helpers/StringHelper.cs b/Runtime/Helpers/StringHelper.cs deleted file mode 100644 index 1559f79..0000000 --- a/Runtime/Helpers/StringHelper.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace FishingCactus -{ - public static class StringHelper - { - public static string Capitalize( string str ) - { - if ( str == null ) - return null; - - if ( str.Length > 1 ) - return char.ToUpper( str[ 0 ] ) + str.Substring( 1 ); - - return str.ToUpper(); - } - - public static string SafeFormat( string format, params object[] args ) - { - if ( !string.IsNullOrEmpty( format ) ) - { - return string.Format( format, args ); - } - - string result = string.Empty; - bool first_arg = true; - - foreach( var arg in args ) - { - if ( !first_arg ) - { - result += " - "; - } - - if ( arg != null ) - { - result += arg.ToString(); - } - - first_arg = false; - } - - return result; - } - } -} \ No newline at end of file diff --git a/Runtime/Helpers/StringHelper.cs.meta b/Runtime/Helpers/StringHelper.cs.meta deleted file mode 100644 index 47aee98..0000000 --- a/Runtime/Helpers/StringHelper.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 3fbf6600996bff74395511db371277ba -timeCreated: 1465552499 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From fd3a60f2c29d3e2d87467be90feff6aa62a3fee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Fri, 26 Apr 2024 17:08:26 +0200 Subject: [PATCH 03/19] Helpers are static classes --- Runtime/Helpers/ArgumentHelpers.cs | 4 ++-- Runtime/Helpers/EnumHelper.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Runtime/Helpers/ArgumentHelpers.cs b/Runtime/Helpers/ArgumentHelpers.cs index c198b37..fb7acf1 100644 --- a/Runtime/Helpers/ArgumentHelpers.cs +++ b/Runtime/Helpers/ArgumentHelpers.cs @@ -1,8 +1,8 @@ using System; -namespace FishingCactus +namespace FishingCactus { - public class ArgumentHelpers + public static class ArgumentHelpers { // -- PUBLIC diff --git a/Runtime/Helpers/EnumHelper.cs b/Runtime/Helpers/EnumHelper.cs index d86b175..450255f 100644 --- a/Runtime/Helpers/EnumHelper.cs +++ b/Runtime/Helpers/EnumHelper.cs @@ -4,7 +4,7 @@ namespace FishingCactus { - public class EnumHelper + public static class EnumHelper { public static T ParseEnum( string value ) where T : Enum { From 0c50740913d09bb5d0992d345a87057d3bc30036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Fri, 26 Apr 2024 17:18:44 +0200 Subject: [PATCH 04/19] Move EnumDictionaryPropertyDrawer in PropertyDrawer folder --- Editor/{ => PropertyDrawer}/EnumDictionaryPropertyDrawer.cs | 0 Editor/{ => PropertyDrawer}/EnumDictionaryPropertyDrawer.cs.meta | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Editor/{ => PropertyDrawer}/EnumDictionaryPropertyDrawer.cs (100%) rename Editor/{ => PropertyDrawer}/EnumDictionaryPropertyDrawer.cs.meta (100%) diff --git a/Editor/EnumDictionaryPropertyDrawer.cs b/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs similarity index 100% rename from Editor/EnumDictionaryPropertyDrawer.cs rename to Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs diff --git a/Editor/EnumDictionaryPropertyDrawer.cs.meta b/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs.meta similarity index 100% rename from Editor/EnumDictionaryPropertyDrawer.cs.meta rename to Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs.meta From 7464fa5d1e5fbb7d2f0c0dd54a9d3196237657f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Sun, 28 Apr 2024 22:26:36 +0200 Subject: [PATCH 05/19] Move attribute drawers in property drawers folder --- Editor/{ => PropertyDrawer}/AttributesDrawer.meta | 0 .../AttributesDrawer/EnumFlagsAttributeDrawer.cs | 0 .../AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta | 0 .../AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs | 0 .../ExposedScriptableObjectAttributeDrawer.cs.meta | 0 Editor/PropertyDrawer/{ => AttributesDrawer}/MaxDrawer.cs | 0 Editor/PropertyDrawer/{ => AttributesDrawer}/MaxDrawer.cs.meta | 0 Editor/{ => PropertyDrawer}/AttributesDrawer/ReadOnlyDrawer.cs | 0 .../{ => PropertyDrawer}/AttributesDrawer/ReadOnlyDrawer.cs.meta | 0 .../AttributesDrawer/SubClassPickerAttributeDrawer.cs | 0 .../AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename Editor/{ => PropertyDrawer}/AttributesDrawer.meta (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/EnumFlagsAttributeDrawer.cs (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs.meta (100%) rename Editor/PropertyDrawer/{ => AttributesDrawer}/MaxDrawer.cs (100%) rename Editor/PropertyDrawer/{ => AttributesDrawer}/MaxDrawer.cs.meta (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/ReadOnlyDrawer.cs (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/ReadOnlyDrawer.cs.meta (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/SubClassPickerAttributeDrawer.cs (100%) rename Editor/{ => PropertyDrawer}/AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta (100%) diff --git a/Editor/AttributesDrawer.meta b/Editor/PropertyDrawer/AttributesDrawer.meta similarity index 100% rename from Editor/AttributesDrawer.meta rename to Editor/PropertyDrawer/AttributesDrawer.meta diff --git a/Editor/AttributesDrawer/EnumFlagsAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs similarity index 100% rename from Editor/AttributesDrawer/EnumFlagsAttributeDrawer.cs rename to Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs diff --git a/Editor/AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta b/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta similarity index 100% rename from Editor/AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta rename to Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs.meta diff --git a/Editor/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs similarity index 100% rename from Editor/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs rename to Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs diff --git a/Editor/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs.meta b/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs.meta similarity index 100% rename from Editor/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs.meta rename to Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs.meta diff --git a/Editor/PropertyDrawer/MaxDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs similarity index 100% rename from Editor/PropertyDrawer/MaxDrawer.cs rename to Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs diff --git a/Editor/PropertyDrawer/MaxDrawer.cs.meta b/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs.meta similarity index 100% rename from Editor/PropertyDrawer/MaxDrawer.cs.meta rename to Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs.meta diff --git a/Editor/AttributesDrawer/ReadOnlyDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs similarity index 100% rename from Editor/AttributesDrawer/ReadOnlyDrawer.cs rename to Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs diff --git a/Editor/AttributesDrawer/ReadOnlyDrawer.cs.meta b/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs.meta similarity index 100% rename from Editor/AttributesDrawer/ReadOnlyDrawer.cs.meta rename to Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs.meta diff --git a/Editor/AttributesDrawer/SubClassPickerAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs similarity index 100% rename from Editor/AttributesDrawer/SubClassPickerAttributeDrawer.cs rename to Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs diff --git a/Editor/AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta b/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta similarity index 100% rename from Editor/AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta rename to Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs.meta From b5c7edeb3c8521d5f39dfd0fd07d71fa03243c29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Sun, 28 Apr 2024 22:27:54 +0200 Subject: [PATCH 06/19] Remove Utils folder --- Runtime/{Utils => }/ReadOnlyCollections.meta | 0 .../{Utils => }/ReadOnlyCollections/ReadOnlyDictionary.cs | 0 .../ReadOnlyCollections/ReadOnlyDictionary.cs.meta | 0 .../{Utils => }/ReadOnlyCollections/ReadOnlyHashSet.cs | 0 .../ReadOnlyCollections/ReadOnlyHashSet.cs.meta | 0 Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyList.cs | 0 .../{Utils => }/ReadOnlyCollections/ReadOnlyList.cs.meta | 0 Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyQueue.cs | 0 .../{Utils => }/ReadOnlyCollections/ReadOnlyQueue.cs.meta | 0 .../ReadOnlyCollections/ReadOnlySerializableDictionary.cs | 0 .../ReadOnlySerializableDictionary.cs.meta | 0 Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyStack.cs | 0 .../{Utils => }/ReadOnlyCollections/ReadOnlyStack.cs.meta | 0 Runtime/{Utils => }/SerializableDictionary.cs | 0 Runtime/{Utils => }/SerializableDictionary.cs.meta | 0 Runtime/{Utils => }/TagLink.cs | 0 Runtime/{Utils => }/TagLink.cs.meta | 0 Runtime/Utils.meta | 8 -------- 18 files changed, 8 deletions(-) rename Runtime/{Utils => }/ReadOnlyCollections.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyDictionary.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyDictionary.cs.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyHashSet.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyHashSet.cs.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyList.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyList.cs.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyQueue.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyQueue.cs.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlySerializableDictionary.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlySerializableDictionary.cs.meta (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyStack.cs (100%) rename Runtime/{Utils => }/ReadOnlyCollections/ReadOnlyStack.cs.meta (100%) rename Runtime/{Utils => }/SerializableDictionary.cs (100%) rename Runtime/{Utils => }/SerializableDictionary.cs.meta (100%) rename Runtime/{Utils => }/TagLink.cs (100%) rename Runtime/{Utils => }/TagLink.cs.meta (100%) delete mode 100644 Runtime/Utils.meta diff --git a/Runtime/Utils/ReadOnlyCollections.meta b/Runtime/ReadOnlyCollections.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections.meta rename to Runtime/ReadOnlyCollections.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyDictionary.cs b/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyDictionary.cs rename to Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyDictionary.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyDictionary.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyHashSet.cs b/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyHashSet.cs rename to Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyHashSet.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyHashSet.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyList.cs b/Runtime/ReadOnlyCollections/ReadOnlyList.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyList.cs rename to Runtime/ReadOnlyCollections/ReadOnlyList.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyList.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlyList.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyList.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlyList.cs.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyQueue.cs b/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyQueue.cs rename to Runtime/ReadOnlyCollections/ReadOnlyQueue.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyQueue.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyQueue.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlyQueue.cs.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlySerializableDictionary.cs b/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlySerializableDictionary.cs rename to Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlySerializableDictionary.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlySerializableDictionary.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs.meta diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyStack.cs b/Runtime/ReadOnlyCollections/ReadOnlyStack.cs similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyStack.cs rename to Runtime/ReadOnlyCollections/ReadOnlyStack.cs diff --git a/Runtime/Utils/ReadOnlyCollections/ReadOnlyStack.cs.meta b/Runtime/ReadOnlyCollections/ReadOnlyStack.cs.meta similarity index 100% rename from Runtime/Utils/ReadOnlyCollections/ReadOnlyStack.cs.meta rename to Runtime/ReadOnlyCollections/ReadOnlyStack.cs.meta diff --git a/Runtime/Utils/SerializableDictionary.cs b/Runtime/SerializableDictionary.cs similarity index 100% rename from Runtime/Utils/SerializableDictionary.cs rename to Runtime/SerializableDictionary.cs diff --git a/Runtime/Utils/SerializableDictionary.cs.meta b/Runtime/SerializableDictionary.cs.meta similarity index 100% rename from Runtime/Utils/SerializableDictionary.cs.meta rename to Runtime/SerializableDictionary.cs.meta diff --git a/Runtime/Utils/TagLink.cs b/Runtime/TagLink.cs similarity index 100% rename from Runtime/Utils/TagLink.cs rename to Runtime/TagLink.cs diff --git a/Runtime/Utils/TagLink.cs.meta b/Runtime/TagLink.cs.meta similarity index 100% rename from Runtime/Utils/TagLink.cs.meta rename to Runtime/TagLink.cs.meta diff --git a/Runtime/Utils.meta b/Runtime/Utils.meta deleted file mode 100644 index 88dc1b6..0000000 --- a/Runtime/Utils.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d646b6f50ba5d084291b975435b7f433 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: From 2a7f8281184a317047e017ba5eb8d156bd8217f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Sun, 28 Apr 2024 22:28:04 +0200 Subject: [PATCH 07/19] Remove Math folder --- Runtime/Math.meta | 8 -------- Runtime/{Math => }/Range.cs | 0 Runtime/{Math => }/Range.cs.meta | 0 3 files changed, 8 deletions(-) delete mode 100644 Runtime/Math.meta rename Runtime/{Math => }/Range.cs (100%) rename Runtime/{Math => }/Range.cs.meta (100%) diff --git a/Runtime/Math.meta b/Runtime/Math.meta deleted file mode 100644 index 609333e..0000000 --- a/Runtime/Math.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6d1813f2fccf1d64bb8c923f4a824fab -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Math/Range.cs b/Runtime/Range.cs similarity index 100% rename from Runtime/Math/Range.cs rename to Runtime/Range.cs diff --git a/Runtime/Math/Range.cs.meta b/Runtime/Range.cs.meta similarity index 100% rename from Runtime/Math/Range.cs.meta rename to Runtime/Range.cs.meta From 8651ee513985d794079e6f0643294bf46421c0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Sun, 28 Apr 2024 22:35:36 +0200 Subject: [PATCH 08/19] Add summary in readme --- README.md | 319 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 319 insertions(+) diff --git a/README.md b/README.md index 9399ffe..d9081cf 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,321 @@ FishingCactus - Unity Common Code. +Use this to format your tables: http://markdowntable.com/ + +# Runtime scripts summary + +| Classes | Static? | Mono? | Notes | +|----------------------------------------|---------|-------|----------------------------------------------------------------------| +| `DebugTimeScaler` | | X | Scales time and fixed delta time with the exposed value | +| `EnumDictionary` | | | Serializable dictionary initialized with all the enum values as keys | +| `FloatRange` | | | Provides tools to handle min and max float values | +| `FPSCounter` | | X | FPS counter with colors | +| `GUIConsole` | | X | Runtime console to show Unity logs | +| `GyroscopeHelper` | | | Gyroscope support | +| `IntegerRange` | | | Provides tools to handle min an max integer values | +| `NetworkStatusChecker` | X | | | +| `Optional` | | | Wrapper that comes with a serialized bool | +| `SerializableDictionary` | | | Unity serialization support for dictionaries | +| `Singleton` | X | X | Monobehaviour Singleton | +| `TagLink` | | | | +| `TimeScaleManager` | X | X | Scales time with lerp and callback | +| `Vector3Range` | | | Provides tools to handle min and max `Vector3` values | +| `VersionNumber` | | X | Shows application version on start in console and on GUI | + +## Animator + +| Classes | Static? | Mono? | Notes | +|--------------------------------|---------|-------|-------| +| `AnimatorLayerController` | | | | +| `BooleanAnimatorParameterLink` | | | | +| `IntegerAnimatorParameterLink` | | | | +| `FloatAnimatorParameterLink` | | | | +| `TriggerAnimatorParameterLink` | | | | + +## Attributes + +| Classes | Target | Notes | +|-----------------------------------------------------------------------------------|-------------------------------------|----------------------------------------------------------------------------------------------------------------| +| `EnumFlagsAttributes` | `Enum` | When is this useful? The field will already have a special drawer if the enum has the `System.Flags` attribute | +| `ExposedScriptableObjectAttribute( bool it_must_display_object_selector = true )` | `ScriptableObject` | Displays the content of the referenced scriptable object | +| `MaxAttribute( float max )` | `float` | Ensures that the value won't exceed the max | +| `ReadOnlyAttribute` | Any | The exposed value can't be modified | +| `SubClassPickerAttribute` | With `SerializeReference` attribute | You can choose a child class to initialize an object marked as `SerializeReference` | + +## Coroutines + +Still useful? + +## Extensions + +### AnimationCurve + +| Methods | Notes | +|------------------------------------------------------------------------------|-------| +| `static float GetDuration( this AnimationCurve animation_curve )` | | +| `static float GetStartTime( this AnimationCurve animation_curve )` | | +| `static float GetStartValue( this AnimationCurve animation_curve )` | | +| `static float GetEndTime( this AnimationCurve animation_curve )` | | +| `static float GetEndValue( this AnimationCurve animation_curve )` | | +| `static float GetMaximumValueKeyTime( this AnimationCurve animation_curve )` | | + +### Animator + +Internally caches a name-id map but whats the added value? + +| Methods | Notes | +|------------------------------------------------------------------------------------------------------------|-------| +| `static bool HasParameter( this Animator animator, string parameter_name )` | | +| `static bool HasParameter( this Animator animator, int parameter_hash_id )` | | +| `static void ResetAllTriggerParameters( this Animator animator )` | | +| `static void SetTriggerParameter( this Animator animator, string cached_parameter_name )` | | +| `static void ResetTriggerParameter( this Animator animator, string cached_parameter_name )` | | +| `static void GetBooleanParameter( this Animator animator, string cached_parameter_name )` | | +| `static void SetBooleanParameter( this Animator animator, string cached_parameter_name, bool it_is_true )` | | +| `static void GetFloatParameter( this Animator animator, string cached_parameter_name )` | | +| `static void SetFloatParameter( this Animator animator, string cached_parameter_name, float value )` | | +| `static void GetIntegerParameter( this Animator animator, string cached_parameter_name )` | | +| `static void SetIntegerParameter( this Animator animator, string cached_parameter_name, int value )` | | +| `static void ToggleBooleanParameter( this Animator animator, string cached_parameter_name )` | | +| `static void ClearAllTransitions( this Animator animator )` | | + +### Collections + +| Methods | Notes | +|------------------------------------------------------------------------------------------------------------|-------| +| `static T GetItemByIndexClamped( this List list, int index )` | | +| `static T GetItemByIndexClamped( this T[] array, int index )` | | +| `static T GetRandomItem( this List list )` | | +| `static T GetRandomItem( this T[] array )` | | +| `static T GetRandomItem( this List list, out int index )` | | +| `static T GetRandomItem( this T[] array, out int index )` | | + +### GameObject + +| Methods | Notes | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `static void SetParent( this GameObject game_object, Transform parent, bool reset_local_position = true, bool reset_local_rotation = true, bool reset_local_scale = false )` | | +| `static T GetSafeComponent( this GameObject game_object )` | obsolete | +| `static T GetCheckedComponent( this GameObject game_object ) where T : MonoBehaviour` | | +| `static T GetCheckedComponentInParent( this GameObject game_object ) where T : MonoBehaviour` | | +| `static T GetCheckedComponentInChildren( this GameObject game_object ) where T : MonoBehaviour` | | +| `static T GetOrAddComponent( this GameObject game_object ) where T : MonoBehaviour` | | +| `static Component GetOrAddComponent( this GameObject game_object, System.Type component_type )` | | +| `static void SafeDestroy( this GameObject game_object_instance )` | | + +### IComparable + +| Methods | Notes | +|----------------------------------------------------------------------|-------| +| `static T Clamp( this T value, T min, T max ) where T : IComparable` | | + +### List + +| Methods | Notes | +|-----------------------------------------------------------|-------| +| `static T LastValue( this List list )` | | +| `static void Shuffle( this List list )` | | +| `static void MoveDown( this List list, int index )` | | + +### MonoBehaviour + +| Methods | Notes | +|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| +| `static void SetParent( this MonoBehaviour mono_behaviour, Transform parent, bool reset_local_position = true, bool reset_local_rotation = true, bool reset_local_scale = false )` | | +| `static void Invoke( this MonoBehaviour mono_behaviour, Action action, float time )` | | +| `static void InvokeRepeating( this MonoBehaviour mono_behaviour, Action action, float time, float repeat_rate )` | | +| `static T GetOrAddComponent( this MonoBehaviour mono_behaviour ) where T : MonoBehaviour` | | +| `static Component GetOrAddComponent( this MonoBehaviour mono_behaviour, Type component_type )` | | + +### String + +| Methods | Notes | +|------------------------------------------------------------------------|-------| +| `static int CountOccurence( this string main, string pattern )` | | +| `static string Capitalize( this string str )` | | +| `static string SafeFormat( this string format, params object[] args )` | | + +### Transform + +| Methods | Notes | +|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------| +| `static void SetParent( this Transform transform, Transform parent, bool reset_local_position = true, bool reset_local_rotation = true, bool reset_local_scale = false )` | | +| `static void SetX( this Transform transform, float x )` | | +| `static void SetY( this Transform transform, float y )` | | +| `static void SetZ( this Transform transform, float z )` | | +| `static void SetLocalX( this Transform transform, float x )` | | +| `static void SetLocalY( this Transform transform, float y )` | | +| `static void SetLocalZ( this Transform transform, float z )` | | +| `static void CopyTransform( this Transform transform, Transform source )` | | +| `static void CopyLocalTransform( this Transform transform, Transform source )` | | +| `static void Reset( this Transform transform )` | | +| `static void ResetLocal( this Transform transform )` | | +| `static void DestroyChildren( this Transform transform )` | | +| `static void DestroyImmediateChildren( this Transform transform )` | | + +### ULong + +| Methods | Notes | +|--------------------------------------------------------|-------| +| `static uint GetToggledFlagsCount( this ulong flags )` | | + +### Vector3 + +| Methods | Notes | +|-------------------------------------------------------------------------------------------|-------| +| `static float GetSquaredMagnitude( this Vector3 vector, Vector3 other_vector )` | | +| `static float GetHorizontalMagnitude( this Vector3 vector, Vector3 other_vector )` | | +| `static float GetSquaredHorizontalMagnitude( this Vector3 vector, Vector3 other_vector )` | | +| `static float GetVerticalMagnitude( this Vector3 vector, Vector3 other_vector )` | | +| `static float GetSquaredVerticalMagnitude( this Vector3 vector, Vector3 other_vector )` | | + +## Helpers + +Stateless static functions, shouldn't be extensions because too specific or can't be because not called on an instance + +### ArgumentHelpers + +For command line arguments + +| Methods | Notes | +|--------------------------------------------------------|-------| +| `static bool FindArg( out string value, string name )` | | +| `static string GetArg( string name )` | | +| `static bool HasArg( string name )` | | + +### EnumHelper + +| Methods | Notes | +|----------------------------------------------------------------------------|-------| +| `static T ParseEnum( string value ) where T : Enum` | | +| `static IEnumerable GetValueTable() where T : Enum` | | +| `static T GetRandom() where T : Enum` | | +| `static T GetRandom( T min_inclusive, T max_inclusive ) where T : Enum` | | + +### Math + +| Methods | Notes | +|-----------------------------------------------------------------------------------------------------------------------------|-------| +| `static Vector3 CatmulRomInterpolation( Vector3 point0, Vector3 point1, Vector3 point2, Vector3 point3, float percentage )` | | +| `static bool SameSign( int first_value, int second_value )` | | +| `static bool SameSign( float first_value, float second_value )` | | +| `static int MathMod( int dividend, int modulus )` | | + +### ReflectionUtilities + +| Methods | Notes | +|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------| +| `static bool IsStaticClass( Type type )` | | +| `static IEnumerable GetImplementations( Func implementation_delegate = null )` | | +| `static IEnumerable GetImplementations( Type base_type, Func implementation_delegate = null )` | | +| `static IEnumerable CreateInstances( object[] parameters = null, Func implementation_delegate = null ) where TBase : class` | | + +### ThrowHelper + +| Methods | Notes | +|-----------------------------------------------------------------------------------------------|-------| +| `static void ThrowIfArgumentNull( string name, object argument )` | | +| `static void ThrowIfArgumentOutOfRange( string name, int index, int count )` | | +| `static void ThrowIfArgumentOutOfRange( string name, int index, int start_index, int count )` | | + +### TimeHelper + +| Methods | Notes | +|-------------------------------------------------------------------------------------------------------------------------------------------|-------| +| `static int GetMinutesFromSeconds( double seconds )` | | +| `static int GetHoursFromSeconds( double seconds )` | | +| `static string GetFormattedTimeFromSeconds( double seconds, bool show_hours = true, bool show_minutes = true, bool show_seconds = true )` | | + +## ReadOnlyCollections + +| Classes | Static? | Mono? | Notes | +|------------------------------------------------|---------|-------|-------| +| `ReadOnlyDictionary` | | | | +| `ReadOnlyHashSet` | | | | +| `ReadOnlyList` | | | | +| `ReadOnlyQueue` | | | | +| `ReadOnlySerializableDictionary` | | | | +| `ReadOnlyStack` | | | | + +## UI + +| Classes | Static? | Mono? | Notes | +|---------------|---------|-------|----------------------------------------------------| +| `Wizard` | | X | Succession of `WizardPanel` navigable with buttons | +| `WizardPanel` | | X | | + +--- + +# Editor scripts summary + +| Classes | Static? | Notes | +|--------------------------------|---------|-------| +| `ApplySelectedPrefabs` | | | +| `AttributesDrawer` | | | +| `CreateNewPrefab` | | | +| `EditorUtils` | X | | +| `InternalEditorStyle` | X | | +| `ObjectToTerrain` | | | +| `PropertyDrawer` | | | +| `ScriptableObjectCreator` | X | | + +## ContextMenus + +### PropertyContextMenus + +| Classes | Notes | +|--------------------------------------|-------| +| `CreateAssetContextMenu` | | +| `PropertyContextMenuCallbackFetcher` | | +| `VectorContextMenu` | | + +## Dropdowns + +| Classes | Notes | +|--------------------------------|-------| +| `SelectImplementationDropdown` | | + +### Items + +| Classes | Notes | +|--------------------|-------| +| `TypeDropdownItem` | | + +## DropHandlers + +| Classes | Notes | +|------------------------------|-------| +| `HierarchyScriptDropHandler` | | + +## Inspector + +| Classes | Notes | +|-----------------------------------|-------| +| `ReorderableSubAssetList` | | + +## PropertyDrawer + +| Classes | Notes | +|--------------------------------|--------------------------------------------------------| +| `AnimatorParameterLinkDrawer` | See [`AnimatorParameterLink` child classes](#animator) | +| `EnumDictionaryPropertyDrawer` | See [`EnumDictionary`](#runtime-scripts-summary) | +| `OptionalDrawer` | See [`Optional`](#runtime-scripts-summary) | +| `RangeDrawer` | See [`Range` child classes](#runtime-scripts-summary) | +| `TagLinkDrawer` | See [`TagLink`](#runtime-scripts-summary) | + +### AttributesDrawer + +See [Attributes](#attributes) + +## Utilities + +| Classes | Notes | +|----------------------|-------| +| `HierarchyUtilities` | | +| `InspectorUtilities` | | + +## Wizzard + +| Classes | Notes | +|----------------|-------| +| `WizzardUtils` | | From 6f09db3ec1832fce26b276d23d6888ff9a6547b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Sun, 28 Apr 2024 22:56:31 +0200 Subject: [PATCH 09/19] Update changelog and package.json --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38758ec..2626e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.0.0] - 2024-04-29 +### Added +- Summary in readme +### Updated +- Files reorganized +- `StringHelper` methods are now extensions in `StringExtensions` + ## [1.2.0] - 2024-04-24 ### Added - Add `ReflectionUtilities` static class diff --git a/package.json b/package.json index 28ff9a1..54f6e22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.fishingcactus.common-code", - "version": "1.2.0", + "version": "2.0.0", "displayName": "FC - Common Code", "description": "Code, Extensions and extra features for Fishing Cactus Games.", "unity": "2020.3", From 25a8a8ce6506cc136f552ff769575e4133753e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 11:54:31 +0200 Subject: [PATCH 10/19] Add todo about screenshots --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index d9081cf..2cdcdb4 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ FishingCactus - Unity Common Code. Use this to format your tables: http://markdowntable.com/ +| :memo: TODO: We could add some screenshots and put them in the notes column or below the tables (especially for editor tools) | +|-------------------------------------------------------------------------------------------------------------------------------| + # Runtime scripts summary | Classes | Static? | Mono? | Notes | From c962fb3e19b4aa0baf8c33400231827d9fdbbc92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 13:49:13 +0200 Subject: [PATCH 11/19] Add Serializable columns --- README.md | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 2cdcdb4..b4dc33d 100644 --- a/README.md +++ b/README.md @@ -7,33 +7,33 @@ Use this to format your tables: http://markdowntable.com/ # Runtime scripts summary -| Classes | Static? | Mono? | Notes | -|----------------------------------------|---------|-------|----------------------------------------------------------------------| -| `DebugTimeScaler` | | X | Scales time and fixed delta time with the exposed value | -| `EnumDictionary` | | | Serializable dictionary initialized with all the enum values as keys | -| `FloatRange` | | | Provides tools to handle min and max float values | -| `FPSCounter` | | X | FPS counter with colors | -| `GUIConsole` | | X | Runtime console to show Unity logs | -| `GyroscopeHelper` | | | Gyroscope support | -| `IntegerRange` | | | Provides tools to handle min an max integer values | -| `NetworkStatusChecker` | X | | | -| `Optional` | | | Wrapper that comes with a serialized bool | -| `SerializableDictionary` | | | Unity serialization support for dictionaries | -| `Singleton` | X | X | Monobehaviour Singleton | -| `TagLink` | | | | -| `TimeScaleManager` | X | X | Scales time with lerp and callback | -| `Vector3Range` | | | Provides tools to handle min and max `Vector3` values | -| `VersionNumber` | | X | Shows application version on start in console and on GUI | +| Classes | Static? | Mono? | Serializable? | Notes | +|----------------------------------------|---------|-------|---------------|----------------------------------------------------------------------| +| `DebugTimeScaler` | | X | | Scales time and fixed delta time with the exposed value | +| `EnumDictionary` | | | X | Serializable dictionary initialized with all the enum values as keys | +| `FloatRange` | | | X | Provides tools to handle min and max float values | +| `FPSCounter` | | X | | FPS counter with colors | +| `GUIConsole` | | X | | Runtime console to show Unity logs | +| `GyroscopeHelper` | | | | Gyroscope support | +| `IntegerRange` | | | X | Provides tools to handle min an max integer values | +| `NetworkStatusChecker` | X | | | | +| `Optional` | | | X | Wrapper to create optional values | +| `SerializableDictionary` | | | X | Unity serialization support for dictionaries | +| `Singleton` | X | X | | Monobehaviour Singleton | +| `TagLink` | | | X | | +| `TimeScaleManager` | X | X | | Scales time with lerp and callback | +| `Vector3Range` | | | X | Provides tools to handle min and max `Vector3` values | +| `VersionNumber` | | X | | Shows application version on start in console and on GUI | ## Animator -| Classes | Static? | Mono? | Notes | -|--------------------------------|---------|-------|-------| -| `AnimatorLayerController` | | | | -| `BooleanAnimatorParameterLink` | | | | -| `IntegerAnimatorParameterLink` | | | | -| `FloatAnimatorParameterLink` | | | | -| `TriggerAnimatorParameterLink` | | | | +| Classes | Static? | Mono? | Serializable? | Notes | +|--------------------------------|---------|-------|---- ---| | +| `AnimatorLayerController` | | | X | | +| `BooleanAnimatorParameterLink` | | | X | | +| `IntegerAnimatorParameterLink` | | | X | | +| `FloatAnimatorParameterLink` | | | X | | +| `TriggerAnimatorParameterLink` | | | X | | ## Attributes From 2811e4fb3b299d72237df2ce2aa2669bbc2caa72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 13:49:33 +0200 Subject: [PATCH 12/19] Add suggestion for Animator scripts --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b4dc33d..6e86089 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ Still useful? ### Animator -Internally caches a name-id map but whats the added value? +| :memo: TODO: Instead of still relying on strings (and thus not gaining any perf or ease of use), we could provide an enum value as the argument and internally cache the parameters' ids in a map. Either we generate that enum class according to the animator's parameters, or we just update it manually (it has to be in Samples to be editable) | +|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Methods | Notes | |------------------------------------------------------------------------------------------------------------|-------| From 7fa2ba37fc93744ce0118fbe4569b5daff725de3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 14:16:45 +0200 Subject: [PATCH 13/19] Rename helpers > utilities --- .../CreateAssetContextMenu.cs | 4 +- .../PropertyContextMenuCallbackFetcher.cs | 2 +- .../DropDowns/SelectImplementationDropdown.cs | 2 +- .../HierarchyScriptDropHandler.cs | 2 +- Editor/{ => Utilities}/EditorUtils.cs | 0 Editor/{ => Utilities}/EditorUtils.cs.meta | 0 ...ierarchyUtilities.cs => HierarchyUtils.cs} | 2 +- ...ilities.cs.meta => HierarchyUtils.cs.meta} | 0 ...nspectorUtilities.cs => InspectorUtils.cs} | 2 +- ...ilities.cs.meta => InspectorUtils.cs.meta} | 0 Editor/{Wizzard => Utilities}/WizzardUtils.cs | 2 +- .../WizzardUtils.cs.meta | 0 Editor/Wizzard.meta | 8 ---- README.md | 47 +++++++++++++------ Runtime/SerializableDictionary.cs | 42 ++++++++--------- Runtime/{Helpers.meta => Utilities.meta} | 0 .../ArgumentUtils.cs} | 2 +- .../ArgumentUtils.cs.meta} | 0 Runtime/{Helpers => Utilities}/Contracts.meta | 0 .../Contracts/IEnableable.cs | 0 .../Contracts/IEnableable.cs.meta | 0 .../EnumHelper.cs => Utilities/EnumUtils.cs} | 2 +- .../EnumUtils.cs.meta} | 0 .../Math.cs => Utilities/MathUtils.cs} | 2 +- .../MathUtils.cs.meta} | 0 .../ReflectionUtils.cs} | 2 +- .../ReflectionUtils.cs.meta} | 0 .../ThrowUtils.cs} | 2 +- .../ThrowUtils.cs.meta} | 0 .../TimeHelper.cs => Utilities/TimeUtils.cs} | 2 +- .../TimeUtils.cs.meta} | 0 31 files changed, 67 insertions(+), 58 deletions(-) rename Editor/{ => Utilities}/EditorUtils.cs (100%) rename Editor/{ => Utilities}/EditorUtils.cs.meta (100%) rename Editor/Utilities/{HierarchyUtilities.cs => HierarchyUtils.cs} (97%) rename Editor/Utilities/{HierarchyUtilities.cs.meta => HierarchyUtils.cs.meta} (100%) rename Editor/Utilities/{InspectorUtilities.cs => InspectorUtils.cs} (98%) rename Editor/Utilities/{InspectorUtilities.cs.meta => InspectorUtils.cs.meta} (100%) rename Editor/{Wizzard => Utilities}/WizzardUtils.cs (97%) rename Editor/{Wizzard => Utilities}/WizzardUtils.cs.meta (100%) delete mode 100644 Editor/Wizzard.meta rename Runtime/{Helpers.meta => Utilities.meta} (100%) rename Runtime/{Helpers/ArgumentHelpers.cs => Utilities/ArgumentUtils.cs} (96%) rename Runtime/{Helpers/ArgumentHelpers.cs.meta => Utilities/ArgumentUtils.cs.meta} (100%) rename Runtime/{Helpers => Utilities}/Contracts.meta (100%) rename Runtime/{Helpers => Utilities}/Contracts/IEnableable.cs (100%) rename Runtime/{Helpers => Utilities}/Contracts/IEnableable.cs.meta (100%) rename Runtime/{Helpers/EnumHelper.cs => Utilities/EnumUtils.cs} (97%) rename Runtime/{Helpers/EnumHelper.cs.meta => Utilities/EnumUtils.cs.meta} (100%) rename Runtime/{Helpers/Math.cs => Utilities/MathUtils.cs} (98%) rename Runtime/{Helpers/Math.cs.meta => Utilities/MathUtils.cs.meta} (100%) rename Runtime/{Helpers/ReflectionUtilities.cs => Utilities/ReflectionUtils.cs} (98%) rename Runtime/{Helpers/ReflectionUtilities.cs.meta => Utilities/ReflectionUtils.cs.meta} (100%) rename Runtime/{Helpers/ThrowHelper.cs => Utilities/ThrowUtils.cs} (96%) rename Runtime/{Helpers/ThrowHelper.cs.meta => Utilities/ThrowUtils.cs.meta} (100%) rename Runtime/{Helpers/TimeHelper.cs => Utilities/TimeUtils.cs} (97%) rename Runtime/{Helpers/TimeHelper.cs.meta => Utilities/TimeUtils.cs.meta} (100%) diff --git a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs index a921383..b23baaf 100644 --- a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs +++ b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs @@ -27,7 +27,7 @@ SerializedProperty property return; } - Type property_type = InspectorUtilities.GetPropertyType( property ); + Type property_type = InspectorUtils.GetPropertyType( property ); Type scriptable_object_type = typeof( ScriptableObject ); if( !scriptable_object_type.IsAssignableFrom( property_type ) ) @@ -46,7 +46,7 @@ SerializedProperty property _dropdown.OnImplementationSelected -= Dropdown_OnImplementationSelected; } - var implementations = ReflectionUtilities.GetImplementations( property_type, IsValidImplementation ); + var implementations = ReflectionUtils.GetImplementations( property_type, IsValidImplementation ); _dropdown = new SelectImplementationDropdown( new AdvancedDropdownState(), property_type, IsValidImplementation ); _dropdown.Show( context_menu_rect ); _dropdown.OnImplementationSelected += Dropdown_OnImplementationSelected; diff --git a/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs b/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs index d4b404c..a94a29a 100644 --- a/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs +++ b/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs @@ -14,7 +14,7 @@ private static void Initialize() { EditorApplication.contextualPropertyMenu += EditorApplication_OnPropertyContextMenu; - _targets.AddRange( ReflectionUtilities.CreateInstances() ); + _targets.AddRange( ReflectionUtils.CreateInstances() ); } private static void EditorApplication_OnPropertyContextMenu( diff --git a/Editor/DropDowns/SelectImplementationDropdown.cs b/Editor/DropDowns/SelectImplementationDropdown.cs index 2f5d8aa..62e9c0b 100644 --- a/Editor/DropDowns/SelectImplementationDropdown.cs +++ b/Editor/DropDowns/SelectImplementationDropdown.cs @@ -20,7 +20,7 @@ Func implementation_delegate : base( state ) { _type = type; - _implementations = ReflectionUtilities.GetImplementations( _type, implementation_delegate ); + _implementations = ReflectionUtils.GetImplementations( _type, implementation_delegate ); } protected override AdvancedDropdownItem BuildRoot() diff --git a/Editor/DropHandlers/HierarchyScriptDropHandler.cs b/Editor/DropHandlers/HierarchyScriptDropHandler.cs index d8b3d24..7175dc8 100644 --- a/Editor/DropHandlers/HierarchyScriptDropHandler.cs +++ b/Editor/DropHandlers/HierarchyScriptDropHandler.cs @@ -57,7 +57,7 @@ HierarchyDropFlags drop_mode for( int index = 0; index < mono_scripts.Count; index++ ) { MonoScript mono_script = mono_scripts[ index ]; - GameObject game_object = HierarchyUtilities.CreateAndRename( mono_script.name, parent, active_object_is_default_parent: false ); + GameObject game_object = HierarchyUtils.CreateAndRename( mono_script.name, parent, active_object_is_default_parent: false ); game_object.AddComponent( mono_script.GetClass() ); if( sibling_index >= 0 ) diff --git a/Editor/EditorUtils.cs b/Editor/Utilities/EditorUtils.cs similarity index 100% rename from Editor/EditorUtils.cs rename to Editor/Utilities/EditorUtils.cs diff --git a/Editor/EditorUtils.cs.meta b/Editor/Utilities/EditorUtils.cs.meta similarity index 100% rename from Editor/EditorUtils.cs.meta rename to Editor/Utilities/EditorUtils.cs.meta diff --git a/Editor/Utilities/HierarchyUtilities.cs b/Editor/Utilities/HierarchyUtils.cs similarity index 97% rename from Editor/Utilities/HierarchyUtilities.cs rename to Editor/Utilities/HierarchyUtils.cs index 80e4ce8..391f5ec 100644 --- a/Editor/Utilities/HierarchyUtilities.cs +++ b/Editor/Utilities/HierarchyUtils.cs @@ -4,7 +4,7 @@ namespace FishingCactus { - public static class HierarchyUtilities + public static class HierarchyUtils { public static GameObject CreateAndRename( string default_name, diff --git a/Editor/Utilities/HierarchyUtilities.cs.meta b/Editor/Utilities/HierarchyUtils.cs.meta similarity index 100% rename from Editor/Utilities/HierarchyUtilities.cs.meta rename to Editor/Utilities/HierarchyUtils.cs.meta diff --git a/Editor/Utilities/InspectorUtilities.cs b/Editor/Utilities/InspectorUtils.cs similarity index 98% rename from Editor/Utilities/InspectorUtilities.cs rename to Editor/Utilities/InspectorUtils.cs index 19dcf75..4c49c30 100644 --- a/Editor/Utilities/InspectorUtilities.cs +++ b/Editor/Utilities/InspectorUtils.cs @@ -3,7 +3,7 @@ using System.Reflection; using UnityEditor; -public static class InspectorUtilities +public static class InspectorUtils { public static bool TryGetArrayOrListElementType( Type list_type, diff --git a/Editor/Utilities/InspectorUtilities.cs.meta b/Editor/Utilities/InspectorUtils.cs.meta similarity index 100% rename from Editor/Utilities/InspectorUtilities.cs.meta rename to Editor/Utilities/InspectorUtils.cs.meta diff --git a/Editor/Wizzard/WizzardUtils.cs b/Editor/Utilities/WizzardUtils.cs similarity index 97% rename from Editor/Wizzard/WizzardUtils.cs rename to Editor/Utilities/WizzardUtils.cs index 7199f81..9a439a7 100644 --- a/Editor/Wizzard/WizzardUtils.cs +++ b/Editor/Utilities/WizzardUtils.cs @@ -3,7 +3,7 @@ namespace FishingCactus.UnityCommonCode { - public class WizzardUtils + public static class WizzardUtils { // -- TYPES diff --git a/Editor/Wizzard/WizzardUtils.cs.meta b/Editor/Utilities/WizzardUtils.cs.meta similarity index 100% rename from Editor/Wizzard/WizzardUtils.cs.meta rename to Editor/Utilities/WizzardUtils.cs.meta diff --git a/Editor/Wizzard.meta b/Editor/Wizzard.meta deleted file mode 100644 index 4b244b7..0000000 --- a/Editor/Wizzard.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6a24cfabfc3d75d4eb4606597f0638bf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/README.md b/README.md index 6e86089..8cac7e5 100644 --- a/README.md +++ b/README.md @@ -173,11 +173,11 @@ Still useful? | `static float GetVerticalMagnitude( this Vector3 vector, Vector3 other_vector )` | | | `static float GetSquaredVerticalMagnitude( this Vector3 vector, Vector3 other_vector )` | | -## Helpers +## Utilities Stateless static functions, shouldn't be extensions because too specific or can't be because not called on an instance -### ArgumentHelpers +### ArgumentUtils For command line arguments @@ -187,7 +187,7 @@ For command line arguments | `static string GetArg( string name )` | | | `static bool HasArg( string name )` | | -### EnumHelper +### EnumUtils | Methods | Notes | |----------------------------------------------------------------------------|-------| @@ -196,7 +196,7 @@ For command line arguments | `static T GetRandom() where T : Enum` | | | `static T GetRandom( T min_inclusive, T max_inclusive ) where T : Enum` | | -### Math +### MathUtils | Methods | Notes | |-----------------------------------------------------------------------------------------------------------------------------|-------| @@ -205,7 +205,7 @@ For command line arguments | `static bool SameSign( float first_value, float second_value )` | | | `static int MathMod( int dividend, int modulus )` | | -### ReflectionUtilities +### ReflectionUtils | Methods | Notes | |-------------------------------------------------------------------------------------------------------------------------------------------------------|-------| @@ -214,7 +214,7 @@ For command line arguments | `static IEnumerable GetImplementations( Type base_type, Func implementation_delegate = null )` | | | `static IEnumerable CreateInstances( object[] parameters = null, Func implementation_delegate = null ) where TBase : class` | | -### ThrowHelper +### ThrowUtils | Methods | Notes | |-----------------------------------------------------------------------------------------------|-------| @@ -222,7 +222,7 @@ For command line arguments | `static void ThrowIfArgumentOutOfRange( string name, int index, int count )` | | | `static void ThrowIfArgumentOutOfRange( string name, int index, int start_index, int count )` | | -### TimeHelper +### TimeUtils | Methods | Notes | |-------------------------------------------------------------------------------------------------------------------------------------------|-------| @@ -313,13 +313,30 @@ See [Attributes](#attributes) ## Utilities -| Classes | Notes | -|----------------------|-------| -| `HierarchyUtilities` | | -| `InspectorUtilities` | | +### EditorUtils + +| Classes | Notes | +|---------------------------------------------------------------------------------------------|-------| +| `static void AddDefineIfNecessary( string define, BuildTargetGroup build_target_group )` | | +| `static void RemoveDefineIfNecessary( string define, BuildTargetGroup build_target_group )` | | +| `static bool IsDefined( string define, BuildTargetGroup build_target_group )` | | + +### HierarchyUtils + +| Classes | Notes | +|----------------------------------------------------------------------------------------------------------------------------------|-------| +| `static GameObject CreateAndRename( string default_name, Transform parent = null, bool active_object_is_default_parent = true )` | | +| `static void Rename( GameObject game_object )` | | + +### InspectorUtils + +| Classes | Notes | +|-------------------------------------------------------------------------------------|-------| +| `static bool TryGetArrayOrListElementType( Type list_type, out Type element_type )` | | +| `static Type GetPropertyType( SerializedProperty property )` | | -## Wizzard +### WizzardUtils -| Classes | Notes | -|----------------|-------| -| `WizzardUtils` | | +| Classes | Notes | +|-----------------------------------------------------------------------------------------------------------------------------------|-------| +| `static string DisplayPathSelector( string original_path, string description, PanelMode panel_mode, string file_extension = "" )` | | diff --git a/Runtime/SerializableDictionary.cs b/Runtime/SerializableDictionary.cs index 5ce973f..0afad44 100644 --- a/Runtime/SerializableDictionary.cs +++ b/Runtime/SerializableDictionary.cs @@ -307,7 +307,7 @@ readonly DictionaryEntry IDictionaryEnumerator.Entry { if( !IsValidIndex( _currentIndex ) ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return new DictionaryEntry( _current.Key, _current.Value ); @@ -320,7 +320,7 @@ readonly object IDictionaryEnumerator.Key { if( !IsValidIndex( _currentIndex ) ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return _current.Key; @@ -333,7 +333,7 @@ readonly object IDictionaryEnumerator.Value { if( !IsValidIndex( _currentIndex ) ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return _current.Value; @@ -346,7 +346,7 @@ readonly object IEnumerator.Current { if( !IsValidIndex( _currentIndex ) ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return new KeyValuePair( _current.Key, _current.Value ); @@ -396,7 +396,7 @@ void IEnumerator.Reset() { if( _version != _dictionary._version ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_COLLECTION_MODIFIED ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_COLLECTION_MODIFIED ); } _currentIndex = 0; @@ -432,7 +432,7 @@ public KeyCollection( SerializableDictionary dictionary ) { - ThrowHelper.ThrowIfArgumentNull( nameof( dictionary ), dictionary ); + ThrowUtils.ThrowIfArgumentNull( nameof( dictionary ), dictionary ); _dictionary = dictionary; } @@ -449,8 +449,8 @@ public void CopyTo( int index ) { - ThrowHelper.ThrowIfArgumentNull( nameof( array ), array ); - ThrowHelper.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); + ThrowUtils.ThrowIfArgumentNull( nameof( array ), array ); + ThrowUtils.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); if( array.Length - index < _dictionary.Count ) { @@ -506,14 +506,14 @@ void ICollection.CopyTo( int index ) { - ThrowHelper.ThrowIfArgumentNull( nameof( array ), array ); + ThrowUtils.ThrowIfArgumentNull( nameof( array ), array ); if( array.Rank != 1 ) { throw new ArgumentException( "Array must not be multi-dimensionnal." ); } - ThrowHelper.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); + ThrowUtils.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); if( array.Length - index < _dictionary.Count ) { @@ -571,7 +571,7 @@ readonly object IEnumerator.Current || _currentIndex == _dictionary.Count + 1 ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return _currentKey; @@ -582,7 +582,7 @@ void IEnumerator.Reset() { if( _version != _dictionary._version ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_COLLECTION_MODIFIED ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_COLLECTION_MODIFIED ); } _currentIndex = 0; @@ -611,7 +611,7 @@ public bool MoveNext() { if( _version != _dictionary._version ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_COLLECTION_MODIFIED ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_COLLECTION_MODIFIED ); } while( _currentIndex < _dictionary.KeyValueList.Count ) @@ -650,7 +650,7 @@ public ValueCollection( SerializableDictionary dictionary ) { - ThrowHelper.ThrowIfArgumentNull( nameof( dictionary ), dictionary ); + ThrowUtils.ThrowIfArgumentNull( nameof( dictionary ), dictionary ); _dictionary = dictionary; } @@ -667,8 +667,8 @@ public void CopyTo( int index ) { - ThrowHelper.ThrowIfArgumentNull( nameof( array ), array ); - ThrowHelper.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); + ThrowUtils.ThrowIfArgumentNull( nameof( array ), array ); + ThrowUtils.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); if( array.Length - index < _dictionary.Count ) { @@ -724,14 +724,14 @@ void ICollection.CopyTo( int index ) { - ThrowHelper.ThrowIfArgumentNull( nameof( array ), array ); + ThrowUtils.ThrowIfArgumentNull( nameof( array ), array ); if( array.Rank != 1 ) { throw new ArgumentException( "Array must not be multi-dimensionnal." ); } - ThrowHelper.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); + ThrowUtils.ThrowIfArgumentOutOfRange( nameof( index ), index, array.Length ); if( array.Length - index < _dictionary.Count ) { @@ -788,7 +788,7 @@ readonly object IEnumerator.Current || _currentIndex == _dictionary.Count + 1 ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_CANNOT_HAPPEN ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_CANNOT_HAPPEN ); } return _currentKey; @@ -799,7 +799,7 @@ void IEnumerator.Reset() { if( _version != _dictionary._version ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_COLLECTION_MODIFIED ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_COLLECTION_MODIFIED ); } _currentIndex = 0; @@ -828,7 +828,7 @@ public bool MoveNext() { if( _version != _dictionary._version ) { - throw new InvalidOperationException( ThrowHelper.ENUMERATION_COLLECTION_MODIFIED ); + throw new InvalidOperationException( ThrowUtils.ENUMERATION_COLLECTION_MODIFIED ); } while( _currentIndex < _dictionary.KeyValueList.Count ) diff --git a/Runtime/Helpers.meta b/Runtime/Utilities.meta similarity index 100% rename from Runtime/Helpers.meta rename to Runtime/Utilities.meta diff --git a/Runtime/Helpers/ArgumentHelpers.cs b/Runtime/Utilities/ArgumentUtils.cs similarity index 96% rename from Runtime/Helpers/ArgumentHelpers.cs rename to Runtime/Utilities/ArgumentUtils.cs index fb7acf1..1668bc6 100644 --- a/Runtime/Helpers/ArgumentHelpers.cs +++ b/Runtime/Utilities/ArgumentUtils.cs @@ -2,7 +2,7 @@ namespace FishingCactus { - public static class ArgumentHelpers + public static class ArgumentUtils { // -- PUBLIC diff --git a/Runtime/Helpers/ArgumentHelpers.cs.meta b/Runtime/Utilities/ArgumentUtils.cs.meta similarity index 100% rename from Runtime/Helpers/ArgumentHelpers.cs.meta rename to Runtime/Utilities/ArgumentUtils.cs.meta diff --git a/Runtime/Helpers/Contracts.meta b/Runtime/Utilities/Contracts.meta similarity index 100% rename from Runtime/Helpers/Contracts.meta rename to Runtime/Utilities/Contracts.meta diff --git a/Runtime/Helpers/Contracts/IEnableable.cs b/Runtime/Utilities/Contracts/IEnableable.cs similarity index 100% rename from Runtime/Helpers/Contracts/IEnableable.cs rename to Runtime/Utilities/Contracts/IEnableable.cs diff --git a/Runtime/Helpers/Contracts/IEnableable.cs.meta b/Runtime/Utilities/Contracts/IEnableable.cs.meta similarity index 100% rename from Runtime/Helpers/Contracts/IEnableable.cs.meta rename to Runtime/Utilities/Contracts/IEnableable.cs.meta diff --git a/Runtime/Helpers/EnumHelper.cs b/Runtime/Utilities/EnumUtils.cs similarity index 97% rename from Runtime/Helpers/EnumHelper.cs rename to Runtime/Utilities/EnumUtils.cs index 450255f..f143391 100644 --- a/Runtime/Helpers/EnumHelper.cs +++ b/Runtime/Utilities/EnumUtils.cs @@ -4,7 +4,7 @@ namespace FishingCactus { - public static class EnumHelper + public static class EnumUtils { public static T ParseEnum( string value ) where T : Enum { diff --git a/Runtime/Helpers/EnumHelper.cs.meta b/Runtime/Utilities/EnumUtils.cs.meta similarity index 100% rename from Runtime/Helpers/EnumHelper.cs.meta rename to Runtime/Utilities/EnumUtils.cs.meta diff --git a/Runtime/Helpers/Math.cs b/Runtime/Utilities/MathUtils.cs similarity index 98% rename from Runtime/Helpers/Math.cs rename to Runtime/Utilities/MathUtils.cs index f40f994..ddf22d4 100644 --- a/Runtime/Helpers/Math.cs +++ b/Runtime/Utilities/MathUtils.cs @@ -2,7 +2,7 @@ namespace FishingCactus { - public static class Math + public static class MathUtils { public static Vector3 CatmulRomInterpolation( Vector3 point0, Vector3 point1, Vector3 point2, Vector3 point3, float percentage ) { diff --git a/Runtime/Helpers/Math.cs.meta b/Runtime/Utilities/MathUtils.cs.meta similarity index 100% rename from Runtime/Helpers/Math.cs.meta rename to Runtime/Utilities/MathUtils.cs.meta diff --git a/Runtime/Helpers/ReflectionUtilities.cs b/Runtime/Utilities/ReflectionUtils.cs similarity index 98% rename from Runtime/Helpers/ReflectionUtilities.cs rename to Runtime/Utilities/ReflectionUtils.cs index 8bac2b5..7658de2 100644 --- a/Runtime/Helpers/ReflectionUtilities.cs +++ b/Runtime/Utilities/ReflectionUtils.cs @@ -6,7 +6,7 @@ namespace FishingCactus { - public static class ReflectionUtilities + public static class ReflectionUtils { public static bool IsStaticClass( Type type diff --git a/Runtime/Helpers/ReflectionUtilities.cs.meta b/Runtime/Utilities/ReflectionUtils.cs.meta similarity index 100% rename from Runtime/Helpers/ReflectionUtilities.cs.meta rename to Runtime/Utilities/ReflectionUtils.cs.meta diff --git a/Runtime/Helpers/ThrowHelper.cs b/Runtime/Utilities/ThrowUtils.cs similarity index 96% rename from Runtime/Helpers/ThrowHelper.cs rename to Runtime/Utilities/ThrowUtils.cs index a9eef90..d534d4f 100644 --- a/Runtime/Helpers/ThrowHelper.cs +++ b/Runtime/Utilities/ThrowUtils.cs @@ -2,7 +2,7 @@ namespace FishingCactus { - public static class ThrowHelper + public static class ThrowUtils { // -- CONSTS diff --git a/Runtime/Helpers/ThrowHelper.cs.meta b/Runtime/Utilities/ThrowUtils.cs.meta similarity index 100% rename from Runtime/Helpers/ThrowHelper.cs.meta rename to Runtime/Utilities/ThrowUtils.cs.meta diff --git a/Runtime/Helpers/TimeHelper.cs b/Runtime/Utilities/TimeUtils.cs similarity index 97% rename from Runtime/Helpers/TimeHelper.cs rename to Runtime/Utilities/TimeUtils.cs index 7e19fee..efc2e33 100644 --- a/Runtime/Helpers/TimeHelper.cs +++ b/Runtime/Utilities/TimeUtils.cs @@ -3,7 +3,7 @@ namespace FishingCactus { - public static class TimeHelper + public static class TimeUtils { public static int GetMinutesFromSeconds( double seconds ) { diff --git a/Runtime/Helpers/TimeHelper.cs.meta b/Runtime/Utilities/TimeUtils.cs.meta similarity index 100% rename from Runtime/Helpers/TimeHelper.cs.meta rename to Runtime/Utilities/TimeUtils.cs.meta From 53ea5ca5e95a96ba71d959871d5e2ee93dec3480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 14:34:47 +0200 Subject: [PATCH 14/19] Add method descriptions --- README.md | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 8cac7e5..7c98c61 100644 --- a/README.md +++ b/README.md @@ -207,12 +207,12 @@ For command line arguments ### ReflectionUtils -| Methods | Notes | -|-------------------------------------------------------------------------------------------------------------------------------------------------------|-------| -| `static bool IsStaticClass( Type type )` | | -| `static IEnumerable GetImplementations( Func implementation_delegate = null )` | | -| `static IEnumerable GetImplementations( Type base_type, Func implementation_delegate = null )` | | -| `static IEnumerable CreateInstances( object[] parameters = null, Func implementation_delegate = null ) where TBase : class` | | +| Methods | Notes | +|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| +| `static bool IsStaticClass( Type type )` | | +| `static IEnumerable GetImplementations( Func implementation_delegate = null )` | Gets all types that implement the given type and match the given delegate | +| `static IEnumerable GetImplementations( Type base_type, Func implementation_delegate = null )` | Gets all types that implement the given type and match the given delegate | +| `static IEnumerable CreateInstances( object[] parameters = null, Func implementation_delegate = null ) where TBase : class` | Creates exactly one instance of each type that implements the given type and matches the given delegate | ### ThrowUtils @@ -232,6 +232,8 @@ For command line arguments ## ReadOnlyCollections +Provide readonly access to common collections types with garbage free enumerating and utility functions. + | Classes | Static? | Mono? | Notes | |------------------------------------------------|---------|-------|-------| | `ReadOnlyDictionary` | | | | @@ -267,17 +269,17 @@ For command line arguments ### PropertyContextMenus -| Classes | Notes | -|--------------------------------------|-------| -| `CreateAssetContextMenu` | | -| `PropertyContextMenuCallbackFetcher` | | -| `VectorContextMenu` | | +| Classes | Notes | +|--------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `CreateAssetContextMenu` | Adds a context menu action to choose, create and reference an instance of an implemenation of the property type when right clicking on exposed properties deriving from `ScriptableObject` | +| `PropertyContextMenuCallbackFetcher` | Utils script to fetch scripts that derive from `IPropertyContextMenuCallback` and add them automatically to property context menus. This is not meant to be used in project | +| `VectorContextMenu` | Adds context menu actions to quickly set values of integer, floating-points and vectors values in inspector | ## Dropdowns -| Classes | Notes | -|--------------------------------|-------| -| `SelectImplementationDropdown` | | +| Classes | Notes | +|--------------------------------|-----------------------------------------------------------------------------| +| `SelectImplementationDropdown` | Dropdown that allows to search and select an implementation of a given type | ### Items @@ -287,15 +289,15 @@ For command line arguments ## DropHandlers -| Classes | Notes | -|------------------------------|-------| -| `HierarchyScriptDropHandler` | | +| Classes | Notes | +|------------------------------|-----------------------------------------------------------------------------------------------------------------------------| +| `HierarchyScriptDropHandler` | Allows people to drag and drop scripts inside a scene to quickly create empty game objects with the dragged script attached | ## Inspector -| Classes | Notes | -|-----------------------------------|-------| -| `ReorderableSubAssetList` | | +| Classes | Notes | +|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `ReorderableSubAssetList` | Used to draw a list of subassets in inspector from a serialized list on scriptable objects. Supports creating new subassets by selecting a specific implementation and delete existing subassets | ## PropertyDrawer @@ -323,6 +325,8 @@ See [Attributes](#attributes) ### HierarchyUtils +Utility functions related to the scene hierarchy. + | Classes | Notes | |----------------------------------------------------------------------------------------------------------------------------------|-------| | `static GameObject CreateAndRename( string default_name, Transform parent = null, bool active_object_is_default_parent = true )` | | @@ -330,6 +334,8 @@ See [Attributes](#attributes) ### InspectorUtils +Utility functions related todrawing things in inspector. + | Classes | Notes | |-------------------------------------------------------------------------------------|-------| | `static bool TryGetArrayOrListElementType( Type list_type, out Type element_type )` | | From 946501bbfedd14900383368468580bbb8f1748cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 6 May 2024 14:50:18 +0200 Subject: [PATCH 15/19] Rename/add namespace > FishingCactus.CommonCode --- Editor/ApplySelectedPrefabs.cs | 2 +- .../CreateAssetContextMenu.cs | 2 +- .../IPropertyContextMenuCallback.cs | 2 +- .../PropertyContextMenuCallbackFetcher.cs | 2 +- .../PropertyContextMenus/VectorContextMenu.cs | 2 +- Editor/CreateNewPrefab.cs | 273 +++++------ Editor/DropDowns/Items/TypeDropdownItem.cs | 2 +- .../DropDowns/SelectImplementationDropdown.cs | 2 +- .../HierarchyScriptDropHandler.cs | 2 +- Editor/Inspector/ReorderableSubAssetList.cs | 2 +- Editor/InternalEditorStyle.cs | 425 +++++++++--------- Editor/ObjectToTerrain.cs | 183 ++++---- .../AnimatorParameterLinkDrawer.cs | 4 +- .../EnumFlagsAttributeDrawer.cs | 2 +- .../ExposedScriptableObjectAttributeDrawer.cs | 2 +- .../AttributesDrawer/MaxDrawer.cs | 2 +- .../AttributesDrawer/ReadOnlyDrawer.cs | 3 +- .../SubClassPickerAttributeDrawer.cs | 2 +- .../EnumDictionaryPropertyDrawer.cs | 133 +++--- Editor/PropertyDrawer/OptionalDrawer.cs | 2 +- Editor/PropertyDrawer/RangeDrawer.cs | 2 +- Editor/PropertyDrawer/TagLinkDrawer.cs | 2 +- Editor/ScriptableObjectCreator.cs | 2 +- Editor/Utilities/EditorUtils.cs | 2 +- Editor/Utilities/HierarchyUtils.cs | 2 +- Editor/Utilities/InspectorUtils.cs | 101 +++-- Editor/Utilities/WizzardUtils.cs | 2 +- Runtime/Animator/AnimatorLayerController.cs | 189 ++++---- Runtime/Animator/AnimatorParameterLink.cs | 2 +- Runtime/Attributes/EnumFlagsAttribute.cs | 2 +- .../ExposedScriptableObjectAttribute.cs | 2 +- Runtime/Attributes/MaxAttribute.cs | 2 +- Runtime/Attributes/ReadOnlyAttribute.cs | 3 +- Runtime/Attributes/SubClassPickerAttribute.cs | 2 +- Runtime/Coroutines/CoroutineHelper.cs | 2 +- Runtime/Coroutines/ManualReturnRoutine.cs | 2 +- .../Coroutines/ParallelizedMultiRoutines.cs | 2 +- .../Coroutines/ResultCompletionEventArgs.cs | 2 +- Runtime/Coroutines/Routine.cs | 2 +- Runtime/Coroutines/SequentialRoutine.cs | 2 +- Runtime/DebugTimeScaler.cs | 33 +- Runtime/EnumDictionary.cs | 91 ++-- .../Extensions/AnimationCurveExtensions.cs | 2 +- Runtime/Extensions/AnimatorExtensions.cs | 2 +- Runtime/Extensions/CollectionsExtensions.cs | 2 +- Runtime/Extensions/GameObjectExtensions.cs | 2 +- Runtime/Extensions/IComparableExtensions.cs | 2 +- Runtime/Extensions/ListExtensions.cs | 2 +- Runtime/Extensions/MonoBehaviourExtensions.cs | 2 +- Runtime/Extensions/StringExtensions.cs | 81 ++-- Runtime/Extensions/TransformExtensions.cs | 2 +- Runtime/Extensions/ULongExtensions.cs | 2 +- Runtime/Extensions/Vector3Extensions.cs | 2 +- Runtime/FPSCounter.cs | 2 +- Runtime/GUIConsole.cs | 2 +- Runtime/GyroscopeHelper.cs | 2 +- Runtime/NetworkStatusChecker.cs | 2 +- Runtime/Optional.cs | 2 +- Runtime/Range.cs | 6 +- .../ReadOnlyCollections/ReadOnlyDictionary.cs | 2 +- .../ReadOnlyCollections/ReadOnlyHashSet.cs | 2 +- Runtime/ReadOnlyCollections/ReadOnlyList.cs | 2 +- Runtime/ReadOnlyCollections/ReadOnlyQueue.cs | 2 +- .../ReadOnlySerializableDictionary.cs | 2 +- Runtime/ReadOnlyCollections/ReadOnlyStack.cs | 2 +- Runtime/SerializableDictionary.cs | 2 +- Runtime/Singleton.cs | 2 +- Runtime/TagLink.cs | 2 +- Runtime/TimeScaleManager.cs | 81 ++-- Runtime/UI/Wizard.cs | 2 +- Runtime/UI/WizardPanel.cs | 2 +- Runtime/Utilities/ArgumentUtils.cs | 2 +- Runtime/Utilities/Contracts/IEnableable.cs | 2 +- Runtime/Utilities/EnumUtils.cs | 2 +- Runtime/Utilities/MathUtils.cs | 2 +- Runtime/Utilities/ReflectionUtils.cs | 2 +- Runtime/Utilities/ThrowUtils.cs | 2 +- Runtime/Utilities/TimeUtils.cs | 2 +- Runtime/VersionNumber.cs | 83 ++-- 79 files changed, 926 insertions(+), 891 deletions(-) diff --git a/Editor/ApplySelectedPrefabs.cs b/Editor/ApplySelectedPrefabs.cs index 269ddec..6eac5fc 100644 --- a/Editor/ApplySelectedPrefabs.cs +++ b/Editor/ApplySelectedPrefabs.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class ApplySelectedPrefabs : EditorWindow { diff --git a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs index b23baaf..8eaa369 100644 --- a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs +++ b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs @@ -6,7 +6,7 @@ using UnityEngine; using UnityEngine.SceneManagement; -namespace FishingCactus +namespace FishingCactus.UnityCommonCode { public sealed class CreateAssetContextMenu : IPropertyContextMenuCallback { diff --git a/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs b/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs index effb786..cc9655b 100644 --- a/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs +++ b/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.UnityCommonCode { public interface IPropertyContextMenuCallback { diff --git a/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs b/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs index a94a29a..07f115e 100644 --- a/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs +++ b/Editor/ContextMenus/PropertyContextMenus/PropertyContextMenuCallbackFetcher.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class PropertyContextMenuCallbackFetcher { diff --git a/Editor/ContextMenus/PropertyContextMenus/VectorContextMenu.cs b/Editor/ContextMenus/PropertyContextMenus/VectorContextMenu.cs index 4d89494..7afd9db 100644 --- a/Editor/ContextMenus/PropertyContextMenus/VectorContextMenu.cs +++ b/Editor/ContextMenus/PropertyContextMenus/VectorContextMenu.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public sealed class VectorContextMenu : IPropertyContextMenuCallback { diff --git a/Editor/CreateNewPrefab.cs b/Editor/CreateNewPrefab.cs index a7f92de..cde96e5 100644 --- a/Editor/CreateNewPrefab.cs +++ b/Editor/CreateNewPrefab.cs @@ -1,180 +1,183 @@ using UnityEngine; using UnityEditor; -public class CreateNewPrefab : EditorWindow +namespace FishingCactus.CommonCode { - // -- TYPES - - private enum VariantMode + public class CreateNewPrefab : EditorWindow { - Enabled = 0, - Disabled - } + // -- TYPES - private enum ParentMode - { - Free = 0, - Attached - } + private enum VariantMode + { + Enabled = 0, + Disabled + } - private enum PathSelection - { - Default = 0, - DisplayDialog - } + private enum ParentMode + { + Free = 0, + Attached + } - // -- FIELDS + private enum PathSelection + { + Default = 0, + DisplayDialog + } - static string PrefabPathLocalKey = "FC/CommonCode/NewPrefabPath"; + // -- FIELDS - static string PrefabCreationPath = "Assets/_Content/Prefabs/Assets/"; - static string PrefabPrefix = "P_"; - static string PrefabExtension = ".prefab"; + static string PrefabPathLocalKey = "FC/CommonCode/NewPrefabPath"; - // -- METHODS + static string PrefabCreationPath = "Assets/_Content/Prefabs/Assets/"; + static string PrefabPrefix = "P_"; + static string PrefabExtension = ".prefab"; - static private void CreatePrefabs( - VariantMode variant_mode, - ParentMode parent_mode, - PathSelection path_mode - ) - { - string previous_path = EditorPrefs.GetString( PrefabPathLocalKey, PrefabExtension ); - string destination_path = string.Empty; + // -- METHODS - if( path_mode == PathSelection.DisplayDialog ) + static private void CreatePrefabs( + VariantMode variant_mode, + ParentMode parent_mode, + PathSelection path_mode + ) { - destination_path = EditorUtility.OpenFolderPanel( "Destination Path :", PrefabCreationPath, "" ); - - if( string.IsNullOrEmpty( destination_path ) - || !AssetDatabase.IsValidFolder( destination_path ) - ) - { - Debug.LogWarning( $"[CreatePrefabs] : Invalid path : \"{destination_path}\"." ); + string previous_path = EditorPrefs.GetString( PrefabPathLocalKey, PrefabExtension ); + string destination_path = string.Empty; - return; - } - - if( destination_path.StartsWith( Application.dataPath ) ) + if( path_mode == PathSelection.DisplayDialog ) { - destination_path = "Assets" + destination_path.Substring( Application.dataPath.Length ); - } - - destination_path += "/"; - - EditorPrefs.SetString( PrefabPathLocalKey, destination_path ); - } - else - { - destination_path = PrefabCreationPath; - } + destination_path = EditorUtility.OpenFolderPanel( "Destination Path :", PrefabCreationPath, "" ); - GameObject[] object_table = Selection.gameObjects; + if( string.IsNullOrEmpty( destination_path ) + || !AssetDatabase.IsValidFolder( destination_path ) + ) + { + Debug.LogWarning( $"[CreatePrefabs] : Invalid path : \"{destination_path}\"." ); - foreach( GameObject game_object in object_table ) - { - GameObject new_prefab; + return; + } - if( parent_mode == ParentMode.Attached ) - { - new_prefab = new GameObject( game_object.name ); - new_prefab.name = game_object.name.Replace( "(Clone)", "" ); + if( destination_path.StartsWith( Application.dataPath ) ) + { + destination_path = "Assets" + destination_path.Substring( Application.dataPath.Length ); + } - game_object.name = game_object.name.Replace( PrefabPrefix, "" ); + destination_path += "/"; - GameObject game_object_as_child = Instantiate( game_object, new_prefab.transform ); - game_object_as_child.name = game_object_as_child.name.Replace( "(Clone)", "" ); - game_object_as_child.transform.position = Vector3.zero; + EditorPrefs.SetString( PrefabPathLocalKey, destination_path ); } else { - new_prefab = game_object; + destination_path = PrefabCreationPath; } - if( !new_prefab.name.StartsWith(PrefabPrefix) ) + GameObject[] object_table = Selection.gameObjects; + + foreach( GameObject game_object in object_table ) { - new_prefab.name = PrefabPrefix + game_object.name; - } + GameObject new_prefab; - string local_path = destination_path + new_prefab.name + PrefabExtension; + if( parent_mode == ParentMode.Attached ) + { + new_prefab = new GameObject( game_object.name ); + new_prefab.name = game_object.name.Replace( "(Clone)", "" ); - if( AssetDatabase.LoadAssetAtPath( local_path, typeof(GameObject)) ) - { - if( !EditorUtility.DisplayDialog("Are you sure?", "The prefab already exists. Do you want to overwrite it?", "Yes", "No") ) + game_object.name = game_object.name.Replace( PrefabPrefix, "" ); + + GameObject game_object_as_child = Instantiate( game_object, new_prefab.transform ); + game_object_as_child.name = game_object_as_child.name.Replace( "(Clone)", "" ); + game_object_as_child.transform.position = Vector3.zero; + } + else { - return; + new_prefab = game_object; } - } - if( variant_mode == VariantMode.Enabled ) - { - Debug.Log( new_prefab.name + " prefab variant created" ); - CreateVariant( new_prefab, local_path ); - } - else - { - Debug.Log( new_prefab.name + " prefab created" ); - CreateNew( new_prefab, local_path ); - } + if( !new_prefab.name.StartsWith(PrefabPrefix) ) + { + new_prefab.name = PrefabPrefix + game_object.name; + } - if( parent_mode == ParentMode.Attached ) - { - new_prefab.transform.position = game_object.transform.position; - - DestroyImmediate( game_object ); + string local_path = destination_path + new_prefab.name + PrefabExtension; + + if( AssetDatabase.LoadAssetAtPath( local_path, typeof(GameObject)) ) + { + if( !EditorUtility.DisplayDialog("Are you sure?", "The prefab already exists. Do you want to overwrite it?", "Yes", "No") ) + { + return; + } + } + + if( variant_mode == VariantMode.Enabled ) + { + Debug.Log( new_prefab.name + " prefab variant created" ); + CreateVariant( new_prefab, local_path ); + } + else + { + Debug.Log( new_prefab.name + " prefab created" ); + CreateNew( new_prefab, local_path ); + } + + if( parent_mode == ParentMode.Attached ) + { + new_prefab.transform.position = game_object.transform.position; + + DestroyImmediate( game_object ); + } } } - } - static private void CreateNew( - GameObject new_object, - string local_path - ) - { - PrefabUtility.SaveAsPrefabAsset(new_object, local_path); - } + static private void CreateNew( + GameObject new_object, + string local_path + ) + { + PrefabUtility.SaveAsPrefabAsset(new_object, local_path); + } - static private void CreateVariant( - GameObject new_object, - string local_path - ) - { - PrefabUtility.SaveAsPrefabAssetAndConnect( new_object, local_path, InteractionMode.UserAction ); - } + static private void CreateVariant( + GameObject new_object, + string local_path + ) + { + PrefabUtility.SaveAsPrefabAssetAndConnect( new_object, local_path, InteractionMode.UserAction ); + } - [MenuItem("FishingCactus/Tools/Create New Prefab/New or Variant", true)] - static private bool ValidateCreatePrefabOrVariant() - { - return Selection.activeGameObject != null; - } + [MenuItem("FishingCactus/Tools/Create New Prefab/New or Variant", true)] + static private bool ValidateCreatePrefabOrVariant() + { + return Selection.activeGameObject != null; + } - [MenuItem("FishingCactus/Tools/Create New Prefab/New or Variant")] - static private void CreatePrefabOrVariant() - { - CreatePrefabs( VariantMode.Enabled, ParentMode.Free, PathSelection.DisplayDialog ); - } + [MenuItem("FishingCactus/Tools/Create New Prefab/New or Variant")] + static private void CreatePrefabOrVariant() + { + CreatePrefabs( VariantMode.Enabled, ParentMode.Free, PathSelection.DisplayDialog ); + } - [MenuItem("FishingCactus/Tools/Create New Prefab/Force new (no variant)", true)] - static private bool ValidateCreatePrefab() - { - return Selection.activeGameObject != null; - } + [MenuItem("FishingCactus/Tools/Create New Prefab/Force new (no variant)", true)] + static private bool ValidateCreatePrefab() + { + return Selection.activeGameObject != null; + } - [MenuItem("FishingCactus/Tools/Create New Prefab/Force new (no variant)")] - static private void CreatePrefab() - { - CreatePrefabs( VariantMode.Disabled, ParentMode.Free, PathSelection.DisplayDialog ); - } + [MenuItem("FishingCactus/Tools/Create New Prefab/Force new (no variant)")] + static private void CreatePrefab() + { + CreatePrefabs( VariantMode.Disabled, ParentMode.Free, PathSelection.DisplayDialog ); + } - [MenuItem("FishingCactus/Tools/Create New Prefab/New within an Empty Parent", true)] - static private bool ValidateCreateEmptyParentPrefab() - { - return Selection.activeGameObject != null; - } + [MenuItem("FishingCactus/Tools/Create New Prefab/New within an Empty Parent", true)] + static private bool ValidateCreateEmptyParentPrefab() + { + return Selection.activeGameObject != null; + } - [MenuItem("FishingCactus/Tools/Create New Prefab/New within an Empty Parent")] - static private void CreateEmptyParentPrefab() - { - CreatePrefabs( VariantMode.Disabled, ParentMode.Attached, PathSelection.DisplayDialog ); + [MenuItem("FishingCactus/Tools/Create New Prefab/New within an Empty Parent")] + static private void CreateEmptyParentPrefab() + { + CreatePrefabs( VariantMode.Disabled, ParentMode.Attached, PathSelection.DisplayDialog ); + } } } diff --git a/Editor/DropDowns/Items/TypeDropdownItem.cs b/Editor/DropDowns/Items/TypeDropdownItem.cs index 29efa3d..fe8186c 100644 --- a/Editor/DropDowns/Items/TypeDropdownItem.cs +++ b/Editor/DropDowns/Items/TypeDropdownItem.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEditor.IMGUI.Controls; -namespace FishingCactus +namespace FishingCactus.CommonCode { public sealed class TypeDropdownItem : AdvancedDropdownItem { diff --git a/Editor/DropDowns/SelectImplementationDropdown.cs b/Editor/DropDowns/SelectImplementationDropdown.cs index 62e9c0b..7793bc2 100644 --- a/Editor/DropDowns/SelectImplementationDropdown.cs +++ b/Editor/DropDowns/SelectImplementationDropdown.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEditor.IMGUI.Controls; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class SelectImplementationDropdown : AdvancedDropdown { diff --git a/Editor/DropHandlers/HierarchyScriptDropHandler.cs b/Editor/DropHandlers/HierarchyScriptDropHandler.cs index 7175dc8..5725ed5 100644 --- a/Editor/DropHandlers/HierarchyScriptDropHandler.cs +++ b/Editor/DropHandlers/HierarchyScriptDropHandler.cs @@ -4,7 +4,7 @@ using UnityEngine; using Object = UnityEngine.Object; -namespace FishingCactus +namespace FishingCactus.CommonCode { [InitializeOnLoad] public static class HierarchyScriptDropHandler diff --git a/Editor/Inspector/ReorderableSubAssetList.cs b/Editor/Inspector/ReorderableSubAssetList.cs index 753bacc..8d069d3 100644 --- a/Editor/Inspector/ReorderableSubAssetList.cs +++ b/Editor/Inspector/ReorderableSubAssetList.cs @@ -5,7 +5,7 @@ using UnityEngine; using UnityObject = UnityEngine.Object; -namespace FishingCactus +namespace FishingCactus.CommonCode { public sealed class ReorderableSubAssetList : ReorderableList where TAsset : ScriptableObject diff --git a/Editor/InternalEditorStyle.cs b/Editor/InternalEditorStyle.cs index 1c8d263..dbef8f5 100644 --- a/Editor/InternalEditorStyle.cs +++ b/Editor/InternalEditorStyle.cs @@ -1,327 +1,330 @@ using UnityEngine; using UnityEditor; -public class InternalEditorStyle +namespace FishingCactus.CommonCode { - // -- PUBLIC + public class InternalEditorStyle + { + // -- PUBLIC - public static float MinimalButtonWidth = 24.0f; + public static float MinimalButtonWidth = 24.0f; - public static GUIStyle BlackBoldLabel - { - get + public static GUIStyle BlackBoldLabel { - if( BlackBoldLabelStyle == null ) + get { - BlackBoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - BlackBoldLabelStyle.fontStyle = FontStyle.Bold; + if( BlackBoldLabelStyle == null ) + { + BlackBoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + BlackBoldLabelStyle.fontStyle = FontStyle.Bold; - SetTextsColor( BlackBoldLabelStyle, Color.black ); - } + SetTextsColor( BlackBoldLabelStyle, Color.black ); + } - return BlackBoldLabelStyle; + return BlackBoldLabelStyle; + } } - } - public static GUIStyle BlueFoldout - { - get + public static GUIStyle BlueFoldout { - if( BlueFoldoutStyle == null ) + get { - BlueFoldoutStyle = new GUIStyle( EditorStyles.foldout ); - BlueFoldoutStyle.fontStyle = FontStyle.Normal; + if( BlueFoldoutStyle == null ) + { + BlueFoldoutStyle = new GUIStyle( EditorStyles.foldout ); + BlueFoldoutStyle.fontStyle = FontStyle.Normal; - SetTextsColor( BlueFoldoutStyle, BlueColor ); - } + SetTextsColor( BlueFoldoutStyle, BlueColor ); + } - return BlueFoldoutStyle; + return BlueFoldoutStyle; + } } - } - public static GUIStyle BlueBoldFoldout - { - get + public static GUIStyle BlueBoldFoldout { - if( BlueBoldFoldoutStyle == null ) + get { - BlueBoldFoldoutStyle = new GUIStyle( EditorStyles.foldout ); - BlueBoldFoldoutStyle.fontStyle = FontStyle.Bold; + if( BlueBoldFoldoutStyle == null ) + { + BlueBoldFoldoutStyle = new GUIStyle( EditorStyles.foldout ); + BlueBoldFoldoutStyle.fontStyle = FontStyle.Bold; - SetTextsColor( BlueBoldFoldoutStyle, BlueColor ); - } + SetTextsColor( BlueBoldFoldoutStyle, BlueColor ); + } - return BlueBoldFoldoutStyle; + return BlueBoldFoldoutStyle; + } } - } - public static GUIStyle BlueGroupLabel - { - get + public static GUIStyle BlueGroupLabel { - if ( BlueGroupLabelStyle == null ) + get { - BlueGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - BlueGroupLabelStyle.fontStyle = FontStyle.Bold; + if ( BlueGroupLabelStyle == null ) + { + BlueGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + BlueGroupLabelStyle.fontStyle = FontStyle.Bold; - SetTextsColor( BlueGroupLabelStyle, BlueColor ); - } + SetTextsColor( BlueGroupLabelStyle, BlueColor ); + } - return BlueGroupLabelStyle; + return BlueGroupLabelStyle; + } } - } - public static GUIStyle BlueSubGroupLabel - { - get + public static GUIStyle BlueSubGroupLabel { - if( BlueSubGroupLabelStyle == null ) + get { - BlueSubGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + if( BlueSubGroupLabelStyle == null ) + { + BlueSubGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - BlueSubGroupLabelStyle.fontSize = 10; - BlueSubGroupLabelStyle.fontStyle = FontStyle.Italic; + BlueSubGroupLabelStyle.fontSize = 10; + BlueSubGroupLabelStyle.fontStyle = FontStyle.Italic; - SetTextsColor( BlueSubGroupLabelStyle, BlueColor ); - } + SetTextsColor( BlueSubGroupLabelStyle, BlueColor ); + } - return BlueSubGroupLabelStyle; + return BlueSubGroupLabelStyle; + } } - } - public static GUIStyle GreenBoldLabel - { - get + public static GUIStyle GreenBoldLabel { - if( GreenBoldLabelStyle == null ) + get { - GreenBoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - GreenBoldLabelStyle.fontStyle = FontStyle.Bold; + if( GreenBoldLabelStyle == null ) + { + GreenBoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + GreenBoldLabelStyle.fontStyle = FontStyle.Bold; - SetTextsColor( GreenBoldLabelStyle, GreenColor ); - } + SetTextsColor( GreenBoldLabelStyle, GreenColor ); + } - return GreenBoldLabelStyle; + return GreenBoldLabelStyle; + } } - } - public static GUIStyle OrangeItalicLabel - { - get + public static GUIStyle OrangeItalicLabel { - if( OrangeItalicLabelStyle == null ) + get { - OrangeItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - OrangeItalicLabelStyle.fontStyle = FontStyle.Italic; + if( OrangeItalicLabelStyle == null ) + { + OrangeItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + OrangeItalicLabelStyle.fontStyle = FontStyle.Italic; - SetTextsColor( OrangeItalicLabelStyle, OrangeColor ); - } + SetTextsColor( OrangeItalicLabelStyle, OrangeColor ); + } - return OrangeItalicLabelStyle; + return OrangeItalicLabelStyle; + } } - } - public static GUIStyle RedBoldFoldout - { - get + public static GUIStyle RedBoldFoldout { - if( RedBoldFoldoutStyle == null ) + get { - RedBoldFoldoutStyle = new GUIStyle( EditorStyles.foldout ); - RedBoldFoldoutStyle.fontStyle = FontStyle.Bold; + if( RedBoldFoldoutStyle == null ) + { + RedBoldFoldoutStyle = new GUIStyle( EditorStyles.foldout ); + RedBoldFoldoutStyle.fontStyle = FontStyle.Bold; - SetTextsColor( RedBoldFoldoutStyle, RedColor ); - } + SetTextsColor( RedBoldFoldoutStyle, RedColor ); + } - return RedBoldFoldoutStyle; + return RedBoldFoldoutStyle; + } } - } - public static GUIStyle RedGroupLabel - { - get + public static GUIStyle RedGroupLabel { - if( RedGroupLabelStyle == null ) + get { - RedGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - RedGroupLabelStyle.fontStyle = FontStyle.Bold; + if( RedGroupLabelStyle == null ) + { + RedGroupLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + RedGroupLabelStyle.fontStyle = FontStyle.Bold; - SetTextsColor( RedGroupLabelStyle, RedColor ); - } + SetTextsColor( RedGroupLabelStyle, RedColor ); + } - return RedGroupLabelStyle; + return RedGroupLabelStyle; + } } - } - public static GUIStyle RedItalicLabel - { - get + public static GUIStyle RedItalicLabel { - if( RedItalicLabelStyle == null ) + get { - RedItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - RedItalicLabelStyle.fontStyle = FontStyle.Italic; + if( RedItalicLabelStyle == null ) + { + RedItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + RedItalicLabelStyle.fontStyle = FontStyle.Italic; - SetTextsColor( RedItalicLabelStyle, RedColor ); - } + SetTextsColor( RedItalicLabelStyle, RedColor ); + } - return RedItalicLabelStyle; + return RedItalicLabelStyle; + } } - } - public static GUIStyle LockerToggle - { - get + public static GUIStyle LockerToggle { - if( LockerToggleStyle == null ) + get { - LockerToggleStyle = new GUIStyle( EditorStyles.toggle ); + if( LockerToggleStyle == null ) + { + LockerToggleStyle = new GUIStyle( EditorStyles.toggle ); - LockerToggleStyle.alignment = TextAnchor.MiddleCenter; + LockerToggleStyle.alignment = TextAnchor.MiddleCenter; - LockerToggleStyle.normal.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; - LockerToggleStyle.hover.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; - LockerToggleStyle.focused.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; - LockerToggleStyle.active.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; + LockerToggleStyle.normal.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; + LockerToggleStyle.hover.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; + LockerToggleStyle.focused.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; + LockerToggleStyle.active.background = EditorGUIUtility.IconContent( "LockIcon-On" ).image as Texture2D; - LockerToggleStyle.onFocused.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; - LockerToggleStyle.onNormal.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; - LockerToggleStyle.onHover.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; - LockerToggleStyle.onActive.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; - } + LockerToggleStyle.onFocused.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; + LockerToggleStyle.onNormal.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; + LockerToggleStyle.onHover.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; + LockerToggleStyle.onActive.background = EditorGUIUtility.IconContent( "LockIcon" ).image as Texture2D; + } - return LockerToggleStyle; + return LockerToggleStyle; + } } - } - public static GUIStyle CenteredToggle - { - get + public static GUIStyle CenteredToggle { - if( CenteredToggleStyle == null ) + get { - CenteredToggleStyle = new GUIStyle( EditorStyles.toggle ); - CenteredToggleStyle.alignment = TextAnchor.MiddleCenter; - } + if( CenteredToggleStyle == null ) + { + CenteredToggleStyle = new GUIStyle( EditorStyles.toggle ); + CenteredToggleStyle.alignment = TextAnchor.MiddleCenter; + } - return CenteredToggleStyle; + return CenteredToggleStyle; + } } - } - public static GUIStyle EyeButton - { - get + public static GUIStyle EyeButton { - if( EyeButtonStyle == null ) + get { - EyeButtonStyle = new GUIStyle( EditorStyles.miniButton ); - EyeButtonStyle.alignment = TextAnchor.UpperCenter; - EyeButtonStyle.normal.background = null; + if( EyeButtonStyle == null ) + { + EyeButtonStyle = new GUIStyle( EditorStyles.miniButton ); + EyeButtonStyle.alignment = TextAnchor.UpperCenter; + EyeButtonStyle.normal.background = null; + } + + return EyeButtonStyle; } - - return EyeButtonStyle; } - } - public static GUIStyle CenteredLabel - { - get + public static GUIStyle CenteredLabel { - if( CenteredLabelStyle == null ) + get { - CenteredLabelStyle = new GUIStyle( EditorStyles.label ); - CenteredLabelStyle.alignment = TextAnchor.MiddleCenter; - } + if( CenteredLabelStyle == null ) + { + CenteredLabelStyle = new GUIStyle( EditorStyles.label ); + CenteredLabelStyle.alignment = TextAnchor.MiddleCenter; + } - return CenteredLabelStyle; + return CenteredLabelStyle; + } } - } - public static GUIStyle RightLabel - { - get + public static GUIStyle RightLabel { - if( RightLabelStyle == null ) + get { - RightLabelStyle = new GUIStyle( EditorStyles.label ); - RightLabelStyle.alignment = TextAnchor.MiddleRight; - } + if( RightLabelStyle == null ) + { + RightLabelStyle = new GUIStyle( EditorStyles.label ); + RightLabelStyle.alignment = TextAnchor.MiddleRight; + } - return RightLabelStyle; + return RightLabelStyle; + } } - } - public static GUIStyle ItalicLabel - { - get + public static GUIStyle ItalicLabel { - if( ItalicLabelStyle == null ) + get { - ItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - ItalicLabelStyle.fontStyle = FontStyle.Italic; - } + if( ItalicLabelStyle == null ) + { + ItalicLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + ItalicLabelStyle.fontStyle = FontStyle.Italic; + } - return ItalicLabelStyle; + return ItalicLabelStyle; + } } - } - public static GUIStyle BoldLabel - { - get + public static GUIStyle BoldLabel { - if( BoldLabelStyle == null ) + get { - BoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); - BoldLabelStyle.fontStyle = FontStyle.Bold; - } + if( BoldLabelStyle == null ) + { + BoldLabelStyle = new GUIStyle( EditorStyles.boldLabel ); + BoldLabelStyle.fontStyle = FontStyle.Bold; + } - return BoldLabelStyle; + return BoldLabelStyle; + } } - } - // -- PRIVATE + // -- PRIVATE - private static GUIStyle BlackBoldLabelStyle; + private static GUIStyle BlackBoldLabelStyle; - private static GUIStyle BlueFoldoutStyle; - private static GUIStyle BlueBoldFoldoutStyle; - private static GUIStyle BlueGroupLabelStyle; - private static GUIStyle BlueSubGroupLabelStyle; + private static GUIStyle BlueFoldoutStyle; + private static GUIStyle BlueBoldFoldoutStyle; + private static GUIStyle BlueGroupLabelStyle; + private static GUIStyle BlueSubGroupLabelStyle; - private static GUIStyle GreenBoldLabelStyle; + private static GUIStyle GreenBoldLabelStyle; - private static GUIStyle OrangeItalicLabelStyle; + private static GUIStyle OrangeItalicLabelStyle; - private static GUIStyle RedBoldFoldoutStyle; - private static GUIStyle RedGroupLabelStyle; - private static GUIStyle RedItalicLabelStyle; + private static GUIStyle RedBoldFoldoutStyle; + private static GUIStyle RedGroupLabelStyle; + private static GUIStyle RedItalicLabelStyle; - private static GUIStyle LockerToggleStyle; - private static GUIStyle CenteredToggleStyle; - private static GUIStyle EyeButtonStyle; - private static GUIStyle CenteredLabelStyle; - private static GUIStyle RightLabelStyle; - private static GUIStyle BoldLabelStyle; - private static GUIStyle ItalicLabelStyle; + private static GUIStyle LockerToggleStyle; + private static GUIStyle CenteredToggleStyle; + private static GUIStyle EyeButtonStyle; + private static GUIStyle CenteredLabelStyle; + private static GUIStyle RightLabelStyle; + private static GUIStyle BoldLabelStyle; + private static GUIStyle ItalicLabelStyle; - private static Color BlueColor = new Color( 0.29f, 0.69f, 1.0f, 1.0f ); - private static Color GreenColor = new Color( 0.2f, 0.8f, 0.2f, 1.0f ); - private static Color RedColor = new Color( 1.1f, 0.2f, 0.2f, 1.0f ); - private static Color OrangeColor = new Color( 0.8f, 0.8f, 0.2f, 1.0f ); + private static Color BlueColor = new Color( 0.29f, 0.69f, 1.0f, 1.0f ); + private static Color GreenColor = new Color( 0.2f, 0.8f, 0.2f, 1.0f ); + private static Color RedColor = new Color( 1.1f, 0.2f, 0.2f, 1.0f ); + private static Color OrangeColor = new Color( 0.8f, 0.8f, 0.2f, 1.0f ); - private static void SetTextsColor( - GUIStyle style_to_update, - Color new_text_color - ) - { - style_to_update.normal.textColor = new_text_color; - style_to_update.onNormal.textColor = new_text_color; - style_to_update.hover.textColor = new_text_color; - style_to_update.onHover.textColor = new_text_color; - style_to_update.focused.textColor = new_text_color; - style_to_update.onFocused.textColor = new_text_color; - style_to_update.active.textColor = new_text_color; - style_to_update.onActive.textColor = new_text_color; + private static void SetTextsColor( + GUIStyle style_to_update, + Color new_text_color + ) + { + style_to_update.normal.textColor = new_text_color; + style_to_update.onNormal.textColor = new_text_color; + style_to_update.hover.textColor = new_text_color; + style_to_update.onHover.textColor = new_text_color; + style_to_update.focused.textColor = new_text_color; + style_to_update.onFocused.textColor = new_text_color; + style_to_update.active.textColor = new_text_color; + style_to_update.onActive.textColor = new_text_color; + } } } diff --git a/Editor/ObjectToTerrain.cs b/Editor/ObjectToTerrain.cs index 893c1ca..ccce6fe 100644 --- a/Editor/ObjectToTerrain.cs +++ b/Editor/ObjectToTerrain.cs @@ -1,132 +1,135 @@ using UnityEngine; using UnityEditor; -public class ObjectToTerrain : EditorWindow +namespace FishingCactus.CommonCode { - // -- PRIVATE - - private static string[] choice_name_table = new string[] { "Bottom Up", "Top Down" }; + public class ObjectToTerrain : EditorWindow + { + // -- PRIVATE - private int resolution = 512; - private int radio_selected_index = 0; - private float height_shift = 0.0f; - private Vector3 terrain_offset; + private static string[] choice_name_table = new string[] { "Bottom Up", "Top Down" }; - delegate void CleanUp(); + private int resolution = 512; + private int radio_selected_index = 0; + private float height_shift = 0.0f; + private Vector3 terrain_offset; - private void CreateTerrain() - { - ShowProgressBar( 1, 100 ); + delegate void CleanUp(); - TerrainData terrain = new TerrainData(); - terrain.heightmapResolution = resolution; + private void CreateTerrain() + { + ShowProgressBar( 1, 100 ); - GameObject terrainObject = Terrain.CreateTerrainGameObject( terrain ); + TerrainData terrain = new TerrainData(); + terrain.heightmapResolution = resolution; - Undo.RecordObject( terrainObject, "Object to Terrain" ); + GameObject terrainObject = Terrain.CreateTerrainGameObject( terrain ); - MeshCollider collider = Selection.activeGameObject.GetComponent(); - CleanUp cleanUp = null; + Undo.RecordObject( terrainObject, "Object to Terrain" ); - if( !collider ) - { - collider = Selection.activeGameObject.AddComponent(); - cleanUp = () => DestroyImmediate( collider ); - } + MeshCollider collider = Selection.activeGameObject.GetComponent(); + CleanUp cleanUp = null; - Bounds bounds = collider.bounds; - float sizeFactor = collider.bounds.size.y / ( collider.bounds.size.y + terrain_offset.y ); + if( !collider ) + { + collider = Selection.activeGameObject.AddComponent(); + cleanUp = () => DestroyImmediate( collider ); + } - terrain.size = collider.bounds.size + terrain_offset; - bounds.size = new Vector3( terrain.size.x, collider.bounds.size.y, terrain.size.z ); + Bounds bounds = collider.bounds; + float sizeFactor = collider.bounds.size.y / ( collider.bounds.size.y + terrain_offset.y ); - float[,] heights_array = new float[terrain.heightmapResolution, terrain.heightmapResolution]; - Ray ray = new Ray( new Vector3( bounds.min.x, bounds.max.y + bounds.size.y, bounds.min.z ), -Vector3.up ); - RaycastHit hit = new RaycastHit(); - float mesh_height_inverse = 1 / bounds.size.y; - Vector3 ray_origin = ray.origin; - int max_height = heights_array.GetLength( 0 ); - int max_length = heights_array.GetLength( 1 ); - Vector2 x_z_step = new Vector2( bounds.size.x / max_length, bounds.size.z / max_height ); + terrain.size = collider.bounds.size + terrain_offset; + bounds.size = new Vector3( terrain.size.x, collider.bounds.size.y, terrain.size.z ); - for( int z_index = 0; z_index < max_height; z_index++ ) - { - ShowProgressBar( z_index, max_height ); + float[,] heights_array = new float[terrain.heightmapResolution, terrain.heightmapResolution]; + Ray ray = new Ray( new Vector3( bounds.min.x, bounds.max.y + bounds.size.y, bounds.min.z ), -Vector3.up ); + RaycastHit hit = new RaycastHit(); + float mesh_height_inverse = 1 / bounds.size.y; + Vector3 ray_origin = ray.origin; + int max_height = heights_array.GetLength( 0 ); + int max_length = heights_array.GetLength( 1 ); + Vector2 x_z_step = new Vector2( bounds.size.x / max_length, bounds.size.z / max_height ); - for( int x_index = 0; x_index < max_length; x_index++ ) + for( int z_index = 0; z_index < max_height; z_index++ ) { - float height = 0.0f; + ShowProgressBar( z_index, max_height ); - if( collider.Raycast( ray, out hit, bounds.size.y * 3.0f ) ) + for( int x_index = 0; x_index < max_length; x_index++ ) { - height = ( hit.point.y - bounds.min.y ) * mesh_height_inverse; - height += height_shift; + float height = 0.0f; - if( radio_selected_index == 0 ) + if( collider.Raycast( ray, out hit, bounds.size.y * 3.0f ) ) { - height *= sizeFactor; + height = ( hit.point.y - bounds.min.y ) * mesh_height_inverse; + height += height_shift; + + if( radio_selected_index == 0 ) + { + height *= sizeFactor; + } + + height = Mathf.Max( 0.0f, height ); } - height = Mathf.Max( 0.0f, height ); + heights_array[z_index, x_index] = height; + ray_origin.x += x_z_step[0]; + ray.origin = ray_origin; } - heights_array[z_index, x_index] = height; - ray_origin.x += x_z_step[0]; + ray_origin.z += x_z_step[1]; + ray_origin.x = bounds.min.x; ray.origin = ray_origin; } - ray_origin.z += x_z_step[1]; - ray_origin.x = bounds.min.x; - ray.origin = ray_origin; - } - - terrain.SetHeights( 0, 0, heights_array ); - - EditorUtility.ClearProgressBar(); + terrain.SetHeights( 0, 0, heights_array ); - cleanUp?.Invoke(); - } + EditorUtility.ClearProgressBar(); - void ShowProgressBar( - float progress, - float maximum_progress - ) - { - float current_progress = progress / maximum_progress; + cleanUp?.Invoke(); + } - EditorUtility.DisplayProgressBar( - "Creating Terrain...", - string.Format( "{0}%", Mathf.RoundToInt( current_progress * 100.0f ) ), - current_progress - ); - } + void ShowProgressBar( + float progress, + float maximum_progress + ) + { + float current_progress = progress / maximum_progress; - // -- UNITY + EditorUtility.DisplayProgressBar( + "Creating Terrain...", + string.Format( "{0}%", Mathf.RoundToInt( current_progress * 100.0f ) ), + current_progress + ); + } - [MenuItem( "FishingCactus/Tools/Object to Terrain", false, 2000 )] - static void OpenWindow() - { - GetWindow( true ); - } + // -- UNITY - void OnGUI() - { - resolution = EditorGUILayout.IntField( "Resolution", resolution ); - terrain_offset = EditorGUILayout.Vector3Field( "Add terrain", terrain_offset ); - height_shift = EditorGUILayout.Slider( "Shift height", height_shift, -1.0f, 1.0f ); - radio_selected_index = GUILayout.SelectionGrid( radio_selected_index, choice_name_table, choice_name_table.Length, EditorStyles.radioButton ); + [MenuItem( "FishingCactus/Tools/Object to Terrain", false, 2000 )] + static void OpenWindow() + { + GetWindow( true ); + } - if( GUILayout.Button( "Create Terrain" ) ) + void OnGUI() { - if( Selection.activeGameObject == null ) - { - EditorUtility.DisplayDialog( "No object selected", "Please select an object.", "Ok" ); + resolution = EditorGUILayout.IntField( "Resolution", resolution ); + terrain_offset = EditorGUILayout.Vector3Field( "Add terrain", terrain_offset ); + height_shift = EditorGUILayout.Slider( "Shift height", height_shift, -1.0f, 1.0f ); + radio_selected_index = GUILayout.SelectionGrid( radio_selected_index, choice_name_table, choice_name_table.Length, EditorStyles.radioButton ); - return; - } - else + if( GUILayout.Button( "Create Terrain" ) ) { - CreateTerrain(); + if( Selection.activeGameObject == null ) + { + EditorUtility.DisplayDialog( "No object selected", "Please select an object.", "Ok" ); + + return; + } + else + { + CreateTerrain(); + } } } } diff --git a/Editor/PropertyDrawer/AnimatorParameterLinkDrawer.cs b/Editor/PropertyDrawer/AnimatorParameterLinkDrawer.cs index 314d0db..61253a3 100644 --- a/Editor/PropertyDrawer/AnimatorParameterLinkDrawer.cs +++ b/Editor/PropertyDrawer/AnimatorParameterLinkDrawer.cs @@ -3,7 +3,7 @@ using UnityEditor.Animations; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( BooleanAnimatorParameterLink ), true )] [CustomPropertyDrawer( typeof( TriggerAnimatorParameterLink ), true )] @@ -45,7 +45,7 @@ AnimatorControllerParameterType type_to_filter public override void OnGUI( Rect position, - SerializedProperty property, + SerializedProperty property, GUIContent label ) { diff --git a/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs index 3898e25..f596fb8 100644 --- a/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs +++ b/Editor/PropertyDrawer/AttributesDrawer/EnumFlagsAttributeDrawer.cs @@ -2,7 +2,7 @@ using UnityEngine; using UnityEditor; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( EnumFlagsAttribute ) )] class EnumFlagsAttributeDrawer : PropertyDrawer diff --git a/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs index 4fa76a9..b13f353 100644 --- a/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs +++ b/Editor/PropertyDrawer/AttributesDrawer/ExposedScriptableObjectAttributeDrawer.cs @@ -1,7 +1,7 @@ using UnityEngine; using UnityEditor; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( ExposedScriptableObjectAttribute ), true )] public class ExposedScriptableObjectAttributeDrawer : PropertyDrawer diff --git a/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs index 2d94502..5544274 100644 --- a/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs +++ b/Editor/PropertyDrawer/AttributesDrawer/MaxDrawer.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer(typeof(MaxAttribute))] public class MaxDrawer : PropertyDrawer diff --git a/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs index c2108e6..4a0f174 100644 --- a/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs +++ b/Editor/PropertyDrawer/AttributesDrawer/ReadOnlyDrawer.cs @@ -1,6 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus + +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( ReadOnlyAttribute ) )] public class ReadOnlyDrawer : PropertyDrawer diff --git a/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs b/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs index 70a13b7..eecfab6 100644 --- a/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs +++ b/Editor/PropertyDrawer/AttributesDrawer/SubClassPickerAttributeDrawer.cs @@ -5,7 +5,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class SubClassPickerAttributeDrawer : MonoBehaviour { diff --git a/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs b/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs index 93878b3..b2c4c64 100644 --- a/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs +++ b/Editor/PropertyDrawer/EnumDictionaryPropertyDrawer.cs @@ -1,97 +1,100 @@ using UnityEngine; using UnityEditor; -[CustomPropertyDrawer(typeof(EnumDictionary<,>),true)] -public class EnumDictionaryPropertyDrawer : PropertyDrawer +namespace FishingCactus.CommonCode { - // -- FIELDS - - private static float IndentationWidth = 12.0f; - - // -- UNITY - - public override void OnGUI( - Rect position, - SerializedProperty property, - GUIContent label - ) + [CustomPropertyDrawer(typeof(EnumDictionary<,>),true)] + public class EnumDictionaryPropertyDrawer : PropertyDrawer { - SerializedProperty type_property = property.FindPropertyRelative("EnumNameTable"); - SerializedProperty values_property = property.FindPropertyRelative("ValueTable"); + // -- FIELDS - Debug.Assert( type_property.arraySize == values_property.arraySize, "EnumDictionary array sizes mismatched." ); + private static float IndentationWidth = 12.0f; - Rect gui_rectangle = new Rect( position ); - gui_rectangle.x += IndentationWidth; - gui_rectangle.width -= IndentationWidth; - gui_rectangle.height = EditorGUIUtility.singleLineHeight; + // -- UNITY - EditorGUI.BeginProperty( gui_rectangle, label, property ); + public override void OnGUI( + Rect position, + SerializedProperty property, + GUIContent label + ) + { + SerializedProperty type_property = property.FindPropertyRelative("EnumNameTable"); + SerializedProperty values_property = property.FindPropertyRelative("ValueTable"); - property.isExpanded = EditorGUI.Foldout( gui_rectangle, property.isExpanded, label, true ); + Debug.Assert( type_property.arraySize == values_property.arraySize, "EnumDictionary array sizes mismatched." ); - if( property.isExpanded ) - { + Rect gui_rectangle = new Rect( position ); gui_rectangle.x += IndentationWidth; gui_rectangle.width -= IndentationWidth; + gui_rectangle.height = EditorGUIUtility.singleLineHeight; - gui_rectangle.y += 18.0f; + EditorGUI.BeginProperty( gui_rectangle, label, property ); - Rect element_rectangle = gui_rectangle; + property.isExpanded = EditorGUI.Foldout( gui_rectangle, property.isExpanded, label, true ); - for( int name_index = 0; name_index < type_property.arraySize; name_index++ ) + if( property.isExpanded ) { - SerializedProperty property_to_draw = values_property.GetArrayElementAtIndex(name_index); + gui_rectangle.x += IndentationWidth; + gui_rectangle.width -= IndentationWidth; - if( property_to_draw.hasChildren ) - { - EditorGUI.PropertyField( gui_rectangle, property_to_draw, new GUIContent( type_property.GetArrayElementAtIndex(name_index).stringValue ), true ); - gui_rectangle.y += EditorGUI.GetPropertyHeight( property_to_draw, GUIContent.none ); - } - else - { - element_rectangle.x = gui_rectangle.x; - element_rectangle.width = gui_rectangle.width; + gui_rectangle.y += 18.0f; - const float label_width_percentage = 0.33f; - element_rectangle.width = gui_rectangle.width * label_width_percentage; - EditorGUI.LabelField(element_rectangle, new GUIContent( type_property.GetArrayElementAtIndex(name_index).stringValue ) ); + Rect element_rectangle = gui_rectangle; - element_rectangle.x += element_rectangle.width; - element_rectangle.width = gui_rectangle.width * ( 1.0f - label_width_percentage ); - EditorGUI.PropertyField( element_rectangle, property_to_draw, GUIContent.none ); - element_rectangle.y += EditorGUI.GetPropertyHeight( property_to_draw, GUIContent.none ); + for( int name_index = 0; name_index < type_property.arraySize; name_index++ ) + { + SerializedProperty property_to_draw = values_property.GetArrayElementAtIndex(name_index); + + if( property_to_draw.hasChildren ) + { + EditorGUI.PropertyField( gui_rectangle, property_to_draw, new GUIContent( type_property.GetArrayElementAtIndex(name_index).stringValue ), true ); + gui_rectangle.y += EditorGUI.GetPropertyHeight( property_to_draw, GUIContent.none ); + } + else + { + element_rectangle.x = gui_rectangle.x; + element_rectangle.width = gui_rectangle.width; + + const float label_width_percentage = 0.33f; + element_rectangle.width = gui_rectangle.width * label_width_percentage; + EditorGUI.LabelField(element_rectangle, new GUIContent( type_property.GetArrayElementAtIndex(name_index).stringValue ) ); + + element_rectangle.x += element_rectangle.width; + element_rectangle.width = gui_rectangle.width * ( 1.0f - label_width_percentage ); + EditorGUI.PropertyField( element_rectangle, property_to_draw, GUIContent.none ); + element_rectangle.y += EditorGUI.GetPropertyHeight( property_to_draw, GUIContent.none ); + } } - } - gui_rectangle.x -= IndentationWidth; - gui_rectangle.width += IndentationWidth; - } - - EditorGUI.EndProperty(); + gui_rectangle.x -= IndentationWidth; + gui_rectangle.width += IndentationWidth; + } - property.serializedObject.ApplyModifiedProperties(); - } + EditorGUI.EndProperty(); - public override float GetPropertyHeight( - SerializedProperty property, - GUIContent label - ) - { - float height_to_use = 18.0f; + property.serializedObject.ApplyModifiedProperties(); + } - if (property.isExpanded) + public override float GetPropertyHeight( + SerializedProperty property, + GUIContent label + ) { - SerializedProperty list_property = property.FindPropertyRelative("ValueTable"); + float height_to_use = 18.0f; - foreach( SerializedProperty element_property in list_property ) + if (property.isExpanded) { - height_to_use += EditorGUI.GetPropertyHeight(element_property, GUIContent.none); + SerializedProperty list_property = property.FindPropertyRelative("ValueTable"); + + foreach( SerializedProperty element_property in list_property ) + { + height_to_use += EditorGUI.GetPropertyHeight(element_property, GUIContent.none); + } } - } - height_to_use += 4.0f; + height_to_use += 4.0f; - return height_to_use; + return height_to_use; + } } } diff --git a/Editor/PropertyDrawer/OptionalDrawer.cs b/Editor/PropertyDrawer/OptionalDrawer.cs index fcbe32d..298b901 100644 --- a/Editor/PropertyDrawer/OptionalDrawer.cs +++ b/Editor/PropertyDrawer/OptionalDrawer.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( Optional<> ) )] public sealed class OptionalDrawer : PropertyDrawer diff --git a/Editor/PropertyDrawer/RangeDrawer.cs b/Editor/PropertyDrawer/RangeDrawer.cs index f4f5068..8ea3187 100644 --- a/Editor/PropertyDrawer/RangeDrawer.cs +++ b/Editor/PropertyDrawer/RangeDrawer.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer(typeof(IntegerRange), true)] [CustomPropertyDrawer(typeof(FloatRange), true)] diff --git a/Editor/PropertyDrawer/TagLinkDrawer.cs b/Editor/PropertyDrawer/TagLinkDrawer.cs index 3799e83..9a29d36 100644 --- a/Editor/PropertyDrawer/TagLinkDrawer.cs +++ b/Editor/PropertyDrawer/TagLinkDrawer.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [CustomPropertyDrawer( typeof( TagLink ), true )] public class TagLinkDrawer : PropertyDrawer diff --git a/Editor/ScriptableObjectCreator.cs b/Editor/ScriptableObjectCreator.cs index 7e34c50..79cd3a7 100644 --- a/Editor/ScriptableObjectCreator.cs +++ b/Editor/ScriptableObjectCreator.cs @@ -2,7 +2,7 @@ using UnityEditor; using System.IO; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ScriptableObjectCreator { diff --git a/Editor/Utilities/EditorUtils.cs b/Editor/Utilities/EditorUtils.cs index 1f9baff..3b7f774 100644 --- a/Editor/Utilities/EditorUtils.cs +++ b/Editor/Utilities/EditorUtils.cs @@ -2,7 +2,7 @@ using UnityEditor; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class EditorUtils { diff --git a/Editor/Utilities/HierarchyUtils.cs b/Editor/Utilities/HierarchyUtils.cs index 391f5ec..e13396b 100644 --- a/Editor/Utilities/HierarchyUtils.cs +++ b/Editor/Utilities/HierarchyUtils.cs @@ -2,7 +2,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class HierarchyUtils { diff --git a/Editor/Utilities/InspectorUtils.cs b/Editor/Utilities/InspectorUtils.cs index 4c49c30..3e7715f 100644 --- a/Editor/Utilities/InspectorUtils.cs +++ b/Editor/Utilities/InspectorUtils.cs @@ -3,75 +3,78 @@ using System.Reflection; using UnityEditor; -public static class InspectorUtils +namespace FishingCactus.CommonCode { - public static bool TryGetArrayOrListElementType( - Type list_type, - out Type element_type - ) + public static class InspectorUtils { - if( list_type.IsArray ) - { - element_type = list_type.GetElementType(); - - return true; - } - - if( list_type.IsGenericType - && list_type.GetGenericTypeDefinition() == typeof( List<> ) + public static bool TryGetArrayOrListElementType( + Type list_type, + out Type element_type ) { - element_type = list_type.GetGenericArguments()[ 0 ]; + if( list_type.IsArray ) + { + element_type = list_type.GetElementType(); - return true; - } + return true; + } - element_type = null; + if( list_type.IsGenericType + && list_type.GetGenericTypeDefinition() == typeof( List<> ) + ) + { + element_type = list_type.GetGenericArguments()[ 0 ]; - return false; - } + return true; + } - public static Type GetPropertyType( - SerializedProperty property - ) - { - Type parent_type = property.serializedObject.targetObject.GetType(); - Type property_type = parent_type; - string[] parts = property.propertyPath.Split( '.' ); + element_type = null; - for( int part_index = 0; part_index < parts.Length; part_index++ ) + return false; + } + + public static Type GetPropertyType( + SerializedProperty property + ) { - string member = parts[ part_index ]; + Type parent_type = property.serializedObject.targetObject.GetType(); + Type property_type = parent_type; + string[] parts = property.propertyPath.Split( '.' ); - if( part_index < parts.Length - 1 - && member == "Array" && parts[ part_index + 1 ].StartsWith( "data[" ) - ) + for( int part_index = 0; part_index < parts.Length; part_index++ ) { - if( TryGetArrayOrListElementType( property_type, out Type element_type ) ) + string member = parts[ part_index ]; + + if( part_index < parts.Length - 1 + && member == "Array" && parts[ part_index + 1 ].StartsWith( "data[" ) + ) { - property_type = element_type; - } + if( TryGetArrayOrListElementType( property_type, out Type element_type ) ) + { + property_type = element_type; + } - part_index++; + part_index++; - continue; - } + continue; + } - FieldInfo found_field = null; + FieldInfo found_field = null; - for( Type current_type = property_type; found_field == null && current_type != null; current_type = current_type.BaseType ) - { - found_field = current_type.GetField( member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic ); - } + for( Type current_type = property_type; found_field == null && current_type != null; current_type = current_type.BaseType ) + { + found_field = current_type.GetField( member, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic ); + } - if( found_field == null ) - { - return null; + if( found_field == null ) + { + return null; + } + + property_type = found_field.FieldType; } - property_type = found_field.FieldType; + return property_type; } - - return property_type; } } diff --git a/Editor/Utilities/WizzardUtils.cs b/Editor/Utilities/WizzardUtils.cs index 9a439a7..60bf9e8 100644 --- a/Editor/Utilities/WizzardUtils.cs +++ b/Editor/Utilities/WizzardUtils.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus.UnityCommonCode +namespace FishingCactus.CommonCode { public static class WizzardUtils { diff --git a/Runtime/Animator/AnimatorLayerController.cs b/Runtime/Animator/AnimatorLayerController.cs index 1d8923c..834829b 100644 --- a/Runtime/Animator/AnimatorLayerController.cs +++ b/Runtime/Animator/AnimatorLayerController.cs @@ -1,130 +1,133 @@ using UnityEngine; -[System.Serializable] -public class AnimatorLayerController +namespace FishingCactus.CommonCode { - // -- PUBLIC - - public enum State + [System.Serializable] + public class AnimatorLayerController { - Disabled = 0, - Enabling, - Enabled, - Disabling - } + // -- PUBLIC + + public enum State + { + Disabled = 0, + Enabling, + Enabled, + Disabling + } - public int LayerIndex { get; private set; } - public string LayerName { get { return _LayerName; } } - - public bool CanBeEnabled { get { return InternalState == State.Disabled || InternalState == State.Disabling; } } - public bool CanBeDisabled { get { return InternalState == State.Enabled || InternalState == State.Enabling; } } + public int LayerIndex { get; private set; } + public string LayerName { get { return _LayerName; } } - public void Setup( - Animator linked_animator - ) - { - LinkedAnimator = linked_animator; + public bool CanBeEnabled { get { return InternalState == State.Disabled || InternalState == State.Disabling; } } + public bool CanBeDisabled { get { return InternalState == State.Enabled || InternalState == State.Enabling; } } - LayerIndex = LinkedAnimator.GetLayerIndex( _LayerName ); - Debug.Assert( LayerIndex != -1, $"No layer '{_LayerName}' found in '{linked_animator.name}'." ); + public void Setup( + Animator linked_animator + ) + { + LinkedAnimator = linked_animator; - LayerWeight = 0.0f; - LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); + LayerIndex = LinkedAnimator.GetLayerIndex( _LayerName ); + Debug.Assert( LayerIndex != -1, $"No layer '{_LayerName}' found in '{linked_animator.name}'." ); - InternalState = State.Disabled; - } + LayerWeight = 0.0f; + LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); - public void Enable() - { - if( CanBeEnabled ) + InternalState = State.Disabled; + } + + public void Enable() { - if( EnablingSpeed == 0.0f ) + if( CanBeEnabled ) { - LayerWeight = 1.0f; - LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); - InternalState = State.Enabled; - } - else - { - InternalState = State.Enabling; + if( EnablingSpeed == 0.0f ) + { + LayerWeight = 1.0f; + LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); + InternalState = State.Enabled; + } + else + { + InternalState = State.Enabling; + } } } - } - public void Disable() - { - if( CanBeDisabled ) + public void Disable() { - if( DisablingSpeed == 0.0f ) - { - LayerWeight = 0.0f; - LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); - InternalState = State.Disabled; - } - else + if( CanBeDisabled ) { - InternalState = State.Disabling; + if( DisablingSpeed == 0.0f ) + { + LayerWeight = 0.0f; + LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); + InternalState = State.Disabled; + } + else + { + InternalState = State.Disabling; + } } } - } - public bool UpdateWeight( - float delta_time - ) - { - if( InternalState == State.Disabled - || InternalState == State.Enabled + public bool UpdateWeight( + float delta_time ) { - return true; - } - - switch( InternalState ) - { - case State.Enabling: + if( InternalState == State.Disabled + || InternalState == State.Enabled + ) { - LayerWeight = Mathf.Min( 1.0f, LayerWeight + EnablingSpeed * delta_time ); - LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); + return true; + } - if( LayerWeight >= 1.0f ) + switch( InternalState ) + { + case State.Enabling: { - InternalState = State.Enabled; + LayerWeight = Mathf.Min( 1.0f, LayerWeight + EnablingSpeed * delta_time ); + LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); - return true; - } - } - break; + if( LayerWeight >= 1.0f ) + { + InternalState = State.Enabled; - case State.Disabling: - { - LayerWeight = Mathf.Max( 0.0f, LayerWeight - DisablingSpeed * delta_time ); - LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); + return true; + } + } + break; - if( LayerWeight <= 0.0f ) + case State.Disabling: { - InternalState = State.Disabled; + LayerWeight = Mathf.Max( 0.0f, LayerWeight - DisablingSpeed * delta_time ); + LinkedAnimator.SetLayerWeight( LayerIndex, LayerWeight ); - return true; + if( LayerWeight <= 0.0f ) + { + InternalState = State.Disabled; + + return true; + } } + break; } - break; - } - return false; - } + return false; + } - // -- PRIVATE + // -- PRIVATE - #pragma warning disable 0649 - [SerializeField] - private string _LayerName; - #pragma warning restore - [SerializeField] - private float EnablingSpeed = 1.0f; - [SerializeField] - private float DisablingSpeed = 1.0f; + #pragma warning disable 0649 + [SerializeField] + private string _LayerName; + #pragma warning restore + [SerializeField] + private float EnablingSpeed = 1.0f; + [SerializeField] + private float DisablingSpeed = 1.0f; - private Animator LinkedAnimator; - private State InternalState; - private float LayerWeight; + private Animator LinkedAnimator; + private State InternalState; + private float LayerWeight; + } } diff --git a/Runtime/Animator/AnimatorParameterLink.cs b/Runtime/Animator/AnimatorParameterLink.cs index c1a5755..b251216 100644 --- a/Runtime/Animator/AnimatorParameterLink.cs +++ b/Runtime/Animator/AnimatorParameterLink.cs @@ -1,7 +1,7 @@ using UnityEngine; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { [System.Serializable] public abstract class AnimatorParameterLink diff --git a/Runtime/Attributes/EnumFlagsAttribute.cs b/Runtime/Attributes/EnumFlagsAttribute.cs index 6fbc39f..0cddf0c 100644 --- a/Runtime/Attributes/EnumFlagsAttribute.cs +++ b/Runtime/Attributes/EnumFlagsAttribute.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class EnumFlagsAttribute : PropertyAttribute { diff --git a/Runtime/Attributes/ExposedScriptableObjectAttribute.cs b/Runtime/Attributes/ExposedScriptableObjectAttribute.cs index 7d4bce0..9445d64 100644 --- a/Runtime/Attributes/ExposedScriptableObjectAttribute.cs +++ b/Runtime/Attributes/ExposedScriptableObjectAttribute.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class ExposedScriptableObjectAttribute : PropertyAttribute { diff --git a/Runtime/Attributes/MaxAttribute.cs b/Runtime/Attributes/MaxAttribute.cs index ad00ba1..17667e0 100644 --- a/Runtime/Attributes/MaxAttribute.cs +++ b/Runtime/Attributes/MaxAttribute.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public sealed class MaxAttribute : PropertyAttribute { diff --git a/Runtime/Attributes/ReadOnlyAttribute.cs b/Runtime/Attributes/ReadOnlyAttribute.cs index 3c90520..dd31686 100644 --- a/Runtime/Attributes/ReadOnlyAttribute.cs +++ b/Runtime/Attributes/ReadOnlyAttribute.cs @@ -1,5 +1,6 @@ using UnityEngine; -namespace FishingCactus + +namespace FishingCactus.CommonCode { public class ReadOnlyAttribute : PropertyAttribute { } } \ No newline at end of file diff --git a/Runtime/Attributes/SubClassPickerAttribute.cs b/Runtime/Attributes/SubClassPickerAttribute.cs index d15bc90..ddcb24e 100644 --- a/Runtime/Attributes/SubClassPickerAttribute.cs +++ b/Runtime/Attributes/SubClassPickerAttribute.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class SubClassPicker : PropertyAttribute { } } \ No newline at end of file diff --git a/Runtime/Coroutines/CoroutineHelper.cs b/Runtime/Coroutines/CoroutineHelper.cs index 6185d8c..5e2925f 100644 --- a/Runtime/Coroutines/CoroutineHelper.cs +++ b/Runtime/Coroutines/CoroutineHelper.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class CoroutineHelper : MonoBehaviour { diff --git a/Runtime/Coroutines/ManualReturnRoutine.cs b/Runtime/Coroutines/ManualReturnRoutine.cs index 1cdbe4c..262d138 100644 --- a/Runtime/Coroutines/ManualReturnRoutine.cs +++ b/Runtime/Coroutines/ManualReturnRoutine.cs @@ -1,4 +1,4 @@ -namespace FishingCactus +namespace FishingCactus.CommonCode { public class ManualReturnRoutine : Routine { diff --git a/Runtime/Coroutines/ParallelizedMultiRoutines.cs b/Runtime/Coroutines/ParallelizedMultiRoutines.cs index 20f6c28..8383dbe 100644 --- a/Runtime/Coroutines/ParallelizedMultiRoutines.cs +++ b/Runtime/Coroutines/ParallelizedMultiRoutines.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class ParallelizedMultiRoutines : Routine { diff --git a/Runtime/Coroutines/ResultCompletionEventArgs.cs b/Runtime/Coroutines/ResultCompletionEventArgs.cs index ace8503..ae1e89a 100644 --- a/Runtime/Coroutines/ResultCompletionEventArgs.cs +++ b/Runtime/Coroutines/ResultCompletionEventArgs.cs @@ -1,7 +1,7 @@ using UnityEngine; using System; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class ResultCompletionEventArgs : EventArgs { diff --git a/Runtime/Coroutines/Routine.cs b/Runtime/Coroutines/Routine.cs index 6060974..d48b8d7 100644 --- a/Runtime/Coroutines/Routine.cs +++ b/Runtime/Coroutines/Routine.cs @@ -1,6 +1,6 @@ using System; -namespace FishingCactus +namespace FishingCactus.CommonCode { public abstract class Routine : IDisposable { diff --git a/Runtime/Coroutines/SequentialRoutine.cs b/Runtime/Coroutines/SequentialRoutine.cs index dca9d7e..a8ed402 100644 --- a/Runtime/Coroutines/SequentialRoutine.cs +++ b/Runtime/Coroutines/SequentialRoutine.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class SequentialRoutine : Routine { diff --git a/Runtime/DebugTimeScaler.cs b/Runtime/DebugTimeScaler.cs index b30754c..7d6d526 100644 --- a/Runtime/DebugTimeScaler.cs +++ b/Runtime/DebugTimeScaler.cs @@ -1,26 +1,29 @@ using UnityEngine; -public class DebugTimeScaler : MonoBehaviour +namespace FishingCactus.CommonCode { - // -- PUBLIC + public class DebugTimeScaler : MonoBehaviour + { + // -- PUBLIC - [Range(0.01f, 10.0f)] - public float TimeScale = 1.0f; + [Range(0.01f, 10.0f)] + public float TimeScale = 1.0f; - // -- PRIVATE + // -- PRIVATE - private float InitialFixedDeltaTime; + private float InitialFixedDeltaTime; - // -- UNITY + // -- UNITY - void Awake() - { - InitialFixedDeltaTime = Time.fixedDeltaTime; - } + void Awake() + { + InitialFixedDeltaTime = Time.fixedDeltaTime; + } - void LateUpdate() - { - Time.timeScale = TimeScale; - Time.fixedDeltaTime = InitialFixedDeltaTime * TimeScale; + void LateUpdate() + { + Time.timeScale = TimeScale; + Time.fixedDeltaTime = InitialFixedDeltaTime * TimeScale; + } } } diff --git a/Runtime/EnumDictionary.cs b/Runtime/EnumDictionary.cs index 34e52e7..045f2d7 100644 --- a/Runtime/EnumDictionary.cs +++ b/Runtime/EnumDictionary.cs @@ -1,68 +1,71 @@ using UnityEngine; using System.Collections.Generic; -[System.Serializable] -public class EnumDictionary where TEnum : struct, - System.IConvertible +namespace FishingCactus.CommonCode { - // -- FIELDS + [System.Serializable] + public class EnumDictionary where TEnum : struct, + System.IConvertible + { + // -- FIELDS - [SerializeField] private TObject[] ValueTable; - [SerializeField] public List EnumNameTable; + [SerializeField] private TObject[] ValueTable; + [SerializeField] public List EnumNameTable; - // -- PROPERTIES + // -- PROPERTIES - public int Count{ get{ return ValueTable.Length; } } - public TObject[] Values{ get{ return ValueTable; } } + public int Count{ get{ return ValueTable.Length; } } + public TObject[] Values{ get{ return ValueTable; } } - // -- METHODS + // -- METHODS - public EnumDictionary() - { - ResetTables(); - } - - public TObject this[ TEnum enum_value ] - { - get + public EnumDictionary() { - return ValueTable[ EnumNameTable.IndexOf( enum_value.ToString() ) ]; + ResetTables(); } - set + + public TObject this[ TEnum enum_value ] { - ValueTable[EnumNameTable.IndexOf( enum_value.ToString() )] = value; + get + { + return ValueTable[ EnumNameTable.IndexOf( enum_value.ToString() ) ]; + } + set + { + ValueTable[EnumNameTable.IndexOf( enum_value.ToString() )] = value; + } } - } - - private void ResetTables() - { - EnumNameTable = new List(); - EnumNameTable.AddRange( System.Enum.GetNames( typeof( TEnum ) ) ); - EnumNameTable.Remove( "Count" ); - EnumNameTable.Remove( "None" ); - - ValueTable = new TObject[EnumNameTable.Count]; - } + private void ResetTables() + { + EnumNameTable = new List(); + EnumNameTable.AddRange( System.Enum.GetNames( typeof( TEnum ) ) ); -#if UNITY_EDITOR - public void CheckEnumSizeChange() - { - TObject[] backup_value_array = ValueTable; - List backup_enum_name_table = EnumNameTable; + EnumNameTable.Remove( "Count" ); + EnumNameTable.Remove( "None" ); - ResetTables(); + ValueTable = new TObject[EnumNameTable.Count]; + } - foreach( string enum_name in EnumNameTable ) + #if UNITY_EDITOR + public void CheckEnumSizeChange() { - int - backup_element_index = backup_enum_name_table.IndexOf( enum_name ); + TObject[] backup_value_array = ValueTable; + List backup_enum_name_table = EnumNameTable; - if( backup_element_index != -1 ) + ResetTables(); + + foreach( string enum_name in EnumNameTable ) { - ValueTable[ EnumNameTable.IndexOf( enum_name ) ] = backup_value_array[backup_element_index]; + int + backup_element_index = backup_enum_name_table.IndexOf( enum_name ); + + if( backup_element_index != -1 ) + { + ValueTable[ EnumNameTable.IndexOf( enum_name ) ] = backup_value_array[backup_element_index]; + } } } + #endif } -#endif } diff --git a/Runtime/Extensions/AnimationCurveExtensions.cs b/Runtime/Extensions/AnimationCurveExtensions.cs index 3724867..7437b04 100644 --- a/Runtime/Extensions/AnimationCurveExtensions.cs +++ b/Runtime/Extensions/AnimationCurveExtensions.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class AnimationCurveExtensions { diff --git a/Runtime/Extensions/AnimatorExtensions.cs b/Runtime/Extensions/AnimatorExtensions.cs index 27c19cc..98d623b 100644 --- a/Runtime/Extensions/AnimatorExtensions.cs +++ b/Runtime/Extensions/AnimatorExtensions.cs @@ -4,7 +4,7 @@ using UnityEditor.Animations; #endif -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class AnimatorExtensions { diff --git a/Runtime/Extensions/CollectionsExtensions.cs b/Runtime/Extensions/CollectionsExtensions.cs index 2d8b105..5747dc6 100644 --- a/Runtime/Extensions/CollectionsExtensions.cs +++ b/Runtime/Extensions/CollectionsExtensions.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class CollectionsExtensions { diff --git a/Runtime/Extensions/GameObjectExtensions.cs b/Runtime/Extensions/GameObjectExtensions.cs index 4d2d531..934eced 100644 --- a/Runtime/Extensions/GameObjectExtensions.cs +++ b/Runtime/Extensions/GameObjectExtensions.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class GameObjectExtensions { diff --git a/Runtime/Extensions/IComparableExtensions.cs b/Runtime/Extensions/IComparableExtensions.cs index ceaf1f2..4c05cb3 100644 --- a/Runtime/Extensions/IComparableExtensions.cs +++ b/Runtime/Extensions/IComparableExtensions.cs @@ -1,6 +1,6 @@ using System; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class IComparableExtensions { diff --git a/Runtime/Extensions/ListExtensions.cs b/Runtime/Extensions/ListExtensions.cs index 5629175..4920d2d 100644 --- a/Runtime/Extensions/ListExtensions.cs +++ b/Runtime/Extensions/ListExtensions.cs @@ -1,7 +1,7 @@ using UnityEngine; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ListExtensions { diff --git a/Runtime/Extensions/MonoBehaviourExtensions.cs b/Runtime/Extensions/MonoBehaviourExtensions.cs index 7473380..ba5a25d 100644 --- a/Runtime/Extensions/MonoBehaviourExtensions.cs +++ b/Runtime/Extensions/MonoBehaviourExtensions.cs @@ -1,7 +1,7 @@ using System; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class MonoBehaviourExtensions { diff --git a/Runtime/Extensions/StringExtensions.cs b/Runtime/Extensions/StringExtensions.cs index 2d95638..0e616d3 100644 --- a/Runtime/Extensions/StringExtensions.cs +++ b/Runtime/Extensions/StringExtensions.cs @@ -1,64 +1,67 @@ using System; -public static class StringExtensions +namespace FishingCactus.CommonCode { - public static int CountOccurence( this string main, string pattern ) + public static class StringExtensions { - int count = 0; - int previous_index = 0; - - if( !string.IsNullOrEmpty( pattern ) ) + public static int CountOccurence( this string main, string pattern ) { - while( ( previous_index = main.IndexOf( pattern, previous_index ) ) != -1 ) + int count = 0; + int previous_index = 0; + + if( !string.IsNullOrEmpty( pattern ) ) { - ++previous_index; - ++count; + while( ( previous_index = main.IndexOf( pattern, previous_index ) ) != -1 ) + { + ++previous_index; + ++count; + } } - } - - return count; - } - public static string Capitalize( this string str ) - { - if( string.IsNullOrEmpty( str ) ) - { - return null; + return count; } - if( str.Length > 1 ) + public static string Capitalize( this string str ) { - return char.ToUpper( str[ 0 ] ) + str.Substring( 1 ); - } + if( string.IsNullOrEmpty( str ) ) + { + return null; + } - return str.ToUpper(); - } + if( str.Length > 1 ) + { + return char.ToUpper( str[ 0 ] ) + str.Substring( 1 ); + } - public static string SafeFormat( this string format, params object[] args ) - { - if( !string.IsNullOrEmpty( format ) ) - { - return string.Format( format, args ); + return str.ToUpper(); } - string result = string.Empty; - bool first_arg = true; - - foreach( var arg in args ) + public static string SafeFormat( this string format, params object[] args ) { - if( !first_arg ) + if( !string.IsNullOrEmpty( format ) ) { - result += " - "; + return string.Format( format, args ); } - if( arg != null ) + string result = string.Empty; + bool first_arg = true; + + foreach( var arg in args ) { - result += arg.ToString(); + if( !first_arg ) + { + result += " - "; + } + + if( arg != null ) + { + result += arg.ToString(); + } + + first_arg = false; } - first_arg = false; + return result; } - - return result; } } diff --git a/Runtime/Extensions/TransformExtensions.cs b/Runtime/Extensions/TransformExtensions.cs index 38cbb9e..e0482a5 100644 --- a/Runtime/Extensions/TransformExtensions.cs +++ b/Runtime/Extensions/TransformExtensions.cs @@ -1,7 +1,7 @@ using System.Linq; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class TransformExtensions { diff --git a/Runtime/Extensions/ULongExtensions.cs b/Runtime/Extensions/ULongExtensions.cs index f46a21c..8ceb6df 100644 --- a/Runtime/Extensions/ULongExtensions.cs +++ b/Runtime/Extensions/ULongExtensions.cs @@ -1,4 +1,4 @@ -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ULongExtensions { diff --git a/Runtime/Extensions/Vector3Extensions.cs b/Runtime/Extensions/Vector3Extensions.cs index bff068e..e3a6071 100644 --- a/Runtime/Extensions/Vector3Extensions.cs +++ b/Runtime/Extensions/Vector3Extensions.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class Vector3Extensions { diff --git a/Runtime/FPSCounter.cs b/Runtime/FPSCounter.cs index 35b032b..6704ac3 100644 --- a/Runtime/FPSCounter.cs +++ b/Runtime/FPSCounter.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class FPSCounter : MonoBehaviour { diff --git a/Runtime/GUIConsole.cs b/Runtime/GUIConsole.cs index 3ae39c1..5a0366d 100644 --- a/Runtime/GUIConsole.cs +++ b/Runtime/GUIConsole.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class GUIConsole : MonoBehaviour { diff --git a/Runtime/GyroscopeHelper.cs b/Runtime/GyroscopeHelper.cs index bbb076c..9e563bb 100644 --- a/Runtime/GyroscopeHelper.cs +++ b/Runtime/GyroscopeHelper.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class GyroscopeHelper { diff --git a/Runtime/NetworkStatusChecker.cs b/Runtime/NetworkStatusChecker.cs index 69506a9..6c0370a 100644 --- a/Runtime/NetworkStatusChecker.cs +++ b/Runtime/NetworkStatusChecker.cs @@ -3,7 +3,7 @@ using System.Net.Http; using System.Threading.Tasks; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class NetworkStatusChecker { diff --git a/Runtime/Optional.cs b/Runtime/Optional.cs index 4dc38e9..71c6434 100644 --- a/Runtime/Optional.cs +++ b/Runtime/Optional.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [System.Serializable] public struct Optional diff --git a/Runtime/Range.cs b/Runtime/Range.cs index 6ff5805..5c56ed9 100644 --- a/Runtime/Range.cs +++ b/Runtime/Range.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [System.Serializable] public abstract class Range< T > @@ -76,7 +76,7 @@ public class FloatRange : Range // -- METHODS - public FloatRange( + public FloatRange( float minimum_value, float maximum_value ) @@ -109,7 +109,7 @@ public class Vector3Range : Range // -- METHODS - public Vector3Range( + public Vector3Range( Vector3 minimum_value, Vector3 maximum_value ) diff --git a/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs b/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs index 45494f5..c7e9523 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlyDictionary.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlyDictionary : IReadOnlyDictionary { diff --git a/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs b/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs index 5878b55..47c4e4d 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlyHashSet.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlyHashSet : IReadOnlyCollection { diff --git a/Runtime/ReadOnlyCollections/ReadOnlyList.cs b/Runtime/ReadOnlyCollections/ReadOnlyList.cs index 444ba04..a223f1d 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlyList.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlyList.cs @@ -2,7 +2,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlyList : IReadOnlyList { diff --git a/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs b/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs index 17f8e4e..67ab8c3 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlyQueue.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlyQueue : IReadOnlyCollection { diff --git a/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs b/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs index ffa5a3e..4a68c66 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlySerializableDictionary.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlySerializableDictionary : IReadOnlyDictionary { diff --git a/Runtime/ReadOnlyCollections/ReadOnlyStack.cs b/Runtime/ReadOnlyCollections/ReadOnlyStack.cs index a9e4842..5f5a41d 100644 --- a/Runtime/ReadOnlyCollections/ReadOnlyStack.cs +++ b/Runtime/ReadOnlyCollections/ReadOnlyStack.cs @@ -1,7 +1,7 @@ using System.Collections; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public readonly struct ReadOnlyStack : IReadOnlyCollection { diff --git a/Runtime/SerializableDictionary.cs b/Runtime/SerializableDictionary.cs index 0afad44..df5924f 100644 --- a/Runtime/SerializableDictionary.cs +++ b/Runtime/SerializableDictionary.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class SerializableDictionary { diff --git a/Runtime/Singleton.cs b/Runtime/Singleton.cs index 9196482..9bd45b6 100644 --- a/Runtime/Singleton.cs +++ b/Runtime/Singleton.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class Singleton<_INSTANCE_> : MonoBehaviour where _INSTANCE_ : Singleton<_INSTANCE_> diff --git a/Runtime/TagLink.cs b/Runtime/TagLink.cs index d9d25e3..06d5588 100644 --- a/Runtime/TagLink.cs +++ b/Runtime/TagLink.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { [System.Serializable] public class TagLink diff --git a/Runtime/TimeScaleManager.cs b/Runtime/TimeScaleManager.cs index a366e6f..62cf2fd 100644 --- a/Runtime/TimeScaleManager.cs +++ b/Runtime/TimeScaleManager.cs @@ -1,58 +1,61 @@ using System; using UnityEngine; -public class TimeScaleManager : MonoBehaviour +namespace FishingCactus.CommonCode { - public static TimeScaleManager Instance { get; private set; } - - void Awake() - { - Instance = this; - - enabled = false; - } - - void Update() + public class TimeScaleManager : MonoBehaviour { - var delta_time = Time.realtimeSinceStartup - timeScaleLerpLastTime; - timeScaleLerpLastTime = Time.realtimeSinceStartup; - Time.timeScale = Mathf.MoveTowards( Time.timeScale, targetTimeScale, delta_time * lerpSpeed ); + public static TimeScaleManager Instance { get; private set; } - if ( Time.timeScale == targetTimeScale ) + void Awake() { - RunCallback(); + Instance = this; enabled = false; } - } - public void LerpTimeScale( float target_timescale, float lerp_speed, Action callback ) - { - if ( lerp_speed <= 0.0f ) + void Update() { - Time.timeScale = target_timescale; - RunCallback(); - return; - } + var delta_time = Time.realtimeSinceStartup - timeScaleLerpLastTime; + timeScaleLerpLastTime = Time.realtimeSinceStartup; + Time.timeScale = Mathf.MoveTowards( Time.timeScale, targetTimeScale, delta_time * lerpSpeed ); - timeScaleLerpLastTime = Time.realtimeSinceStartup; - targetTimeScale = target_timescale; - lerpSpeed = lerp_speed; - this.callback = callback; + if ( Time.timeScale == targetTimeScale ) + { + RunCallback(); - enabled = true; - } + enabled = false; + } + } - private void RunCallback() - { - if ( callback != null ) + public void LerpTimeScale( float target_timescale, float lerp_speed, Action callback ) { - callback(); + if ( lerp_speed <= 0.0f ) + { + Time.timeScale = target_timescale; + RunCallback(); + return; + } + + timeScaleLerpLastTime = Time.realtimeSinceStartup; + targetTimeScale = target_timescale; + lerpSpeed = lerp_speed; + this.callback = callback; + + enabled = true; } - } - private float timeScaleLerpLastTime; - private float targetTimeScale; - private float lerpSpeed; - private Action callback; + private void RunCallback() + { + if ( callback != null ) + { + callback(); + } + } + + private float timeScaleLerpLastTime; + private float targetTimeScale; + private float lerpSpeed; + private Action callback; + } } diff --git a/Runtime/UI/Wizard.cs b/Runtime/UI/Wizard.cs index bd94ad7..4a43a4a 100644 --- a/Runtime/UI/Wizard.cs +++ b/Runtime/UI/Wizard.cs @@ -2,7 +2,7 @@ using UnityEngine.UI; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public abstract class Wizard : MonoBehaviour { diff --git a/Runtime/UI/WizardPanel.cs b/Runtime/UI/WizardPanel.cs index 7f2e10d..defe7ff 100644 --- a/Runtime/UI/WizardPanel.cs +++ b/Runtime/UI/WizardPanel.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public class WizardPanel : MonoBehaviour { diff --git a/Runtime/Utilities/ArgumentUtils.cs b/Runtime/Utilities/ArgumentUtils.cs index 1668bc6..5f37be6 100644 --- a/Runtime/Utilities/ArgumentUtils.cs +++ b/Runtime/Utilities/ArgumentUtils.cs @@ -1,6 +1,6 @@ using System; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ArgumentUtils { diff --git a/Runtime/Utilities/Contracts/IEnableable.cs b/Runtime/Utilities/Contracts/IEnableable.cs index c1f5b52..5a37d0a 100644 --- a/Runtime/Utilities/Contracts/IEnableable.cs +++ b/Runtime/Utilities/Contracts/IEnableable.cs @@ -1,4 +1,4 @@ -namespace FishingCactus +namespace FishingCactus.CommonCode { public interface IEnableable { diff --git a/Runtime/Utilities/EnumUtils.cs b/Runtime/Utilities/EnumUtils.cs index f143391..b18ad1c 100644 --- a/Runtime/Utilities/EnumUtils.cs +++ b/Runtime/Utilities/EnumUtils.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class EnumUtils { diff --git a/Runtime/Utilities/MathUtils.cs b/Runtime/Utilities/MathUtils.cs index ddf22d4..b2589dd 100644 --- a/Runtime/Utilities/MathUtils.cs +++ b/Runtime/Utilities/MathUtils.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class MathUtils { diff --git a/Runtime/Utilities/ReflectionUtils.cs b/Runtime/Utilities/ReflectionUtils.cs index 7658de2..708c0e9 100644 --- a/Runtime/Utilities/ReflectionUtils.cs +++ b/Runtime/Utilities/ReflectionUtils.cs @@ -4,7 +4,7 @@ using System.Reflection; using UnityEngine; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ReflectionUtils { diff --git a/Runtime/Utilities/ThrowUtils.cs b/Runtime/Utilities/ThrowUtils.cs index d534d4f..77a0a96 100644 --- a/Runtime/Utilities/ThrowUtils.cs +++ b/Runtime/Utilities/ThrowUtils.cs @@ -1,6 +1,6 @@ using System; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class ThrowUtils { diff --git a/Runtime/Utilities/TimeUtils.cs b/Runtime/Utilities/TimeUtils.cs index efc2e33..9c19a24 100644 --- a/Runtime/Utilities/TimeUtils.cs +++ b/Runtime/Utilities/TimeUtils.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace FishingCactus +namespace FishingCactus.CommonCode { public static class TimeUtils { diff --git a/Runtime/VersionNumber.cs b/Runtime/VersionNumber.cs index ea6ca6b..41a35ae 100644 --- a/Runtime/VersionNumber.cs +++ b/Runtime/VersionNumber.cs @@ -1,63 +1,66 @@ using UnityEngine; -public class VersionNumber : MonoBehaviour +namespace FishingCactus.CommonCode { - // -- PUBLIC - - public string Version + public class VersionNumber : MonoBehaviour { - get + // -- PUBLIC + + public string Version { - if ( VersionInformation == null ) + get { - if( ItMustAddCompanyName ) + if ( VersionInformation == null ) { - VersionInformation = $"{Application.companyName} - {Application.productName} - {Application.version}"; - } - else - { - VersionInformation = $"{Application.productName} - {Application.version}"; + if( ItMustAddCompanyName ) + { + VersionInformation = $"{Application.companyName} - {Application.productName} - {Application.version}"; + } + else + { + VersionInformation = $"{Application.productName} - {Application.version}"; + } } + return VersionInformation; } - return VersionInformation; } - } - // -- PRIVATE + // -- PRIVATE - [SerializeField] - private float ShowVersionForSeconds = -1; - [SerializeField] - private bool ItMustAddCompanyName = true; + [SerializeField] + private float ShowVersionForSeconds = -1; + [SerializeField] + private bool ItMustAddCompanyName = true; - private string VersionInformation; - private Rect Position = new Rect( 0, 0, 300, 20 ); + private string VersionInformation; + private Rect Position = new Rect( 0, 0, 300, 20 ); - // -- UNITY + // -- UNITY - void Start() - { - DontDestroyOnLoad( this ); + void Start() + { + DontDestroyOnLoad( this ); - Debug.Log( string.Format( "Currently running version is {0}", Version ) ); + Debug.Log( string.Format( "Currently running version is {0}", Version ) ); - if ( ShowVersionForSeconds >= 0.0f ) - { - Destroy( this, ShowVersionForSeconds ); - } + if ( ShowVersionForSeconds >= 0.0f ) + { + Destroy( this, ShowVersionForSeconds ); + } - Position.x = 10f; - Position.y = Screen.height - Position.height - 10f; - } + Position.x = 10f; + Position.y = Screen.height - Position.height - 10f; + } - void OnGUI() - { - if ( ShowVersionForSeconds == 0.0f ) + void OnGUI() { - return; - } + if ( ShowVersionForSeconds == 0.0f ) + { + return; + } - GUI.contentColor = Color.gray; - GUI.Label( Position, Version ); + GUI.contentColor = Color.gray; + GUI.Label( Position, Version ); + } } } From 3b241a30866948bb3c4b1abc137868ca0c698646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Tue, 7 May 2024 15:05:08 +0200 Subject: [PATCH 16/19] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 946d18e..3b7e5e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Updated - Files reorganized - `StringHelper` methods are now extensions in `StringExtensions` +- Utility script names are more consistent +- Namespaces added/renamed to `FishingCactus.CommonCode` ## [1.2.0] - 2024-04-24 ### Added From 189658c2658932c9a08b90a9b721b95b9dcfe18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Tue, 7 May 2024 15:28:50 +0200 Subject: [PATCH 17/19] Update remaining UnityCommonCode after bad merge --- .../ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs | 2 +- .../PropertyContextMenus/IPropertyContextMenuCallback.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs index b28ed17..f10090c 100644 --- a/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs +++ b/Editor/ContextMenus/PropertyContextMenus/CreateAssetContextMenu.cs @@ -6,7 +6,7 @@ using UnityEngine; using UnityEngine.SceneManagement; -namespace FishingCactus.UnityCommonCode +namespace FishingCactus.CommonCode { public sealed class CreateAssetContextMenu : IPropertyContextMenuCallback { diff --git a/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs b/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs index cc9655b..b43d8c8 100644 --- a/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs +++ b/Editor/ContextMenus/PropertyContextMenus/IPropertyContextMenuCallback.cs @@ -1,7 +1,7 @@ using UnityEditor; using UnityEngine; -namespace FishingCactus.UnityCommonCode +namespace FishingCactus.CommonCode { public interface IPropertyContextMenuCallback { From 1b8df2aee18d84eeda325f5374d557597c80d01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 27 May 2024 10:23:23 +0200 Subject: [PATCH 18/19] Add MathematicsVectorContextMenu in readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8c1c855..494520f 100644 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ Provide readonly access to common collections types with garbage free enumeratin | `CreateAssetContextMenu` | Adds a context menu action to choose, create and reference an instance of an implemenation of the property type when right clicking on exposed properties deriving from `ScriptableObject` | | `PropertyContextMenuCallbackFetcher` | Utils script to fetch scripts that derive from `IPropertyContextMenuCallback` and add them automatically to property context menus. This is not meant to be used in project | | `VectorContextMenu` | Adds context menu actions to quickly set values of integer, floating-points and vectors values in inspector | +| `MathematicsVectorContextMenu` | Same as `VectorContextMenu` but for `Unity.Mathematics` | ## Dropdowns From 1d6bfc82066a8e8780150ec876a13717b6d61221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Constant?= Date: Mon, 27 May 2024 12:04:40 +0200 Subject: [PATCH 19/19] Add suggested change to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c9b2f..d5f34ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - Files reorganized - `StringHelper` methods are now extensions in `StringExtensions` - Utility script names are more consistent -- Namespaces added/renamed to `FishingCactus.CommonCode` +- Namespaces added or updated from `FishingCactus` to `FishingCactus.CommonCode` ## [1.2.1] - 2024-05-06 ### Added