From 865100fbe0095e12a633fdc7159a2239502e1f48 Mon Sep 17 00:00:00 2001 From: Ali Qadir <94987050+ALI-QADIR@users.noreply.github.com> Date: Fri, 16 Aug 2024 20:55:33 +0530 Subject: [PATCH] Made Custom Unity Package --- .gitattributes | 2 - .gitignore | 102 --- .idea/.idea.Utils/.idea/.gitignore | 13 - .idea/.idea.Utils/.idea/encodings.xml | 4 - .idea/.idea.Utils/.idea/indexLayout.xml | 8 - .idea/.idea.Utils/.idea/vcs.xml | 6 - .vsconfig | 6 - Assets/Scenes/SampleScene.unity | 434 ----------- Assets/TripleA/Extensions.meta | 3 - Assets/TripleA/ImprovedTimer.meta | 3 - Assets/TripleA/LowLevel.meta | 3 - Assets/TripleA/Observables.meta | 3 - Assets/TripleA/Singletons.meta | 3 - CHANGELOG.md | 4 + CHANGELOG.md.meta | 7 + .../SampleScene.unity.meta => LICENSE.meta | 2 +- Packages/manifest.json | 46 -- Packages/packages-lock.json | 457 ----------- ProjectSettings/SceneTemplateSettings.json | 121 --- README.md.meta | 7 + Assets/Scenes.meta => Runtime.meta | 2 +- .../TripleA.meta => Runtime/Extensions.meta | 2 +- .../Extensions/GameObjectExtensions.cs | 124 +-- .../Extensions/GameObjectExtensions.cs.meta | 4 +- .../Extensions/ListExtensions.cs | 116 +-- .../Extensions/ListExtensions.cs.meta | 4 +- .../Extensions/MathfExtension.cs | 90 +-- .../Extensions/MathfExtension.cs.meta | 4 +- .../Extensions/NumberExtensions.cs | 52 +- .../Extensions/NumberExtensions.cs.meta | 4 +- .../Extensions/StringExtensions.cs | 116 +-- .../Extensions/StringExtensions.cs.meta | 4 +- .../Extensions/TransformExtensions.cs | 200 ++--- .../Extensions/TransformExtensions.cs.meta | 4 +- .../Extensions/Vector2Extensions.cs | 590 +++++++------- .../Extensions/Vector2Extensions.cs.meta | 4 +- .../Extensions/Vector2Math.cs | 176 ++--- .../Extensions/Vector2Math.cs.meta | 4 +- .../Extensions/Vector3Extensions.cs | 732 +++++++++--------- .../Extensions/Vector3Extensions.cs.meta | 4 +- .../Extensions/Vector3Math.cs | 204 ++--- .../Extensions/Vector3Math.cs.meta | 4 +- Runtime/ImprovedTimer.meta | 8 + .../ImprovedTimer/Timer.cs | 184 ++--- .../ImprovedTimer/Timer.cs.meta | 4 +- .../ImprovedTimer/TimerBootstrapper.cs | 124 +-- .../ImprovedTimer/TimerBootstrapper.cs.meta | 4 +- .../ImprovedTimer/TimerManager.cs | 104 +-- .../ImprovedTimer/TimerManager.cs.meta | 4 +- .../ImprovedTimer/Timers.meta | 4 +- .../ImprovedTimer/Timers/CountDownTimer.cs | 50 +- .../Timers/CountDownTimer.cs.meta | 4 +- .../ImprovedTimer/Timers/FrequencyTimer.cs | 100 +-- .../Timers/FrequencyTimer.cs.meta | 4 +- .../ImprovedTimer/Timers/StopWatchTimer.cs | 40 +- .../Timers/StopWatchTimer.cs.meta | 4 +- Runtime/LowLevel.meta | 8 + .../LowLevel/PlayerLoopUtils.cs | 184 ++--- .../LowLevel/PlayerLoopUtils.cs.meta | 4 +- Runtime/Observables.meta | 8 + .../Observables/Observable.cs | 130 ++-- .../Observables/Observable.cs.meta | 4 +- Runtime/Singletons.meta | 8 + .../Singletons/GenericSingleton.cs | 100 +-- .../Singletons/GenericSingleton.cs.meta | 4 +- .../Singletons/PersistentSingleton.cs | 52 +- .../Singletons/PersistentSingleton.cs.meta | 4 +- .../Singletons/RegulatorSingleton.cs | 102 +-- .../Singletons/RegulatorSingleton.cs.meta | 4 +- Runtime/com.TripleA.Utils.asmdef | 14 + Runtime/com.TripleA.Utils.asmdef.meta | 7 + package.json | 17 + package.json.meta | 7 + 73 files changed, 1927 insertions(+), 3046 deletions(-) delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 .idea/.idea.Utils/.idea/.gitignore delete mode 100644 .idea/.idea.Utils/.idea/encodings.xml delete mode 100644 .idea/.idea.Utils/.idea/indexLayout.xml delete mode 100644 .idea/.idea.Utils/.idea/vcs.xml delete mode 100644 .vsconfig delete mode 100644 Assets/Scenes/SampleScene.unity delete mode 100644 Assets/TripleA/Extensions.meta delete mode 100644 Assets/TripleA/ImprovedTimer.meta delete mode 100644 Assets/TripleA/LowLevel.meta delete mode 100644 Assets/TripleA/Observables.meta delete mode 100644 Assets/TripleA/Singletons.meta create mode 100644 CHANGELOG.md create mode 100644 CHANGELOG.md.meta rename Assets/Scenes/SampleScene.unity.meta => LICENSE.meta (74%) delete mode 100644 Packages/manifest.json delete mode 100644 Packages/packages-lock.json delete mode 100644 ProjectSettings/SceneTemplateSettings.json create mode 100644 README.md.meta rename Assets/Scenes.meta => Runtime.meta (77%) rename Assets/TripleA.meta => Runtime/Extensions.meta (77%) rename {Assets/TripleA => Runtime}/Extensions/GameObjectExtensions.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/GameObjectExtensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/ListExtensions.cs (96%) rename {Assets/TripleA => Runtime}/Extensions/ListExtensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/MathfExtension.cs (94%) rename {Assets/TripleA => Runtime}/Extensions/MathfExtension.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/NumberExtensions.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/NumberExtensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/StringExtensions.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/StringExtensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/TransformExtensions.cs (98%) rename {Assets/TripleA => Runtime}/Extensions/TransformExtensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector2Extensions.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector2Extensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector2Math.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector2Math.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector3Extensions.cs (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector3Extensions.cs.meta (97%) rename {Assets/TripleA => Runtime}/Extensions/Vector3Math.cs (98%) rename {Assets/TripleA => Runtime}/Extensions/Vector3Math.cs.meta (97%) create mode 100644 Runtime/ImprovedTimer.meta rename {Assets/TripleA => Runtime}/ImprovedTimer/Timer.cs (94%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timer.cs.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/TimerBootstrapper.cs (96%) rename {Assets/TripleA => Runtime}/ImprovedTimer/TimerBootstrapper.cs.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/TimerManager.cs (96%) rename {Assets/TripleA => Runtime}/ImprovedTimer/TimerManager.cs.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/CountDownTimer.cs (95%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/CountDownTimer.cs.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/FrequencyTimer.cs (95%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/FrequencyTimer.cs.meta (97%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/StopWatchTimer.cs (95%) rename {Assets/TripleA => Runtime}/ImprovedTimer/Timers/StopWatchTimer.cs.meta (97%) create mode 100644 Runtime/LowLevel.meta rename {Assets/TripleA => Runtime}/LowLevel/PlayerLoopUtils.cs (97%) rename {Assets/TripleA => Runtime}/LowLevel/PlayerLoopUtils.cs.meta (97%) create mode 100644 Runtime/Observables.meta rename {Assets/TripleA => Runtime}/Observables/Observable.cs (95%) rename {Assets/TripleA => Runtime}/Observables/Observable.cs.meta (97%) create mode 100644 Runtime/Singletons.meta rename {Assets/TripleA => Runtime}/Singletons/GenericSingleton.cs (94%) rename {Assets/TripleA => Runtime}/Singletons/GenericSingleton.cs.meta (97%) rename {Assets/TripleA => Runtime}/Singletons/PersistentSingleton.cs (94%) rename {Assets/TripleA => Runtime}/Singletons/PersistentSingleton.cs.meta (97%) rename {Assets/TripleA => Runtime}/Singletons/RegulatorSingleton.cs (95%) rename {Assets/TripleA => Runtime}/Singletons/RegulatorSingleton.cs.meta (97%) create mode 100644 Runtime/com.TripleA.Utils.asmdef create mode 100644 Runtime/com.TripleA.Utils.asmdef.meta create mode 100644 package.json create mode 100644 package.json.meta diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index dfe0770..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 1448d50..0000000 --- a/.gitignore +++ /dev/null @@ -1,102 +0,0 @@ -# This .gitignore file should be placed at the root of your Unity project directory -# -# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore -# -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ -/[Bb]uilds/ -/[Ll]ogs/ -/[Uu]ser[Ss]ettings/ - -# MemoryCaptures can get excessive in size. -# They also could contain extremely sensitive data -/[Mm]emoryCaptures/ - -# Recordings can get excessive in size -/[Rr]ecordings/ - -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* - -# Autogenerated Jetbrains Rider plugin -/[Aa]ssets/Plugins/Editor/JetBrains* - -# Visual Studio cache directory -.vs/ - -# Gradle cache directory -.gradle/ - -# Autogenerated VS/MD/Consulo solution and project files -ExportedObj/ -.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.mdb -*.opendb -*.VC.db - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta -*.mdb.meta - -# Unity3D generated file on crash reports -sysinfo.txt - -# Builds -*.apk -*.aab -*.unitypackage -*.app - -# Crashlytics generated file -crashlytics-build.properties - -# Packed Addressables -/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* - -# Temporary auto-generated Android Assets -/[Aa]ssets/[Ss]treamingAssets/aa.meta -/[Aa]ssets/[Ss]treamingAssets/aa/* - -# Everything in Assest/_IGNORE folder -/[Aa]ssets/_IGNORE/* -/[Aa]ssets/_IGNORE.meta -ProjectSettings/AudioManager.asset -ProjectSettings/ClusterInputManager.asset -ProjectSettings/DynamicsManager.asset -ProjectSettings/EditorBuildSettings.asset -ProjectSettings/EditorSettings.asset -ProjectSettings/GraphicsSettings.asset -ProjectSettings/InputManager.asset -ProjectSettings/MemorySettings.asset -ProjectSettings/MultiplayerManager.asset -ProjectSettings/NavMeshAreas.asset -ProjectSettings/PackageManagerSettings.asset -ProjectSettings/Physics2DSettings.asset -ProjectSettings/PresetManager.asset -ProjectSettings/ProjectSettings.asset -ProjectSettings/ProjectVersion.txt -ProjectSettings/QualitySettings.asset -ProjectSettings/ShaderGraphSettings.asset -ProjectSettings/TagManager.asset -ProjectSettings/TimeManager.asset -ProjectSettings/UnityConnectSettings.asset -ProjectSettings/URPProjectSettings.asset -ProjectSettings/VersionControlSettings.asset -ProjectSettings/VFXManager.asset -ProjectSettings/XRSettings.asset -Assets/Scenes/TestScene.unity -Assets/Scenes/TestScene.unity.meta diff --git a/.idea/.idea.Utils/.idea/.gitignore b/.idea/.idea.Utils/.idea/.gitignore deleted file mode 100644 index 9a3efa0..0000000 --- a/.idea/.idea.Utils/.idea/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Rider ignored files -/contentModel.xml -/projectSettingsUpdater.xml -/.idea.Utils.iml -/modules.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/.idea.Utils/.idea/encodings.xml b/.idea/.idea.Utils/.idea/encodings.xml deleted file mode 100644 index df87cf9..0000000 --- a/.idea/.idea.Utils/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/.idea.Utils/.idea/indexLayout.xml b/.idea/.idea.Utils/.idea/indexLayout.xml deleted file mode 100644 index 7b08163..0000000 --- a/.idea/.idea.Utils/.idea/indexLayout.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/.idea.Utils/.idea/vcs.xml b/.idea/.idea.Utils/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/.idea.Utils/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.vsconfig b/.vsconfig deleted file mode 100644 index f019fd0..0000000 --- a/.vsconfig +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0", - "components": [ - "Microsoft.VisualStudio.Workload.ManagedGame" - ] -} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity deleted file mode 100644 index 6d1f77d..0000000 --- a/Assets/Scenes/SampleScene.unity +++ /dev/null @@ -1,434 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!29 &1 -OcclusionCullingSettings: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_OcclusionBakeSettings: - smallestOccluder: 5 - smallestHole: 0.25 - backfaceThreshold: 100 - m_SceneGUID: 00000000000000000000000000000000 - m_OcclusionCullingData: {fileID: 0} ---- !u!104 &2 -RenderSettings: - m_ObjectHideFlags: 0 - serializedVersion: 10 - m_Fog: 0 - m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} - m_FogMode: 3 - m_FogDensity: 0.01 - m_LinearFogStart: 0 - m_LinearFogEnd: 300 - m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} - m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} - m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} - m_AmbientIntensity: 1 - m_AmbientMode: 0 - m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} - m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} - m_HaloStrength: 0.5 - m_FlareStrength: 1 - m_FlareFadeSpeed: 3 - m_HaloTexture: {fileID: 0} - m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} - m_DefaultReflectionMode: 0 - m_DefaultReflectionResolution: 128 - m_ReflectionBounces: 1 - m_ReflectionIntensity: 1 - m_CustomReflection: {fileID: 0} - m_Sun: {fileID: 0} - m_UseRadianceAmbientProbe: 0 ---- !u!157 &3 -LightmapSettings: - m_ObjectHideFlags: 0 - serializedVersion: 12 - m_GISettings: - serializedVersion: 2 - m_BounceScale: 1 - m_IndirectOutputScale: 1 - m_AlbedoBoost: 1 - m_EnvironmentLightingMode: 0 - m_EnableBakedLightmaps: 1 - m_EnableRealtimeLightmaps: 0 - m_LightmapEditorSettings: - serializedVersion: 12 - m_Resolution: 2 - m_BakeResolution: 40 - m_AtlasSize: 1024 - m_AO: 0 - m_AOMaxDistance: 1 - m_CompAOExponent: 1 - m_CompAOExponentDirect: 0 - m_ExtractAmbientOcclusion: 0 - m_Padding: 2 - m_LightmapParameters: {fileID: 0} - m_LightmapsBakeMode: 1 - m_TextureCompression: 1 - m_ReflectionCompression: 2 - m_MixedBakeMode: 2 - m_BakeBackend: 1 - m_PVRSampling: 1 - m_PVRDirectSampleCount: 32 - m_PVRSampleCount: 512 - m_PVRBounces: 2 - m_PVREnvironmentSampleCount: 256 - m_PVREnvironmentReferencePointCount: 2048 - m_PVRFilteringMode: 1 - m_PVRDenoiserTypeDirect: 1 - m_PVRDenoiserTypeIndirect: 1 - m_PVRDenoiserTypeAO: 1 - m_PVRFilterTypeDirect: 0 - m_PVRFilterTypeIndirect: 0 - m_PVRFilterTypeAO: 0 - m_PVREnvironmentMIS: 1 - m_PVRCulling: 1 - m_PVRFilteringGaussRadiusDirect: 1 - m_PVRFilteringGaussRadiusIndirect: 5 - m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousPositionSigmaDirect: 0.5 - m_PVRFilteringAtrousPositionSigmaIndirect: 2 - m_PVRFilteringAtrousPositionSigmaAO: 1 - m_ExportTrainingData: 0 - m_TrainingDataDestination: TrainingData - m_LightProbeSampleCountMultiplier: 4 - m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} - m_LightingSettings: {fileID: 0} ---- !u!196 &4 -NavMeshSettings: - serializedVersion: 2 - m_ObjectHideFlags: 0 - m_BuildSettings: - serializedVersion: 3 - agentTypeID: 0 - agentRadius: 0.5 - agentHeight: 2 - agentSlope: 45 - agentClimb: 0.4 - ledgeDropHeight: 0 - maxJumpAcrossDistance: 0 - minRegionArea: 2 - manualCellSize: 0 - cellSize: 0.16666667 - manualTileSize: 0 - tileSize: 256 - buildHeightMesh: 0 - maxJobWorkers: 0 - preserveTilesOutsideBounds: 0 - debug: - m_Flags: 0 - m_NavMeshData: {fileID: 0} ---- !u!1 &330585543 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 330585546} - - component: {fileID: 330585545} - - component: {fileID: 330585544} - - component: {fileID: 330585547} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!81 &330585544 -AudioListener: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330585543} - m_Enabled: 1 ---- !u!20 &330585545 -Camera: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330585543} - m_Enabled: 1 - serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} - m_projectionMatrixMode: 1 - m_GateFitMode: 2 - m_FOVAxisMode: 0 - m_Iso: 200 - m_ShutterSpeed: 0.005 - m_Aperture: 16 - m_FocusDistance: 10 - m_FocalLength: 50 - m_BladeCount: 5 - m_Curvature: {x: 2, y: 11} - m_BarrelClipping: 0.25 - m_Anamorphism: 0 - m_SensorSize: {x: 36, y: 24} - m_LensShift: {x: 0, y: 0} - m_NormalizedViewPortRect: - serializedVersion: 2 - x: 0 - y: 0 - width: 1 - height: 1 - near clip plane: 0.3 - far clip plane: 1000 - field of view: 60 - orthographic: 0 - orthographic size: 5 - m_Depth: -1 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingPath: -1 - m_TargetTexture: {fileID: 0} - m_TargetDisplay: 0 - m_TargetEye: 3 - m_HDR: 1 - m_AllowMSAA: 1 - m_AllowDynamicResolution: 0 - m_ForceIntoRT: 0 - m_OcclusionCulling: 1 - m_StereoConvergence: 10 - m_StereoSeparation: 0.022 ---- !u!4 &330585546 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330585543} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &330585547 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 330585543} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} - m_Name: - m_EditorClassIdentifier: - m_RenderShadows: 1 - m_RequiresDepthTextureOption: 2 - m_RequiresOpaqueTextureOption: 2 - m_CameraType: 0 - m_Cameras: [] - m_RendererIndex: -1 - m_VolumeLayerMask: - serializedVersion: 2 - m_Bits: 1 - m_VolumeTrigger: {fileID: 0} - m_VolumeFrameworkUpdateModeOption: 2 - m_RenderPostProcessing: 1 - m_Antialiasing: 0 - m_AntialiasingQuality: 2 - m_StopNaN: 0 - m_Dithering: 0 - m_ClearDepth: 1 - m_AllowXRRendering: 1 - m_AllowHDROutput: 1 - m_UseScreenCoordOverride: 0 - m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} - m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} - m_RequiresDepthTexture: 0 - m_RequiresColorTexture: 0 - m_Version: 2 - m_TaaSettings: - m_Quality: 3 - m_FrameInfluence: 0.1 - m_JitterScale: 1 - m_MipBias: 0 - m_VarianceClampScale: 0.9 - m_ContrastAdaptiveSharpening: 0 ---- !u!1 &410087039 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 410087041} - - component: {fileID: 410087040} - - component: {fileID: 410087042} - m_Layer: 0 - m_Name: Directional Light - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!108 &410087040 -Light: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 410087039} - m_Enabled: 1 - serializedVersion: 11 - m_Type: 1 - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_Intensity: 2 - m_Range: 10 - m_SpotAngle: 30 - m_InnerSpotAngle: 21.80208 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_CullingMatrixOverride: - e00: 1 - e01: 0 - e02: 0 - e03: 0 - e10: 0 - e11: 1 - e12: 0 - e13: 0 - e20: 0 - e21: 0 - e22: 1 - e23: 0 - e30: 0 - e31: 0 - e32: 0 - e33: 1 - m_UseCullingMatrixOverride: 0 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: - serializedVersion: 2 - m_Bits: 4294967295 - m_RenderingLayerMask: 1 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 5000 - m_UseColorTemperature: 1 - m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} - m_UseBoundingSphereOverride: 0 - m_UseViewFrustumForShadowCasterCull: 1 - m_ForceVisible: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 - m_LightUnit: 1 - m_LuxAtDistance: 1 - m_EnableSpotReflector: 1 ---- !u!4 &410087041 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 410087039} - serializedVersion: 2 - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!114 &410087042 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 410087039} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Version: 3 - m_UsePipelineSettings: 1 - m_AdditionalLightsShadowResolutionTier: 2 - m_LightLayerMask: 1 - m_RenderingLayers: 1 - m_CustomShadowLayers: 0 - m_ShadowLayerMask: 1 - m_ShadowRenderingLayers: 1 - m_LightCookieSize: {x: 1, y: 1} - m_LightCookieOffset: {x: 0, y: 0} - m_SoftShadowQuality: 1 ---- !u!1 &832575517 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 832575519} - - component: {fileID: 832575518} - m_Layer: 0 - m_Name: Global Volume - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &832575518 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 832575517} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 172515602e62fb746b5d573b38a5fe58, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IsGlobal: 1 - priority: 0 - blendDistance: 0 - weight: 1 - sharedProfile: {fileID: 11400000, guid: 10fc4df2da32a41aaa32d77bc913491c, type: 2} ---- !u!4 &832575519 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 832575517} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1660057539 &9223372036854775807 -SceneRoots: - m_ObjectHideFlags: 0 - m_Roots: - - {fileID: 330585546} - - {fileID: 410087041} - - {fileID: 832575519} diff --git a/Assets/TripleA/Extensions.meta b/Assets/TripleA/Extensions.meta deleted file mode 100644 index cb84d75..0000000 --- a/Assets/TripleA/Extensions.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 21be881149344af3bb2e11aee559ae98 -timeCreated: 1723048313 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer.meta b/Assets/TripleA/ImprovedTimer.meta deleted file mode 100644 index d2d5da3..0000000 --- a/Assets/TripleA/ImprovedTimer.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 7e6594eb2371434bbaf1a044106d88a5 -timeCreated: 1723805924 \ No newline at end of file diff --git a/Assets/TripleA/LowLevel.meta b/Assets/TripleA/LowLevel.meta deleted file mode 100644 index e0c32f9..0000000 --- a/Assets/TripleA/LowLevel.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c61bb6794c7a4c729e6729190a9cc54c -timeCreated: 1723806183 \ No newline at end of file diff --git a/Assets/TripleA/Observables.meta b/Assets/TripleA/Observables.meta deleted file mode 100644 index 7f44721..0000000 --- a/Assets/TripleA/Observables.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a822e25dbe584eed849b4427350d055d -timeCreated: 1723140939 \ No newline at end of file diff --git a/Assets/TripleA/Singletons.meta b/Assets/TripleA/Singletons.meta deleted file mode 100644 index 43fd875..0000000 --- a/Assets/TripleA/Singletons.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 6a55ffea83244650aaf57f890ca50102 -timeCreated: 1723138988 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ef8c239 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +## [1.0.0] - 2024-08-16 +### First Release +- Extension methods for unity +- Timer that uses low level unity player loop system for timers \ No newline at end of file diff --git a/CHANGELOG.md.meta b/CHANGELOG.md.meta new file mode 100644 index 0000000..6b5eecf --- /dev/null +++ b/CHANGELOG.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8e2eda68b7270e448b06a98f804eed4f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity.meta b/LICENSE.meta similarity index 74% rename from Assets/Scenes/SampleScene.unity.meta rename to LICENSE.meta index 9531828..5f36986 100644 --- a/Assets/Scenes/SampleScene.unity.meta +++ b/LICENSE.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 99c9720ab356a0642a771bea13969a05 +guid: e1752514b20a3be4fbb959b84f2c70a5 DefaultImporter: externalObjects: {} userData: diff --git a/Packages/manifest.json b/Packages/manifest.json deleted file mode 100644 index c94adac..0000000 --- a/Packages/manifest.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "dependencies": { - "com.unity.ai.navigation": "2.0.0", - "com.unity.collab-proxy": "2.4.4", - "com.unity.ide.rider": "3.0.31", - "com.unity.ide.visualstudio": "2.0.22", - "com.unity.inputsystem": "1.9.0", - "com.unity.render-pipelines.universal": "17.0.3", - "com.unity.test-framework": "1.4.4", - "com.unity.timeline": "1.8.7", - "com.unity.ugui": "2.0.0", - "com.unity.visualscripting": "1.9.4", - "com.unity.modules.accessibility": "1.0.0", - "com.unity.modules.ai": "1.0.0", - "com.unity.modules.androidjni": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.cloth": "1.0.0", - "com.unity.modules.director": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.particlesystem": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.physics2d": "1.0.0", - "com.unity.modules.screencapture": "1.0.0", - "com.unity.modules.terrain": "1.0.0", - "com.unity.modules.terrainphysics": "1.0.0", - "com.unity.modules.tilemap": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.uielements": "1.0.0", - "com.unity.modules.umbra": "1.0.0", - "com.unity.modules.unityanalytics": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.unitywebrequesttexture": "1.0.0", - "com.unity.modules.unitywebrequestwww": "1.0.0", - "com.unity.modules.vehicles": "1.0.0", - "com.unity.modules.video": "1.0.0", - "com.unity.modules.vr": "1.0.0", - "com.unity.modules.wind": "1.0.0", - "com.unity.modules.xr": "1.0.0" - } -} diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json deleted file mode 100644 index 77f7b1d..0000000 --- a/Packages/packages-lock.json +++ /dev/null @@ -1,457 +0,0 @@ -{ - "dependencies": { - "com.unity.ai.navigation": { - "version": "2.0.0", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.modules.ai": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.burst": { - "version": "1.8.17", - "depth": 2, - "source": "registry", - "dependencies": { - "com.unity.mathematics": "1.2.1", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.collab-proxy": { - "version": "2.4.4", - "depth": 0, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.collections": { - "version": "2.4.1", - "depth": 2, - "source": "registry", - "dependencies": { - "com.unity.burst": "1.8.13", - "com.unity.nuget.mono-cecil": "1.11.4", - "com.unity.test-framework": "1.4.3", - "com.unity.test-framework.performance": "3.0.3" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ext.nunit": { - "version": "2.0.5", - "depth": 1, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.ide.rider": { - "version": "3.0.31", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ext.nunit": "1.0.6" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ide.visualstudio": { - "version": "2.0.22", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.1.9" - }, - "url": "https://packages.unity.com" - }, - "com.unity.inputsystem": { - "version": "1.9.0", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.modules.uielements": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.mathematics": { - "version": "1.3.2", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.nuget.mono-cecil": { - "version": "1.11.4", - "depth": 3, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.render-pipelines.core": { - "version": "17.0.3", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.burst": "1.8.14", - "com.unity.mathematics": "1.3.2", - "com.unity.ugui": "2.0.0", - "com.unity.collections": "2.4.1", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.terrain": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.rendering.light-transport": "1.0.1" - } - }, - "com.unity.render-pipelines.universal": { - "version": "17.0.3", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.render-pipelines.core": "17.0.3", - "com.unity.shadergraph": "17.0.3", - "com.unity.render-pipelines.universal-config": "17.0.3" - } - }, - "com.unity.render-pipelines.universal-config": { - "version": "17.0.3", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.render-pipelines.core": "17.0.3" - } - }, - "com.unity.rendering.light-transport": { - "version": "1.0.1", - "depth": 2, - "source": "builtin", - "dependencies": { - "com.unity.collections": "2.2.0", - "com.unity.mathematics": "1.2.4", - "com.unity.modules.terrain": "1.0.0" - } - }, - "com.unity.searcher": { - "version": "4.9.2", - "depth": 2, - "source": "registry", - "dependencies": {}, - "url": "https://packages.unity.com" - }, - "com.unity.shadergraph": { - "version": "17.0.3", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.render-pipelines.core": "17.0.3", - "com.unity.searcher": "4.9.2" - } - }, - "com.unity.test-framework": { - "version": "1.4.4", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ext.nunit": "2.0.3", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.test-framework.performance": { - "version": "3.0.3", - "depth": 3, - "source": "registry", - "dependencies": { - "com.unity.test-framework": "1.1.31", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.timeline": { - "version": "1.8.7", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.modules.director": "1.0.0", - "com.unity.modules.animation": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.particlesystem": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.ugui": { - "version": "2.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0" - } - }, - "com.unity.visualscripting": { - "version": "1.9.4", - "depth": 0, - "source": "registry", - "dependencies": { - "com.unity.ugui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - }, - "url": "https://packages.unity.com" - }, - "com.unity.modules.accessibility": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.ai": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.androidjni": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.animation": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.assetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.audio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.cloth": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.director": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.animation": "1.0.0" - } - }, - "com.unity.modules.hierarchycore": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.imageconversion": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.imgui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.jsonserialize": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.particlesystem": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.physics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.physics2d": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.screencapture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.subsystems": { - "version": "1.0.0", - "depth": 1, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.terrain": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.terrainphysics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.terrain": "1.0.0" - } - }, - "com.unity.modules.tilemap": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics2d": "1.0.0" - } - }, - "com.unity.modules.ui": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.uielements": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.imgui": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.hierarchycore": "1.0.0" - } - }, - "com.unity.modules.umbra": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unityanalytics": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0" - } - }, - "com.unity.modules.unitywebrequest": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.unitywebrequestassetbundle": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestaudio": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.audio": "1.0.0" - } - }, - "com.unity.modules.unitywebrequesttexture": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.unitywebrequestwww": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.unitywebrequest": "1.0.0", - "com.unity.modules.unitywebrequestassetbundle": "1.0.0", - "com.unity.modules.unitywebrequestaudio": "1.0.0", - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.assetbundle": "1.0.0", - "com.unity.modules.imageconversion": "1.0.0" - } - }, - "com.unity.modules.vehicles": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0" - } - }, - "com.unity.modules.video": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.audio": "1.0.0", - "com.unity.modules.ui": "1.0.0", - "com.unity.modules.unitywebrequest": "1.0.0" - } - }, - "com.unity.modules.vr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.xr": "1.0.0" - } - }, - "com.unity.modules.wind": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": {} - }, - "com.unity.modules.xr": { - "version": "1.0.0", - "depth": 0, - "source": "builtin", - "dependencies": { - "com.unity.modules.physics": "1.0.0", - "com.unity.modules.jsonserialize": "1.0.0", - "com.unity.modules.subsystems": "1.0.0" - } - } - } -} diff --git a/ProjectSettings/SceneTemplateSettings.json b/ProjectSettings/SceneTemplateSettings.json deleted file mode 100644 index ede5887..0000000 --- a/ProjectSettings/SceneTemplateSettings.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "templatePinStates": [], - "dependencyTypeInfos": [ - { - "userAdded": false, - "type": "UnityEngine.AnimationClip", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.Animations.AnimatorController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.AnimatorOverrideController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.Audio.AudioMixerController", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.ComputeShader", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Cubemap", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.GameObject", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.LightingDataAsset", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.LightingSettings", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Material", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.MonoScript", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicsMaterial", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.PhysicsMaterial2D", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Rendering.VolumeProfile", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEditor.SceneAsset", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Shader", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.ShaderVariantCollection", - "defaultInstantiationMode": 1 - }, - { - "userAdded": false, - "type": "UnityEngine.Texture", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Texture2D", - "defaultInstantiationMode": 0 - }, - { - "userAdded": false, - "type": "UnityEngine.Timeline.TimelineAsset", - "defaultInstantiationMode": 0 - } - ], - "defaultDependencyTypeInfo": { - "userAdded": false, - "type": "", - "defaultInstantiationMode": 1 - }, - "newSceneOverride": 0 -} \ No newline at end of file diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..44445b9 --- /dev/null +++ b/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6c860c2018a019045ad7f682d7e48408 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes.meta b/Runtime.meta similarity index 77% rename from Assets/Scenes.meta rename to Runtime.meta index ab92fba..4442359 100644 --- a/Assets/Scenes.meta +++ b/Runtime.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 2adfaf2bb963f954580f6c36ee466a87 +guid: 1d48dcf184696dd48a7f103eec45c378 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/TripleA.meta b/Runtime/Extensions.meta similarity index 77% rename from Assets/TripleA.meta rename to Runtime/Extensions.meta index 08e0e02..d99d3d9 100644 --- a/Assets/TripleA.meta +++ b/Runtime/Extensions.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: dec99c18b264bec40bca668d54cb62c4 +guid: 859a1bdc38239a941b2da77d3f55715e folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/TripleA/Extensions/GameObjectExtensions.cs b/Runtime/Extensions/GameObjectExtensions.cs similarity index 97% rename from Assets/TripleA/Extensions/GameObjectExtensions.cs rename to Runtime/Extensions/GameObjectExtensions.cs index 09c429e..992f575 100644 --- a/Assets/TripleA/Extensions/GameObjectExtensions.cs +++ b/Runtime/Extensions/GameObjectExtensions.cs @@ -1,63 +1,63 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public static class GameObjectExtensions - { - /// - /// Hides the game object in the hierarchy - /// - public static void HideInHierarchy(this GameObject gameObject) - { - gameObject.hideFlags = HideFlags.HideInHierarchy; - } - - /// - /// Gets the component or adds it if it doesn't exist - /// - /// The type of the component - public static T GetOrAddComponent(this GameObject gameObject) where T : Component - { - return gameObject.GetComponent() ?? gameObject.AddComponent(); - } - - /// - /// Returns the object on the game object or null if it's null - /// - /// The type of the object - public static T OrNull(this T obj) where T : Object - { - return obj ? obj : null; - } - - /// - /// Destroys all children of the game object - /// - public static void DestroyChildren(this GameObject gameObject) - { - foreach (Transform child in gameObject.transform) Object.Destroy(child.gameObject); - } - - /// - /// Sets the layer of the game object and all of its children - /// - /// The game object - /// The int layer - public static void SetLayerRecursively(this GameObject gameObject, int layer) - { - gameObject.layer = layer; - foreach (Transform child in gameObject.transform) child.gameObject.SetLayerRecursively(layer); - } - - /// - /// Sets the layer of the game object and all of its children - /// - /// The game object - /// The layer mask - public static void SetLayerRecursively(this GameObject gameObject, LayerMask layerMask) - { - gameObject.layer = layerMask.value; - foreach (Transform child in gameObject.transform) child.gameObject.SetLayerRecursively(layerMask); - } - } +using UnityEngine; + +namespace TripleA.Extensions +{ + public static class GameObjectExtensions + { + /// + /// Hides the game object in the hierarchy + /// + public static void HideInHierarchy(this GameObject gameObject) + { + gameObject.hideFlags = HideFlags.HideInHierarchy; + } + + /// + /// Gets the component or adds it if it doesn't exist + /// + /// The type of the component + public static T GetOrAddComponent(this GameObject gameObject) where T : Component + { + return gameObject.GetComponent() ?? gameObject.AddComponent(); + } + + /// + /// Returns the object on the game object or null if it's null + /// + /// The type of the object + public static T OrNull(this T obj) where T : Object + { + return obj ? obj : null; + } + + /// + /// Destroys all children of the game object + /// + public static void DestroyChildren(this GameObject gameObject) + { + foreach (Transform child in gameObject.transform) Object.Destroy(child.gameObject); + } + + /// + /// Sets the layer of the game object and all of its children + /// + /// The game object + /// The int layer + public static void SetLayerRecursively(this GameObject gameObject, int layer) + { + gameObject.layer = layer; + foreach (Transform child in gameObject.transform) child.gameObject.SetLayerRecursively(layer); + } + + /// + /// Sets the layer of the game object and all of its children + /// + /// The game object + /// The layer mask + public static void SetLayerRecursively(this GameObject gameObject, LayerMask layerMask) + { + gameObject.layer = layerMask.value; + foreach (Transform child in gameObject.transform) child.gameObject.SetLayerRecursively(layerMask); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/GameObjectExtensions.cs.meta b/Runtime/Extensions/GameObjectExtensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/GameObjectExtensions.cs.meta rename to Runtime/Extensions/GameObjectExtensions.cs.meta index 6886332..0dae675 100644 --- a/Assets/TripleA/Extensions/GameObjectExtensions.cs.meta +++ b/Runtime/Extensions/GameObjectExtensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: dff8f81aad8248d2960bf5afb31d440d +fileFormatVersion: 2 +guid: dff8f81aad8248d2960bf5afb31d440d timeCreated: 1723569038 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/ListExtensions.cs b/Runtime/Extensions/ListExtensions.cs similarity index 96% rename from Assets/TripleA/Extensions/ListExtensions.cs rename to Runtime/Extensions/ListExtensions.cs index bb1201a..e8aaa3f 100644 --- a/Assets/TripleA/Extensions/ListExtensions.cs +++ b/Runtime/Extensions/ListExtensions.cs @@ -1,59 +1,59 @@ -using System; -using System.Collections.Generic; - -namespace TripleA.Extensions -{ - public static class ListExtensions - { - private static Random _rand; - - /// - /// Clones the list - /// - public static List Clone(this List listToClone) - { - List newList = new(); - foreach (var item in listToClone) newList.Add(item); - return newList; - } - - /// - /// Refreshes the list with the given items - /// - /// The items to add - public static void RefreshWith(this List list, IEnumerable items) - { - list.Clear(); - list.AddRange(items); - } - - /// - /// Shuffles the list using Fisher-Yates algorithm. - /// Reference: http://en.wikipedia.org/wiki/Fisher-Yates_shuffle - /// - /// The shuffled list - public static IList Shuffle(this IList list) - { - _rand ??= new Random(); - var n = list.Count; - while (n > 1) - { - n--; - var k = _rand.Next(n + 1); - (list[k], list[n]) = (list[n], list[k]); - } - - return list; - } - - /// - /// Swaps two elements in the list - /// - /// The first index - /// The second index - public static void Swap(this IList list, int indexA, int indexB) - { - (list[indexA], list[indexB]) = (list[indexB], list[indexA]); - } - } +using System; +using System.Collections.Generic; + +namespace TripleA.Extensions +{ + public static class ListExtensions + { + private static Random _rand; + + /// + /// Clones the list + /// + public static List Clone(this List listToClone) + { + List newList = new(); + foreach (var item in listToClone) newList.Add(item); + return newList; + } + + /// + /// Refreshes the list with the given items + /// + /// The items to add + public static void RefreshWith(this List list, IEnumerable items) + { + list.Clear(); + list.AddRange(items); + } + + /// + /// Shuffles the list using Fisher-Yates algorithm. + /// Reference: http://en.wikipedia.org/wiki/Fisher-Yates_shuffle + /// + /// The shuffled list + public static IList Shuffle(this IList list) + { + _rand ??= new Random(); + var n = list.Count; + while (n > 1) + { + n--; + var k = _rand.Next(n + 1); + (list[k], list[n]) = (list[n], list[k]); + } + + return list; + } + + /// + /// Swaps two elements in the list + /// + /// The first index + /// The second index + public static void Swap(this IList list, int indexA, int indexB) + { + (list[indexA], list[indexB]) = (list[indexB], list[indexA]); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/ListExtensions.cs.meta b/Runtime/Extensions/ListExtensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/ListExtensions.cs.meta rename to Runtime/Extensions/ListExtensions.cs.meta index e12c987..a6108c8 100644 --- a/Assets/TripleA/Extensions/ListExtensions.cs.meta +++ b/Runtime/Extensions/ListExtensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: d21688fad6f340afaf436dd31292e0f3 +fileFormatVersion: 2 +guid: d21688fad6f340afaf436dd31292e0f3 timeCreated: 1723617815 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/MathfExtension.cs b/Runtime/Extensions/MathfExtension.cs similarity index 94% rename from Assets/TripleA/Extensions/MathfExtension.cs rename to Runtime/Extensions/MathfExtension.cs index 6265bbd..2be9cf2 100644 --- a/Assets/TripleA/Extensions/MathfExtension.cs +++ b/Runtime/Extensions/MathfExtension.cs @@ -1,45 +1,45 @@ -namespace TripleA.Extensions -{ - public static class MathfExtension - { - public static double Max(double a, double b) { - return (a > b) ? a : b; - } - - public static double Max(params double[] values) { - int num = values.Length; - if (num == 0) { - return 0f; - } - - double num2 = values[0]; - for (int i = 1; i < num; i++) { - if (values[i] > num2) { - num2 = values[i]; - } - } - - return num2; - } - - public static double Min(double a, double b) { - return (a < b) ? a : b; - } - - public static double Min(params double[] values) { - int num = values.Length; - if (num == 0) { - return 0f; - } - - double num2 = values[0]; - for (int i = 1; i < num; i++) { - if (values[i] < num2) { - num2 = values[i]; - } - } - - return num2; - } - } -} +namespace TripleA.Extensions +{ + public static class MathfExtension + { + public static double Max(double a, double b) { + return (a > b) ? a : b; + } + + public static double Max(params double[] values) { + int num = values.Length; + if (num == 0) { + return 0f; + } + + double num2 = values[0]; + for (int i = 1; i < num; i++) { + if (values[i] > num2) { + num2 = values[i]; + } + } + + return num2; + } + + public static double Min(double a, double b) { + return (a < b) ? a : b; + } + + public static double Min(params double[] values) { + int num = values.Length; + if (num == 0) { + return 0f; + } + + double num2 = values[0]; + for (int i = 1; i < num; i++) { + if (values[i] < num2) { + num2 = values[i]; + } + } + + return num2; + } + } +} diff --git a/Assets/TripleA/Extensions/MathfExtension.cs.meta b/Runtime/Extensions/MathfExtension.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/MathfExtension.cs.meta rename to Runtime/Extensions/MathfExtension.cs.meta index 709ab12..e653c50 100644 --- a/Assets/TripleA/Extensions/MathfExtension.cs.meta +++ b/Runtime/Extensions/MathfExtension.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 30fea4737df84eafb87c466161849b9d +fileFormatVersion: 2 +guid: 30fea4737df84eafb87c466161849b9d timeCreated: 1723626127 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/NumberExtensions.cs b/Runtime/Extensions/NumberExtensions.cs similarity index 97% rename from Assets/TripleA/Extensions/NumberExtensions.cs rename to Runtime/Extensions/NumberExtensions.cs index 26d3f31..fbbf352 100644 --- a/Assets/TripleA/Extensions/NumberExtensions.cs +++ b/Runtime/Extensions/NumberExtensions.cs @@ -1,26 +1,26 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public static class NumberExtensions - { - public static float PercentageOf(this int part, int whole) - { - if (whole == 0) return 0; - return (float) part / whole * 100; - } - - public static bool IsApproximately(this float a, float b) => Mathf.Approximately(a, b); - public static bool IsEven(this int a) => a % 2 == 0; - public static bool IsOdd(this int a) => a % 2 == 1; - - public static int AtLeast(this int a, int b) => Mathf.Max(a, b); - public static int AtMost(this int a, int b) => Mathf.Min(a, b); - - public static float AtLeast(this float a, float b) => Mathf.Max(a, b); - public static float AtMost(this float a, float b) => Mathf.Min(a, b); - - public static double AtLeast(this double a, double b) => MathfExtension.Max(a, b); - public static double AtMost(this double a, double b) => MathfExtension.Min(a, b); - } -} +using UnityEngine; + +namespace TripleA.Extensions +{ + public static class NumberExtensions + { + public static float PercentageOf(this int part, int whole) + { + if (whole == 0) return 0; + return (float) part / whole * 100; + } + + public static bool IsApproximately(this float a, float b) => Mathf.Approximately(a, b); + public static bool IsEven(this int a) => a % 2 == 0; + public static bool IsOdd(this int a) => a % 2 == 1; + + public static int AtLeast(this int a, int b) => Mathf.Max(a, b); + public static int AtMost(this int a, int b) => Mathf.Min(a, b); + + public static float AtLeast(this float a, float b) => Mathf.Max(a, b); + public static float AtMost(this float a, float b) => Mathf.Min(a, b); + + public static double AtLeast(this double a, double b) => MathfExtension.Max(a, b); + public static double AtMost(this double a, double b) => MathfExtension.Min(a, b); + } +} diff --git a/Assets/TripleA/Extensions/NumberExtensions.cs.meta b/Runtime/Extensions/NumberExtensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/NumberExtensions.cs.meta rename to Runtime/Extensions/NumberExtensions.cs.meta index 37cab35..cc4f1a0 100644 --- a/Assets/TripleA/Extensions/NumberExtensions.cs.meta +++ b/Runtime/Extensions/NumberExtensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 6c4020e154ea4b82b7ba2db8147ed4d2 +fileFormatVersion: 2 +guid: 6c4020e154ea4b82b7ba2db8147ed4d2 timeCreated: 1723625666 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/StringExtensions.cs b/Runtime/Extensions/StringExtensions.cs similarity index 97% rename from Assets/TripleA/Extensions/StringExtensions.cs rename to Runtime/Extensions/StringExtensions.cs index e0d693b..b9f6b37 100644 --- a/Assets/TripleA/Extensions/StringExtensions.cs +++ b/Runtime/Extensions/StringExtensions.cs @@ -1,59 +1,59 @@ -using System; - -namespace TripleA.Extensions -{ - public static class StringExtensions - { - /// Checks if a string is Null or white space - public static bool IsNullOrWhiteSpace(this string val) - { - return string.IsNullOrWhiteSpace(val); - } - - /// Checks if a string is Null or empty - public static bool IsNullOrEmpty(this string value) - { - return string.IsNullOrEmpty(value); - } - - /// Checks if a string contains null, empty or white space. - public static bool IsBlank(this string val) - { - return val.IsNullOrWhiteSpace() || val.IsNullOrEmpty(); - } - - /// Checks if a string is null and returns an empty string if it is. - public static string OrEmpty(this string val) - { - return val ?? string.Empty; - } - - /// - /// Shortens a string to the specified maximum length. If the string's length - /// is less than the maxLength, the original string is returned. - /// - public static string Shorten(this string val, int maxLength) - { - if (val.IsBlank()) return val; - return val.Length <= maxLength ? val : val.Substring(0, maxLength); - } - - /// Slices a string from the start index to the end index. - /// The sliced string. - public static string Slice(this string val, int startIndex, int endIndex) - { - if (val.IsBlank()) throw new ArgumentNullException(nameof(val), "Value cannot be null or empty."); - - if (startIndex < 0 || startIndex > val.Length - 1) - throw new ArgumentOutOfRangeException(nameof(startIndex)); - - // If the end index is negative, it will be counted from the end of the string. - endIndex = endIndex < 0 ? val.Length + endIndex : endIndex; - - if (endIndex < 0 || endIndex < startIndex || endIndex > val.Length) - throw new ArgumentOutOfRangeException(nameof(endIndex)); - - return val.Substring(startIndex, endIndex - startIndex); - } - } +using System; + +namespace TripleA.Extensions +{ + public static class StringExtensions + { + /// Checks if a string is Null or white space + public static bool IsNullOrWhiteSpace(this string val) + { + return string.IsNullOrWhiteSpace(val); + } + + /// Checks if a string is Null or empty + public static bool IsNullOrEmpty(this string value) + { + return string.IsNullOrEmpty(value); + } + + /// Checks if a string contains null, empty or white space. + public static bool IsBlank(this string val) + { + return val.IsNullOrWhiteSpace() || val.IsNullOrEmpty(); + } + + /// Checks if a string is null and returns an empty string if it is. + public static string OrEmpty(this string val) + { + return val ?? string.Empty; + } + + /// + /// Shortens a string to the specified maximum length. If the string's length + /// is less than the maxLength, the original string is returned. + /// + public static string Shorten(this string val, int maxLength) + { + if (val.IsBlank()) return val; + return val.Length <= maxLength ? val : val.Substring(0, maxLength); + } + + /// Slices a string from the start index to the end index. + /// The sliced string. + public static string Slice(this string val, int startIndex, int endIndex) + { + if (val.IsBlank()) throw new ArgumentNullException(nameof(val), "Value cannot be null or empty."); + + if (startIndex < 0 || startIndex > val.Length - 1) + throw new ArgumentOutOfRangeException(nameof(startIndex)); + + // If the end index is negative, it will be counted from the end of the string. + endIndex = endIndex < 0 ? val.Length + endIndex : endIndex; + + if (endIndex < 0 || endIndex < startIndex || endIndex > val.Length) + throw new ArgumentOutOfRangeException(nameof(endIndex)); + + return val.Substring(startIndex, endIndex - startIndex); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/StringExtensions.cs.meta b/Runtime/Extensions/StringExtensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/StringExtensions.cs.meta rename to Runtime/Extensions/StringExtensions.cs.meta index 8d494e4..e78ce0a 100644 --- a/Assets/TripleA/Extensions/StringExtensions.cs.meta +++ b/Runtime/Extensions/StringExtensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 19dab5d43cfe4b56b834e56f4460a60b +fileFormatVersion: 2 +guid: 19dab5d43cfe4b56b834e56f4460a60b timeCreated: 1723626555 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/TransformExtensions.cs b/Runtime/Extensions/TransformExtensions.cs similarity index 98% rename from Assets/TripleA/Extensions/TransformExtensions.cs rename to Runtime/Extensions/TransformExtensions.cs index 08620d3..6e7d589 100644 --- a/Assets/TripleA/Extensions/TransformExtensions.cs +++ b/Runtime/Extensions/TransformExtensions.cs @@ -1,101 +1,101 @@ -using System; -using System.Collections.Generic; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace TripleA.Extensions -{ - public static class TransformExtensions - { - /// - /// Check if the transform is within a certain distance and optionally within a certain angle (FOV) from the target transform. - /// - /// The transform to check. - /// The target transform to compare the distance and optional angle with. - /// The maximum distance allowed between the two transforms. - /// The maximum allowed angle between the transform's forward vector and the direction to the target (default is 360). - /// True if the transform is within range and angle (if provided) of the target, false otherwise. - public static bool InRangeOf(this Transform source, Transform target, float maxDistance, float maxAngle = 360f) { - Vector3 directionToTarget = (target.position - source.position).With(y: 0); - return directionToTarget.magnitude <= maxDistance && Vector3.Angle(source.forward, directionToTarget) <= maxAngle / 2; - } - - /// - /// Retrieves all the children of a given Transform. - /// - /// - /// This method can be used with LINQ to perform operations on all child Transforms. For example, - /// you could use it to find all children with a specific tag, to disable all children, etc. - /// Transform implements IEnumerable and the GetEnumerator method which returns an IEnumerator of all its children. - /// - /// The Transform to retrieve children from. - /// An IEnumerable<Transform> containing all the child Transforms of the parent. - public static IEnumerable Children(this Transform parent) { - foreach (Transform child in parent) { - yield return child; - } - } - - /// - /// Resets transform's position, scale and rotation - /// - /// Transform to use - public static void Reset(this Transform transform) { - transform.position = Vector3.zero; - transform.localRotation = Quaternion.identity; - transform.localScale = Vector3.one; - } - - /// - /// Destroys all child game objects of the given transform. - /// - /// The Transform whose child game objects are to be destroyed. - public static void DestroyChildren(this Transform parent) { - parent.ForEveryChild(child => Object.Destroy(child.gameObject)); - } - - /// - /// Immediately destroys all child game objects of the given transform. - /// - /// The Transform whose child game objects are to be immediately destroyed. - public static void DestroyChildrenImmediate(this Transform parent) { - parent.ForEveryChild(child => Object.DestroyImmediate(child.gameObject)); - } - - /// - /// Enables all child game objects of the given transform. - /// - /// The Transform whose child game objects are to be enabled. - public static void EnableChildren(this Transform parent) { - parent.ForEveryChild(child => child.gameObject.SetActive(true)); - } - - /// - /// Disables all child game objects of the given transform. - /// - /// The Transform whose child game objects are to be disabled. - public static void DisableChildren(this Transform parent) { - parent.ForEveryChild(child => child.gameObject.SetActive(false)); - } - - /// - /// Executes a specified action for each child of a given transform. - /// - /// The parent transform. - /// The action to be performed on each child. - /// - /// This method iterates over all child transforms in reverse order and executes a given action on them. - /// The action is a delegate that takes a Transform as parameter. - /// - public static void ForEveryChild(this Transform parent, System.Action action) { - for (var i = parent.childCount - 1; i >= 0; i--) { - action(parent.GetChild(i)); - } - } - - [Obsolete("Renamed to ForEveryChild")] - static void PerformActionOnChildren(this Transform parent, System.Action action) { - parent.ForEveryChild(action); - } - } +using System; +using System.Collections.Generic; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace TripleA.Extensions +{ + public static class TransformExtensions + { + /// + /// Check if the transform is within a certain distance and optionally within a certain angle (FOV) from the target transform. + /// + /// The transform to check. + /// The target transform to compare the distance and optional angle with. + /// The maximum distance allowed between the two transforms. + /// The maximum allowed angle between the transform's forward vector and the direction to the target (default is 360). + /// True if the transform is within range and angle (if provided) of the target, false otherwise. + public static bool InRangeOf(this Transform source, Transform target, float maxDistance, float maxAngle = 360f) { + Vector3 directionToTarget = (target.position - source.position).With(y: 0); + return directionToTarget.magnitude <= maxDistance && Vector3.Angle(source.forward, directionToTarget) <= maxAngle / 2; + } + + /// + /// Retrieves all the children of a given Transform. + /// + /// + /// This method can be used with LINQ to perform operations on all child Transforms. For example, + /// you could use it to find all children with a specific tag, to disable all children, etc. + /// Transform implements IEnumerable and the GetEnumerator method which returns an IEnumerator of all its children. + /// + /// The Transform to retrieve children from. + /// An IEnumerable<Transform> containing all the child Transforms of the parent. + public static IEnumerable Children(this Transform parent) { + foreach (Transform child in parent) { + yield return child; + } + } + + /// + /// Resets transform's position, scale and rotation + /// + /// Transform to use + public static void Reset(this Transform transform) { + transform.position = Vector3.zero; + transform.localRotation = Quaternion.identity; + transform.localScale = Vector3.one; + } + + /// + /// Destroys all child game objects of the given transform. + /// + /// The Transform whose child game objects are to be destroyed. + public static void DestroyChildren(this Transform parent) { + parent.ForEveryChild(child => Object.Destroy(child.gameObject)); + } + + /// + /// Immediately destroys all child game objects of the given transform. + /// + /// The Transform whose child game objects are to be immediately destroyed. + public static void DestroyChildrenImmediate(this Transform parent) { + parent.ForEveryChild(child => Object.DestroyImmediate(child.gameObject)); + } + + /// + /// Enables all child game objects of the given transform. + /// + /// The Transform whose child game objects are to be enabled. + public static void EnableChildren(this Transform parent) { + parent.ForEveryChild(child => child.gameObject.SetActive(true)); + } + + /// + /// Disables all child game objects of the given transform. + /// + /// The Transform whose child game objects are to be disabled. + public static void DisableChildren(this Transform parent) { + parent.ForEveryChild(child => child.gameObject.SetActive(false)); + } + + /// + /// Executes a specified action for each child of a given transform. + /// + /// The parent transform. + /// The action to be performed on each child. + /// + /// This method iterates over all child transforms in reverse order and executes a given action on them. + /// The action is a delegate that takes a Transform as parameter. + /// + public static void ForEveryChild(this Transform parent, System.Action action) { + for (var i = parent.childCount - 1; i >= 0; i--) { + action(parent.GetChild(i)); + } + } + + [Obsolete("Renamed to ForEveryChild")] + static void PerformActionOnChildren(this Transform parent, System.Action action) { + parent.ForEveryChild(action); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/TransformExtensions.cs.meta b/Runtime/Extensions/TransformExtensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/TransformExtensions.cs.meta rename to Runtime/Extensions/TransformExtensions.cs.meta index 94ba04b..5a481c4 100644 --- a/Assets/TripleA/Extensions/TransformExtensions.cs.meta +++ b/Runtime/Extensions/TransformExtensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 9a17f20a8bb24251b692f1aa8d18209c +fileFormatVersion: 2 +guid: 9a17f20a8bb24251b692f1aa8d18209c timeCreated: 1723626331 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector2Extensions.cs b/Runtime/Extensions/Vector2Extensions.cs similarity index 97% rename from Assets/TripleA/Extensions/Vector2Extensions.cs rename to Runtime/Extensions/Vector2Extensions.cs index 5605d11..a4ec8b2 100644 --- a/Assets/TripleA/Extensions/Vector2Extensions.cs +++ b/Runtime/Extensions/Vector2Extensions.cs @@ -1,296 +1,296 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public static class Vector2Extensions - { - #region Swap - - /// - /// Swaps and returns the x and y values of the original Vector2. - /// - public static Vector2 Swap(this Vector2 vector) - { - return new Vector2(vector.y, vector.x); - } - - /// - /// Swaps the x and y values of the original Vector2 and assigns the result to the original Vector2. - /// - public static void SwapThis(this ref Vector2 vector) - { - vector = vector.Swap(); - } - - #endregion Swap - - #region With - - /// - /// Creates and returns a new Vector2 with the specified x and y values or the same values as the original vector if no - /// new values are provided. - /// - public static Vector2 With(this Vector2 vector, float? x = null, float? y = null) - { - return new Vector2(x ?? vector.x, y ?? vector.y); - } - - /// - /// Sets the x and y values of the original Vector2. - /// - public static void Set(this ref Vector2 vector, float? x = null, float? y = null) - { - vector = vector.With(x, y); - } - - #endregion With - - #region Math Operations - - /// - /// Adds and returns the specified x and y values to the original Vector2. - /// - public static Vector2 Add(this Vector2 vector, float x = 0, float y = 0) - { - return new Vector2(vector.x + x, vector.y + y); - } - - /// - /// Adds the specified x and y values to the original Vector2 and assigns the result to the original Vector2. - /// - public static void AddToThis(this ref Vector2 vector, float x = 0, float y = 0) - { - vector = vector.Add(x, y); - } - - /// - /// Subtracts and returns the specified x and y values to the original Vector2. - /// - public static Vector2 Subtract(this Vector2 vector, float x = 0, float y = 0) - { - return new Vector2(vector.x - x, vector.y - y); - } - - /// - /// Subtracts the specified x and y values to the original Vector2 and assigns the result to the original Vector2. - /// - public static void SubtractFromThis(this ref Vector2 vector, float x = 0, float y = 0) - { - vector = vector.Subtract(x, y); - } - - /// - /// Multiplies and returns the specified x and y values to the original Vector2. - /// - public static Vector2 Multiply(this Vector2 vector, float x = 1, float y = 1) - { - return new Vector2(vector.x * x, vector.y * y); - } - - /// - /// Multiplies the specified x and y values to the original Vector2 and assigns the result to the original Vector2. - /// - public static void MultiplyThisBy(this ref Vector2 vector, float x = 1, float y = 1) - { - vector = vector.Multiply(x, y); - } - - /// - /// Divides and returns the specified x and y values to the original Vector2. - /// - public static Vector2 Divide(this Vector2 vector, float x = 1, float y = 1) - { - return new Vector2(vector.x / x, vector.y / y); - } - - /// - /// Divides the specified x and y values to the original Vector2 and assigns the result to the original Vector2. - /// - public static void DivideThisBy(this ref Vector2 vector, float x = 1, float y = 1) - { - vector = vector.Divide(x, y); - } - - /// - /// Divides two Vector2 objects component-wise. - /// - /// - /// For each component in v0 (x, y), it is divided by the corresponding component in v1 if the component in v1 is - /// not zero. - /// Otherwise, the component in v0 remains unchanged. - /// - /// - /// Use 'ComponentDivide' to scale a game object proportionally: - /// - /// myObject.transform.localScale = originalScale.ComponentDivide(targetDimensions); - /// - /// This scales the object size to fit within the target dimensions while maintaining its original proportions. - /// - /// The Vector2 object that this method extends. - /// The Vector2 object by which v0 is divided. - /// A new Vector3 object resulting from the component-wise division. - public static Vector2 ComponentDivide(this Vector2 v0, Vector2 v1) - { - return new Vector2( - v1.x != 0 ? v0.x / v1.x : v0.x, - v1.y != 0 ? v0.y / v1.y : v0.y); - } - - /// - /// Multiplies two Vector3 objects component-wise. - /// - /// - /// For each component in v0 (x, y), it is multiplied by the corresponding component in v1 if the component in v1 is - /// not zero. - /// Otherwise, the component in v0 remains unchanged. - /// - /// - /// Use 'ComponentMultiply' to scale a game object proportionally: - /// - /// myObject.transform.localScale = originalScale.ComponentMultiply(targetDimensions); - /// - /// This scales the object size to fit within the target dimensions while maintaining its original proportions. - /// - /// The Vector2 object that this method extends. - /// The Vector2 object by which v0 is multiplied. - /// A new Vector3 object resulting from the component-wise multiplication. - public static Vector2 ComponentMultiply(this Vector2 v0, Vector2 v1) - { - return new Vector2( - v1.x != 0 ? v0.x * v1.x : v0.x, - v1.y != 0 ? v0.y * v1.y : v0.y); - } - - /// - /// Rounds and returns the Vector to the nearest integer according to the specified conditions. - /// By default, rounds all the values to the nearest integer. - /// - public static Vector2 Round(this Vector2 vector, bool shouldRoundX = true, bool shouldRoundY = true) - { - return new Vector2(shouldRoundX ? Mathf.Round(vector.x) : vector.x, - shouldRoundY ? Mathf.Round(vector.y) : vector.y); - } - - /// - /// Rounds the Vector to the nearest integer according to the specified conditions. - /// By default, rounds all the values to the nearest integer. - /// - public static void RoundThis(this ref Vector2 vector, bool shouldRoundX = true, bool shouldRoundY = true) - { - vector = vector.Round(shouldRoundX, shouldRoundY); - } - - /// - /// Clamps and returns the Vector to the specified min and max values. - /// - public static Vector2 Clamp(this Vector2 vector, float min, float max) - { - return new Vector2( - Mathf.Clamp(vector.x, min, max), - Mathf.Clamp(vector.y, min, max)); - } - - /// - /// Clamps the Vector to the specified min and max values and assigns the result to the original Vector2. - /// - public static void ClampThis(this ref Vector2 vector, float min, float max) - { - vector = vector.Clamp(min, max); - } - - /// - /// Clamps the x value to the specified min and max values and returns the result. - /// - public static Vector2 ClampX(this Vector2 vector, float min, float max) - { - return new Vector2(vector.x, Mathf.Clamp(vector.y, min, max)); - } - - /// - /// Clamps the x value to the specified min and max values and assigns the result to the original Vector2. - /// - public static void ClampThisX(this ref Vector2 vector, float min, float max) - { - vector = vector.ClampX(min, max); - } - - /// - /// Clamps the y value to the specified min and max values and returns the result. - /// - public static Vector2 ClampY(this Vector2 vector, float min, float max) - { - return new Vector2(vector.x, Mathf.Clamp(vector.y, min, max)); - } - - /// - /// Clamps the y value to the specified min and max values and assigns the result to the original Vector2. - /// - public static void ClampThisY(this ref Vector2 vector, float min, float max) - { - vector = vector.ClampY(min, max); - } - - - /// - /// Lerps the x value of the vector and returns the result - /// - public static Vector2 LerpX(this Vector2 vector, float x, float t) - { - return vector.With(Mathf.Lerp(vector.x, x, t)); - } - - /// - /// Lerps the x value of the vector and assigns the result to the original vector - /// - public static void LerpThisX(this ref Vector2 vector, float x, float t) - { - vector = vector.LerpX(x, t); - } - - /// - /// Lerps the y value of the vector and returns the result - /// - public static Vector2 LerpY(this Vector2 vector, float y, float t) - { - return vector.With(y: Mathf.Lerp(vector.y, y, t)); - } - - /// - /// Lerps the y value of the vector and assigns the result to the original vector - /// - public static void LerpThisY(this ref Vector2 vector, float y, float t) - { - vector = vector.LerpY(y, t); - } - - #endregion Math Operations - - #region Conversion - - /// - /// Converts the vector 2 to a vector 3 with a y value of 0. - /// - public static Vector3 ToVector3WithoutY(this Vector2 vector) - { - return new Vector3(vector.x, 0, vector.y); - } - - /// - /// Converts the vector 2 to a vector 3 with a x value of 0. - /// - public static Vector3 ToVector3WithoutX(this Vector2 vector) - { - return new Vector3(0, vector.x, vector.y); - } - - /// - /// Converts the vector 2 to a vector 3 with a z value of 0. - /// - public static Vector3 ToVector3WithoutZ(this Vector2 vector) - { - return new Vector3(vector.x, vector.y, 0); - } - - #endregion Conversion - } +using UnityEngine; + +namespace TripleA.Extensions +{ + public static class Vector2Extensions + { + #region Swap + + /// + /// Swaps and returns the x and y values of the original Vector2. + /// + public static Vector2 Swap(this Vector2 vector) + { + return new Vector2(vector.y, vector.x); + } + + /// + /// Swaps the x and y values of the original Vector2 and assigns the result to the original Vector2. + /// + public static void SwapThis(this ref Vector2 vector) + { + vector = vector.Swap(); + } + + #endregion Swap + + #region With + + /// + /// Creates and returns a new Vector2 with the specified x and y values or the same values as the original vector if no + /// new values are provided. + /// + public static Vector2 With(this Vector2 vector, float? x = null, float? y = null) + { + return new Vector2(x ?? vector.x, y ?? vector.y); + } + + /// + /// Sets the x and y values of the original Vector2. + /// + public static void Set(this ref Vector2 vector, float? x = null, float? y = null) + { + vector = vector.With(x, y); + } + + #endregion With + + #region Math Operations + + /// + /// Adds and returns the specified x and y values to the original Vector2. + /// + public static Vector2 Add(this Vector2 vector, float x = 0, float y = 0) + { + return new Vector2(vector.x + x, vector.y + y); + } + + /// + /// Adds the specified x and y values to the original Vector2 and assigns the result to the original Vector2. + /// + public static void AddToThis(this ref Vector2 vector, float x = 0, float y = 0) + { + vector = vector.Add(x, y); + } + + /// + /// Subtracts and returns the specified x and y values to the original Vector2. + /// + public static Vector2 Subtract(this Vector2 vector, float x = 0, float y = 0) + { + return new Vector2(vector.x - x, vector.y - y); + } + + /// + /// Subtracts the specified x and y values to the original Vector2 and assigns the result to the original Vector2. + /// + public static void SubtractFromThis(this ref Vector2 vector, float x = 0, float y = 0) + { + vector = vector.Subtract(x, y); + } + + /// + /// Multiplies and returns the specified x and y values to the original Vector2. + /// + public static Vector2 Multiply(this Vector2 vector, float x = 1, float y = 1) + { + return new Vector2(vector.x * x, vector.y * y); + } + + /// + /// Multiplies the specified x and y values to the original Vector2 and assigns the result to the original Vector2. + /// + public static void MultiplyThisBy(this ref Vector2 vector, float x = 1, float y = 1) + { + vector = vector.Multiply(x, y); + } + + /// + /// Divides and returns the specified x and y values to the original Vector2. + /// + public static Vector2 Divide(this Vector2 vector, float x = 1, float y = 1) + { + return new Vector2(vector.x / x, vector.y / y); + } + + /// + /// Divides the specified x and y values to the original Vector2 and assigns the result to the original Vector2. + /// + public static void DivideThisBy(this ref Vector2 vector, float x = 1, float y = 1) + { + vector = vector.Divide(x, y); + } + + /// + /// Divides two Vector2 objects component-wise. + /// + /// + /// For each component in v0 (x, y), it is divided by the corresponding component in v1 if the component in v1 is + /// not zero. + /// Otherwise, the component in v0 remains unchanged. + /// + /// + /// Use 'ComponentDivide' to scale a game object proportionally: + /// + /// myObject.transform.localScale = originalScale.ComponentDivide(targetDimensions); + /// + /// This scales the object size to fit within the target dimensions while maintaining its original proportions. + /// + /// The Vector2 object that this method extends. + /// The Vector2 object by which v0 is divided. + /// A new Vector3 object resulting from the component-wise division. + public static Vector2 ComponentDivide(this Vector2 v0, Vector2 v1) + { + return new Vector2( + v1.x != 0 ? v0.x / v1.x : v0.x, + v1.y != 0 ? v0.y / v1.y : v0.y); + } + + /// + /// Multiplies two Vector3 objects component-wise. + /// + /// + /// For each component in v0 (x, y), it is multiplied by the corresponding component in v1 if the component in v1 is + /// not zero. + /// Otherwise, the component in v0 remains unchanged. + /// + /// + /// Use 'ComponentMultiply' to scale a game object proportionally: + /// + /// myObject.transform.localScale = originalScale.ComponentMultiply(targetDimensions); + /// + /// This scales the object size to fit within the target dimensions while maintaining its original proportions. + /// + /// The Vector2 object that this method extends. + /// The Vector2 object by which v0 is multiplied. + /// A new Vector3 object resulting from the component-wise multiplication. + public static Vector2 ComponentMultiply(this Vector2 v0, Vector2 v1) + { + return new Vector2( + v1.x != 0 ? v0.x * v1.x : v0.x, + v1.y != 0 ? v0.y * v1.y : v0.y); + } + + /// + /// Rounds and returns the Vector to the nearest integer according to the specified conditions. + /// By default, rounds all the values to the nearest integer. + /// + public static Vector2 Round(this Vector2 vector, bool shouldRoundX = true, bool shouldRoundY = true) + { + return new Vector2(shouldRoundX ? Mathf.Round(vector.x) : vector.x, + shouldRoundY ? Mathf.Round(vector.y) : vector.y); + } + + /// + /// Rounds the Vector to the nearest integer according to the specified conditions. + /// By default, rounds all the values to the nearest integer. + /// + public static void RoundThis(this ref Vector2 vector, bool shouldRoundX = true, bool shouldRoundY = true) + { + vector = vector.Round(shouldRoundX, shouldRoundY); + } + + /// + /// Clamps and returns the Vector to the specified min and max values. + /// + public static Vector2 Clamp(this Vector2 vector, float min, float max) + { + return new Vector2( + Mathf.Clamp(vector.x, min, max), + Mathf.Clamp(vector.y, min, max)); + } + + /// + /// Clamps the Vector to the specified min and max values and assigns the result to the original Vector2. + /// + public static void ClampThis(this ref Vector2 vector, float min, float max) + { + vector = vector.Clamp(min, max); + } + + /// + /// Clamps the x value to the specified min and max values and returns the result. + /// + public static Vector2 ClampX(this Vector2 vector, float min, float max) + { + return new Vector2(vector.x, Mathf.Clamp(vector.y, min, max)); + } + + /// + /// Clamps the x value to the specified min and max values and assigns the result to the original Vector2. + /// + public static void ClampThisX(this ref Vector2 vector, float min, float max) + { + vector = vector.ClampX(min, max); + } + + /// + /// Clamps the y value to the specified min and max values and returns the result. + /// + public static Vector2 ClampY(this Vector2 vector, float min, float max) + { + return new Vector2(vector.x, Mathf.Clamp(vector.y, min, max)); + } + + /// + /// Clamps the y value to the specified min and max values and assigns the result to the original Vector2. + /// + public static void ClampThisY(this ref Vector2 vector, float min, float max) + { + vector = vector.ClampY(min, max); + } + + + /// + /// Lerps the x value of the vector and returns the result + /// + public static Vector2 LerpX(this Vector2 vector, float x, float t) + { + return vector.With(Mathf.Lerp(vector.x, x, t)); + } + + /// + /// Lerps the x value of the vector and assigns the result to the original vector + /// + public static void LerpThisX(this ref Vector2 vector, float x, float t) + { + vector = vector.LerpX(x, t); + } + + /// + /// Lerps the y value of the vector and returns the result + /// + public static Vector2 LerpY(this Vector2 vector, float y, float t) + { + return vector.With(y: Mathf.Lerp(vector.y, y, t)); + } + + /// + /// Lerps the y value of the vector and assigns the result to the original vector + /// + public static void LerpThisY(this ref Vector2 vector, float y, float t) + { + vector = vector.LerpY(y, t); + } + + #endregion Math Operations + + #region Conversion + + /// + /// Converts the vector 2 to a vector 3 with a y value of 0. + /// + public static Vector3 ToVector3WithoutY(this Vector2 vector) + { + return new Vector3(vector.x, 0, vector.y); + } + + /// + /// Converts the vector 2 to a vector 3 with a x value of 0. + /// + public static Vector3 ToVector3WithoutX(this Vector2 vector) + { + return new Vector3(0, vector.x, vector.y); + } + + /// + /// Converts the vector 2 to a vector 3 with a z value of 0. + /// + public static Vector3 ToVector3WithoutZ(this Vector2 vector) + { + return new Vector3(vector.x, vector.y, 0); + } + + #endregion Conversion + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector2Extensions.cs.meta b/Runtime/Extensions/Vector2Extensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/Vector2Extensions.cs.meta rename to Runtime/Extensions/Vector2Extensions.cs.meta index 2b0544a..7083970 100644 --- a/Assets/TripleA/Extensions/Vector2Extensions.cs.meta +++ b/Runtime/Extensions/Vector2Extensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 928b2acf81cf439cb5160cf4ed6777e3 +fileFormatVersion: 2 +guid: 928b2acf81cf439cb5160cf4ed6777e3 timeCreated: 1723050406 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector2Math.cs b/Runtime/Extensions/Vector2Math.cs similarity index 97% rename from Assets/TripleA/Extensions/Vector2Math.cs rename to Runtime/Extensions/Vector2Math.cs index 1b6d4ac..943e65f 100644 --- a/Assets/TripleA/Extensions/Vector2Math.cs +++ b/Runtime/Extensions/Vector2Math.cs @@ -1,89 +1,89 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public class Vector2Math - { - /// - /// Calculates the dot product of a vector and a normalized direction. - /// - /// The vector to project. - /// The direction vector to project onto. - /// The dot product of the vector and the direction. - public static float GetDotProduct(Vector2 vector, Vector2 direction) - { - return Vector2.Dot(vector, direction.normalized); - } - - /// - /// Removes the component of a vector that is in the direction of a given vector. - /// - /// The vector from which to remove the component. - /// The direction vector whose component should be removed. - /// The vector with the specified direction removed. - public static Vector2 RemoveDotVector(Vector2 vector, Vector2 direction) - { - direction.Normalize(); - return vector - direction * Vector2.Dot(vector, direction); - } - - /// - /// Extracts and returns the component of a vector that is in the direction of a given vector. - /// - /// The vector from which to extract the component. - /// The direction vector to extract along. - /// The component of the vector in the direction of the given vector. - public static Vector2 ExtractDotVector(Vector2 vector, Vector2 direction) - { - direction.Normalize(); - return direction * Vector2.Dot(vector, direction); - } - - /// - /// Rotates a vector onto a plane defined by a normal vector using a specified up direction. - /// - /// The vector to be rotated onto the plane. - /// The normal vector of the target plane. - /// The current 'up' direction used to determine the rotation. - /// The vector after being rotated onto the specified plane. - public static Vector2 RotateVectorOntoPlane(Vector2 vector, Vector2 planeNormal, Vector2 upDirection) - { - // Calculate rotation; - var rotation = Quaternion.FromToRotation(upDirection, planeNormal); - - // Apply rotation to vector; - vector = rotation * vector; - - return vector; - } - - /// - /// Projects a given point onto a line defined by a starting position and direction vector. - /// - /// The starting position of the line. - /// The direction vector of the line, which should be normalized. - /// The point to project onto the line. - /// The projected point on the line closest to the original point. - public static Vector2 ProjectPointOntoLine(Vector2 lineStartPosition, Vector2 lineDirection, Vector2 point) - { - var projectLine = point - lineStartPosition; - var dotProduct = Vector2.Dot(projectLine, lineDirection); - - return lineStartPosition + lineDirection * dotProduct; - } - - /// - /// Increments a vector toward a target vector at a specified speed over a given time interval. - /// - /// The current vector to be incremented. - /// The speed at which to move towards the target vector. - /// The time interval over which to move. - /// The target vector to approach. - /// The new vector incremented toward the target vector by the specified speed and time interval. - public static Vector2 IncrementVectorTowardTargetVector(Vector2 currentVector, float speed, float deltaTime, - Vector2 targetVector) - { - return Vector2.MoveTowards(currentVector, targetVector, speed * deltaTime); - } - } +using UnityEngine; + +namespace TripleA.Extensions +{ + public class Vector2Math + { + /// + /// Calculates the dot product of a vector and a normalized direction. + /// + /// The vector to project. + /// The direction vector to project onto. + /// The dot product of the vector and the direction. + public static float GetDotProduct(Vector2 vector, Vector2 direction) + { + return Vector2.Dot(vector, direction.normalized); + } + + /// + /// Removes the component of a vector that is in the direction of a given vector. + /// + /// The vector from which to remove the component. + /// The direction vector whose component should be removed. + /// The vector with the specified direction removed. + public static Vector2 RemoveDotVector(Vector2 vector, Vector2 direction) + { + direction.Normalize(); + return vector - direction * Vector2.Dot(vector, direction); + } + + /// + /// Extracts and returns the component of a vector that is in the direction of a given vector. + /// + /// The vector from which to extract the component. + /// The direction vector to extract along. + /// The component of the vector in the direction of the given vector. + public static Vector2 ExtractDotVector(Vector2 vector, Vector2 direction) + { + direction.Normalize(); + return direction * Vector2.Dot(vector, direction); + } + + /// + /// Rotates a vector onto a plane defined by a normal vector using a specified up direction. + /// + /// The vector to be rotated onto the plane. + /// The normal vector of the target plane. + /// The current 'up' direction used to determine the rotation. + /// The vector after being rotated onto the specified plane. + public static Vector2 RotateVectorOntoPlane(Vector2 vector, Vector2 planeNormal, Vector2 upDirection) + { + // Calculate rotation; + var rotation = Quaternion.FromToRotation(upDirection, planeNormal); + + // Apply rotation to vector; + vector = rotation * vector; + + return vector; + } + + /// + /// Projects a given point onto a line defined by a starting position and direction vector. + /// + /// The starting position of the line. + /// The direction vector of the line, which should be normalized. + /// The point to project onto the line. + /// The projected point on the line closest to the original point. + public static Vector2 ProjectPointOntoLine(Vector2 lineStartPosition, Vector2 lineDirection, Vector2 point) + { + var projectLine = point - lineStartPosition; + var dotProduct = Vector2.Dot(projectLine, lineDirection); + + return lineStartPosition + lineDirection * dotProduct; + } + + /// + /// Increments a vector toward a target vector at a specified speed over a given time interval. + /// + /// The current vector to be incremented. + /// The speed at which to move towards the target vector. + /// The time interval over which to move. + /// The target vector to approach. + /// The new vector incremented toward the target vector by the specified speed and time interval. + public static Vector2 IncrementVectorTowardTargetVector(Vector2 currentVector, float speed, float deltaTime, + Vector2 targetVector) + { + return Vector2.MoveTowards(currentVector, targetVector, speed * deltaTime); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector2Math.cs.meta b/Runtime/Extensions/Vector2Math.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/Vector2Math.cs.meta rename to Runtime/Extensions/Vector2Math.cs.meta index acfae48..b9a3219 100644 --- a/Assets/TripleA/Extensions/Vector2Math.cs.meta +++ b/Runtime/Extensions/Vector2Math.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: d12a97515ce14f4d83a75a573acbd35c +fileFormatVersion: 2 +guid: d12a97515ce14f4d83a75a573acbd35c timeCreated: 1723627202 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector3Extensions.cs b/Runtime/Extensions/Vector3Extensions.cs similarity index 97% rename from Assets/TripleA/Extensions/Vector3Extensions.cs rename to Runtime/Extensions/Vector3Extensions.cs index 29fc005..9eb2d37 100644 --- a/Assets/TripleA/Extensions/Vector3Extensions.cs +++ b/Runtime/Extensions/Vector3Extensions.cs @@ -1,367 +1,367 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public static class Vector3Extensions - { - #region With - - /// - /// Creates and returns a new vector with the specified x, y, and z values or the same values as the original vector if - /// no new values are provided. - /// - public static Vector3 With(this Vector3 vector, float? x = null, float? y = null, float? z = null) - { - return new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z); - } - - /// - /// Assigns the specified x, y, and z values to the original vector. - /// - public static void Set(this ref Vector3 vector, float? x = null, float? y = null, float? z = null) - { - vector = new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z); - } - - #endregion With - - #region Math Operations - - /// - /// Adds the specified x, y, and z values to the original vector and returns the result. - /// - public static Vector3 Add(this Vector3 vector, float x = 0, float y = 0, float z = 0) - { - return new Vector3(vector.x + x, vector.y + y, vector.z + z); - } - - /// - /// Adds the specified x, y, and z values to the original vector and assigns the result to the original vector. - /// - public static void AddToThis(this ref Vector3 vector, float x = 0, float y = 0, float z = 0) - { - vector = vector.Add(x, y, z); - } - - /// - /// Subtracts the specified x, y, and z values from the original vector and returns the result. - /// - public static Vector3 Subtract(this Vector3 vector, float x = 0, float y = 0, float z = 0) - { - return new Vector3(vector.x - x, vector.y - y, vector.z - z); - } - - /// - /// Subtracts the specified x, y, and z values from the original vector and assigns the result to the original vector. - /// - public static void SubtractFromThis(this ref Vector3 vector, float x = 0, float y = 0, float z = 0) - { - vector = vector.Subtract(x, y, z); - } - - /// - /// Multiplies the specified x, y, and z values by the original vector and returns the result. - /// - public static Vector3 Multiply(this Vector3 vector, float x = 1, float y = 1, float z = 1) - { - return new Vector3(vector.x * x, vector.y * y, vector.z * z); - } - - /// - /// Multiplies the specified x, y, and z values by the original vector and assigns the result to the original vector. - /// - public static void MultiplyThisBy(this ref Vector3 vector, float x = 1, float y = 1, float z = 1) - { - vector = vector.Multiply(x, y, z); - } - - /// - /// Divides the specified x, y, and z values by the original vector and returns the result. - /// - public static Vector3 Divide(this Vector3 vector, float x = 1, float y = 1, float z = 1) - { - return new Vector3(vector.x / x, vector.y / y, vector.z / z); - } - - /// - /// Divides the specified x, y, and z values by the original vector and assigns the result to the original vector. - /// - public static void DivideThisBy(this ref Vector3 vector, float x = 1, float y = 1, float z = 1) - { - vector = vector.Divide(x, y, z); - } - - /// - /// Divides two Vector3 objects component-wise. - /// - /// - /// For each component in v0 (x, y, z), it is divided by the corresponding component in v1 if the component in v1 is - /// not zero. - /// Otherwise, the component in v0 remains unchanged. - /// - /// - /// Use 'ComponentDivide' to scale a game object proportionally: - /// - /// myObject.transform.localScale = originalScale.ComponentDivide(targetDimensions); - /// - /// This scales the object size to fit within the target dimensions while maintaining its original proportions. - /// - /// The Vector3 object that this method extends. - /// The Vector3 object by which v0 is divided. - /// A new Vector3 object resulting from the component-wise division. - public static Vector3 ComponentDivide(this Vector3 v0, Vector3 v1) - { - return new Vector3( - v1.x != 0 ? v0.x / v1.x : v0.x, - v1.y != 0 ? v0.y / v1.y : v0.y, - v1.z != 0 ? v0.z / v1.z : v0.z); - } - - /// - /// Multiplies two Vector3 objects component-wise. - /// - /// - /// For each component in v0 (x, y, z), it is multiplied by the corresponding component in v1 if the component in v1 is - /// not zero. - /// Otherwise, the component in v0 remains unchanged. - /// - /// - /// Use 'ComponentMultiply' to scale a game object proportionally: - /// - /// myObject.transform.localScale = originalScale.ComponentMultiply(targetDimensions); - /// - /// This scales the object size to fit within the target dimensions while maintaining its original proportions. - /// - /// The Vector3 object that this method extends. - /// The Vector3 object by which v0 is multiplied. - /// A new Vector3 object resulting from the component-wise multiplication. - public static Vector3 ComponentMultiply(this Vector3 v0, Vector3 v1) - { - return new Vector3( - v1.x != 0 ? v0.x * v1.x : v0.x, - v1.y != 0 ? v0.y * v1.y : v0.y, - v1.z != 0 ? v0.z * v1.z : v0.z); - } - - /// - /// Rounds the Vector to the nearest integer according to the specified conditions and returns the result. - /// By default, rounds all the values to the nearest integer. - /// - public static Vector3 Round(this Vector3 vector, bool shouldRoundX = true, bool shouldRoundY = true, - bool shouldRoundZ = true) - { - return new Vector3(shouldRoundX ? Mathf.RoundToInt(vector.x) : vector.x, - shouldRoundY ? Mathf.RoundToInt(vector.y) : vector.y, - shouldRoundZ ? Mathf.RoundToInt(vector.z) : vector.z); - } - - /// - /// Rounds the Vector to the nearest integer according to the specified conditions and assigns the result to the - /// original vector. - /// By default, rounds all the values to the nearest integer. - /// - public static void RoundThis(this ref Vector3 vector, bool shouldRoundX = true, bool shouldRoundY = true, - bool shouldRoundZ = true) - { - vector = vector.Round(shouldRoundX, shouldRoundY, shouldRoundZ); - } - - /// - /// Clamps the vector to the specified min and max values and returns the result - /// - public static Vector3 Clamp(this Vector3 vector, float min, float max) - { - return new Vector3( - Mathf.Clamp(vector.x, min, max), - Mathf.Clamp(vector.y, min, max), - Mathf.Clamp(vector.z, min, max)); - } - - - /// - /// Clamps the vector to the specified min and max values and assigns the result to the original vector - /// - public static void ClampThis(this ref Vector3 vector, float min, float max) - { - vector = vector.Clamp(min, max); - } - - /// - /// Clamps the x value to the specified min and max values and returns the result - /// - public static Vector3 ClampX(this Vector3 vector, float min, float max) - { - return vector.With(Mathf.Clamp(vector.x, min, max)); - } - - /// - /// Clamps the x value to the specified min and max values and assigns the result to the original vector - /// - public static void ClampThisX(this ref Vector3 vector, float min, float max) - { - vector = vector.ClampX(min, max); - } - - /// - /// Clamps the y value to the specified min and max values and returns the result. - /// - public static Vector3 ClampY(this Vector3 vector, float min, float max) - { - return vector.With(y: Mathf.Clamp(vector.y, min, max)); - } - - /// - /// Clamps the y value to the specified min and max values and assigns the result to the original vector. - /// - public static void ClampThisY(this ref Vector3 vector, float min, float max) - { - vector = vector.ClampY(min, max); - } - - /// - /// Clamps the z value to the specified min and max values and returns the result. - /// - public static Vector3 ClampZ(this Vector3 vector, float min, float max) - { - return vector.With(z: Mathf.Clamp(vector.z, min, max)); - } - - /// - /// Clamps the z value to the specified min and max values and assigns the result to the original vector. - /// - public static void ClampThisZ(this ref Vector3 vector, float min, float max) - { - vector = vector.ClampZ(min, max); - } - - /// - /// Lerps the x value of the vector and returns the result. - /// - public static Vector3 LerpX(this Vector3 vector, float x, float t) - { - return vector.With(Mathf.Lerp(vector.x, x, t)); - } - - /// - /// Lerps the x value of the vector and assigns the result to the original vector - /// - public static void LerpThisX(this ref Vector3 vector, float x, float t) - { - vector = vector.LerpX(x, t); - } - - /// - /// Lerps the y value of the vector and returns the result. - /// - public static Vector3 LerpY(this Vector3 vector, float y, float t) - { - return vector.With(y: Mathf.Lerp(vector.y, y, t)); - } - - /// - /// Lerps the y value of the vector and assigns the result to the original vector. - /// - public static void LerpThisY(this ref Vector3 vector, float y, float t) - { - vector = vector.LerpY(y, t); - } - - /// - /// Lerps the z value of the vector and returns the result. - /// - public static Vector3 LerpZ(this Vector3 vector, float z, float t) - { - return vector.With(z: Mathf.Lerp(vector.z, z, t)); - } - - /// - /// Lerps the z value of the vector and assigns the result to the original vector. - /// - public static void LerpThisZ(this ref Vector3 vector, float z, float t) - { - vector = vector.LerpZ(z, t); - } - - #endregion Math Operations - - #region Conversion To Vector2 - - /// - /// Converts a vector 3 with an x component to a vector2 without an x component with y at x and z at y. - /// - public static Vector2 ToVector2IgnoreX(this Vector3 vector) - { - return new Vector2(vector.y, vector.z); - } - - /// - /// Converts a vector 3 with a y component to a vector2 without a y component with x at y and z at x. - /// - public static Vector2 ToVector2IgnoreY(this Vector3 vector) - { - return new Vector2(vector.x, vector.z); - } - - /// - /// Converts a vector with a Z component to a vector without a Z component with x at x and y at y. - /// - public static Vector2 ToVector2IgnoreZ(this Vector3 vector) - { - return new Vector2(vector.x, vector.y); - } - - #endregion Conversion To Vector2 - - #region Swap - - /// - /// Switches the x and y values of the vector and returns the result. - /// - public static Vector3 SwapXAndY(this Vector3 vector) - { - return new Vector3(vector.y, vector.x, vector.z); - } - - /// - /// Switches the x and y values of the vector and assigns the result to the original vector. - /// - public static void SwapThisXAndY(this ref Vector3 vector) - { - vector = vector.SwapXAndY(); - } - - /// - /// Switches the y and z values of the vector and returns the result. - /// - public static Vector3 SwapYAndZ(this Vector3 vector) - { - return new Vector3(vector.x, vector.z, vector.y); - } - - /// - /// Switches the y and z values of the vector and assigns the result to the original vector. - /// - public static void SwapThisYAndZ(this ref Vector3 vector) - { - vector = vector.SwapYAndZ(); - } - - /// - /// Switches the x and z values of the vector and returns the result. - /// - public static Vector3 SwapXAndZ(this Vector3 vector) - { - return new Vector3(vector.z, vector.x, vector.y); - } - - /// - /// Switches the x and z values of the vector and assigns the result to the original vector. - /// - public static void SwapThisXAndZ(this ref Vector3 vector) - { - vector = vector.SwapXAndZ(); - } - - #endregion Swap - } +using UnityEngine; + +namespace TripleA.Extensions +{ + public static class Vector3Extensions + { + #region With + + /// + /// Creates and returns a new vector with the specified x, y, and z values or the same values as the original vector if + /// no new values are provided. + /// + public static Vector3 With(this Vector3 vector, float? x = null, float? y = null, float? z = null) + { + return new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z); + } + + /// + /// Assigns the specified x, y, and z values to the original vector. + /// + public static void Set(this ref Vector3 vector, float? x = null, float? y = null, float? z = null) + { + vector = new Vector3(x ?? vector.x, y ?? vector.y, z ?? vector.z); + } + + #endregion With + + #region Math Operations + + /// + /// Adds the specified x, y, and z values to the original vector and returns the result. + /// + public static Vector3 Add(this Vector3 vector, float x = 0, float y = 0, float z = 0) + { + return new Vector3(vector.x + x, vector.y + y, vector.z + z); + } + + /// + /// Adds the specified x, y, and z values to the original vector and assigns the result to the original vector. + /// + public static void AddToThis(this ref Vector3 vector, float x = 0, float y = 0, float z = 0) + { + vector = vector.Add(x, y, z); + } + + /// + /// Subtracts the specified x, y, and z values from the original vector and returns the result. + /// + public static Vector3 Subtract(this Vector3 vector, float x = 0, float y = 0, float z = 0) + { + return new Vector3(vector.x - x, vector.y - y, vector.z - z); + } + + /// + /// Subtracts the specified x, y, and z values from the original vector and assigns the result to the original vector. + /// + public static void SubtractFromThis(this ref Vector3 vector, float x = 0, float y = 0, float z = 0) + { + vector = vector.Subtract(x, y, z); + } + + /// + /// Multiplies the specified x, y, and z values by the original vector and returns the result. + /// + public static Vector3 Multiply(this Vector3 vector, float x = 1, float y = 1, float z = 1) + { + return new Vector3(vector.x * x, vector.y * y, vector.z * z); + } + + /// + /// Multiplies the specified x, y, and z values by the original vector and assigns the result to the original vector. + /// + public static void MultiplyThisBy(this ref Vector3 vector, float x = 1, float y = 1, float z = 1) + { + vector = vector.Multiply(x, y, z); + } + + /// + /// Divides the specified x, y, and z values by the original vector and returns the result. + /// + public static Vector3 Divide(this Vector3 vector, float x = 1, float y = 1, float z = 1) + { + return new Vector3(vector.x / x, vector.y / y, vector.z / z); + } + + /// + /// Divides the specified x, y, and z values by the original vector and assigns the result to the original vector. + /// + public static void DivideThisBy(this ref Vector3 vector, float x = 1, float y = 1, float z = 1) + { + vector = vector.Divide(x, y, z); + } + + /// + /// Divides two Vector3 objects component-wise. + /// + /// + /// For each component in v0 (x, y, z), it is divided by the corresponding component in v1 if the component in v1 is + /// not zero. + /// Otherwise, the component in v0 remains unchanged. + /// + /// + /// Use 'ComponentDivide' to scale a game object proportionally: + /// + /// myObject.transform.localScale = originalScale.ComponentDivide(targetDimensions); + /// + /// This scales the object size to fit within the target dimensions while maintaining its original proportions. + /// + /// The Vector3 object that this method extends. + /// The Vector3 object by which v0 is divided. + /// A new Vector3 object resulting from the component-wise division. + public static Vector3 ComponentDivide(this Vector3 v0, Vector3 v1) + { + return new Vector3( + v1.x != 0 ? v0.x / v1.x : v0.x, + v1.y != 0 ? v0.y / v1.y : v0.y, + v1.z != 0 ? v0.z / v1.z : v0.z); + } + + /// + /// Multiplies two Vector3 objects component-wise. + /// + /// + /// For each component in v0 (x, y, z), it is multiplied by the corresponding component in v1 if the component in v1 is + /// not zero. + /// Otherwise, the component in v0 remains unchanged. + /// + /// + /// Use 'ComponentMultiply' to scale a game object proportionally: + /// + /// myObject.transform.localScale = originalScale.ComponentMultiply(targetDimensions); + /// + /// This scales the object size to fit within the target dimensions while maintaining its original proportions. + /// + /// The Vector3 object that this method extends. + /// The Vector3 object by which v0 is multiplied. + /// A new Vector3 object resulting from the component-wise multiplication. + public static Vector3 ComponentMultiply(this Vector3 v0, Vector3 v1) + { + return new Vector3( + v1.x != 0 ? v0.x * v1.x : v0.x, + v1.y != 0 ? v0.y * v1.y : v0.y, + v1.z != 0 ? v0.z * v1.z : v0.z); + } + + /// + /// Rounds the Vector to the nearest integer according to the specified conditions and returns the result. + /// By default, rounds all the values to the nearest integer. + /// + public static Vector3 Round(this Vector3 vector, bool shouldRoundX = true, bool shouldRoundY = true, + bool shouldRoundZ = true) + { + return new Vector3(shouldRoundX ? Mathf.RoundToInt(vector.x) : vector.x, + shouldRoundY ? Mathf.RoundToInt(vector.y) : vector.y, + shouldRoundZ ? Mathf.RoundToInt(vector.z) : vector.z); + } + + /// + /// Rounds the Vector to the nearest integer according to the specified conditions and assigns the result to the + /// original vector. + /// By default, rounds all the values to the nearest integer. + /// + public static void RoundThis(this ref Vector3 vector, bool shouldRoundX = true, bool shouldRoundY = true, + bool shouldRoundZ = true) + { + vector = vector.Round(shouldRoundX, shouldRoundY, shouldRoundZ); + } + + /// + /// Clamps the vector to the specified min and max values and returns the result + /// + public static Vector3 Clamp(this Vector3 vector, float min, float max) + { + return new Vector3( + Mathf.Clamp(vector.x, min, max), + Mathf.Clamp(vector.y, min, max), + Mathf.Clamp(vector.z, min, max)); + } + + + /// + /// Clamps the vector to the specified min and max values and assigns the result to the original vector + /// + public static void ClampThis(this ref Vector3 vector, float min, float max) + { + vector = vector.Clamp(min, max); + } + + /// + /// Clamps the x value to the specified min and max values and returns the result + /// + public static Vector3 ClampX(this Vector3 vector, float min, float max) + { + return vector.With(Mathf.Clamp(vector.x, min, max)); + } + + /// + /// Clamps the x value to the specified min and max values and assigns the result to the original vector + /// + public static void ClampThisX(this ref Vector3 vector, float min, float max) + { + vector = vector.ClampX(min, max); + } + + /// + /// Clamps the y value to the specified min and max values and returns the result. + /// + public static Vector3 ClampY(this Vector3 vector, float min, float max) + { + return vector.With(y: Mathf.Clamp(vector.y, min, max)); + } + + /// + /// Clamps the y value to the specified min and max values and assigns the result to the original vector. + /// + public static void ClampThisY(this ref Vector3 vector, float min, float max) + { + vector = vector.ClampY(min, max); + } + + /// + /// Clamps the z value to the specified min and max values and returns the result. + /// + public static Vector3 ClampZ(this Vector3 vector, float min, float max) + { + return vector.With(z: Mathf.Clamp(vector.z, min, max)); + } + + /// + /// Clamps the z value to the specified min and max values and assigns the result to the original vector. + /// + public static void ClampThisZ(this ref Vector3 vector, float min, float max) + { + vector = vector.ClampZ(min, max); + } + + /// + /// Lerps the x value of the vector and returns the result. + /// + public static Vector3 LerpX(this Vector3 vector, float x, float t) + { + return vector.With(Mathf.Lerp(vector.x, x, t)); + } + + /// + /// Lerps the x value of the vector and assigns the result to the original vector + /// + public static void LerpThisX(this ref Vector3 vector, float x, float t) + { + vector = vector.LerpX(x, t); + } + + /// + /// Lerps the y value of the vector and returns the result. + /// + public static Vector3 LerpY(this Vector3 vector, float y, float t) + { + return vector.With(y: Mathf.Lerp(vector.y, y, t)); + } + + /// + /// Lerps the y value of the vector and assigns the result to the original vector. + /// + public static void LerpThisY(this ref Vector3 vector, float y, float t) + { + vector = vector.LerpY(y, t); + } + + /// + /// Lerps the z value of the vector and returns the result. + /// + public static Vector3 LerpZ(this Vector3 vector, float z, float t) + { + return vector.With(z: Mathf.Lerp(vector.z, z, t)); + } + + /// + /// Lerps the z value of the vector and assigns the result to the original vector. + /// + public static void LerpThisZ(this ref Vector3 vector, float z, float t) + { + vector = vector.LerpZ(z, t); + } + + #endregion Math Operations + + #region Conversion To Vector2 + + /// + /// Converts a vector 3 with an x component to a vector2 without an x component with y at x and z at y. + /// + public static Vector2 ToVector2IgnoreX(this Vector3 vector) + { + return new Vector2(vector.y, vector.z); + } + + /// + /// Converts a vector 3 with a y component to a vector2 without a y component with x at y and z at x. + /// + public static Vector2 ToVector2IgnoreY(this Vector3 vector) + { + return new Vector2(vector.x, vector.z); + } + + /// + /// Converts a vector with a Z component to a vector without a Z component with x at x and y at y. + /// + public static Vector2 ToVector2IgnoreZ(this Vector3 vector) + { + return new Vector2(vector.x, vector.y); + } + + #endregion Conversion To Vector2 + + #region Swap + + /// + /// Switches the x and y values of the vector and returns the result. + /// + public static Vector3 SwapXAndY(this Vector3 vector) + { + return new Vector3(vector.y, vector.x, vector.z); + } + + /// + /// Switches the x and y values of the vector and assigns the result to the original vector. + /// + public static void SwapThisXAndY(this ref Vector3 vector) + { + vector = vector.SwapXAndY(); + } + + /// + /// Switches the y and z values of the vector and returns the result. + /// + public static Vector3 SwapYAndZ(this Vector3 vector) + { + return new Vector3(vector.x, vector.z, vector.y); + } + + /// + /// Switches the y and z values of the vector and assigns the result to the original vector. + /// + public static void SwapThisYAndZ(this ref Vector3 vector) + { + vector = vector.SwapYAndZ(); + } + + /// + /// Switches the x and z values of the vector and returns the result. + /// + public static Vector3 SwapXAndZ(this Vector3 vector) + { + return new Vector3(vector.z, vector.x, vector.y); + } + + /// + /// Switches the x and z values of the vector and assigns the result to the original vector. + /// + public static void SwapThisXAndZ(this ref Vector3 vector) + { + vector = vector.SwapXAndZ(); + } + + #endregion Swap + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector3Extensions.cs.meta b/Runtime/Extensions/Vector3Extensions.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/Vector3Extensions.cs.meta rename to Runtime/Extensions/Vector3Extensions.cs.meta index 9afa178..9582187 100644 --- a/Assets/TripleA/Extensions/Vector3Extensions.cs.meta +++ b/Runtime/Extensions/Vector3Extensions.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 6b8d712ceb01483ea7206af65dbdee21 +fileFormatVersion: 2 +guid: 6b8d712ceb01483ea7206af65dbdee21 timeCreated: 1723048328 \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector3Math.cs b/Runtime/Extensions/Vector3Math.cs similarity index 98% rename from Assets/TripleA/Extensions/Vector3Math.cs rename to Runtime/Extensions/Vector3Math.cs index 6ad9f96..ec38c18 100644 --- a/Assets/TripleA/Extensions/Vector3Math.cs +++ b/Runtime/Extensions/Vector3Math.cs @@ -1,103 +1,103 @@ -using UnityEngine; - -namespace TripleA.Extensions -{ - public class Vector3Math - { - /// - /// Calculates the signed angle between two vectors on a plane defined by a normal vector. - /// - /// The first vector. - /// The second vector. - /// The normal vector of the plane on which to calculate the angle. - /// The signed angle between the vectors in degrees. - public static float GetAngle(Vector3 vector1, Vector3 vector2, Vector3 planeNormal) - { - var angle = Vector3.Angle(vector1, vector2); - var sign = Mathf.Sign(Vector3.Dot(planeNormal, Vector3.Cross(vector1, vector2))); - return angle * sign; - } - - /// - /// Calculates the dot product of a vector and a normalized direction. - /// - /// The vector to project. - /// The direction vector to project onto. - /// The dot product of the vector and the direction. - public static float GetDotProduct(Vector3 vector, Vector3 direction) - { - return Vector3.Dot(vector, direction.normalized); - } - - /// - /// Removes the component of a vector that is in the direction of a given vector. - /// - /// The vector from which to remove the component. - /// The direction vector whose component should be removed. - /// The vector with the specified direction removed. - public static Vector3 RemoveDotVector(Vector3 vector, Vector3 direction) - { - direction.Normalize(); - return vector - direction * Vector3.Dot(vector, direction); - } - - /// - /// Extracts and returns the component of a vector that is in the direction of a given vector. - /// - /// The vector from which to extract the component. - /// The direction vector to extract along. - /// The component of the vector in the direction of the given vector. - public static Vector3 ExtractDotVector(Vector3 vector, Vector3 direction) - { - direction.Normalize(); - return direction * Vector3.Dot(vector, direction); - } - - /// - /// Rotates a vector onto a plane defined by a normal vector using a specified up direction. - /// - /// The vector to be rotated onto the plane. - /// The normal vector of the target plane. - /// The current 'up' direction used to determine the rotation. - /// The vector after being rotated onto the specified plane. - public static Vector3 RotateVectorOntoPlane(Vector3 vector, Vector3 planeNormal, Vector3 upDirection) - { - // Calculate rotation; - var rotation = Quaternion.FromToRotation(upDirection, planeNormal); - - // Apply rotation to vector; - vector = rotation * vector; - - return vector; - } - - /// - /// Projects a given point onto a line defined by a starting position and direction vector. - /// - /// The starting position of the line. - /// The direction vector of the line, which should be normalized. - /// The point to project onto the line. - /// The projected point on the line closest to the original point. - public static Vector3 ProjectPointOntoLine(Vector3 lineStartPosition, Vector3 lineDirection, Vector3 point) - { - var projectLine = point - lineStartPosition; - var dotProduct = Vector3.Dot(projectLine, lineDirection); - - return lineStartPosition + lineDirection * dotProduct; - } - - /// - /// Increments a vector toward a target vector at a specified speed over a given time interval. - /// - /// The current vector to be incremented. - /// The speed at which to move towards the target vector. - /// The time interval over which to move. - /// The target vector to approach. - /// The new vector incremented toward the target vector by the specified speed and time interval. - public static Vector3 IncrementVectorTowardTargetVector(Vector3 currentVector, float speed, float deltaTime, - Vector3 targetVector) - { - return Vector3.MoveTowards(currentVector, targetVector, speed * deltaTime); - } - } +using UnityEngine; + +namespace TripleA.Extensions +{ + public class Vector3Math + { + /// + /// Calculates the signed angle between two vectors on a plane defined by a normal vector. + /// + /// The first vector. + /// The second vector. + /// The normal vector of the plane on which to calculate the angle. + /// The signed angle between the vectors in degrees. + public static float GetAngle(Vector3 vector1, Vector3 vector2, Vector3 planeNormal) + { + var angle = Vector3.Angle(vector1, vector2); + var sign = Mathf.Sign(Vector3.Dot(planeNormal, Vector3.Cross(vector1, vector2))); + return angle * sign; + } + + /// + /// Calculates the dot product of a vector and a normalized direction. + /// + /// The vector to project. + /// The direction vector to project onto. + /// The dot product of the vector and the direction. + public static float GetDotProduct(Vector3 vector, Vector3 direction) + { + return Vector3.Dot(vector, direction.normalized); + } + + /// + /// Removes the component of a vector that is in the direction of a given vector. + /// + /// The vector from which to remove the component. + /// The direction vector whose component should be removed. + /// The vector with the specified direction removed. + public static Vector3 RemoveDotVector(Vector3 vector, Vector3 direction) + { + direction.Normalize(); + return vector - direction * Vector3.Dot(vector, direction); + } + + /// + /// Extracts and returns the component of a vector that is in the direction of a given vector. + /// + /// The vector from which to extract the component. + /// The direction vector to extract along. + /// The component of the vector in the direction of the given vector. + public static Vector3 ExtractDotVector(Vector3 vector, Vector3 direction) + { + direction.Normalize(); + return direction * Vector3.Dot(vector, direction); + } + + /// + /// Rotates a vector onto a plane defined by a normal vector using a specified up direction. + /// + /// The vector to be rotated onto the plane. + /// The normal vector of the target plane. + /// The current 'up' direction used to determine the rotation. + /// The vector after being rotated onto the specified plane. + public static Vector3 RotateVectorOntoPlane(Vector3 vector, Vector3 planeNormal, Vector3 upDirection) + { + // Calculate rotation; + var rotation = Quaternion.FromToRotation(upDirection, planeNormal); + + // Apply rotation to vector; + vector = rotation * vector; + + return vector; + } + + /// + /// Projects a given point onto a line defined by a starting position and direction vector. + /// + /// The starting position of the line. + /// The direction vector of the line, which should be normalized. + /// The point to project onto the line. + /// The projected point on the line closest to the original point. + public static Vector3 ProjectPointOntoLine(Vector3 lineStartPosition, Vector3 lineDirection, Vector3 point) + { + var projectLine = point - lineStartPosition; + var dotProduct = Vector3.Dot(projectLine, lineDirection); + + return lineStartPosition + lineDirection * dotProduct; + } + + /// + /// Increments a vector toward a target vector at a specified speed over a given time interval. + /// + /// The current vector to be incremented. + /// The speed at which to move towards the target vector. + /// The time interval over which to move. + /// The target vector to approach. + /// The new vector incremented toward the target vector by the specified speed and time interval. + public static Vector3 IncrementVectorTowardTargetVector(Vector3 currentVector, float speed, float deltaTime, + Vector3 targetVector) + { + return Vector3.MoveTowards(currentVector, targetVector, speed * deltaTime); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Extensions/Vector3Math.cs.meta b/Runtime/Extensions/Vector3Math.cs.meta similarity index 97% rename from Assets/TripleA/Extensions/Vector3Math.cs.meta rename to Runtime/Extensions/Vector3Math.cs.meta index f1fbc64..f11c522 100644 --- a/Assets/TripleA/Extensions/Vector3Math.cs.meta +++ b/Runtime/Extensions/Vector3Math.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: b3064b6641a942ada82883f99d8781e4 +fileFormatVersion: 2 +guid: b3064b6641a942ada82883f99d8781e4 timeCreated: 1723627016 \ No newline at end of file diff --git a/Runtime/ImprovedTimer.meta b/Runtime/ImprovedTimer.meta new file mode 100644 index 0000000..e96e0b7 --- /dev/null +++ b/Runtime/ImprovedTimer.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3820d0a997791cb428fefee5014e4878 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TripleA/ImprovedTimer/Timer.cs b/Runtime/ImprovedTimer/Timer.cs similarity index 94% rename from Assets/TripleA/ImprovedTimer/Timer.cs rename to Runtime/ImprovedTimer/Timer.cs index e288956..3809e1f 100644 --- a/Assets/TripleA/ImprovedTimer/Timer.cs +++ b/Runtime/ImprovedTimer/Timer.cs @@ -1,93 +1,93 @@ -using System; -using UnityEngine; - -namespace TripleA.ImprovedTimer -{ - public abstract class Timer : IDisposable - { - protected float _initialTime; - - private bool m_disposed; - - public Action onTimerEnd = delegate { }; - public Action onTimerStart = delegate { }; - - public Timer(float value) - { - _initialTime = value; - } - - public float CurrentTime { get; protected set; } - public bool IsRunning { get; private set; } - - public float Progress => Mathf.Clamp01(CurrentTime / _initialTime); - public abstract bool IsFinished { get; protected set; } - - // call this to ensure deregistration of the timer - // when it is no longer needed - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - public abstract void Tick(); - - public void Start() - { - CurrentTime = _initialTime; - onTimerStart?.Invoke(); - - if (IsRunning) return; - IsRunning = true; - IsFinished = false; - TimerManager.RegisterTimer(this); - } - - public void Pause() - { - IsRunning = false; - } - - public void Resume() - { - IsRunning = true; - } - - public virtual void Reset() - { - CurrentTime = _initialTime; - IsRunning = false; - IsFinished = false; - } - - public virtual void Reset(float value) - { - _initialTime = value; - Reset(); - } - - public void Stop() - { - if (!IsRunning) return; - IsRunning = false; - TimerManager.DeregisterTimer(this); - onTimerEnd?.Invoke(); - } - - /// - /// Disposes of the timer. - /// Mathf.Clamp01(CurrentTime / _initialTime); + public abstract bool IsFinished { get; protected set; } + + // call this to ensure deregistration of the timer + // when it is no longer needed + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + public abstract void Tick(); + + public void Start() + { + CurrentTime = _initialTime; + onTimerStart?.Invoke(); + + if (IsRunning) return; + IsRunning = true; + IsFinished = false; + TimerManager.RegisterTimer(this); + } + + public void Pause() + { + IsRunning = false; + } + + public void Resume() + { + IsRunning = true; + } + + public virtual void Reset() + { + CurrentTime = _initialTime; + IsRunning = false; + IsFinished = false; + } + + public virtual void Reset(float value) + { + _initialTime = value; + Reset(); + } + + public void Stop() + { + if (!IsRunning) return; + IsRunning = false; + TimerManager.DeregisterTimer(this); + onTimerEnd?.Invoke(); + } + + /// + /// Disposes of the timer. + /// (ref currentPlayerLoop, 0)) - { - Debug.LogWarning( - "Improved Timers could not be initialised. Unable to register TimerManager in player loop."); - return; - } - - PlayerLoop.SetPlayerLoop(currentPlayerLoop); - // PlayerLoopUtils.PrintPlayerLoop(currentPlayerLoop); - -#if UNITY_EDITOR - EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; - EditorApplication.playModeStateChanged += OnPlayModeStateChanged; - - static void OnPlayModeStateChanged(PlayModeStateChange state) - { - if (state == PlayModeStateChange.ExitingPlayMode) - { - var currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); - RemoveTimerManager(ref currentPlayerLoop); - PlayerLoop.SetPlayerLoop(currentPlayerLoop); - - TimerManager.Clear(); - } - } -#endif - } - - private static void RemoveTimerManager(ref PlayerLoopSystem loop) - { - PlayerLoopUtils.RemoveSystem(ref loop, in m_s_timerSystem); - } - - private static bool InsertTimerManager(ref PlayerLoopSystem loop, int index) - { - m_s_timerSystem = new PlayerLoopSystem - { - type = typeof(TimerManager), - updateDelegate = TimerManager.UpdateTimers, - subSystemList = null - }; - - return PlayerLoopUtils.InsertSystem(ref loop, in m_s_timerSystem, index); - } - } +using TripleA.LowLevel; +using UnityEditor; +using UnityEngine; +using UnityEngine.LowLevel; +using UnityEngine.PlayerLoop; + +namespace TripleA.ImprovedTimer +{ + internal static class TimerBootstrapper + { + private static PlayerLoopSystem m_s_timerSystem; + + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] + internal static void Initialise() + { + var currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); + + if (!InsertTimerManager(ref currentPlayerLoop, 0)) + { + Debug.LogWarning( + "Improved Timers could not be initialised. Unable to register TimerManager in player loop."); + return; + } + + PlayerLoop.SetPlayerLoop(currentPlayerLoop); + // PlayerLoopUtils.PrintPlayerLoop(currentPlayerLoop); + +#if UNITY_EDITOR + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; + + static void OnPlayModeStateChanged(PlayModeStateChange state) + { + if (state == PlayModeStateChange.ExitingPlayMode) + { + var currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop(); + RemoveTimerManager(ref currentPlayerLoop); + PlayerLoop.SetPlayerLoop(currentPlayerLoop); + + TimerManager.Clear(); + } + } +#endif + } + + private static void RemoveTimerManager(ref PlayerLoopSystem loop) + { + PlayerLoopUtils.RemoveSystem(ref loop, in m_s_timerSystem); + } + + private static bool InsertTimerManager(ref PlayerLoopSystem loop, int index) + { + m_s_timerSystem = new PlayerLoopSystem + { + type = typeof(TimerManager), + updateDelegate = TimerManager.UpdateTimers, + subSystemList = null + }; + + return PlayerLoopUtils.InsertSystem(ref loop, in m_s_timerSystem, index); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/TimerBootstrapper.cs.meta b/Runtime/ImprovedTimer/TimerBootstrapper.cs.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/TimerBootstrapper.cs.meta rename to Runtime/ImprovedTimer/TimerBootstrapper.cs.meta index cd5f0af..a042a32 100644 --- a/Assets/TripleA/ImprovedTimer/TimerBootstrapper.cs.meta +++ b/Runtime/ImprovedTimer/TimerBootstrapper.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: a1495980ad534a05bffa46dcb96d72c3 +fileFormatVersion: 2 +guid: a1495980ad534a05bffa46dcb96d72c3 timeCreated: 1723805977 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/TimerManager.cs b/Runtime/ImprovedTimer/TimerManager.cs similarity index 96% rename from Assets/TripleA/ImprovedTimer/TimerManager.cs rename to Runtime/ImprovedTimer/TimerManager.cs index e109a14..0c1cce6 100644 --- a/Assets/TripleA/ImprovedTimer/TimerManager.cs +++ b/Runtime/ImprovedTimer/TimerManager.cs @@ -1,53 +1,53 @@ -using System.Collections.Generic; -using TripleA.Extensions; - -namespace TripleA.ImprovedTimer -{ - public static class TimerManager - { - private static readonly List m_S_Timers = new(); - private static readonly List m_S_Sweep = new(); - - /// - /// Registers a timer with the TimerManager. - /// - /// The timer to register. - public static void RegisterTimer(Timer timer) - { - m_S_Timers.Add(timer); - } - - /// - /// Removes a timer from the TimerManager's list of registered timers. - /// - /// The timer to deregister. - public static void DeregisterTimer(Timer timer) - { - m_S_Timers.Remove(timer); - } - - /// - /// Updates all registered timers by calling their Tick method. - /// - public static void UpdateTimers() - { - if (m_S_Timers.Count == 0) return; - - m_S_Sweep.RefreshWith(m_S_Timers); - - foreach (var timer in new List(m_S_Timers)) timer.Tick(); - } - - /// - /// Clears all registered timers from the TimerManager. - /// - public static void Clear() - { - m_S_Sweep.RefreshWith(m_S_Timers); - foreach (var timer in m_S_Sweep) timer.Dispose(); - - m_S_Sweep.Clear(); - m_S_Timers.Clear(); - } - } +using System.Collections.Generic; +using TripleA.Extensions; + +namespace TripleA.ImprovedTimer +{ + public static class TimerManager + { + private static readonly List m_S_Timers = new(); + private static readonly List m_S_Sweep = new(); + + /// + /// Registers a timer with the TimerManager. + /// + /// The timer to register. + public static void RegisterTimer(Timer timer) + { + m_S_Timers.Add(timer); + } + + /// + /// Removes a timer from the TimerManager's list of registered timers. + /// + /// The timer to deregister. + public static void DeregisterTimer(Timer timer) + { + m_S_Timers.Remove(timer); + } + + /// + /// Updates all registered timers by calling their Tick method. + /// + public static void UpdateTimers() + { + if (m_S_Timers.Count == 0) return; + + m_S_Sweep.RefreshWith(m_S_Timers); + + foreach (var timer in new List(m_S_Timers)) timer.Tick(); + } + + /// + /// Clears all registered timers from the TimerManager. + /// + public static void Clear() + { + m_S_Sweep.RefreshWith(m_S_Timers); + foreach (var timer in m_S_Sweep) timer.Dispose(); + + m_S_Sweep.Clear(); + m_S_Timers.Clear(); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/TimerManager.cs.meta b/Runtime/ImprovedTimer/TimerManager.cs.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/TimerManager.cs.meta rename to Runtime/ImprovedTimer/TimerManager.cs.meta index 37beb97..15f17a1 100644 --- a/Assets/TripleA/ImprovedTimer/TimerManager.cs.meta +++ b/Runtime/ImprovedTimer/TimerManager.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 7cea742612c04260a5cb285d78011ed6 +fileFormatVersion: 2 +guid: 7cea742612c04260a5cb285d78011ed6 timeCreated: 1723808229 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers.meta b/Runtime/ImprovedTimer/Timers.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/Timers.meta rename to Runtime/ImprovedTimer/Timers.meta index 89ef4f9..14c72d2 100644 --- a/Assets/TripleA/ImprovedTimer/Timers.meta +++ b/Runtime/ImprovedTimer/Timers.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 89624c92c1cd4e85ae2ea944137a4c04 +fileFormatVersion: 2 +guid: 89624c92c1cd4e85ae2ea944137a4c04 timeCreated: 1723814478 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs b/Runtime/ImprovedTimer/Timers/CountDownTimer.cs similarity index 95% rename from Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs rename to Runtime/ImprovedTimer/Timers/CountDownTimer.cs index cd9ac2f..52a416a 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs +++ b/Runtime/ImprovedTimer/Timers/CountDownTimer.cs @@ -1,26 +1,26 @@ -using UnityEngine; - -namespace TripleA.ImprovedTimer.Timers -{ - /// - /// A timer that counts down from a specified value to 0. - /// - public class CountDownTimer : Timer - { - public CountDownTimer(float value) : base(value) - { - } - - public override bool IsFinished { get; protected set; } - - public override void Tick() - { - if (IsRunning && CurrentTime >= 0) CurrentTime -= Time.deltaTime; - if (IsRunning && CurrentTime <= 0) - { - IsFinished = true; - Stop(); - } - } - } +using UnityEngine; + +namespace TripleA.ImprovedTimer.Timers +{ + /// + /// A timer that counts down from a specified value to 0. + /// + public class CountDownTimer : Timer + { + public CountDownTimer(float value) : base(value) + { + } + + public override bool IsFinished { get; protected set; } + + public override void Tick() + { + if (IsRunning && CurrentTime >= 0) CurrentTime -= Time.deltaTime; + if (IsRunning && CurrentTime <= 0) + { + IsFinished = true; + Stop(); + } + } + } } \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs.meta b/Runtime/ImprovedTimer/Timers/CountDownTimer.cs.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs.meta rename to Runtime/ImprovedTimer/Timers/CountDownTimer.cs.meta index 4eda1a0..75df0cd 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/CountDownTimer.cs.meta +++ b/Runtime/ImprovedTimer/Timers/CountDownTimer.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 11a91f1397ac401f9edc27b185dfc390 +fileFormatVersion: 2 +guid: 11a91f1397ac401f9edc27b185dfc390 timeCreated: 1723814420 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs b/Runtime/ImprovedTimer/Timers/FrequencyTimer.cs similarity index 95% rename from Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs rename to Runtime/ImprovedTimer/Timers/FrequencyTimer.cs index 3d3fb9a..ee09b02 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs +++ b/Runtime/ImprovedTimer/Timers/FrequencyTimer.cs @@ -1,51 +1,51 @@ -using System; -using UnityEngine; - -namespace TripleA.ImprovedTimer.Timers -{ - /// - /// A timer that ticks at a specified number of ticks per second. - /// - public class FrequencyTimer : Timer - { - private float m_timeThreshold; - public Action onTick = delegate { }; - - public FrequencyTimer(int ticksPerSecond) : base(0) - { - CalculateTimeThreshold(ticksPerSecond); - } - - public int TicksPerSecond { get; private set; } - - public override bool IsFinished { get; protected set; } - - public override void Tick() - { - if (IsRunning && CurrentTime >= m_timeThreshold) - { - CurrentTime -= m_timeThreshold; - onTick.Invoke(); - } - - if (IsRunning && CurrentTime < m_timeThreshold) CurrentTime += Time.deltaTime; - } - - public override void Reset() - { - CurrentTime = 0; - } - - public void Reset(int newTicksPerSecond) - { - CalculateTimeThreshold(newTicksPerSecond); - Reset(); - } - - private void CalculateTimeThreshold(int ticksPerSecond) - { - TicksPerSecond = ticksPerSecond; - m_timeThreshold = 1f / TicksPerSecond; - } - } +using System; +using UnityEngine; + +namespace TripleA.ImprovedTimer.Timers +{ + /// + /// A timer that ticks at a specified number of ticks per second. + /// + public class FrequencyTimer : Timer + { + private float m_timeThreshold; + public Action onTick = delegate { }; + + public FrequencyTimer(int ticksPerSecond) : base(0) + { + CalculateTimeThreshold(ticksPerSecond); + } + + public int TicksPerSecond { get; private set; } + + public override bool IsFinished { get; protected set; } + + public override void Tick() + { + if (IsRunning && CurrentTime >= m_timeThreshold) + { + CurrentTime -= m_timeThreshold; + onTick.Invoke(); + } + + if (IsRunning && CurrentTime < m_timeThreshold) CurrentTime += Time.deltaTime; + } + + public override void Reset() + { + CurrentTime = 0; + } + + public void Reset(int newTicksPerSecond) + { + CalculateTimeThreshold(newTicksPerSecond); + Reset(); + } + + private void CalculateTimeThreshold(int ticksPerSecond) + { + TicksPerSecond = ticksPerSecond; + m_timeThreshold = 1f / TicksPerSecond; + } + } } \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs.meta b/Runtime/ImprovedTimer/Timers/FrequencyTimer.cs.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs.meta rename to Runtime/ImprovedTimer/Timers/FrequencyTimer.cs.meta index 3d9d338..218ff60 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/FrequencyTimer.cs.meta +++ b/Runtime/ImprovedTimer/Timers/FrequencyTimer.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 8acb53bc771e4484b2dff2a8b2bd3153 +fileFormatVersion: 2 +guid: 8acb53bc771e4484b2dff2a8b2bd3153 timeCreated: 1723815506 \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs b/Runtime/ImprovedTimer/Timers/StopWatchTimer.cs similarity index 95% rename from Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs rename to Runtime/ImprovedTimer/Timers/StopWatchTimer.cs index c697cbf..8361d46 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs +++ b/Runtime/ImprovedTimer/Timers/StopWatchTimer.cs @@ -1,21 +1,21 @@ -using UnityEngine; - -namespace TripleA.ImprovedTimer.Timers -{ - /// - /// Timer that counts up from zero to infinity. Great for measuring durations. - /// - public class StopwatchTimer : Timer - { - public StopwatchTimer() : base(0) - { - } - - public override bool IsFinished { get; protected set; } - - public override void Tick() - { - if (IsRunning) CurrentTime += Time.deltaTime; - } - } +using UnityEngine; + +namespace TripleA.ImprovedTimer.Timers +{ + /// + /// Timer that counts up from zero to infinity. Great for measuring durations. + /// + public class StopwatchTimer : Timer + { + public StopwatchTimer() : base(0) + { + } + + public override bool IsFinished { get; protected set; } + + public override void Tick() + { + if (IsRunning) CurrentTime += Time.deltaTime; + } + } } \ No newline at end of file diff --git a/Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs.meta b/Runtime/ImprovedTimer/Timers/StopWatchTimer.cs.meta similarity index 97% rename from Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs.meta rename to Runtime/ImprovedTimer/Timers/StopWatchTimer.cs.meta index 0ec61ef..86d3bae 100644 --- a/Assets/TripleA/ImprovedTimer/Timers/StopWatchTimer.cs.meta +++ b/Runtime/ImprovedTimer/Timers/StopWatchTimer.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: abe70e1375d544a2913591d965e8932b +fileFormatVersion: 2 +guid: abe70e1375d544a2913591d965e8932b timeCreated: 1723816222 \ No newline at end of file diff --git a/Runtime/LowLevel.meta b/Runtime/LowLevel.meta new file mode 100644 index 0000000..aa7a66f --- /dev/null +++ b/Runtime/LowLevel.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6c163ad6c10daa0488702b0d7f5c8bab +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TripleA/LowLevel/PlayerLoopUtils.cs b/Runtime/LowLevel/PlayerLoopUtils.cs similarity index 97% rename from Assets/TripleA/LowLevel/PlayerLoopUtils.cs rename to Runtime/LowLevel/PlayerLoopUtils.cs index fa45d16..31046f6 100644 --- a/Assets/TripleA/LowLevel/PlayerLoopUtils.cs +++ b/Runtime/LowLevel/PlayerLoopUtils.cs @@ -1,93 +1,93 @@ -using System.Collections.Generic; -using System.Text; -using UnityEngine; -using UnityEngine.LowLevel; - -namespace TripleA.LowLevel -{ - public static class PlayerLoopUtils - { - /// - /// Inserts a new subsystem into the given Unity Player Loop at the given index. - /// - /// The type of the subsystem to insert. - /// The player loop to insert into. - /// The subsystem to insert. - /// The index at which to insert the subsystem. - public static bool InsertSystem(ref PlayerLoopSystem loop, in PlayerLoopSystem systemToInsert, int index) - { - if (loop.type != typeof(T)) return HandleSubSystemLoopForInsertion(ref loop, systemToInsert, index); - var playerLoopSystemList = new List(); - if (loop.subSystemList != null) playerLoopSystemList.AddRange(loop.subSystemList); - playerLoopSystemList.Insert(index, systemToInsert); - loop.subSystemList = playerLoopSystemList.ToArray(); - return true; - } - - - /// - /// Prints the Unity Player Loop to the console as a tree. - /// - /// The current player loop. - public static void PrintPlayerLoop(PlayerLoopSystem playerLoop) - { - StringBuilder sb = new(); - sb.AppendLine("Unity Player Loop"); - foreach (var loopSubSystem in playerLoop.subSystemList) PrintSubSystem(loopSubSystem, sb); - Debug.Log(sb.ToString()); - } - - public static void RemoveSystem(ref PlayerLoopSystem loop, in PlayerLoopSystem subSystemToRemove) - { - if (loop.subSystemList == null) return; - - var playerLoopSystemList = new List(loop.subSystemList); - for (var i = 0; i < playerLoopSystemList.Count; i++) - if (playerLoopSystemList[i].type == subSystemToRemove.type && - playerLoopSystemList[i].updateDelegate == subSystemToRemove.updateDelegate) - { - playerLoopSystemList.RemoveAt(i); - loop.subSystemList = playerLoopSystemList.ToArray(); - } - - HandleSubSystemLoopForRemoval(ref loop, subSystemToRemove); - } - - private static bool HandleSubSystemLoopForInsertion(ref PlayerLoopSystem loop, in PlayerLoopSystem subSystem, - int index) - { - if (loop.subSystemList == null || loop.subSystemList.Length == 0) return false; - - for (var i = 0; i < loop.subSystemList.Length; i++) - { - if (!InsertSystem(ref loop.subSystemList[i], subSystem, index)) continue; - return true; - } - - return false; - } - - private static void HandleSubSystemLoopForRemoval(ref PlayerLoopSystem loop, - in PlayerLoopSystem subSystemToRemove) - { - if (loop.subSystemList == null || loop.subSystemList.Length == 0) return; - - for (var i = 0; i < loop.subSystemList.Length; i++) - RemoveSystem(ref loop.subSystemList[i], subSystemToRemove); - } - - /// - /// Recursively prints the subsystems of the given loop. - /// - /// The current subsystem. - /// The StringBuilder to which to write the output. - /// The indentation level. Starts with 0. - private static void PrintSubSystem(PlayerLoopSystem system, StringBuilder sb, int level = 0) - { - sb.Append(' ', level * 2).AppendLine(system.type.ToString()); - if (system.subSystemList == null || system.subSystemList.Length == 0) return; - - foreach (var loopSubSystem in system.subSystemList) PrintSubSystem(loopSubSystem, sb, level + 1); - } - } +using System.Collections.Generic; +using System.Text; +using UnityEngine; +using UnityEngine.LowLevel; + +namespace TripleA.LowLevel +{ + public static class PlayerLoopUtils + { + /// + /// Inserts a new subsystem into the given Unity Player Loop at the given index. + /// + /// The type of the subsystem to insert. + /// The player loop to insert into. + /// The subsystem to insert. + /// The index at which to insert the subsystem. + public static bool InsertSystem(ref PlayerLoopSystem loop, in PlayerLoopSystem systemToInsert, int index) + { + if (loop.type != typeof(T)) return HandleSubSystemLoopForInsertion(ref loop, systemToInsert, index); + var playerLoopSystemList = new List(); + if (loop.subSystemList != null) playerLoopSystemList.AddRange(loop.subSystemList); + playerLoopSystemList.Insert(index, systemToInsert); + loop.subSystemList = playerLoopSystemList.ToArray(); + return true; + } + + + /// + /// Prints the Unity Player Loop to the console as a tree. + /// + /// The current player loop. + public static void PrintPlayerLoop(PlayerLoopSystem playerLoop) + { + StringBuilder sb = new(); + sb.AppendLine("Unity Player Loop"); + foreach (var loopSubSystem in playerLoop.subSystemList) PrintSubSystem(loopSubSystem, sb); + Debug.Log(sb.ToString()); + } + + public static void RemoveSystem(ref PlayerLoopSystem loop, in PlayerLoopSystem subSystemToRemove) + { + if (loop.subSystemList == null) return; + + var playerLoopSystemList = new List(loop.subSystemList); + for (var i = 0; i < playerLoopSystemList.Count; i++) + if (playerLoopSystemList[i].type == subSystemToRemove.type && + playerLoopSystemList[i].updateDelegate == subSystemToRemove.updateDelegate) + { + playerLoopSystemList.RemoveAt(i); + loop.subSystemList = playerLoopSystemList.ToArray(); + } + + HandleSubSystemLoopForRemoval(ref loop, subSystemToRemove); + } + + private static bool HandleSubSystemLoopForInsertion(ref PlayerLoopSystem loop, in PlayerLoopSystem subSystem, + int index) + { + if (loop.subSystemList == null || loop.subSystemList.Length == 0) return false; + + for (var i = 0; i < loop.subSystemList.Length; i++) + { + if (!InsertSystem(ref loop.subSystemList[i], subSystem, index)) continue; + return true; + } + + return false; + } + + private static void HandleSubSystemLoopForRemoval(ref PlayerLoopSystem loop, + in PlayerLoopSystem subSystemToRemove) + { + if (loop.subSystemList == null || loop.subSystemList.Length == 0) return; + + for (var i = 0; i < loop.subSystemList.Length; i++) + RemoveSystem(ref loop.subSystemList[i], subSystemToRemove); + } + + /// + /// Recursively prints the subsystems of the given loop. + /// + /// The current subsystem. + /// The StringBuilder to which to write the output. + /// The indentation level. Starts with 0. + private static void PrintSubSystem(PlayerLoopSystem system, StringBuilder sb, int level = 0) + { + sb.Append(' ', level * 2).AppendLine(system.type.ToString()); + if (system.subSystemList == null || system.subSystemList.Length == 0) return; + + foreach (var loopSubSystem in system.subSystemList) PrintSubSystem(loopSubSystem, sb, level + 1); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/LowLevel/PlayerLoopUtils.cs.meta b/Runtime/LowLevel/PlayerLoopUtils.cs.meta similarity index 97% rename from Assets/TripleA/LowLevel/PlayerLoopUtils.cs.meta rename to Runtime/LowLevel/PlayerLoopUtils.cs.meta index c915383..756338b 100644 --- a/Assets/TripleA/LowLevel/PlayerLoopUtils.cs.meta +++ b/Runtime/LowLevel/PlayerLoopUtils.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: c0ee09abaf0a429cbae79fb9a9b99ccc +fileFormatVersion: 2 +guid: c0ee09abaf0a429cbae79fb9a9b99ccc timeCreated: 1723806199 \ No newline at end of file diff --git a/Runtime/Observables.meta b/Runtime/Observables.meta new file mode 100644 index 0000000..b1a7eca --- /dev/null +++ b/Runtime/Observables.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 58813a0b62a599445904e8b48ec286f1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TripleA/Observables/Observable.cs b/Runtime/Observables/Observable.cs similarity index 95% rename from Assets/TripleA/Observables/Observable.cs rename to Runtime/Observables/Observable.cs index 72fa09e..d3590d0 100644 --- a/Assets/TripleA/Observables/Observable.cs +++ b/Runtime/Observables/Observable.cs @@ -1,66 +1,66 @@ -using System; -using UnityEngine; -using UnityEngine.Events; - -namespace TripleA.Observables -{ - [Serializable] - public class Observable - { - [SerializeField] private T value; - [SerializeField] private UnityEvent onValueChanged; - - public Observable(T value, UnityAction callback = null) - { - this.value = value; - onValueChanged = new UnityEvent(); - if (callback != null) onValueChanged.AddListener(callback); - } - - public T Value - { - get => value; - set => Set(value); - } - - public void AddListener(UnityAction callback) - { - if (callback == null) return; - if (onValueChanged == null) onValueChanged = new UnityEvent(); - onValueChanged.AddListener(callback); - } - - public void RemoveListener(UnityAction callback) - { - if (callback == null) return; - if (onValueChanged == null) return; - - onValueChanged.RemoveListener(callback); - } - - public void RemoveAllListeners() - { - if (onValueChanged == null) return; - onValueChanged.RemoveAllListeners(); - } - - public void Dispose() - { - RemoveAllListeners(); - onValueChanged = null; - value = default; - } - - public void Set(T newValue) - { - if (Equals(value, newValue)) return; - value = newValue; - Invoke(); - } - - public void Invoke() - { - onValueChanged.Invoke(value); - } - } +using System; +using UnityEngine; +using UnityEngine.Events; + +namespace TripleA.Observables +{ + [Serializable] + public class Observable + { + [SerializeField] private T value; + [SerializeField] private UnityEvent onValueChanged; + + public Observable(T value, UnityAction callback = null) + { + this.value = value; + onValueChanged = new UnityEvent(); + if (callback != null) onValueChanged.AddListener(callback); + } + + public T Value + { + get => value; + set => Set(value); + } + + public void AddListener(UnityAction callback) + { + if (callback == null) return; + if (onValueChanged == null) onValueChanged = new UnityEvent(); + onValueChanged.AddListener(callback); + } + + public void RemoveListener(UnityAction callback) + { + if (callback == null) return; + if (onValueChanged == null) return; + + onValueChanged.RemoveListener(callback); + } + + public void RemoveAllListeners() + { + if (onValueChanged == null) return; + onValueChanged.RemoveAllListeners(); + } + + public void Dispose() + { + RemoveAllListeners(); + onValueChanged = null; + value = default; + } + + public void Set(T newValue) + { + if (Equals(value, newValue)) return; + value = newValue; + Invoke(); + } + + public void Invoke() + { + onValueChanged.Invoke(value); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Observables/Observable.cs.meta b/Runtime/Observables/Observable.cs.meta similarity index 97% rename from Assets/TripleA/Observables/Observable.cs.meta rename to Runtime/Observables/Observable.cs.meta index 08e7314..2c08d05 100644 --- a/Assets/TripleA/Observables/Observable.cs.meta +++ b/Runtime/Observables/Observable.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 5ce73bd68b0d4efa9c103139ca284d11 +fileFormatVersion: 2 +guid: 5ce73bd68b0d4efa9c103139ca284d11 timeCreated: 1723469711 \ No newline at end of file diff --git a/Runtime/Singletons.meta b/Runtime/Singletons.meta new file mode 100644 index 0000000..9309043 --- /dev/null +++ b/Runtime/Singletons.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ba6f9f3a5dfe1f34caa13161bc2b42d3 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/TripleA/Singletons/GenericSingleton.cs b/Runtime/Singletons/GenericSingleton.cs similarity index 94% rename from Assets/TripleA/Singletons/GenericSingleton.cs rename to Runtime/Singletons/GenericSingleton.cs index 3f4f5ab..53f48d0 100644 --- a/Assets/TripleA/Singletons/GenericSingleton.cs +++ b/Runtime/Singletons/GenericSingleton.cs @@ -1,51 +1,51 @@ -using UnityEngine; - -namespace TripleA.Singletons -{ - public class GenericSingleton : MonoBehaviour where T : MonoBehaviour - { - protected static T instance; - public static bool HasInstance => instance != null; - - public static T Instance - { - get - { - if (instance == null) - { - instance = FindAnyObjectByType(); - if (instance == null) - { - var obj = new GameObject - { - name = typeof(T).Name + " Auto-Instantiated" - }; - instance = obj.AddComponent(); - } - } - - return instance; - } - } - - protected virtual void Awake() - { - InstantiateSingleton(); - } - - public static T TryGetInstance() - { - return HasInstance ? instance : null; - } - - protected virtual void InstantiateSingleton() - { - if (!Application.isPlaying) return; - - if (instance == null) - instance = this as T; - else - Destroy(gameObject); - } - } +using UnityEngine; + +namespace TripleA.Singletons +{ + public class GenericSingleton : MonoBehaviour where T : MonoBehaviour + { + protected static T instance; + public static bool HasInstance => instance != null; + + public static T Instance + { + get + { + if (instance == null) + { + instance = FindAnyObjectByType(); + if (instance == null) + { + var obj = new GameObject + { + name = typeof(T).Name + " Auto-Instantiated" + }; + instance = obj.AddComponent(); + } + } + + return instance; + } + } + + protected virtual void Awake() + { + InstantiateSingleton(); + } + + public static T TryGetInstance() + { + return HasInstance ? instance : null; + } + + protected virtual void InstantiateSingleton() + { + if (!Application.isPlaying) return; + + if (instance == null) + instance = this as T; + else + Destroy(gameObject); + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Singletons/GenericSingleton.cs.meta b/Runtime/Singletons/GenericSingleton.cs.meta similarity index 97% rename from Assets/TripleA/Singletons/GenericSingleton.cs.meta rename to Runtime/Singletons/GenericSingleton.cs.meta index 6d9165d..16755c2 100644 --- a/Assets/TripleA/Singletons/GenericSingleton.cs.meta +++ b/Runtime/Singletons/GenericSingleton.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 54550fa04e154ea6ade0fab45f932545 +fileFormatVersion: 2 +guid: 54550fa04e154ea6ade0fab45f932545 timeCreated: 1723139026 \ No newline at end of file diff --git a/Assets/TripleA/Singletons/PersistentSingleton.cs b/Runtime/Singletons/PersistentSingleton.cs similarity index 94% rename from Assets/TripleA/Singletons/PersistentSingleton.cs rename to Runtime/Singletons/PersistentSingleton.cs index 1b9f7d1..8de2641 100644 --- a/Assets/TripleA/Singletons/PersistentSingleton.cs +++ b/Runtime/Singletons/PersistentSingleton.cs @@ -1,27 +1,27 @@ -using UnityEngine; - -namespace TripleA.Singletons -{ - public class PersistentSingleton : GenericSingleton where T : MonoBehaviour - { - public bool AutoUnparentOnAwake = true; - - protected override void InstantiateSingleton() - { - if (!Application.isPlaying) return; - - if (AutoUnparentOnAwake) - transform.SetParent(null); - - if (instance == null) - { - instance = this as T; - DontDestroyOnLoad(gameObject); - } - else - { - Destroy(gameObject); - } - } - } +using UnityEngine; + +namespace TripleA.Singletons +{ + public class PersistentSingleton : GenericSingleton where T : MonoBehaviour + { + public bool AutoUnparentOnAwake = true; + + protected override void InstantiateSingleton() + { + if (!Application.isPlaying) return; + + if (AutoUnparentOnAwake) + transform.SetParent(null); + + if (instance == null) + { + instance = this as T; + DontDestroyOnLoad(gameObject); + } + else + { + Destroy(gameObject); + } + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Singletons/PersistentSingleton.cs.meta b/Runtime/Singletons/PersistentSingleton.cs.meta similarity index 97% rename from Assets/TripleA/Singletons/PersistentSingleton.cs.meta rename to Runtime/Singletons/PersistentSingleton.cs.meta index 081cf92..e2958f3 100644 --- a/Assets/TripleA/Singletons/PersistentSingleton.cs.meta +++ b/Runtime/Singletons/PersistentSingleton.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: 59de709101e74748b3f3fe46414c9870 +fileFormatVersion: 2 +guid: 59de709101e74748b3f3fe46414c9870 timeCreated: 1723139477 \ No newline at end of file diff --git a/Assets/TripleA/Singletons/RegulatorSingleton.cs b/Runtime/Singletons/RegulatorSingleton.cs similarity index 95% rename from Assets/TripleA/Singletons/RegulatorSingleton.cs rename to Runtime/Singletons/RegulatorSingleton.cs index 9ed4921..4fef1b2 100644 --- a/Assets/TripleA/Singletons/RegulatorSingleton.cs +++ b/Runtime/Singletons/RegulatorSingleton.cs @@ -1,52 +1,52 @@ -using UnityEngine; - -namespace TripleA.Singletons -{ - public class RegulatorSingleton : MonoBehaviour where T : MonoBehaviour - { - protected static T instance; - public static bool HasInstance => instance != null; - - public float InitializationTime { get; private set; } - - public static T Instance - { - get - { - if (instance == null) - { - instance = FindAnyObjectByType(); - if (instance == null) - { - var go = new GameObject(typeof(T).Name + " Auto-Generated"); - go.hideFlags = HideFlags.HideAndDontSave; - instance = go.AddComponent(); - } - } - - return instance; - } - } - - protected virtual void Awake() - { - InstantiateSingleton(); - } - - protected virtual void InstantiateSingleton() - { - if (!Application.isPlaying) return; - InitializationTime = Time.time; - DontDestroyOnLoad(gameObject); - - var otherInstances = FindObjectsByType(FindObjectsSortMode.None); - - foreach (var other in otherInstances) - if (other.GetComponent>().InitializationTime <= InitializationTime) - Destroy(other.gameObject); - - if (instance == null) - instance = this as T; - } - } +using UnityEngine; + +namespace TripleA.Singletons +{ + public class RegulatorSingleton : MonoBehaviour where T : MonoBehaviour + { + protected static T instance; + public static bool HasInstance => instance != null; + + public float InitializationTime { get; private set; } + + public static T Instance + { + get + { + if (instance == null) + { + instance = FindAnyObjectByType(); + if (instance == null) + { + var go = new GameObject(typeof(T).Name + " Auto-Generated"); + go.hideFlags = HideFlags.HideAndDontSave; + instance = go.AddComponent(); + } + } + + return instance; + } + } + + protected virtual void Awake() + { + InstantiateSingleton(); + } + + protected virtual void InstantiateSingleton() + { + if (!Application.isPlaying) return; + InitializationTime = Time.time; + DontDestroyOnLoad(gameObject); + + var otherInstances = FindObjectsByType(FindObjectsSortMode.None); + + foreach (var other in otherInstances) + if (other.GetComponent>().InitializationTime <= InitializationTime) + Destroy(other.gameObject); + + if (instance == null) + instance = this as T; + } + } } \ No newline at end of file diff --git a/Assets/TripleA/Singletons/RegulatorSingleton.cs.meta b/Runtime/Singletons/RegulatorSingleton.cs.meta similarity index 97% rename from Assets/TripleA/Singletons/RegulatorSingleton.cs.meta rename to Runtime/Singletons/RegulatorSingleton.cs.meta index 6ed5a85..6748eb3 100644 --- a/Assets/TripleA/Singletons/RegulatorSingleton.cs.meta +++ b/Runtime/Singletons/RegulatorSingleton.cs.meta @@ -1,3 +1,3 @@ -fileFormatVersion: 2 -guid: db654eea0187494b97ee5c241bab24cc +fileFormatVersion: 2 +guid: db654eea0187494b97ee5c241bab24cc timeCreated: 1723139922 \ No newline at end of file diff --git a/Runtime/com.TripleA.Utils.asmdef b/Runtime/com.TripleA.Utils.asmdef new file mode 100644 index 0000000..88cc8af --- /dev/null +++ b/Runtime/com.TripleA.Utils.asmdef @@ -0,0 +1,14 @@ +{ + "name": "com.TripleAStudios.Utils", + "rootNamespace": "TripleA", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Runtime/com.TripleA.Utils.asmdef.meta b/Runtime/com.TripleA.Utils.asmdef.meta new file mode 100644 index 0000000..8ee6388 --- /dev/null +++ b/Runtime/com.TripleA.Utils.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f56d77a89ab140640a16deaf02f7e1b4 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json new file mode 100644 index 0000000..e8ab94a --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "com.TripleAStudios.Utils", + "description": "Essential Custom Utilities I use for my Unity Projects", + "version": "1.0.0", + "displayName": "Utils", + "unity": "2021.3", + "documentationUrl": "https://github.com/Triple-A-Studios/Utils.git", + "changelogUrl": "https://github.com/Triple-A-Studios/Utils.git", + "licenseUrl": "https://github.com/Triple-A-Studios/Utils.git", + "dependencies": {}, + "keywords": ["utilities", "essentials", "utils"], + "author": { + "name": "Triple-A-Studios", + "email": "ali.qadir.007@outlook.com", + "url": "https://github.com/Triple-A-Studios" + } +} \ No newline at end of file diff --git a/package.json.meta b/package.json.meta new file mode 100644 index 0000000..6c97117 --- /dev/null +++ b/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0537307d438f3cd498f0b3b00058cf56 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: