├── .gitignore
├── LICENSE
├── LICENSE.meta
├── README.md
├── README.md.meta
├── Scenes.meta
├── Scenes
├── Misc.unity
└── Misc.unity.meta
├── Scripts.meta
├── Scripts
├── Extensions.meta
├── Extensions
│ ├── BoundsExtensions.cs
│ ├── BoundsExtensions.cs.meta
│ ├── CameraExtensions.cs
│ ├── CameraExtensions.cs.meta
│ ├── CanvasExtensions.cs
│ ├── CanvasExtensions.cs.meta
│ ├── ColliderExtensions.cs
│ ├── ColliderExtensions.cs.meta
│ ├── ComponentExtensions.cs
│ ├── ComponentExtensions.cs.meta
│ ├── ExceptionExtensions.cs
│ ├── ExceptionExtensions.cs.meta
│ ├── Extensions.cs
│ ├── Extensions.cs.meta
│ ├── FileInfoExtensions.cs
│ ├── FileInfoExtensions.cs.meta
│ ├── FloatExtensions.cs
│ ├── FloatExtensions.cs.meta
│ ├── GameObjectExtensions.cs
│ ├── GameObjectExtensions.cs.meta
│ ├── GenericEnumerableExtensions.cs
│ ├── GenericEnumerableExtensions.cs.meta
│ ├── KeyValuePairExtensions.cs
│ ├── KeyValuePairExtensions.cs.meta
│ ├── MaterialExtensions.cs
│ ├── MaterialExtensions.cs.meta
│ ├── MeshExtensions.cs
│ ├── MeshExtensions.cs.meta
│ ├── PathExtensions.cs
│ ├── PathExtensions.cs.meta
│ ├── RandomExtensions.cs
│ ├── RandomExtensions.cs.meta
│ ├── RectExtensions.cs
│ ├── RectExtensions.cs.meta
│ ├── RectTransformExtensions.cs
│ ├── RectTransformExtensions.cs.meta
│ ├── RenderTextureExtensions.cs
│ ├── RenderTextureExtensions.cs.meta
│ ├── RigidbodyExtensions.cs
│ ├── RigidbodyExtensions.cs.meta
│ ├── StringExtensions.cs
│ ├── StringExtensions.cs.meta
│ ├── Texture2DExtensions.cs
│ ├── Texture2DExtensions.cs.meta
│ ├── TransformExtensions.cs
│ ├── TransformExtensions.cs.meta
│ ├── TypeExtensions.cs
│ ├── TypeExtensions.cs.meta
│ ├── VectorExtensions.cs
│ └── VectorExtensions.cs.meta
├── Gizmos.meta
├── Gizmos
│ ├── ShowGizmoCapsule.cs
│ └── ShowGizmoCapsule.cs.meta
├── Misc.meta
├── Misc
│ ├── BoundsTest.cs
│ ├── BoundsTest.cs.meta
│ ├── Editor.meta
│ └── Editor
│ │ ├── BoundsTestEditor.cs
│ │ └── BoundsTestEditor.cs.meta
├── Util.meta
└── Util
│ ├── AssertUtils.cs
│ ├── AssertUtils.cs.meta
│ ├── BoolBuffer.cs
│ ├── BoolBuffer.cs.meta
│ ├── BoxColliderData.cs
│ ├── BoxColliderData.cs.meta
│ ├── BoxTriangleIntersector.cs
│ ├── BoxTriangleIntersector.cs.meta
│ ├── BoxTriangleIntersectorOld.cs
│ ├── BoxTriangleIntersectorOld.cs.meta
│ ├── ByteArrayComparer.cs
│ ├── ByteArrayComparer.cs.meta
│ ├── ByteUtils.cs
│ ├── ByteUtils.cs.meta
│ ├── Callbacks.meta
│ ├── Callbacks
│ ├── CollisionCallback.cs
│ ├── CollisionCallback.cs.meta
│ ├── OnDestroyCallback.cs
│ ├── OnDestroyCallback.cs.meta
│ ├── OnDisableCallback.cs
│ ├── OnDisableCallback.cs.meta
│ ├── OnDragCallback.cs
│ ├── OnDragCallback.cs.meta
│ ├── OnDrawGizmoCallback.cs
│ ├── OnDrawGizmoCallback.cs.meta
│ ├── OnPointerClickCallback.cs
│ ├── OnPointerClickCallback.cs.meta
│ ├── OnPointerDownCallback.cs
│ ├── OnPointerDownCallback.cs.meta
│ ├── OnPointerEnterCallback.cs
│ ├── OnPointerEnterCallback.cs.meta
│ ├── OnPointerExitCallback.cs
│ ├── OnPointerExitCallback.cs.meta
│ ├── OnPointerUpCallback.cs
│ ├── OnPointerUpCallback.cs.meta
│ ├── OnPostRender.cs
│ ├── OnPostRender.cs.meta
│ ├── OnPreCullCallback.cs
│ ├── OnPreCullCallback.cs.meta
│ ├── OnRectTransformDimensionsChangeCallback.cs
│ ├── OnRectTransformDimensionsChangeCallback.cs.meta
│ ├── TriggerCallback.cs
│ └── TriggerCallback.cs.meta
│ ├── CapsuleColliderData.cs
│ ├── CapsuleColliderData.cs.meta
│ ├── CircularBuffer.cs
│ ├── CircularBuffer.cs.meta
│ ├── ColliderData.cs
│ ├── ColliderData.cs.meta
│ ├── Conversions.meta
│ ├── Conversions
│ ├── BigEndianBitConverter.cs
│ ├── BigEndianBitConverter.cs.meta
│ ├── DoubleConverter.cs
│ ├── DoubleConverter.cs.meta
│ ├── EndianBitConverter.cs
│ ├── EndianBitConverter.cs.meta
│ ├── Endianness.cs
│ ├── Endianness.cs.meta
│ ├── LittleEndianBitConverter.cs
│ └── LittleEndianBitConverter.cs.meta
│ ├── CylinderBounds.cs
│ ├── CylinderBounds.cs.meta
│ ├── DI.meta
│ ├── DI
│ ├── DependencyInjection.cs
│ ├── DependencyInjection.cs.meta
│ ├── DependencyInjectionUtils.cs
│ └── DependencyInjectionUtils.cs.meta
│ ├── DebugActions.cs
│ ├── DebugActions.cs.meta
│ ├── DontDestroyOnLoad.cs
│ ├── DontDestroyOnLoad.cs.meta
│ ├── Easing.cs
│ ├── Easing.cs.meta
│ ├── Editor.meta
│ ├── Editor
│ ├── AssetPostprocessorUtils.cs
│ ├── AssetPostprocessorUtils.cs.meta
│ ├── EditorUtils.cs
│ ├── EditorUtils.cs.meta
│ ├── InspectorCategoryEditor.cs
│ ├── InspectorCategoryEditor.cs.meta
│ ├── QuickActions.cs
│ ├── QuickActions.cs.meta
│ ├── ReadOnlyDrawer.cs
│ ├── ReadOnlyDrawer.cs.meta
│ ├── SceneList.cs
│ ├── SceneList.cs.meta
│ ├── ScreenshotUtilityEditor.cs
│ ├── ScreenshotUtilityEditor.cs.meta
│ ├── SimpleEditor.cs
│ ├── SimpleEditor.cs.meta
│ ├── Tools.cs
│ └── Tools.cs.meta
│ ├── EnumUtils.cs
│ ├── EnumUtils.cs.meta
│ ├── FastBounds.cs
│ ├── FastBounds.cs.meta
│ ├── FastPool.cs
│ ├── FastPool.cs.meta
│ ├── FastPoolWithCallback.cs
│ ├── FastPoolWithCallback.cs.meta
│ ├── FasterBounds.cs
│ ├── FasterBounds.cs.meta
│ ├── GameGizmoUtils.cs
│ ├── GameGizmoUtils.cs.meta
│ ├── GameObjectStates.cs
│ ├── GameObjectStates.cs.meta
│ ├── GizmoUtils.cs
│ ├── GizmoUtils.cs.meta
│ ├── Gizmos.meta
│ ├── Gizmos
│ ├── EditorGizmoProvider.cs
│ ├── EditorGizmoProvider.cs.meta
│ ├── GameGizmoProvider.cs
│ ├── GameGizmoProvider.cs.meta
│ ├── IGizmoPresenter.cs
│ ├── IGizmoPresenter.cs.meta
│ ├── IGizmoProvider.cs
│ └── IGizmoProvider.cs.meta
│ ├── GuildGenerator.cs
│ ├── GuildGenerator.cs.meta
│ ├── Icons.meta
│ ├── Icons
│ ├── Editor.meta
│ ├── Editor
│ │ ├── IconExplorer.cs
│ │ └── IconExplorer.cs.meta
│ ├── IconFont.cs
│ └── IconFont.cs.meta
│ ├── InspectorCategory.cs
│ ├── InspectorCategory.cs.meta
│ ├── LayoutUtils.cs
│ ├── LayoutUtils.cs.meta
│ ├── Line.cs
│ ├── Line.cs.meta
│ ├── LookAtTransform.cs
│ ├── LookAtTransform.cs.meta
│ ├── MeshBuilder.cs
│ ├── MeshBuilder.cs.meta
│ ├── MeshSerializer.cs
│ ├── MeshSerializer.cs.meta
│ ├── MeshTransform.cs
│ ├── MeshTransform.cs.meta
│ ├── MeshUtility.cs
│ ├── MeshUtility.cs.meta
│ ├── MeshUtilityV2.cs
│ ├── MeshUtilityV2.cs.meta
│ ├── MeshUtils.cs
│ ├── MeshUtils.cs.meta
│ ├── MinimalSphereBounds.cs
│ ├── MinimalSphereBounds.cs.meta
│ ├── OneShotEvent.cs
│ ├── OneShotEvent.cs.meta
│ ├── OrderedIndexPool.cs
│ ├── OrderedIndexPool.cs.meta
│ ├── PauseEditorAfterTime.cs
│ ├── PauseEditorAfterTime.cs.meta
│ ├── PhysicsUtils.cs
│ ├── PhysicsUtils.cs.meta
│ ├── Pool.cs
│ ├── Pool.cs.meta
│ ├── PriorityPool.cs
│ ├── PriorityPool.cs.meta
│ ├── PriorityQueue.cs
│ ├── PriorityQueue.cs.meta
│ ├── PropertyDrawers.meta
│ ├── PropertyDrawers
│ ├── CustomObjectPickerAttribute.cs
│ ├── CustomObjectPickerAttribute.cs.meta
│ ├── Editor.meta
│ ├── Editor
│ │ ├── CustomObjectPickerEditorWindow.cs
│ │ ├── CustomObjectPickerEditorWindow.cs.meta
│ │ ├── CustomObjectPickerPropertyDrawer.cs
│ │ ├── CustomObjectPickerPropertyDrawer.cs.meta
│ │ ├── OfTypeDrawer.cs
│ │ ├── OfTypeDrawer.cs.meta
│ │ ├── SingleUnityLayerPropertyDrawer.cs
│ │ └── SingleUnityLayerPropertyDrawer.cs.meta
│ ├── OfTypeAttribute.cs
│ ├── OfTypeAttribute.cs.meta
│ ├── SingleUnityLayer.cs
│ └── SingleUnityLayer.cs.meta
│ ├── Range.cs
│ ├── Range.cs.meta
│ ├── ReadOnlyAttribute.cs
│ ├── ReadOnlyAttribute.cs.meta
│ ├── SceneSingleton.cs
│ ├── SceneSingleton.cs.meta
│ ├── ScreenshotUtility.cs
│ ├── ScreenshotUtility.cs.meta
│ ├── SequentialIdGenerator.cs
│ ├── SequentialIdGenerator.cs.meta
│ ├── ShowBounds.cs
│ ├── ShowBounds.cs.meta
│ ├── ShowNormals.cs
│ ├── ShowNormals.cs.meta
│ ├── Singleton.cs
│ ├── Singleton.cs.meta
│ ├── SmallestEnclosingCircle.cs
│ ├── SmallestEnclosingCircle.cs.meta
│ ├── SphereBounds.cs
│ ├── SphereBounds.cs.meta
│ ├── SphereColliderData.cs
│ ├── SphereColliderData.cs.meta
│ ├── SynchronizePosition.cs
│ ├── SynchronizePosition.cs.meta
│ ├── TransformData.cs
│ ├── TransformData.cs.meta
│ ├── UnityMainThreadDispatcher.cs
│ ├── UnityMainThreadDispatcher.cs.meta
│ ├── Utils.cs
│ └── Utils.cs.meta
├── Shaders.meta
├── Shaders
├── HiddenPass.shader
├── HiddenPass.shader.meta
├── Vertex Color.shader
└── Vertex Color.shader.meta
├── Tests.meta
└── Tests
├── Editor.meta
└── Editor
├── Extensions.meta
├── Extensions
├── FloatExtensionsTests.cs
├── FloatExtensionsTests.cs.meta
├── VectorExtensionsTests.cs
└── VectorExtensionsTests.cs.meta
├── Utils.meta
└── Utils
├── CircularBufferTests.cs
├── CircularBufferTests.cs.meta
├── OrderedIndexPoolTests.cs
├── OrderedIndexPoolTests.cs.meta
├── PhysicsButtonUtilsTests.cs
├── PhysicsButtonUtilsTests.cs.meta
├── PhysicsUtilsTests.cs
├── PhysicsUtilsTests.cs.meta
├── PriorityPoolTests.cs
├── PriorityPoolTests.cs.meta
├── UtilsTests.cs
└── UtilsTests.cs.meta
/.gitignore:
--------------------------------------------------------------------------------
1 | # This .gitignore file should be placed at the root of your Unity project directory
2 | #
3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
4 | #
5 | /[Ll]ibrary/
6 | /[Tt]emp/
7 | /[Oo]bj/
8 | /[Bb]uild/
9 | /[Bb]uilds/
10 | /[Ll]ogs/
11 | /[Mm]emoryCaptures/
12 |
13 | # Asset meta data should only be ignored when the corresponding asset is also ignored
14 | !/[Aa]ssets/**/*.meta
15 |
16 | # Uncomment this line if you wish to ignore the asset store tools plugin
17 | # /[Aa]ssets/AssetStoreTools*
18 |
19 | # Autogenerated Jetbrains Rider plugin
20 | [Aa]ssets/Plugins/Editor/JetBrains*
21 |
22 | # Visual Studio cache directory
23 | .vs/
24 |
25 | # Gradle cache directory
26 | .gradle/
27 |
28 | # Autogenerated VS/MD/Consulo solution and project files
29 | ExportedObj/
30 | .consulo/
31 | *.csproj
32 | *.unityproj
33 | *.sln
34 | *.suo
35 | *.tmp
36 | *.user
37 | *.userprefs
38 | *.pidb
39 | *.booproj
40 | *.svd
41 | *.pdb
42 | *.mdb
43 | *.opendb
44 | *.VC.db
45 |
46 | # Unity3D generated meta files
47 | *.pidb.meta
48 | *.pdb.meta
49 | *.mdb.meta
50 |
51 | # Unity3D generated file on crash reports
52 | sysinfo.txt
53 |
54 | # Builds
55 | *.apk
56 | *.unitypackage
57 |
58 | # Crashlytics generated file
59 | crashlytics-build.properties
60 |
61 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Elastic Sea
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LICENSE.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: feebf2c112528b4439d656d39aab6e7b
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unity Framework
2 |
3 | Collection of utility methods.
4 |
--------------------------------------------------------------------------------
/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d870090b2188d7b4abae5c90e86bd291
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 680112a336754c9e8d4d92d6c87c528c
3 | timeCreated: 1689606431
--------------------------------------------------------------------------------
/Scenes/Misc.unity:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!29 &1
4 | OcclusionCullingSettings:
5 | m_ObjectHideFlags: 0
6 | serializedVersion: 2
7 | m_OcclusionBakeSettings:
8 | smallestOccluder: 5
9 | smallestHole: 0.25
10 | backfaceThreshold: 100
11 | m_SceneGUID: 00000000000000000000000000000000
12 | m_OcclusionCullingData: {fileID: 0}
13 | --- !u!104 &2
14 | RenderSettings:
15 | m_ObjectHideFlags: 0
16 | serializedVersion: 9
17 | m_Fog: 0
18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
19 | m_FogMode: 3
20 | m_FogDensity: 0.01
21 | m_LinearFogStart: 0
22 | m_LinearFogEnd: 300
23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
26 | m_AmbientIntensity: 1
27 | m_AmbientMode: 0
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
30 | m_HaloStrength: 0.5
31 | m_FlareStrength: 1
32 | m_FlareFadeSpeed: 3
33 | m_HaloTexture: {fileID: 0}
34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
35 | m_DefaultReflectionMode: 0
36 | m_DefaultReflectionResolution: 128
37 | m_ReflectionBounces: 1
38 | m_ReflectionIntensity: 1
39 | m_CustomReflection: {fileID: 0}
40 | m_Sun: {fileID: 0}
41 | m_IndirectSpecularColor: {r: 0.12731749, g: 0.13414757, b: 0.1210787, a: 1}
42 | m_UseRadianceAmbientProbe: 0
43 | --- !u!157 &3
44 | LightmapSettings:
45 | m_ObjectHideFlags: 0
46 | serializedVersion: 12
47 | m_GIWorkflowMode: 1
48 | m_GISettings:
49 | serializedVersion: 2
50 | m_BounceScale: 1
51 | m_IndirectOutputScale: 1
52 | m_AlbedoBoost: 1
53 | m_EnvironmentLightingMode: 0
54 | m_EnableBakedLightmaps: 1
55 | m_EnableRealtimeLightmaps: 0
56 | m_LightmapEditorSettings:
57 | serializedVersion: 12
58 | m_Resolution: 2
59 | m_BakeResolution: 40
60 | m_AtlasSize: 1024
61 | m_AO: 0
62 | m_AOMaxDistance: 1
63 | m_CompAOExponent: 1
64 | m_CompAOExponentDirect: 0
65 | m_ExtractAmbientOcclusion: 0
66 | m_Padding: 2
67 | m_LightmapParameters: {fileID: 0}
68 | m_LightmapsBakeMode: 1
69 | m_TextureCompression: 1
70 | m_FinalGather: 0
71 | m_FinalGatherFiltering: 1
72 | m_FinalGatherRayCount: 256
73 | m_ReflectionCompression: 2
74 | m_MixedBakeMode: 2
75 | m_BakeBackend: 1
76 | m_PVRSampling: 1
77 | m_PVRDirectSampleCount: 32
78 | m_PVRSampleCount: 512
79 | m_PVRBounces: 2
80 | m_PVREnvironmentSampleCount: 256
81 | m_PVREnvironmentReferencePointCount: 2048
82 | m_PVRFilteringMode: 1
83 | m_PVRDenoiserTypeDirect: 1
84 | m_PVRDenoiserTypeIndirect: 1
85 | m_PVRDenoiserTypeAO: 1
86 | m_PVRFilterTypeDirect: 0
87 | m_PVRFilterTypeIndirect: 0
88 | m_PVRFilterTypeAO: 0
89 | m_PVREnvironmentMIS: 1
90 | m_PVRCulling: 1
91 | m_PVRFilteringGaussRadiusDirect: 1
92 | m_PVRFilteringGaussRadiusIndirect: 5
93 | m_PVRFilteringGaussRadiusAO: 2
94 | m_PVRFilteringAtrousPositionSigmaDirect: 0.5
95 | m_PVRFilteringAtrousPositionSigmaIndirect: 2
96 | m_PVRFilteringAtrousPositionSigmaAO: 1
97 | m_ExportTrainingData: 0
98 | m_TrainingDataDestination: TrainingData
99 | m_LightProbeSampleCountMultiplier: 4
100 | m_LightingDataAsset: {fileID: 0}
101 | m_LightingSettings: {fileID: 0}
102 | --- !u!196 &4
103 | NavMeshSettings:
104 | serializedVersion: 2
105 | m_ObjectHideFlags: 0
106 | m_BuildSettings:
107 | serializedVersion: 2
108 | agentTypeID: 0
109 | agentRadius: 0.5
110 | agentHeight: 2
111 | agentSlope: 45
112 | agentClimb: 0.4
113 | ledgeDropHeight: 0
114 | maxJumpAcrossDistance: 0
115 | minRegionArea: 2
116 | manualCellSize: 0
117 | cellSize: 0.16666667
118 | manualTileSize: 0
119 | tileSize: 256
120 | accuratePlacement: 0
121 | maxJobWorkers: 0
122 | preserveTilesOutsideBounds: 0
123 | debug:
124 | m_Flags: 0
125 | m_NavMeshData: {fileID: 0}
126 | --- !u!1 &1551054001
127 | GameObject:
128 | m_ObjectHideFlags: 0
129 | m_CorrespondingSourceObject: {fileID: 0}
130 | m_PrefabInstance: {fileID: 0}
131 | m_PrefabAsset: {fileID: 0}
132 | serializedVersion: 6
133 | m_Component:
134 | - component: {fileID: 1551054002}
135 | - component: {fileID: 1551054003}
136 | m_Layer: 0
137 | m_Name: Bounds
138 | m_TagString: Untagged
139 | m_Icon: {fileID: 0}
140 | m_NavMeshLayer: 0
141 | m_StaticEditorFlags: 0
142 | m_IsActive: 1
143 | --- !u!4 &1551054002
144 | Transform:
145 | m_ObjectHideFlags: 0
146 | m_CorrespondingSourceObject: {fileID: 0}
147 | m_PrefabInstance: {fileID: 0}
148 | m_PrefabAsset: {fileID: 0}
149 | m_GameObject: {fileID: 1551054001}
150 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
151 | m_LocalPosition: {x: 0, y: 0, z: 0}
152 | m_LocalScale: {x: 1, y: 1, z: 1}
153 | m_ConstrainProportionsScale: 0
154 | m_Children: []
155 | m_Father: {fileID: 0}
156 | m_RootOrder: 0
157 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
158 | --- !u!114 &1551054003
159 | MonoBehaviour:
160 | m_ObjectHideFlags: 0
161 | m_CorrespondingSourceObject: {fileID: 0}
162 | m_PrefabInstance: {fileID: 0}
163 | m_PrefabAsset: {fileID: 0}
164 | m_GameObject: {fileID: 1551054001}
165 | m_Enabled: 1
166 | m_EditorHideFlags: 0
167 | m_Script: {fileID: 11500000, guid: ac10d3a60eead0540b9b9fba32f2a9b2, type: 3}
168 | m_Name:
169 | m_EditorClassIdentifier:
170 | pointsCount: 100
171 | Type: 1
172 |
--------------------------------------------------------------------------------
/Scenes/Misc.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aefd1c7e13835e84e9495e4f458a17ea
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 29db699fd98db874dac42320e98f2821
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Extensions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9fd9e6c538a41c24c832319e8d6c9abf
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Extensions/BoundsExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3079498e378151242abf5937c8b8d063
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/CameraExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using ElasticSea.Framework.Scripts.Extensions;
3 | using UnityEngine;
4 | using UnityEngine.Experimental.Rendering;
5 |
6 | namespace ElasticSea.Framework.Extensions
7 | {
8 | public static class CameraExtensions
9 | {
10 | ///
11 | /// Fill camera viewrect with gameobject
12 | ///
13 | public static void FillCameraView(this Camera camera, GameObject gameObject, float boundsMultiplier = 1)
14 | {
15 | var vertices = gameObject.GetWorldVertexPositions();
16 | var center = vertices.Average();
17 | var radius = vertices.Select(v => (center - v).magnitude).Max();
18 |
19 | camera.FillCameraView(center, radius * boundsMultiplier);
20 | }
21 |
22 | ///
23 | /// Fill camera viewrect with object at position with radius
24 | ///
25 | public static void FillCameraView(this Camera camera, Vector3 targetPosition, float targetRadius)
26 | {
27 | if (camera.orthographic)
28 | {
29 | camera.transform.position = targetPosition - camera.transform.forward * (targetRadius + camera.nearClipPlane);
30 | camera.orthographicSize = targetRadius / Mathf.Min(camera.aspect, 1);
31 | }
32 | else
33 | {
34 | var distance = camera.GetFillCameraViewDistance(targetRadius);
35 | camera.transform.position = targetPosition - camera.transform.forward * distance;
36 | }
37 | }
38 |
39 | ///
40 | /// Get distance from the camera to the object based on the objects sphere radius and camera fov
41 | ///
42 | public static float GetFillCameraViewDistance(this Camera camera, float targetRadius)
43 | {
44 | // Get the horizontal FOV, since it may be the limiting of the two FOVs to properly encapsulate the objects
45 | var horizontalFov = 2f * Mathf.Atan(Mathf.Tan(camera.fieldOfView * Mathf.Deg2Rad / 2f) * camera.aspect) * Mathf.Rad2Deg;
46 | // Use the smaller FOV as it limits what would get cut off by the frustum
47 | var fov = Mathf.Min(camera.fieldOfView, horizontalFov);
48 |
49 | // var distance = radius / Mathf.Tan((camera.fieldOfView * Mathf.Deg2Rad) / 2f);
50 | // Take sin so the whole sphere is in the view
51 | return targetRadius / Mathf.Sin((fov * Mathf.Deg2Rad) / 2f);
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/CameraExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c0e43537cc1b4c9baa6952c43cc34cab
3 | timeCreated: 1615909124
--------------------------------------------------------------------------------
/Scripts/Extensions/CanvasExtensions.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Scripts.Extensions
4 | {
5 | public static class CanvasExtensions
6 | {
7 | public static Texture2D Render(this Canvas canvas, TextureFormat format, string renderLayerName, int width, int height)
8 | {
9 | var previousLayer = canvas.gameObject.layer;
10 | var previousRenderMode = canvas.renderMode;
11 | var previousWorldCamera = canvas.worldCamera;
12 |
13 | canvas.gameObject.layer = LayerMask.NameToLayer(renderLayerName);
14 | canvas.renderMode = RenderMode.ScreenSpaceCamera;
15 | var cam = new GameObject().AddComponent();
16 | cam.enabled = false;
17 | // Enabling HDR makes the background black
18 | cam.allowHDR = false;
19 | cam.cullingMask = LayerMask.GetMask(renderLayerName);
20 | cam.clearFlags = CameraClearFlags.Color;
21 | cam.targetTexture = new RenderTexture(width, height, 32, RenderTextureFormat.ARGB32);
22 | canvas.worldCamera = cam;
23 | cam.Render();
24 | var texture = cam.targetTexture.ToTexture2D(format);
25 | GameObject.DestroyImmediate(cam.targetTexture);
26 | GameObject.DestroyImmediate(cam.gameObject);
27 |
28 | canvas.gameObject.layer = previousLayer;
29 | canvas.renderMode = previousRenderMode;
30 | canvas.worldCamera = previousWorldCamera;
31 | return texture;
32 | }
33 | }
34 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/CanvasExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0f50fb8def1e41308d140402ba7c1e71
3 | timeCreated: 1656184364
--------------------------------------------------------------------------------
/Scripts/Extensions/ColliderExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c4cf5b629ad41ea866c408f5f685aaf
3 | timeCreated: 1619093505
--------------------------------------------------------------------------------
/Scripts/Extensions/ComponentExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Extensions
5 | {
6 | public static class ComponentExtensions
7 | {
8 | public static Component GetOrAddComponent(this Component c, Type componentType)
9 | {
10 | return c.gameObject.GetOrAddComponent(componentType);
11 | }
12 |
13 | public static T GetOrAddComponent(this Component c) where T : Component
14 | {
15 | return c.gameObject.GetOrAddComponent();
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/ComponentExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4a306cc18a4c1ce40a02307aa78501fd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/ExceptionExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ElasticSea.Framework.Extensions
5 | {
6 | public static class ExceptionExtensions
7 | {
8 | public static IEnumerable GetAllMessages(this Exception exception)
9 | {
10 | while (exception != null)
11 | {
12 | yield return exception.Message;
13 | exception = exception.InnerException;
14 | }
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/ExceptionExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 916b0f1e4ffd49c4afadf63d2cd4e989
3 | timeCreated: 1606024523
--------------------------------------------------------------------------------
/Scripts/Extensions/Extensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d5aaf28d4b8cf7409c87e4cc94d9c26
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/FileInfoExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace ElasticSea.Framework.Extensions
4 | {
5 | public static class FileInfoExtensions
6 | {
7 | public static byte[] ToBytes(this FileInfo fileInfo)
8 | {
9 | return File.ReadAllBytes(fileInfo.FullName);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/FileInfoExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c0654f93c81341ca97b75649fec43a9d
3 | timeCreated: 1702953997
--------------------------------------------------------------------------------
/Scripts/Extensions/FloatExtensions.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Extensions
4 | {
5 | public static class FloatExtensions
6 | {
7 | public static float RoundTo(this float value, float roundTo)
8 | {
9 | return (float)(Mathf.RoundToInt((value) / roundTo) * (double)roundTo);
10 | }
11 |
12 | public static float FloorTo(this float value, float roundTo)
13 | {
14 | return (float)(Mathf.FloorToInt((value) / roundTo) * (double)roundTo);
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/FloatExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d69c8abbeceb42e8832fb80a86618da9
3 | timeCreated: 1616078109
--------------------------------------------------------------------------------
/Scripts/Extensions/GameObjectExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a4c029e58d3976d4c9d7caf693b9643b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/GenericEnumerableExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 87ca1853ec74d1345908aff929878472
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/KeyValuePairExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace ElasticSea.Framework.Extensions
4 | {
5 | public static class KeyValuePairExtensions
6 | {
7 | public static void Deconstruct(this KeyValuePair tuple, out T1 key, out T2 value)
8 | {
9 | key = tuple.Key;
10 | value = tuple.Value;
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/KeyValuePairExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9bf28372ad8e4f709032dbc9a8d6fb0b
3 | timeCreated: 1607123646
--------------------------------------------------------------------------------
/Scripts/Extensions/MaterialExtensions.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.Rendering;
3 |
4 | namespace ElasticSea.Framework.Extensions
5 | {
6 | public static class MaterialExtensions
7 | {
8 | public enum Mode
9 | {
10 | Opaque,
11 | Cutout,
12 | Fade,
13 | Transparent
14 | }
15 |
16 | public static void SetupMaterialWithBlendMode(this Material material, Mode blendMode)
17 | {
18 | switch (blendMode)
19 | {
20 | case Mode.Opaque:
21 | material.SetInt("_SrcBlend", (int)BlendMode.One);
22 | material.SetInt("_DstBlend", (int)BlendMode.Zero);
23 | material.SetInt("_ZWrite", 1);
24 | material.DisableKeyword("_ALPHATEST_ON");
25 | material.DisableKeyword("_ALPHABLEND_ON");
26 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
27 | material.renderQueue = -1;
28 | break;
29 | case Mode.Cutout:
30 | material.SetInt("_SrcBlend", (int)BlendMode.One);
31 | material.SetInt("_DstBlend", (int)BlendMode.Zero);
32 | material.SetInt("_ZWrite", 1);
33 | material.EnableKeyword("_ALPHATEST_ON");
34 | material.DisableKeyword("_ALPHABLEND_ON");
35 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
36 | material.renderQueue = 2450;
37 | break;
38 | case Mode.Fade:
39 | material.SetInt("_SrcBlend", (int)BlendMode.SrcAlpha);
40 | material.SetInt("_DstBlend", (int)BlendMode.OneMinusSrcAlpha);
41 | material.SetInt("_ZWrite", 1);
42 | material.DisableKeyword("_ALPHATEST_ON");
43 | material.EnableKeyword("_ALPHABLEND_ON");
44 | material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
45 | material.renderQueue = 3000;
46 | break;
47 | case Mode.Transparent:
48 | material.SetInt("_SrcBlend", (int)BlendMode.One);
49 | material.SetInt("_DstBlend", (int)BlendMode.OneMinusSrcAlpha);
50 | material.SetInt("_ZWrite", 0);
51 | material.DisableKeyword("_ALPHATEST_ON");
52 | material.DisableKeyword("_ALPHABLEND_ON");
53 | material.EnableKeyword("_ALPHAPREMULTIPLY_ON");
54 | material.renderQueue = 3000;
55 | break;
56 | }
57 | }
58 |
59 | public static void EnableKeyword(this Material material, string keyword, bool enabled)
60 | {
61 | if (enabled)
62 | {
63 | material.EnableKeyword(keyword);
64 | }
65 | else
66 | {
67 | material.DisableKeyword(keyword);
68 | }
69 | }
70 |
71 | public static void SetNormal(this Material material, Texture2D normal)
72 | {
73 | material.EnableKeyword("_NORMALMAP");
74 | material.SetTexture("_BumpMap", normal);
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/MaterialExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a8c85c4f94df4d96b8fd151b9ad88759
3 | timeCreated: 1607022929
--------------------------------------------------------------------------------
/Scripts/Extensions/MeshExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8e809b42f39f48fbb49edaedbc59a8aa
3 | timeCreated: 1610808507
--------------------------------------------------------------------------------
/Scripts/Extensions/PathExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace ElasticSea.Framework.Scripts.Extensions
4 | {
5 | public static class PathExtensions
6 | {
7 | public static void EnsureDirectory(this FileInfo fileInfo)
8 | {
9 | fileInfo.Directory.EnsureDirectory();
10 | }
11 |
12 | public static void EnsureDirectory(this DirectoryInfo dir, bool clear = false)
13 | {
14 | if (dir.Exists)
15 | {
16 | if (clear)
17 | {
18 | dir.Delete(true);
19 | dir.Create();
20 | }
21 | }
22 | else
23 | {
24 | dir.Create();
25 | }
26 | }
27 |
28 | public static FileInfo File(this DirectoryInfo dir, string path)
29 | {
30 | return new FileInfo(Path.Combine(dir.FullName, path));
31 | }
32 |
33 | public static void Write(this FileInfo file, byte[] bytes)
34 | {
35 | System.IO.File.WriteAllBytes(file.FullName, bytes);
36 | }
37 |
38 | public static void Write(this FileInfo file, string text)
39 | {
40 | System.IO.File.WriteAllText(file.FullName, text);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/PathExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4cff1aea9ecf43a1a09dc19d6c24387b
3 | timeCreated: 1681119240
--------------------------------------------------------------------------------
/Scripts/Extensions/RandomExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ElasticSea.Framework.Scripts.Extensions
4 | {
5 | public static class RandomExtensions
6 | {
7 | public static bool Probability(this Random random, float probability) => random.NextDouble() <= probability;
8 | public static bool FlipCoin(this Random random) => random.NextDouble() >= 0.5;
9 | public static int RollDice(this Random random, int sides) => random.Next(1, sides);
10 | }
11 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/RandomExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 74fa7b0b186d43679545bbca67aee927
3 | timeCreated: 1624013143
--------------------------------------------------------------------------------
/Scripts/Extensions/RectExtensions.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using ElasticSea.Framework.Extensions;
4 | using UnityEngine;
5 |
6 | namespace ElasticSea.Framework.Scripts.Extensions
7 | {
8 | public static class RectExtensions
9 | {
10 | public static Rect Encapsulate(this IEnumerable rects)
11 | {
12 | return rects.ToArray().Encapsulate();
13 | }
14 |
15 | public static Rect Encapsulate(this Rect rect, Rect other)
16 | {
17 | var final = new Rect();
18 | final.min = rect.min.Min(other.min);
19 | final.max = rect.max.Max(other.max);
20 | return final;
21 | }
22 |
23 | public static Rect Encapsulate(this Rect[] rects)
24 | {
25 | var length = rects.Length;
26 | if (length == 0)
27 | {
28 | return default;
29 | }
30 |
31 | var rect = rects[0];
32 | for (var i = 1; i < length; i++)
33 | {
34 | var otherRect = rects[i];
35 | rect.min = rect.min.Min(otherRect.min);
36 | rect.max = rect.max.Max(otherRect.max);
37 | }
38 |
39 | return rect;
40 | }
41 |
42 | public static Rect Grow(this Rect rect, float growBy)
43 | {
44 | return rect.Grow(new Vector2(growBy, growBy));
45 | }
46 |
47 | public static Rect Grow(this Rect rect, Vector2 growBy)
48 | {
49 | return Rect.MinMaxRect(rect.xMin - growBy.x, rect.yMin - growBy.y, rect.xMax + growBy.x, rect.yMax + growBy.y);
50 | }
51 |
52 | public static Rect Shrink(this Rect rect, float shrinkBy)
53 | {
54 | return rect.Grow(-shrinkBy);
55 | }
56 |
57 | public static Rect Shrink(this Rect rect, Vector2 shrinkBy)
58 | {
59 | return rect.Grow(-shrinkBy);
60 | }
61 |
62 | public static Rect Move(this Rect rect, Vector2 moveBy)
63 | {
64 | var newRect = new Rect(rect);
65 | newRect.position += moveBy;
66 | return newRect;
67 | }
68 |
69 | public static (Rect left, Rect right) SplitHorizontal(this Rect rect)
70 | {
71 | var centerPoint = Mathf.Lerp(rect.xMin, rect.xMax, 0.5f);
72 | var left = Rect.MinMaxRect(rect.xMin, rect.yMin, centerPoint, rect.yMax);
73 | var right = Rect.MinMaxRect(centerPoint, rect.yMin, rect.xMax, rect.yMax);
74 | return (left, right);
75 | }
76 |
77 | public static (Rect bottom, Rect top) SplitVertical(this Rect rect)
78 | {
79 | var centerPoint = Mathf.Lerp(rect.yMin, rect.yMax, 0.5f);
80 | var bottom = Rect.MinMaxRect(rect.xMin, rect.yMin, rect.xMax, centerPoint);
81 | var top = Rect.MinMaxRect(rect.xMin, centerPoint, rect.xMax, rect.yMax);
82 | return (bottom, top);
83 | }
84 |
85 | public static Vector2[] Vertices(this Rect rect)
86 | {
87 | return new Vector2[]
88 | {
89 | new (rect.xMin, rect.yMin),
90 | new (rect.xMin, rect.yMax),
91 | new (rect.xMax, rect.yMax),
92 | new (rect.xMax, rect.yMin),
93 | };
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/RectExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad29d0fe27df497fbf672f802d29a6b9
3 | timeCreated: 1663699284
--------------------------------------------------------------------------------
/Scripts/Extensions/RectTransformExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ec96f959bb14b1e4e84f3395232c0391
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Extensions/RenderTextureExtensions.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.Experimental.Rendering;
3 |
4 | namespace ElasticSea.Framework.Scripts.Extensions
5 | {
6 | public static class RenderTextureExtensions
7 | {
8 | public static Texture2D ToTexture2D(this RenderTexture renderTexture, TextureFormat textureFormat = TextureFormat.ARGB32, bool mipmaps = true)
9 | {
10 | var activeRenderTexture = RenderTexture.active;
11 |
12 | var texture = new Texture2D(renderTexture.width, renderTexture.height, textureFormat, mipmaps);
13 | RenderTexture.active = renderTexture;
14 | texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
15 | texture.Apply();
16 |
17 | RenderTexture.active = activeRenderTexture;
18 |
19 | return texture;
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/RenderTextureExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 92e3f787b2ad4043b9de64a3c0866138
3 | timeCreated: 1656184762
--------------------------------------------------------------------------------
/Scripts/Extensions/RigidbodyExtensions.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Scripts.Extensions
4 | {
5 | public static class RigidbodyExtensions
6 | {
7 | public static Vector3 WorldCenterOfMass(this Rigidbody rigidbody)
8 | {
9 | return rigidbody.transform.TransformPoint(rigidbody.centerOfMass);
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/RigidbodyExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 180db247537b44ac87b97544786f01b9
3 | timeCreated: 1622928828
--------------------------------------------------------------------------------
/Scripts/Extensions/StringExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: db2ae094e2234d0cbdeedfee851343d8
3 | timeCreated: 1602346871
--------------------------------------------------------------------------------
/Scripts/Extensions/Texture2DExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading.Tasks;
4 | using UnityEngine;
5 |
6 | namespace ElasticSea.Framework.Scripts.Extensions
7 | {
8 | public static class Texture2DExtensions
9 | {
10 | public static Color AverageColor(this Texture2D texture)
11 | {
12 | var colors = texture.GetPixels32();
13 | var r = 0f;
14 | var g = 0f;
15 | var b = 0f;
16 | var a = 0f;
17 | var length = colors.Length;
18 |
19 | for (var i = 0; i < length; i++)
20 | {
21 | var c = colors[i];
22 | r += c.r / 255f;
23 | g += c.g / 255f;
24 | b += c.b / 255f;
25 | a += c.a / 255f;
26 | }
27 |
28 | return new Color(r / length, g / length, b / length, a / length);
29 | }
30 |
31 | public delegate Color GetPixel(int x, int y);
32 | public delegate Color Build(GetPixel getPixel, int x, int y);
33 | public static Color[] ConvertMt(this Color[] pixels, int width, int height, Build build)
34 | {
35 | var output = new Color[width * height];
36 |
37 | var chunkSize = width * height / (SystemInfo.processorCount * 8);
38 |
39 | var workPackages = new List<(int start, int end)>();
40 |
41 | var sizeBudget = output.Length;
42 | var i = 0;
43 | while (sizeBudget > 0)
44 | {
45 | var currentChunk = Mathf.Min(chunkSize, sizeBudget);
46 |
47 | workPackages.Add((i, i + currentChunk));
48 | sizeBudget -= currentChunk;
49 | i += currentChunk;
50 | }
51 |
52 | GetPixel getPixel = (x, y) => pixels[y * width + x];
53 |
54 | Parallel.ForEach(workPackages, tuple =>
55 | {
56 | var (start, end) = tuple;
57 | for (var j = start; j < end; j++)
58 | {
59 | var x = j % width;
60 | var y = j / width;
61 | output[j] = build(getPixel, x, y);
62 | }
63 | });
64 |
65 | return output;
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/Texture2DExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 89cbba2254f04245a7991a4ba1742444
3 | timeCreated: 1663687026
--------------------------------------------------------------------------------
/Scripts/Extensions/TransformExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d70bae96df53457eacfed21a9fdcc819
3 | timeCreated: 1602346920
--------------------------------------------------------------------------------
/Scripts/Extensions/TypeExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ElasticSea.Framework.Extensions
5 | {
6 | public static class TypeExtensions
7 | {
8 |
9 | public static string GetNameWithoutGenericArity(this Type t)
10 | {
11 | var name = t.Name;
12 | var index = name.IndexOf('`');
13 | return index == -1 ? name : name.Substring(0, index);
14 | }
15 |
16 | public static string SimpleName(this Type t)
17 | {
18 | return t.GetNameWithoutGenericArity().SplitPascalCase();
19 | }
20 |
21 | private static readonly Dictionary TypeAliases = new Dictionary
22 | {
23 | { typeof(byte), "byte" },
24 | { typeof(sbyte), "sbyte" },
25 | { typeof(short), "short" },
26 | { typeof(ushort), "ushort" },
27 | { typeof(int), "int" },
28 | { typeof(uint), "uint" },
29 | { typeof(long), "long" },
30 | { typeof(ulong), "ulong" },
31 | { typeof(float), "float" },
32 | { typeof(double), "double" },
33 | { typeof(decimal), "decimal" },
34 | { typeof(object), "object" },
35 | { typeof(bool), "bool" },
36 | { typeof(char), "char" },
37 | { typeof(string), "string" },
38 | { typeof(void), "void" }
39 | };
40 |
41 | public static string GetSimpleAliasName(this Type type)
42 | {
43 | return (TypeAliases.ContainsKey(type) ? TypeAliases[type] : type.GetNameWithoutGenericArity()).SplitPascalCase();
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/Scripts/Extensions/TypeExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4cfd3a3fac1d4941a547f997b54b2dc6
3 | timeCreated: 1615909391
--------------------------------------------------------------------------------
/Scripts/Extensions/VectorExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 71f8447a0b084520aac01172f18bf97f
3 | timeCreated: 1602346899
--------------------------------------------------------------------------------
/Scripts/Gizmos.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4de037a4306045fcabf69cbac15a03c1
3 | timeCreated: 1691483962
--------------------------------------------------------------------------------
/Scripts/Gizmos/ShowGizmoCapsule.cs:
--------------------------------------------------------------------------------
1 | #if UNITY_EDITOR
2 | using UnityEditor;
3 | #endif
4 | using UnityEngine;
5 |
6 | namespace ElasticSea.Framework.Gizmo
7 | {
8 | public class ShowGizmoCapsule : MonoBehaviour
9 | {
10 | public float Radius;
11 | public float Height;
12 | public Color Color;
13 | public bool OnDrawGizmosEnabled = true;
14 | public bool OnDrawGizmosSelectedEnabled = false;
15 |
16 | private void OnDrawGizmos()
17 | {
18 | if (OnDrawGizmosEnabled)
19 | {
20 | OnDraw();
21 | }
22 | }
23 |
24 | private void OnDrawGizmosSelected()
25 | {
26 | if (OnDrawGizmosSelectedEnabled)
27 | {
28 | OnDraw();
29 | }
30 | }
31 |
32 | private void OnDraw()
33 | {
34 | DrawWireCapsule(Radius, Height, Color);
35 | }
36 |
37 | public void DrawWireCapsule(float _radius, float _height, Color _color)
38 | {
39 | #if UNITY_EDITOR
40 | Handles.color = _color;
41 | Handles.matrix = transform.localToWorldMatrix;
42 |
43 | var pointOffset = (_height - (_radius * 2)) / 2;
44 |
45 | //draw sideways
46 | Handles.DrawWireArc(Vector3.up * pointOffset, Vector3.left, Vector3.back, -180, _radius);
47 | Handles.DrawLine(new Vector3(0, pointOffset, -_radius), new Vector3(0, -pointOffset, -_radius));
48 | Handles.DrawLine(new Vector3(0, pointOffset, _radius), new Vector3(0, -pointOffset, _radius));
49 | Handles.DrawWireArc(Vector3.down * pointOffset, Vector3.left, Vector3.back, 180, _radius);
50 | //draw frontways
51 | Handles.DrawWireArc(Vector3.up * pointOffset, Vector3.back, Vector3.left, 180, _radius);
52 | Handles.DrawLine(new Vector3(-_radius, pointOffset, 0), new Vector3(-_radius, -pointOffset, 0));
53 | Handles.DrawLine(new Vector3(_radius, pointOffset, 0), new Vector3(_radius, -pointOffset, 0));
54 | Handles.DrawWireArc(Vector3.down * pointOffset, Vector3.back, Vector3.left, -180, _radius);
55 | //draw center
56 | Handles.DrawWireDisc(Vector3.up * pointOffset, Vector3.up, _radius);
57 | Handles.DrawWireDisc(Vector3.down * pointOffset, Vector3.up, _radius);
58 | #endif
59 | }
60 | }
61 | }
--------------------------------------------------------------------------------
/Scripts/Gizmos/ShowGizmoCapsule.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ca020720243a4c53afb9a6c8f4925a0a
3 | timeCreated: 1691483990
--------------------------------------------------------------------------------
/Scripts/Misc.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cefe3a3ed9f04296812ebddd53346ee9
3 | timeCreated: 1689606498
--------------------------------------------------------------------------------
/Scripts/Misc/BoundsTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Linq;
4 | using ElasticSea.Framework.Extensions;
5 | using ElasticSea.Framework.Util;
6 | using UnityEngine;
7 | using Random = System.Random;
8 |
9 | namespace ElasticSea.Framework.Scripts.Misc
10 | {
11 | public class BoundsTest : MonoBehaviour
12 | {
13 | public enum TestType
14 | {
15 | FastCircle, Circle
16 | }
17 |
18 | [SerializeField] private int pointsCount;
19 | [SerializeField] private TestType Type;
20 | public TimeSpan Elapsed { get; private set; }
21 |
22 | private void OnDrawGizmos()
23 | {
24 | var transforms = transform.Children();
25 | if (transforms.Any())
26 | {
27 | foreach (var t in transforms)
28 | {
29 | Gizmos.DrawWireSphere(t.position, 0.01f);
30 | }
31 | var points = transforms.Select(t => t.position).ToArray();
32 |
33 | Gizmos.color = Color.yellow;
34 |
35 | switch (Type)
36 | {
37 | case TestType.FastCircle:
38 | DrawCircle(points, BoundsExtensions.ToFastCircleBounds);
39 | break;
40 | case TestType.Circle:
41 | DrawCircle(points, BoundsExtensions.ToCircleBounds);
42 | break;
43 | default:
44 | throw new ArgumentOutOfRangeException();
45 | }
46 | }
47 | }
48 |
49 | private void DrawCircle(Vector3[] points, Func factory)
50 | {
51 | var points2d2 = points.Select(p => new Vector2(p.x, p.z)).ToArray();
52 |
53 | var sw = Stopwatch.StartNew();
54 | var circle2 = factory(points2d2);
55 | Elapsed = sw.Elapsed;
56 | Gizmos.DrawWireSphere(circle2.center.ToXZ(), 0.01f);
57 |
58 | GizmoUtils.DrawCircle(circle2.center.ToXZ(), Vector3.up, circle2.radius, 512);
59 | }
60 |
61 | public void SpawnPoints()
62 | {
63 | transform.DestroyChildren(true);
64 |
65 | var rng = new Random();
66 | for (int i = 0; i < pointsCount; i++)
67 | {
68 | var point = new GameObject("Point " + (i + 1));
69 | point.transform.SetParent(transform, false);
70 |
71 | var angle = (float)(rng.NextDouble() * Mathf.PI * 2);
72 | var radius = (float)rng.NextDouble();
73 | var x = Mathf.Cos(angle) * radius;
74 | var y = Mathf.Sin(angle) * radius;
75 | point.transform.position = new Vector3(x, 0, y);
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Scripts/Misc/BoundsTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac10d3a60eead0540b9b9fba32f2a9b2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Misc/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6a7906375dd0450dba0c183a464ac792
3 | timeCreated: 1689606507
--------------------------------------------------------------------------------
/Scripts/Misc/Editor/BoundsTestEditor.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Scripts.Misc.Editor
5 | {
6 | [CustomEditor(typeof(BoundsTest))]
7 | public class BoundsTestEditor : UnityEditor.Editor
8 | {
9 | public override void OnInspectorGUI()
10 | {
11 | base.OnInspectorGUI();
12 |
13 | var boundsTest = (BoundsTest)target;
14 |
15 | if (GUILayout.Button("SpawnPoints"))
16 | {
17 | boundsTest.SpawnPoints();
18 | }
19 |
20 | GUILayout.Label(boundsTest.Elapsed.ToString());
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/Scripts/Misc/Editor/BoundsTestEditor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 07339289011e442083a0c0eef0c8311a
3 | timeCreated: 1689121606
--------------------------------------------------------------------------------
/Scripts/Util.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2f7458427b988f9479597cd33944ca81
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Util/AssertUtils.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.Assertions;
3 |
4 | namespace ElasticSea.Framework.Util
5 | {
6 | public class AssertUtils
7 | {
8 | public static void AreApproximatelyEqual(Vector3 expected, Vector3 actual)
9 | {
10 | Assert.AreApproximatelyEqual(expected.x, actual.x);
11 | Assert.AreApproximatelyEqual(expected.y, actual.y);
12 | Assert.AreApproximatelyEqual(expected.z, actual.z);
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Scripts/Util/AssertUtils.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 00f657ff47fd42139f78bde1ee423e16
3 | timeCreated: 1704874926
--------------------------------------------------------------------------------
/Scripts/Util/BoolBuffer.cs:
--------------------------------------------------------------------------------
1 | namespace ElasticSea.Framework.Util
2 | {
3 | public class BoolBuffer : CircularBuffer
4 | {
5 | public BoolBuffer(int capacity) : base(capacity)
6 | {
7 | }
8 |
9 | public bool Average()
10 | {
11 | var falseCount = 0;
12 | var trueCount = 0;
13 | var bufferLength = buffer.Length;
14 |
15 | for (var i = 0; i < bufferLength; i++)
16 | {
17 | if (buffer[i])
18 | {
19 | trueCount++;
20 | }
21 | else
22 | {
23 | falseCount++;
24 | }
25 | }
26 |
27 | return trueCount > falseCount;
28 | }
29 |
30 | public void Clear(bool value = false)
31 | {
32 | var bufferLength = buffer.Length;
33 | for (var i = 0; i < bufferLength; i++)
34 | {
35 | buffer[i] = value;
36 | }
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/Scripts/Util/BoolBuffer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f7546aecae35409588ec1b6c9af447c7
3 | timeCreated: 1723825017
--------------------------------------------------------------------------------
/Scripts/Util/BoxColliderData.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util
4 | {
5 | public class BoxColliderData : ColliderData
6 | {
7 | public Vector3 Center;
8 | public Vector3 Size;
9 |
10 | public BoxColliderData(Vector3 center, Vector3 size)
11 | {
12 | Center = center;
13 | Size = size;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Scripts/Util/BoxColliderData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1880adc406314f339e4a1603104cbc4a
3 | timeCreated: 1720810190
--------------------------------------------------------------------------------
/Scripts/Util/BoxTriangleIntersector.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Blocks.Meshbakers;
4 | using ElasticSea.Framework.Extensions;
5 | using UnityEngine;
6 |
7 | namespace ElasticSea.Framework.Scripts.Util
8 | {
9 | public class BoxTriangleIntersector
10 | {
11 | public static bool IsIntersecting(Bounds box, Vector3 t0, Vector3 t1, Vector3 t2)
12 | {
13 | var ibox = new FastBox(box);
14 | var itriangle = new FastTriangle(t0, t1, t2);
15 |
16 | return IsIntersecting(ibox, itriangle);
17 | }
18 |
19 | public class FastTriangle
20 | {
21 | public readonly Vector3 a;
22 | public readonly Vector3 b;
23 | public readonly Vector3 c;
24 | public readonly Vector3[] vertices;
25 | public readonly Vector3 normal;
26 |
27 | public FastTriangle(Vector3 t0, Vector3 t1, Vector3 t2)
28 | {
29 | this.a = t0;
30 | this.b = t1;
31 | this.c = t2;
32 | this.vertices = new[] { t0, t1, t2 };
33 | this.normal = Vector3.Normalize(Vector3.Cross(b - a, c - a));
34 | }
35 | }
36 |
37 | public class FastBox
38 | {
39 | public readonly Vector3 min;
40 | public readonly Vector3 max;
41 | public readonly Vector3[] vertices;
42 | public readonly float[] minCoords;
43 | public readonly float[] maxCoords;
44 |
45 | public FastBox(Bounds bounds)
46 | {
47 | min = bounds.min;
48 | max = bounds.max;
49 | vertices = bounds.GetVertices();
50 | minCoords = new[] { min.x, min.y, min.z };
51 | maxCoords = new[] { max.x, max.y, max.z };
52 | }
53 |
54 | public FastBox(FastBounds bounds)
55 | {
56 | min = bounds.Min;
57 | max = bounds.Max;
58 | vertices = bounds.Vertices();
59 | minCoords = new[] { min.x, min.y, min.z };
60 | maxCoords = new[] { max.x, max.y, max.z };
61 | }
62 | }
63 |
64 | private static readonly Vector3[] boxNormals =
65 | {
66 | new Vector3(1, 0, 0),
67 | new Vector3(0, 1, 0),
68 | new Vector3(0, 0, 1)
69 | };
70 |
71 | public static bool IsIntersecting(FastBox box, FastTriangle fastTriangle)
72 | {
73 | float triangleMin, triangleMax;
74 | float boxMin, boxMax;
75 |
76 | // Test the box normals (x-, y- and z-axes)
77 | for (int i = 0; i < 3; i++)
78 | {
79 | Project(fastTriangle.vertices, boxNormals[i], out triangleMin, out triangleMax);
80 | if (triangleMax < box.minCoords[i] || triangleMin > box.maxCoords[i])
81 | return false; // No intersection possible.
82 | }
83 |
84 | // Test the triangle normal
85 | var triangleOffset = Vector3.Dot(fastTriangle.normal, fastTriangle.a);
86 | Project(box.vertices, fastTriangle.normal, out boxMin, out boxMax);
87 | if (boxMax < triangleOffset || boxMin > triangleOffset)
88 | return false; // No intersection possible.
89 |
90 | // Test the nine edge cross-products
91 | Vector3[] triangleEdges = {
92 | fastTriangle.a - fastTriangle.b,
93 | fastTriangle.b - fastTriangle.c,
94 | fastTriangle.c - fastTriangle.a
95 | };
96 | for (int i = 0; i < 3; i++)
97 | for (int j = 0; j < 3; j++)
98 | {
99 | // The box normals are the same as it's edge tangents
100 | var axis = Vector3.Cross(triangleEdges[i], boxNormals[j]);
101 | Project(box.vertices, axis, out boxMin, out boxMax);
102 | Project(fastTriangle.vertices, axis, out triangleMin, out triangleMax);
103 | if (boxMax <= triangleMin || boxMin >= triangleMax)
104 | return false; // No intersection possible
105 | }
106 |
107 | // No separating axis found.
108 | return true;
109 | }
110 |
111 | static void Project(Vector3[] points, Vector3 axis, out float min, out float max)
112 | {
113 | min = float.PositiveInfinity;
114 | max = float.NegativeInfinity;
115 | var length = points.Length;
116 | for (var i = 0; i < length; i++)
117 | {
118 | var point = points[i];
119 | // TODO check next line performance on il2cpp vs Vecto3.Dot
120 | var val = axis.x * point.x + axis.y * point.y + axis.z * point.z;
121 | if (val < min) min = val;
122 | if (val > max) max = val;
123 | }
124 | }
125 | }
126 | }
--------------------------------------------------------------------------------
/Scripts/Util/BoxTriangleIntersector.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 148888b2239a4ed79b705e5eadfa188a
3 | timeCreated: 1679141523
--------------------------------------------------------------------------------
/Scripts/Util/BoxTriangleIntersectorOld.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3daf83e8d05459187fd5e4622c98f75
3 | timeCreated: 1679141300
--------------------------------------------------------------------------------
/Scripts/Util/ByteArrayComparer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace ElasticSea.Framework.Util
5 | {
6 | public class ByteArrayComparer : EqualityComparer
7 | {
8 | public override bool Equals(byte[] first, byte[] second)
9 | {
10 | if (first == null || second == null) {
11 | // null == null returns true.
12 | // non-null == null returns false.
13 | return first == second;
14 | }
15 | if (ReferenceEquals(first, second)) {
16 | return true;
17 | }
18 | if (first.Length != second.Length) {
19 | return false;
20 | }
21 |
22 | for (var i = 0; i < first.Length; i++)
23 | {
24 | if (first[i] != second[i])
25 | {
26 | return false;
27 | }
28 | }
29 |
30 | return true;
31 | }
32 |
33 | public override int GetHashCode(byte[] obj)
34 | {
35 | if (obj == null) {
36 | throw new ArgumentNullException("obj");
37 | }
38 | // quick and dirty, instantly identifies obviously different
39 | // arrays as being different
40 | return obj.Length;
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/Scripts/Util/ByteArrayComparer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dcc10575afe71e14085e39b090bdac94
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/ByteUtils.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 469761be3f9d8d4449c002cc308e3b4b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f7e1fdcfa78804d4e8a0ea190238b048
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/CollisionCallback.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util.Callbacks
4 | {
5 | public class CollisionCallback : MonoBehaviour
6 | {
7 | public delegate void CollisionHandler(Collision collision);
8 |
9 | public event CollisionHandler OnEnter;
10 | public event CollisionHandler OnStay;
11 | public event CollisionHandler OnExit;
12 |
13 | private void OnCollisionEnter(Collision collision) => OnEnter?.Invoke(collision);
14 | private void OnCollisionStay(Collision collision) => OnStay?.Invoke(collision);
15 | private void OnCollisionExit(Collision collision) => OnExit?.Invoke(collision);
16 | }
17 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/CollisionCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e80f72102387f1749a9f6bcef8ba8e29
3 | timeCreated: 1478873540
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDestroyCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Util.Callbacks
5 | {
6 | public class OnDestroyCallback : MonoBehaviour
7 | {
8 | public event Action OnDestroyEvent = () => { };
9 |
10 | private void OnDestroy()
11 | {
12 | OnDestroyEvent();
13 | foreach(var d in OnDestroyEvent.GetInvocationList())
14 | {
15 | OnDestroyEvent -= (Action)d;
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDestroyCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f0ae40073e7048898774c5f9264783ad
3 | timeCreated: 1549731932
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDisableCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Scripts.Util.Callbacks
5 | {
6 | public class OnDisableCallback : MonoBehaviour
7 | {
8 | public event Action OnDisableEvent = () => { };
9 |
10 | private void OnDisable()
11 | {
12 | OnDisableEvent();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDisableCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 69c29a08e50844508a6fad34ecb38126
3 | timeCreated: 1668295675
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDragCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnDragCallback : MonoBehaviour, IDragHandler
8 | {
9 | public event Action OnDragEvent = data => { };
10 | public void OnDrag(PointerEventData eventData) => OnDragEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDragCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d0b0636675d9405cbc1e3c16af334127
3 | timeCreated: 1551617750
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDrawGizmoCallback.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util.Callbacks
4 | {
5 | public class OnDrawGizmoCallback : MonoBehaviour
6 | {
7 | public delegate void OnDrawGizmosHandler();
8 |
9 | public event OnDrawGizmosHandler OnDrawGizmosEvent;
10 | public event OnDrawGizmosHandler OnDrawGizmosSelectedEvent;
11 |
12 | private void OnDrawGizmos() => OnDrawGizmosEvent?.Invoke();
13 | private void OnDrawGizmosSelected() => OnDrawGizmosSelectedEvent?.Invoke();
14 | }
15 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnDrawGizmoCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b1e6b5eea034882aab1360c54fcb833
3 | timeCreated: 1708058130
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerClickCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnPointerClickCallback : MonoBehaviour, IPointerClickHandler
8 | {
9 | public event Action OnPointerClickEvent = data => { };
10 | public void OnPointerClick(PointerEventData eventData) => OnPointerClickEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerClickCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a0fc9443c8de40c0af4de32ef1d089dd
3 | timeCreated: 1554753472
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerDownCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnPointerDownCallback : MonoBehaviour, IPointerDownHandler
8 | {
9 | public event Action OnPointerDownEvent = data => { };
10 | public void OnPointerDown(PointerEventData eventData) => OnPointerDownEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerDownCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 789a7255cb594ab0a8b2064db9e5617e
3 | timeCreated: 1551617642
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerEnterCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnPointerEnterCallback : MonoBehaviour, IPointerEnterHandler
8 | {
9 | public event Action OnPointerEnterEvent = data => { };
10 | public void OnPointerEnter(PointerEventData eventData) => OnPointerEnterEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerEnterCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2587768b824040fb89f2331dcc0e6cb4
3 | timeCreated: 1551617720
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerExitCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnPointerExitCallback : MonoBehaviour, IPointerExitHandler
8 | {
9 | public event Action OnPointerExitEvent = data => { };
10 | public void OnPointerExit(PointerEventData eventData) => OnPointerExitEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerExitCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1d0c448388134b07b6b43033f38df9bd
3 | timeCreated: 1551617732
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerUpCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 | using UnityEngine.EventSystems;
4 |
5 | namespace ElasticSea.Framework.Util.Callbacks
6 | {
7 | public class OnPointerUpCallback : MonoBehaviour, IPointerUpHandler
8 | {
9 | public event Action OnPointerUpEvent = data => { };
10 | public void OnPointerUp(PointerEventData eventData) => OnPointerUpEvent(eventData);
11 | }
12 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPointerUpCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d092f8a5463f48ca9dfb76f39a375aa3
3 | timeCreated: 1551617701
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPostRender.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util.Callbacks
4 | {
5 | public class OnPostRenderCallback : MonoBehaviour
6 | {
7 | public event OnPostRenderHandler OnPostRenderEvent;
8 |
9 | public delegate void OnPostRenderHandler();
10 |
11 | private void OnPostRender() => OnPostRenderEvent?.Invoke();
12 | }
13 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPostRender.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8911d5fd06704ee4ac7b186e0c340755
3 | timeCreated: 1708056913
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPreCullCallback.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util.Callbacks
4 | {
5 | public class OnPreCullCallback : MonoBehaviour
6 | {
7 | public delegate void OnPreCullHandler();
8 |
9 | public event OnPreCullHandler OnPreCullEvent;
10 |
11 | private void OnPreCull() => OnPreCullEvent?.Invoke();
12 | }
13 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnPreCullCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 334d2a71602e415aa61507ab81d1012f
3 | timeCreated: 1621962081
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnRectTransformDimensionsChangeCallback.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Util.Callbacks
5 | {
6 | public class OnRectTransformDimensionsChangeCallback : MonoBehaviour
7 | {
8 | public event Action OnRectTransformDimensionsChangeEvent = () => { };
9 |
10 | private void OnRectTransformDimensionsChange()
11 | {
12 | OnRectTransformDimensionsChangeEvent();
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/OnRectTransformDimensionsChangeCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cfb4a9e201774fc9a4517fd32bfd7058
3 | timeCreated: 1638986657
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/TriggerCallback.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util.Callbacks
4 | {
5 | public class TriggerCallback : MonoBehaviour
6 | {
7 | public delegate void TriggerHandler(Collider collider);
8 |
9 | public event TriggerHandler OnEnter;
10 | public event TriggerHandler OnStay;
11 | public event TriggerHandler OnExit;
12 |
13 | private void OnTriggerEnter(Collider collider) => OnEnter?.Invoke(collider);
14 | private void OnTriggerStay(Collider collider) => OnStay?.Invoke(collider);
15 | private void OnTriggerExit(Collider collider) => OnExit?.Invoke(collider);
16 | }
17 | }
--------------------------------------------------------------------------------
/Scripts/Util/Callbacks/TriggerCallback.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6859cad787eee6440b91a69835a39037
3 | timeCreated: 1478873540
4 | licenseType: Pro
5 | MonoImporter:
6 | serializedVersion: 2
7 | defaultReferences: []
8 | executionOrder: 0
9 | icon: {instanceID: 0}
10 | userData:
11 | assetBundleName:
12 | assetBundleVariant:
13 |
--------------------------------------------------------------------------------
/Scripts/Util/CapsuleColliderData.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace ElasticSea.Framework.Util
4 | {
5 | public class CapsuleColliderData : ColliderData
6 | {
7 | public Vector3 Start;
8 | public Vector3 End;
9 | public float Radius;
10 |
11 | public CapsuleColliderData(Vector3 start, Vector3 end, float radius)
12 | {
13 | Start = start;
14 | End = end;
15 | Radius = radius;
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/Scripts/Util/CapsuleColliderData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0ca4bedd11c54e138880203024f9593c
3 | timeCreated: 1720810220
--------------------------------------------------------------------------------
/Scripts/Util/CircularBuffer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace ElasticSea.Framework.Util
6 | {
7 | public class CircularBuffer : IEnumerable
8 | {
9 | protected T[] buffer;
10 | private int nextIndex;
11 |
12 | public CircularBuffer(int capacity)
13 | {
14 | buffer = new T[capacity];
15 | Capacity = capacity;
16 | }
17 |
18 | public int Capacity { get; }
19 |
20 | public int Count { get; private set; }
21 |
22 | public bool IsFull => Count == Capacity;
23 |
24 | public IEnumerator GetEnumerator()
25 | {
26 | int start;
27 | int count;
28 |
29 | if (!IsFull)
30 | {
31 | start = 0;
32 | count = nextIndex;
33 | }
34 | else
35 | {
36 | start = nextIndex;
37 | count = start + Capacity;
38 | }
39 |
40 | for (var i = start; i < count; i++)
41 | {
42 | yield return buffer[i % Capacity];
43 | }
44 | }
45 |
46 | IEnumerator IEnumerable.GetEnumerator()
47 | {
48 | return GetEnumerator();
49 | }
50 |
51 | public void Add(T element)
52 | {
53 | buffer[nextIndex] = element;
54 | Count = Mathf.Min(Count + 1, Capacity);
55 | nextIndex = (nextIndex + 1) % Capacity;
56 | }
57 |
58 | public void Reset()
59 | {
60 | nextIndex = 0;
61 | Count = 0;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/Scripts/Util/CircularBuffer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1b8ac4b678f1e7146b616a3a764860f3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/ColliderData.cs:
--------------------------------------------------------------------------------
1 | namespace ElasticSea.Framework.Util
2 | {
3 | public class ColliderData
4 | {
5 |
6 | }
7 | }
--------------------------------------------------------------------------------
/Scripts/Util/ColliderData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e9fe23bbd89d4be798e3bb759cea9dc4
3 | timeCreated: 1720810145
--------------------------------------------------------------------------------
/Scripts/Util/Conversions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c34a2f4a213fc15439c62b4393556927
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/BigEndianBitConverter.cs:
--------------------------------------------------------------------------------
1 | namespace ElasticSea.Framework.Util.Conversions
2 | {
3 | ///
4 | /// Implementation of EndianBitConverter which converts to/from big-endian
5 | /// byte arrays.
6 | ///
7 | public sealed class BigEndianBitConverter : EndianBitConverter
8 | {
9 | ///
10 | /// Indicates the byte order ("endianess") in which data is converted using this class.
11 | ///
12 | ///
13 | /// Different computer architectures store data using different byte orders. "Big-endian"
14 | /// means the most significant byte is on the left end of a word. "Little-endian" means the
15 | /// most significant byte is on the right end of a word.
16 | ///
17 | /// true if this converter is little-endian, false otherwise.
18 | public sealed override bool IsLittleEndian()
19 | {
20 | return false;
21 | }
22 |
23 | ///
24 | /// Indicates the byte order ("endianess") in which data is converted using this class.
25 | ///
26 | public sealed override Endianness Endianness
27 | {
28 | get { return Endianness.BigEndian; }
29 | }
30 |
31 | ///
32 | /// Copies the specified number of bytes from value to buffer, starting at index.
33 | ///
34 | /// The value to copy
35 | /// The number of bytes to copy
36 | /// The buffer to copy the bytes into
37 | /// The index to start at
38 | protected override void CopyBytesImpl(long value, int bytes, byte[] buffer, int index)
39 | {
40 | int endOffset = index + bytes - 1;
41 | for (int i = 0; i < bytes; i++)
42 | {
43 | buffer[endOffset - i] = unchecked((byte) (value & 0xff));
44 | value = value >> 8;
45 | }
46 | }
47 |
48 | ///
49 | /// Returns a value built from the specified number of bytes from the given buffer,
50 | /// starting at index.
51 | ///
52 | /// The data in byte array format
53 | /// The first index to use
54 | /// The number of bytes to use
55 | /// The value built from the given bytes
56 | protected override long FromBytes(byte[] buffer, int startIndex, int bytesToConvert)
57 | {
58 | long ret = 0;
59 | for (int i = 0; i < bytesToConvert; i++)
60 | {
61 | ret = unchecked((ret << 8) | buffer[startIndex + i]);
62 | }
63 |
64 | return ret;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/BigEndianBitConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c4842728e16e1c749b94d249f0471d2c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/DoubleConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 92831c3b43cfd9142a0e87bcb195baf9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/EndianBitConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ffb6e3f73d0831b458ec11b84167e172
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/Endianness.cs:
--------------------------------------------------------------------------------
1 | namespace ElasticSea.Framework.Util.Conversions
2 | {
3 | ///
4 | /// Endianness of a converter
5 | ///
6 | public enum Endianness
7 | {
8 | ///
9 | /// Little endian - least significant byte first
10 | ///
11 | LittleEndian,
12 |
13 | ///
14 | /// Big endian - most significant byte first
15 | ///
16 | BigEndian
17 | }
18 | }
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/Endianness.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 46d37ef2b6991074d9e967212809dd49
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/LittleEndianBitConverter.cs:
--------------------------------------------------------------------------------
1 | namespace ElasticSea.Framework.Util.Conversions
2 | {
3 | ///
4 | /// Implementation of EndianBitConverter which converts to/from little-endian
5 | /// byte arrays.
6 | ///
7 | public sealed class LittleEndianBitConverter : EndianBitConverter
8 | {
9 | ///
10 | /// Indicates the byte order ("endianess") in which data is converted using this class.
11 | ///
12 | ///
13 | /// Different computer architectures store data using different byte orders. "Big-endian"
14 | /// means the most significant byte is on the left end of a word. "Little-endian" means the
15 | /// most significant byte is on the right end of a word.
16 | ///
17 | /// true if this converter is little-endian, false otherwise.
18 | public sealed override bool IsLittleEndian()
19 | {
20 | return true;
21 | }
22 |
23 | ///
24 | /// Indicates the byte order ("endianess") in which data is converted using this class.
25 | ///
26 | public sealed override Endianness Endianness
27 | {
28 | get { return Endianness.LittleEndian; }
29 | }
30 |
31 | ///
32 | /// Copies the specified number of bytes from value to buffer, starting at index.
33 | ///
34 | /// The value to copy
35 | /// The number of bytes to copy
36 | /// The buffer to copy the bytes into
37 | /// The index to start at
38 | protected override void CopyBytesImpl(long value, int bytes, byte[] buffer, int index)
39 | {
40 | for (int i = 0; i < bytes; i++)
41 | {
42 | buffer[i + index] = unchecked((byte) (value & 0xff));
43 | value = value >> 8;
44 | }
45 | }
46 |
47 | ///
48 | /// Returns a value built from the specified number of bytes from the given buffer,
49 | /// starting at index.
50 | ///
51 | /// The data in byte array format
52 | /// The first index to use
53 | /// The number of bytes to use
54 | /// The value built from the given bytes
55 | protected override long FromBytes(byte[] buffer, int startIndex, int bytesToConvert)
56 | {
57 | long ret = 0;
58 | for (int i = 0; i < bytesToConvert; i++)
59 | {
60 | ret = unchecked((ret << 8) | buffer[startIndex + bytesToConvert - 1 - i]);
61 | }
62 |
63 | return ret;
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/Scripts/Util/Conversions/LittleEndianBitConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: da7fe0a41490c9f4cb187d94d2d6d82a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/CylinderBounds.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace ElasticSea.Framework.Scripts.Util
5 | {
6 | [Serializable]
7 | public struct CylinderBounds
8 | {
9 | public float Height;
10 | public float Radius;
11 | public Vector3 Center;
12 |
13 | public CylinderBounds(Vector3 center, float radius, float height)
14 | {
15 | Height = height;
16 | Radius = radius;
17 | Center = center;
18 | }
19 |
20 | public Vector3 BottomCenter()
21 | {
22 | return Center - new Vector3(0, Height / 2, 0);
23 | }
24 |
25 | public Vector3 TopCenter()
26 | {
27 | return Center + new Vector3(0, Height / 2, 0);
28 | }
29 |
30 | public static bool operator ==(CylinderBounds c1, CylinderBounds c2)
31 | {
32 | return c1.Equals(c2);
33 | }
34 |
35 | public static bool operator !=(CylinderBounds c1, CylinderBounds c2)
36 | {
37 | return !c1.Equals(c2);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/Scripts/Util/CylinderBounds.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02d361494bbf47269f15ef65f0161fff
3 | timeCreated: 1679242266
--------------------------------------------------------------------------------
/Scripts/Util/DI.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 277184506e799f94899e342a2e9eec81
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Scripts/Util/DI/DependencyInjection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace ElasticSea.Framework.Scripts.Util.DI
4 | {
5 | public class DependencyInjectionAttribute : Attribute
6 | {
7 |
8 | }
9 | }
--------------------------------------------------------------------------------
/Scripts/Util/DI/DependencyInjection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c6666346bee0a14fadd3e90a9e0bd12
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Scripts/Util/DI/DependencyInjectionUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using UnityEngine;
6 |
7 | namespace ElasticSea.Framework.Scripts.Util.DI
8 | {
9 | public static class DependencyInjectionUtils
10 | {
11 | private static Dictionary action)>> dict = new Dictionary action)>>();
12 | private static List<(Type fieldType, Action