├── .editorconfig
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── labeler.yml
└── workflows
│ └── label.yml
├── .gitignore
├── .idea
└── .idea.UniversalInventorySystem
│ └── .idea
│ ├── .gitignore
│ ├── indexLayout.xml
│ ├── misc.xml
│ └── vcs.xml
├── Assets
├── HandsomeDinosaur.meta
└── HandsomeDinosaur
│ ├── InventorySystem.meta
│ ├── InventorySystem
│ ├── Demo.meta
│ ├── Demo
│ │ ├── Scenes.meta
│ │ └── Scenes
│ │ │ ├── DemoScene.unity
│ │ │ ├── DemoScene.unity.meta
│ │ │ ├── Resources.meta
│ │ │ └── Resources
│ │ │ ├── TestReg.asset
│ │ │ └── TestReg.asset.meta
│ ├── Scripts.meta
│ └── Scripts
│ │ ├── Inventory.meta
│ │ ├── Inventory
│ │ ├── BasicInventory.cs
│ │ ├── BasicInventory.cs.meta
│ │ ├── BasicSlot.cs
│ │ ├── BasicSlot.cs.meta
│ │ ├── Interfaces.meta
│ │ └── Interfaces
│ │ │ ├── IInventory.cs
│ │ │ ├── IInventory.cs.meta
│ │ │ ├── ISlot.cs
│ │ │ └── ISlot.cs.meta
│ │ ├── InventorySystem.asmdef
│ │ ├── InventorySystem.asmdef.meta
│ │ ├── Items.meta
│ │ ├── Items
│ │ ├── BasicItem.cs
│ │ ├── BasicItem.cs.meta
│ │ ├── Interfaces.meta
│ │ ├── Interfaces
│ │ │ ├── IItem.cs
│ │ │ ├── IItem.cs.meta
│ │ │ ├── IItemData.cs
│ │ │ ├── IItemData.cs.meta
│ │ │ ├── IItemStack.cs
│ │ │ └── IItemStack.cs.meta
│ │ ├── ItemDatas.meta
│ │ ├── ItemDatas
│ │ │ ├── BasicItemData.cs
│ │ │ └── BasicItemData.cs.meta
│ │ ├── ItemStack.cs
│ │ ├── ItemStack.cs.meta
│ │ ├── SODefinitions.meta
│ │ └── SODefinitions
│ │ │ ├── SOItem.cs
│ │ │ └── SOItem.cs.meta
│ │ ├── Registries.meta
│ │ └── Registries
│ │ ├── Interfaces.meta
│ │ ├── Interfaces
│ │ ├── IItemRegistry.cs
│ │ └── IItemRegistry.cs.meta
│ │ ├── ItemRegistry.cs
│ │ ├── ItemRegistry.cs.meta
│ │ ├── ItemRegistrySO.cs
│ │ └── ItemRegistrySO.cs.meta
│ ├── MolecularLib.meta
│ └── MolecularLib
│ ├── Core.meta
│ └── Core
│ ├── AutoAssign.meta
│ ├── AutoAssign
│ ├── AutoAssignAt.cs
│ ├── AutoAssignAt.cs.meta
│ ├── AutoAssignController.cs
│ ├── AutoAssignController.cs.meta
│ ├── AutoAssignMonoBehaviour.cs
│ ├── AutoAssignMonoBehaviour.cs.meta
│ ├── FindAttribute.cs
│ ├── FindAttribute.cs.meta
│ ├── FindGameObjectsWithTag.cs
│ ├── FindGameObjectsWithTag.cs.meta
│ ├── FindObjectOfTypeAttribute.cs
│ ├── FindObjectOfTypeAttribute.cs.meta
│ ├── FindObjectsOfTypeAttribute.cs
│ ├── FindObjectsOfTypeAttribute.cs.meta
│ ├── FindWithTagAttribute.cs
│ ├── FindWithTagAttribute.cs.meta
│ ├── GetComponentAttribute.cs
│ ├── GetComponentAttribute.cs.meta
│ ├── GetComponentInChildrenAttribute.cs
│ ├── GetComponentInChildrenAttribute.cs.meta
│ ├── GetComponentInParentAttribute.cs
│ ├── GetComponentInParentAttribute.cs.meta
│ ├── GetComponentsAttribute.cs
│ ├── GetComponentsAttribute.cs.meta
│ ├── GetComponentsInChildrenAttribute.cs
│ ├── GetComponentsInChildrenAttribute.cs.meta
│ ├── GetComponentsInParentAttribute.cs
│ ├── GetComponentsInParentAttribute.cs.meta
│ ├── LoadResourceAttribute.cs
│ ├── LoadResourceAttribute.cs.meta
│ ├── UseAutoAssignAttribute.cs
│ └── UseAutoAssignAttribute.cs.meta
│ ├── Demo.meta
│ ├── Demo
│ ├── Demo.unity
│ ├── Demo.unity.meta
│ ├── DemoAutoAssign.cs
│ ├── DemoAutoAssign.cs.meta
│ ├── DemoDrawersScript.cs
│ ├── DemoDrawersScript.cs.meta
│ ├── DemoSceneController.cs
│ ├── DemoSceneController.cs.meta
│ ├── InstantiateWithArgsDemoObject.cs
│ ├── InstantiateWithArgsDemoObject.cs.meta
│ ├── Resources.meta
│ ├── Resources
│ │ ├── ArgsInstantiated.prefab
│ │ └── ArgsInstantiated.prefab.meta
│ ├── TestVolatileScriptableObject.cs
│ ├── TestVolatileScriptableObject.cs.meta
│ ├── TimersTest.cs
│ ├── TimersTest.cs.meta
│ ├── Volatile SO.asset
│ └── Volatile SO.asset.meta
│ ├── Editor.meta
│ ├── Editor
│ ├── BaseMolecularInspector.cs
│ ├── BaseMolecularInspector.cs.meta
│ ├── EditorHelper.cs
│ ├── EditorHelper.cs.meta
│ ├── MolecularEditor.Core.asmdef
│ ├── MolecularEditor.Core.asmdef.meta
│ ├── OptionalPropertyDrawer.cs
│ ├── OptionalPropertyDrawer.cs.meta
│ ├── PolymorphicVariableDrawer.cs
│ ├── PolymorphicVariableDrawer.cs.meta
│ ├── RangeEditorDrawer.cs
│ ├── RangeEditorDrawer.cs.meta
│ ├── SerializableDictionaryEditorDrawer.cs
│ ├── SerializableDictionaryEditorDrawer.cs.meta
│ ├── SpriteEditorDrawer.cs
│ ├── SpriteEditorDrawer.cs.meta
│ ├── TagEditorDrawer.cs
│ ├── TagEditorDrawer.cs.meta
│ ├── TypeVariableDrawer.cs
│ ├── TypeVariableDrawer.cs.meta
│ ├── VolatileScriptableObjectInspector.cs
│ └── VolatileScriptableObjectInspector.cs.meta
│ ├── Helpers.meta
│ ├── Helpers
│ ├── ColorHelper.cs
│ ├── ColorHelper.cs.meta
│ ├── Maths.cs
│ ├── Maths.cs.meta
│ ├── Optional.cs
│ ├── Optional.cs.meta
│ ├── PlayStatus.cs
│ ├── PlayStatus.cs.meta
│ ├── Range.cs
│ ├── Range.cs.meta
│ ├── StringExtensionMethods.cs
│ ├── StringExtensionMethods.cs.meta
│ ├── Tag.cs
│ ├── Tag.cs.meta
│ ├── TimedScope.cs
│ ├── TimedScope.cs.meta
│ ├── TypeVariable.cs
│ ├── TypeVariable.cs.meta
│ ├── VectorHelpers.cs
│ └── VectorHelpers.cs.meta
│ ├── InstantiateHelpers.meta
│ ├── InstantiateHelpers
│ ├── InstantiateWithArgsInterfaces.cs
│ ├── InstantiateWithArgsInterfaces.cs.meta
│ ├── InstantiateWithArgsMethods.cs
│ └── InstantiateWithArgsMethods.cs.meta
│ ├── Molecular.cs
│ ├── Molecular.cs.meta
│ ├── MolecularLib Docs.docx
│ ├── MolecularLib Docs.docx.meta
│ ├── MolecularLib Docs.pdf
│ ├── MolecularLib Docs.pdf.meta
│ ├── MolecularLib.asmdef
│ ├── MolecularLib.asmdef.meta
│ ├── PolymorphismSupport.meta
│ ├── PolymorphismSupport
│ ├── IPolymorphicSerializationOverride.cs
│ ├── IPolymorphicSerializationOverride.cs.meta
│ ├── PolymorphicVariable.cs
│ ├── PolymorphicVariable.cs.meta
│ ├── SerializedPolymorphicData.cs
│ ├── SerializedPolymorphicData.cs.meta
│ ├── SerializedPolymorphicField.cs
│ └── SerializedPolymorphicField.cs.meta
│ ├── SerializableDict.meta
│ ├── SerializableDict
│ ├── SerializableDictionary.cs
│ └── SerializableDictionary.cs.meta
│ ├── Singletons.meta
│ ├── Singletons
│ ├── AutoSingleton.cs
│ └── AutoSingleton.cs.meta
│ ├── Timers.meta
│ ├── Timers
│ ├── TimerManager.cs
│ ├── TimerManager.cs.meta
│ ├── Timers.cs
│ └── Timers.cs.meta
│ ├── TypeLibrary.cs
│ ├── TypeLibrary.cs.meta
│ ├── VolatileScriptableObject.cs
│ └── VolatileScriptableObject.cs.meta
├── GetStarted.gif
├── LICENSE
├── Packages
├── manifest.json
└── packages-lock.json
├── ProjectSettings
├── AudioManager.asset
├── ClusterInputManager.asset
├── DynamicsManager.asset
├── EditorBuildSettings.asset
├── EditorSettings.asset
├── GraphicsSettings.asset
├── InputManager.asset
├── NavMeshAreas.asset
├── NetworkManager.asset
├── PackageManagerSettings.asset
├── Physics2DSettings.asset
├── PresetManager.asset
├── ProjectSettings.asset
├── ProjectVersion.txt
├── QualitySettings.asset
├── TagManager.asset
├── TimeManager.asset
├── UnityConnectSettings.asset
├── VFXManager.asset
├── VersionControlSettings.asset
└── XRSettings.asset
├── README.md
├── UserSettings
└── EditorUserSettings.asset
└── image.png
/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.cs]
2 |
3 | # CS0649: Campo "Inventory._slots" nunca é atribuído e sempre terá seu valor padrão null
4 | dotnet_diagnostic.CS0649.severity = none
5 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: Heymity
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: BUG
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Screenshots**
20 | If applicable, add screenshots to help explain your problem.
21 |
22 | **Specs**
23 | - Unity Version [e.g. 2019.3.0f3]
24 | - UIS Version [e.g. v4-branch; 3.0.1; 2.0.0]
25 |
26 | **Additional context**
27 | Add any other context about the problem here.
28 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/labeler.yml:
--------------------------------------------------------------------------------
1 | core:
2 | - Assets/InventorySystem/Scripts/Inventory/*.cs
3 |
4 | editor:
5 | - Assets/InventorySystem/Editor/**/*
6 |
7 | source:
8 | - Assets
9 |
--------------------------------------------------------------------------------
/.github/workflows/label.yml:
--------------------------------------------------------------------------------
1 | # This workflow will triage pull requests and apply a label based on the
2 | # paths that are modified in the pull request.
3 | #
4 | # To use this workflow, you will need to set up a .github/labeler.yml
5 | # file with configuration. For more information, see:
6 | # https://github.com/actions/labeler
7 |
8 | name: Labeler
9 | on: [pull_request]
10 |
11 | jobs:
12 | label:
13 |
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - uses: actions/labeler@v2
18 | with:
19 | repo-token: "${{ secrets.GITHUB_TOKEN }}"
20 |
--------------------------------------------------------------------------------
/.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 | /Assets/TextMeshPro
6 | /Assets/TextMesh Pro
7 | /[Ll]ibrary/
8 | /[Tt]emp/
9 | /[Oo]bj/
10 | /[Bb]uild/
11 | /[Bb]uilds/
12 | /[Ll]ogs/
13 | /[Mm]emoryCaptures/
14 |
15 | # Asset meta data should only be ignored when the corresponding asset is also ignored
16 | !/[Aa]ssets/**/*.meta
17 |
18 | # Uncomment this line if you wish to ignore the asset store tools plugin
19 | # /[Aa]ssets/AssetStoreTools*
20 |
21 | # Autogenerated Jetbrains Rider plugin
22 | [Aa]ssets/Plugins/Editor/JetBrains*
23 |
24 | # Visual Studio cache directory
25 | .vs/
26 |
27 | # Gradle cache directory
28 | .gradle/
29 |
30 | # Autogenerated VS/MD/Consulo solution and project files
31 | ExportedObj/
32 | .consulo/
33 | *.csproj
34 | *.unityproj
35 | *.sln
36 | *.suo
37 | *.tmp
38 | *.user
39 | *.userprefs
40 | *.pidb
41 | *.booproj
42 | *.svd
43 | *.pdb
44 | *.mdb
45 | *.opendb
46 | *.VC.db
47 |
48 | # Unity3D generated meta files
49 | *.pidb.meta
50 | *.pdb.meta
51 | *.mdb.meta
52 |
53 | # Unity3D generated file on crash reports
54 | sysinfo.txt
55 |
56 | # Builds
57 | *.apk
58 | *.unitypackage
59 |
60 | # Crashlytics generated file
61 | crashlytics-build.properties
62 |
63 |
--------------------------------------------------------------------------------
/.idea/.idea.UniversalInventorySystem/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Rider ignored files
5 | /.idea.UniversalInventorySystem.iml
6 | /projectSettingsUpdater.xml
7 | /modules.xml
8 | /contentModel.xml
9 | # Editor-based HTTP Client requests
10 | /httpRequests/
11 | # Datasource local storage ignored files
12 | /dataSources/
13 | /dataSources.local.xml
14 |
--------------------------------------------------------------------------------
/.idea/.idea.UniversalInventorySystem/.idea/indexLayout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/.idea.UniversalInventorySystem/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/.idea.UniversalInventorySystem/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 734c0c094e4e8a34bbab9724c7792710
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 34ba6c686f092554d9b810de9d5d566b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 227cbc01899f482489560930e004ca67
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b18c1a45b220c764282b0dfb72ba0070
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes/DemoScene.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: 3
28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
29 | m_SkyboxMaterial: {fileID: 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, g: 0, b: 0, 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: 0
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 &1307086747
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: 1307086750}
135 | - component: {fileID: 1307086749}
136 | - component: {fileID: 1307086748}
137 | m_Layer: 0
138 | m_Name: Main Camera
139 | m_TagString: MainCamera
140 | m_Icon: {fileID: 0}
141 | m_NavMeshLayer: 0
142 | m_StaticEditorFlags: 0
143 | m_IsActive: 1
144 | --- !u!81 &1307086748
145 | AudioListener:
146 | m_ObjectHideFlags: 0
147 | m_CorrespondingSourceObject: {fileID: 0}
148 | m_PrefabInstance: {fileID: 0}
149 | m_PrefabAsset: {fileID: 0}
150 | m_GameObject: {fileID: 1307086747}
151 | m_Enabled: 1
152 | --- !u!20 &1307086749
153 | Camera:
154 | m_ObjectHideFlags: 0
155 | m_CorrespondingSourceObject: {fileID: 0}
156 | m_PrefabInstance: {fileID: 0}
157 | m_PrefabAsset: {fileID: 0}
158 | m_GameObject: {fileID: 1307086747}
159 | m_Enabled: 1
160 | serializedVersion: 2
161 | m_ClearFlags: 1
162 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
163 | m_projectionMatrixMode: 1
164 | m_GateFitMode: 2
165 | m_FOVAxisMode: 0
166 | m_SensorSize: {x: 36, y: 24}
167 | m_LensShift: {x: 0, y: 0}
168 | m_FocalLength: 50
169 | m_NormalizedViewPortRect:
170 | serializedVersion: 2
171 | x: 0
172 | y: 0
173 | width: 1
174 | height: 1
175 | near clip plane: 0.3
176 | far clip plane: 1000
177 | field of view: 60
178 | orthographic: 1
179 | orthographic size: 5
180 | m_Depth: -1
181 | m_CullingMask:
182 | serializedVersion: 2
183 | m_Bits: 4294967295
184 | m_RenderingPath: -1
185 | m_TargetTexture: {fileID: 0}
186 | m_TargetDisplay: 0
187 | m_TargetEye: 3
188 | m_HDR: 1
189 | m_AllowMSAA: 1
190 | m_AllowDynamicResolution: 0
191 | m_ForceIntoRT: 0
192 | m_OcclusionCulling: 1
193 | m_StereoConvergence: 10
194 | m_StereoSeparation: 0.022
195 | --- !u!4 &1307086750
196 | Transform:
197 | m_ObjectHideFlags: 0
198 | m_CorrespondingSourceObject: {fileID: 0}
199 | m_PrefabInstance: {fileID: 0}
200 | m_PrefabAsset: {fileID: 0}
201 | m_GameObject: {fileID: 1307086747}
202 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
203 | m_LocalPosition: {x: 0, y: 0, z: -10}
204 | m_LocalScale: {x: 1, y: 1, z: 1}
205 | m_Children: []
206 | m_Father: {fileID: 0}
207 | m_RootOrder: 0
208 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
209 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes/DemoScene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8d2dad0abb72c154eb2701d634ef4627
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes/Resources.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6bf9b569ff7578f47ba84b4af2b0df3c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes/Resources/TestReg.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: 0d3f0e99225940e8bd1ec25fb0192de1, type: 3}
13 | m_Name: TestReg
14 | m_EditorClassIdentifier:
15 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Demo/Scenes/Resources/TestReg.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7b99ef23aba075945aa561bef29b7289
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 0
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1154890f111399d44a0604fa455c1710
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 485429e5f89847a3994feda060685976
3 | timeCreated: 1683855860
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/BasicInventory.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.InventorySystem.Items;
2 |
3 | namespace MolecularLib.InventorySystem.Inventory
4 | {
5 | public class BasicInventory : IInventory
6 | {
7 | public bool AddItem(IItem item)
8 | {
9 | throw new System.NotImplementedException();
10 | }
11 |
12 | public bool AddItem(ItemStack item)
13 | {
14 | throw new System.NotImplementedException();
15 | }
16 |
17 | public bool AddItem(BasicSlot slot, ItemStack item)
18 | {
19 | throw new System.NotImplementedException();
20 | }
21 |
22 | public bool AddItem(BasicSlot slot, IItem item)
23 | {
24 | throw new System.NotImplementedException();
25 | }
26 |
27 | public bool AddItem(int slotId, ItemStack item)
28 | {
29 | throw new System.NotImplementedException();
30 | }
31 |
32 | public bool AddItem(int slotId, IItem item)
33 | {
34 | throw new System.NotImplementedException();
35 | }
36 |
37 | public bool RemoveItem(IItem item)
38 | {
39 | throw new System.NotImplementedException();
40 | }
41 |
42 | public bool RemoveItem(ItemStack item)
43 | {
44 | throw new System.NotImplementedException();
45 | }
46 |
47 | public bool RemoveItem(BasicSlot slot)
48 | {
49 | throw new System.NotImplementedException();
50 | }
51 | }
52 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/BasicInventory.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 62246bfac4394788a1a361d4134ec46a
3 | timeCreated: 1689807588
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/BasicSlot.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Helpers;
2 | using MolecularLib.InventorySystem.Items;
3 |
4 | namespace MolecularLib.InventorySystem.Inventory
5 | {
6 | public class BasicSlot : ISlot
7 | {
8 | public int Id { get; }
9 | public ItemStack Stack { get; }
10 |
11 |
12 | // TODO implement a way to set this values from unity and from code. Some sort of SlotConfig (per inventory and not perhaps)
13 | public Optional MaxSlotCapacity()
14 | {
15 | return int.MaxValue;
16 | }
17 |
18 | public Optional MinSlotCapacity()
19 | {
20 | return 0;
21 | }
22 |
23 | public bool IsEmpty() => Stack is null || Stack.IsEmpty();
24 | }
25 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/BasicSlot.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e75b4871c374909a835c6fb71dce795
3 | timeCreated: 1689807596
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/Interfaces.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b29cca3bb59c4d6ea413ade73c6e6a9a
3 | timeCreated: 1683855866
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/Interfaces/IInventory.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.InventorySystem.Items;
2 |
3 | namespace MolecularLib.InventorySystem
4 | {
5 | public interface IInventory where TSlot : ISlot where TStack : IItemStack
6 | {
7 | public bool AddItem(IItem item);
8 | public bool AddItem(TStack item);
9 | public bool AddItem(TSlot slot, TStack item);
10 | public bool AddItem(TSlot slot, IItem item);
11 | public bool AddItem(int slotId, TStack item);
12 | public bool AddItem(int slotId, IItem item);
13 |
14 | public bool RemoveItem(IItem item);
15 | public bool RemoveItem(TStack item);
16 | public bool RemoveItem(TSlot slot);
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/Interfaces/IInventory.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 376069d24d6247a59fda0edb44cab09a
3 | timeCreated: 1683855877
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/Interfaces/ISlot.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Helpers;
2 | using MolecularLib.InventorySystem.Items;
3 |
4 | namespace MolecularLib.InventorySystem
5 | {
6 | public interface ISlot where TStack : IItemStack
7 | {
8 | public int Id { get; }
9 |
10 | public TStack Stack { get; }
11 |
12 | public Optional MaxSlotCapacity();
13 | public Optional MinSlotCapacity();
14 |
15 | public bool IsEmpty();
16 |
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Inventory/Interfaces/ISlot.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b18186426e846c996e4c37aa482947d
3 | timeCreated: 1689807017
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/InventorySystem.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MolecularLib.InventorySystem",
3 | "rootNamespace": "MolecularLib.InventorySystem",
4 | "references": [
5 | "GUID:9e5a0ec676ae0684c98f3cc02d1c6c30"
6 | ],
7 | "includePlatforms": [],
8 | "excludePlatforms": [],
9 | "allowUnsafeCode": false,
10 | "overrideReferences": false,
11 | "precompiledReferences": [],
12 | "autoReferenced": true,
13 | "defineConstraints": [],
14 | "versionDefines": [],
15 | "noEngineReferences": false
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/InventorySystem.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c912dfb4f0a53be47a571fcf78c2b382
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d02b4a5db74a40c0b8a902a0f8d78b7a
3 | timeCreated: 1683388538
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/BasicItem.cs:
--------------------------------------------------------------------------------
1 | namespace MolecularLib.InventorySystem.Items
2 | {
3 | public class BasicItem : IItem
4 | {
5 | private BasicItemData data;
6 |
7 | public string Id { get; set; }
8 | public IItemData ModelItemData => data;
9 | }
10 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/BasicItem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 56d8b80f2788418b8e5f0b837f072712
3 | timeCreated: 1709822055
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 13fe455ad30a4ebba0764d5bb512769e
3 | timeCreated: 1683854426
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItem.cs:
--------------------------------------------------------------------------------
1 | namespace MolecularLib.InventorySystem.Items
2 | {
3 | public interface IItem
4 | {
5 | string Id { get; set; }
6 | IItemData ModelItemData { get; }
7 | }
8 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: be206467358b4d8fa85fa007409f7afa
3 | timeCreated: 1683854489
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItemData.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Helpers;
2 |
3 | namespace MolecularLib.InventorySystem.Items
4 | {
5 | public interface IItemData
6 | {
7 | public string DisplayName { get; }
8 |
9 | public Optional MaxStackSize { get; }
10 | public Optional MinStackSize { get; }
11 |
12 | public IItemData Clone();
13 |
14 | public bool CanCombine(in IItemData other);
15 |
16 | public bool Combine(IItemData other);
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItemData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8b8c8caa065749cd8e99b9be703f1464
3 | timeCreated: 1683428546
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItemStack.cs:
--------------------------------------------------------------------------------
1 | namespace MolecularLib.InventorySystem.Items
2 | {
3 | public interface IItemStack
4 | {
5 | public IItem ItemModel { get; }
6 | public IItemData Data { get; }
7 | public bool Merge(ref IItemStack other);
8 | public bool Merge(ref IItemStack other, int amount);
9 | public int Amount { get; }
10 |
11 | public bool IsEmpty();
12 |
13 | public bool Add(int amount);
14 | public bool CanAdd(int amount);
15 |
16 | public bool Remove(int amount);
17 | public bool CanRemove(int amount);
18 |
19 | public int MaxStackSize();
20 | public int MinStackSize();
21 | }
22 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/Interfaces/IItemStack.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 41dea25a08bd4ae19e0e32569175ade0
3 | timeCreated: 1683854442
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/ItemDatas.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0b95ef1a15574fa7a2b12c496df6d48a
3 | timeCreated: 1689790354
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/ItemDatas/BasicItemData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MolecularLib.Helpers;
3 | using UnityEngine;
4 |
5 | namespace MolecularLib.InventorySystem.Items
6 | {
7 | [Serializable]
8 | public class BasicItemData : IItemData
9 | {
10 | private string _displayName;
11 | private Sprite _itemIcon;
12 | private Optional _maxStackSize;
13 | private Optional _minStackSize;
14 |
15 | public Optional MaxStackSize
16 | {
17 | get => _maxStackSize;
18 | set => _maxStackSize = value;
19 | }
20 |
21 | public Optional MinStackSize
22 | {
23 | get => _minStackSize;
24 | set => _minStackSize = value;
25 | }
26 |
27 | public Sprite ItemIcon
28 | {
29 | get => _itemIcon;
30 | set => _itemIcon = value;
31 | }
32 |
33 | public string DisplayName
34 | {
35 | get => _displayName;
36 | set => _displayName = value;
37 | }
38 |
39 | public IItemData Clone()
40 | {
41 | return new BasicItemData
42 | {
43 | ItemIcon = this.ItemIcon,
44 | DisplayName = this.DisplayName
45 | };
46 | }
47 |
48 | public bool CanCombine(in IItemData other)
49 | {
50 | return other is BasicItemData data &&
51 | other.DisplayName == this.DisplayName &&
52 | data.ItemIcon == this.ItemIcon;
53 | }
54 |
55 | public bool Combine(IItemData other)
56 | {
57 | return CanCombine(other);
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/ItemDatas/BasicItemData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5552bc47b8eb41f5b20b2f8fdc11f208
3 | timeCreated: 1683402113
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/ItemStack.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.InventorySystem.Items
4 | {
5 | [Serializable]
6 | public class ItemStack : IItemStack
7 | {
8 | public IItem ItemModel { get; private set; }
9 | public int Amount { get; private set; }
10 | public IItemData Data { get; private set; }
11 |
12 | public ItemStack(IItem model, int count, IItemData data)
13 | {
14 | ItemModel = model;
15 | Amount = count;
16 | Data = data;
17 | }
18 |
19 | public ItemStack(IItem model, int count = 1) : this(model, count, model.ModelItemData.Clone()) { }
20 |
21 | public bool Merge(ref IItemStack stack, int amount)
22 | {
23 | if (stack is null) return false;
24 | if (!Data.Combine(stack.Data)) return false;
25 |
26 | if (!CanAdd(amount) || !CanRemove(amount)) return false;
27 |
28 | Add(amount);
29 | stack.Remove(amount);
30 |
31 | return true;
32 | }
33 |
34 | public bool Merge(ref IItemStack stack)
35 | {
36 | if (stack is null) return false;
37 | if (!Data.Combine(stack.Data)) return false;
38 |
39 | var toAdd = stack.Amount + Amount > MaxStackSize() ? MaxStackSize() - Amount : stack.Amount;
40 |
41 | //TODO Account for MinStackSize when removing.
42 |
43 | return Merge(ref stack, toAdd);
44 | }
45 |
46 | public bool IsEmpty()
47 | {
48 | return Amount > 0 || Data == null || ItemModel == null;
49 | }
50 |
51 | public bool CanAdd(int amount) => Amount + amount <= MaxStackSize();
52 | public bool CanRemove(int amount) => Amount - amount >= MinStackSize();
53 |
54 | public bool Add(int amount)
55 | {
56 | if (CanAdd(amount)) return false;
57 | Amount += amount;
58 | return true;
59 | }
60 |
61 | public bool Remove(int amount)
62 | {
63 | if (CanRemove(amount)) return false;
64 | Amount -= amount;
65 | return true;
66 | }
67 |
68 | public int MaxStackSize()
69 | {
70 | // TODO when implementing slots, or equivalent, use the min between the slot max items or item max items
71 | if (Data.MaxStackSize.UseValue)
72 | return Data.MaxStackSize;
73 |
74 | return int.MaxValue;
75 | }
76 |
77 | public int MinStackSize()
78 | {
79 | if (Data.MinStackSize.UseValue)
80 | return Data.MinStackSize;
81 |
82 | return 0;
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/ItemStack.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8504bd5edd974fbeb3c04850f77b0528
3 | timeCreated: 1683388581
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/SODefinitions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9537c77a87b34fb6862c12d43d14ec73
3 | timeCreated: 1709822422
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/SODefinitions/SOItem.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace MolecularLib.InventorySystem.Items.SODefinitions
4 | {
5 | public class SOItem : ScriptableObject, IItem where TItem : IItem
6 | {
7 | public string Id
8 | {
9 | get => item.Id;
10 | set => item.Id = value;
11 | }
12 |
13 | public IItemData ModelItemData => item.ModelItemData;
14 |
15 | [SerializeField] private TItem item;
16 | }
17 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Items/SODefinitions/SOItem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e650fb4d2e5c457cb0d78acfe8935d56
3 | timeCreated: 1709822438
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39e1f8a9765f8464c8edac6845f0d8cf
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/Interfaces.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5513233c77274b27b7db2c588219ed66
3 | timeCreated: 1709734011
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/Interfaces/IItemRegistry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using UnityEngine;
5 |
6 | namespace MolecularLib.InventorySystem.Items.Interfaces
7 | {
8 | public interface IItemRegistry : IEnumerable
9 | {
10 | IItem this[string id] { get; }
11 |
12 | string RegisterId { get; }
13 |
14 | IEnumerable Items { get; }
15 |
16 | IItem GetItemOfId(string id);
17 |
18 | bool TryGetItemOfId(string id, out IItem item);
19 |
20 | bool RegisterItem(string id, IItem item);
21 | }
22 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/Interfaces/IItemRegistry.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 53a76eca5435404ca82f6fbeae0c606e
3 | timeCreated: 1709734033
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/ItemRegistry.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using MolecularLib.InventorySystem.Items.Interfaces;
6 | using UnityEngine;
7 |
8 | namespace MolecularLib.InventorySystem.Items
9 | {
10 | [System.Serializable]
11 | public class ItemRegistry : IItemRegistry
12 | {
13 | [SerializeField] private string registerId;
14 | [SerializeField] private SerializableDictionary items;
15 |
16 | public IItem this[string id] => items[id];
17 |
18 | public string RegisterId => registerId;
19 |
20 | public IEnumerable Items => items.Values.AsEnumerable();
21 |
22 | public IItem GetItemOfId(string id) => items[id];
23 |
24 | public bool TryGetItemOfId(string id, out IItem item) => items.TryGetValue(id, out item);
25 |
26 | public bool RegisterItem(string id, IItem item)
27 | {
28 | if (items.ContainsKey(id)) return false;
29 | items.Add(id, item);
30 |
31 | return true;
32 | }
33 |
34 | public void OnValidate()
35 | {
36 | foreach (var itemDefinitionKp in items)
37 | {
38 | var itemDef = itemDefinitionKp.Value;
39 | if (itemDef == null) continue;
40 | itemDef.Id = itemDefinitionKp.Key;
41 | }
42 | }
43 |
44 | public IEnumerator GetEnumerator() => items.Values.GetEnumerator();
45 |
46 | IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/ItemRegistry.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac8e073a38f0e224494ec152af863c78
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/ItemRegistrySO.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using MolecularLib.InventorySystem.Items.Interfaces;
5 | using UnityEngine;
6 |
7 | namespace MolecularLib.InventorySystem.Items
8 | {
9 | [CreateAssetMenu(menuName = "Inventory System/New ItemRegister", order = 1, fileName = "UnnamedItemRegister")]
10 | public class ItemRegistrySO : ScriptableObject
11 | {
12 | //TODO I dont quite like this approach, it should be two separated things, the ItemRegistry and the SO, but the SO should have its own editor or something like that, not relying on the drawer for the ItemRegistry.
13 |
14 | [SerializeField] private ItemRegistry registry;
15 |
16 | public ItemRegistry Registry => registry;
17 | }
18 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/InventorySystem/Scripts/Registries/ItemRegistrySO.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d3f0e99225940e8bd1ec25fb0192de1
3 | timeCreated: 1709734241
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c7395c7fcba7a7e41b808f422237be91
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1d13c6f7bfb9f52438a810cd92ffd6a9
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 411b014dbd0203d49888354dd333b0f9
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/AutoAssignAt.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Helpers;
2 | using MolecularLib.Timers;
3 | using MolecularLib.AutoAssign;
4 | using MolecularLib.PolymorphismSupport;
5 |
6 | namespace MolecularLib.AutoAssign
7 | {
8 | /*public enum AutoAssignAt
9 | {
10 | None,
11 | Awake,
12 | Start,
13 | OnEnable,
14 | }*/
15 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/AutoAssignAt.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 73de328bae6749a0813fcf7972b68e3b
3 | timeCreated: 1658441456
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/AutoAssignController.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0e110e6286f3468dbc394e4e7eee58cf
3 | timeCreated: 1658442204
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/AutoAssignMonoBehaviour.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | public class AutoAssignMonoBehaviour : MonoBehaviour
6 | {
7 | protected virtual void Awake()
8 | {
9 | this.AutoAssign();
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/AutoAssignMonoBehaviour.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a078a57b47484c26b410f5e50671e10e
3 | timeCreated: 1658457163
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class FindAttribute : Attribute
8 | {
9 | public readonly string Name;
10 |
11 | public FindAttribute(string name)
12 | {
13 | Name = name;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fe8e966fd3234e9c8e905c0d8dc4a77b
3 | timeCreated: 1658454397
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindGameObjectsWithTag.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class FindGameObjectsWithTag : Attribute
8 | {
9 | public readonly string Tag;
10 |
11 | public FindGameObjectsWithTag(string tag)
12 | {
13 | Tag = tag;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindGameObjectsWithTag.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f814da1cbd574fa69067b5b929f885f0
3 | timeCreated: 1658454434
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindObjectOfTypeAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class FindObjectOfTypeAttribute : Attribute
8 | {
9 | public readonly Type Type;
10 |
11 | public FindObjectOfTypeAttribute(Type type = null)
12 | {
13 | Type = type;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindObjectOfTypeAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7c7b5dd5f5664530a0cdffa56ec88e65
3 | timeCreated: 1658454665
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindObjectsOfTypeAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class FindObjectsOfTypeAttribute : Attribute
8 | {
9 | public readonly Type Type;
10 |
11 | public FindObjectsOfTypeAttribute(Type type = null)
12 | {
13 | Type = type;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindObjectsOfTypeAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: db15b1046d994ed08d02dae4813cca17
3 | timeCreated: 1658454745
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindWithTagAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class FindWithTagAttribute : Attribute
8 | {
9 | public readonly string Tag;
10 |
11 | public FindWithTagAttribute(string tag)
12 | {
13 | Tag = tag;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/FindWithTagAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3a4eb0b94a7c4f3d82fb44fd05a47be5
3 | timeCreated: 1658454414
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentAttribute(Type componentType = null)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e7b92ac5204a4b4abb20fbeb93792589
3 | timeCreated: 1658441673
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentInChildrenAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentInChildrenAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentInChildrenAttribute(Type componentType = null)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentInChildrenAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f7213569488244f28f58e9c6b5a7918c
3 | timeCreated: 1658454093
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentInParentAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentInParentAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentInParentAttribute(Type componentType)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentInParentAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0984fc12534043b7b93f5f6fe076887d
3 | timeCreated: 1659128235
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentsAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentsAttribute(Type componentType = null)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ba59ec6ad7b1491a834132a29a665d27
3 | timeCreated: 1658541130
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsInChildrenAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentsInChildrenAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentsInChildrenAttribute(Type componentType = null)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsInChildrenAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5140c6cf4d764ee3a9b21184009ce4b3
3 | timeCreated: 1658541057
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsInParentAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class GetComponentsInParentAttribute : Attribute
8 | {
9 | public readonly Type ComponentType;
10 |
11 | public GetComponentsInParentAttribute(Type componentType)
12 | {
13 | ComponentType = componentType;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/GetComponentsInParentAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3dae173b5ab2491d9f7ac3e4312c0812
3 | timeCreated: 1659128247
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/LoadResourceAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
6 | [JetBrains.Annotations.MeansImplicitUse(JetBrains.Annotations.ImplicitUseKindFlags.Assign), JetBrains.Annotations.UsedImplicitly]
7 | public class LoadResourceAttribute : Attribute
8 | {
9 | public readonly string ResourcePath;
10 |
11 | public LoadResourceAttribute(string resourcePath)
12 | {
13 | ResourcePath = resourcePath;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/LoadResourceAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a7cc8fb3efcd44978d28754b55d2d31a
3 | timeCreated: 1658541201
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/UseAutoAssignAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MolecularLib.AutoAssign
4 | {
5 | [AttributeUsage(AttributeTargets.Class)]
6 | [JetBrains.Annotations.UsedImplicitly]
7 | public class UseAutoAssignAttribute : Attribute
8 | {
9 | //public readonly AutoAssignAt DefaultAutoAssignMoment;
10 |
11 | public UseAutoAssignAttribute(/*AutoAssignAt defaultAutoAssignMoment = AutoAssignAt.Awake*/)
12 | {
13 | //this.DefaultAutoAssignMoment = defaultAutoAssignMoment;
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/AutoAssign/UseAutoAssignAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 805ede1b33994442bdaa8dde15534f25
3 | timeCreated: 1658441337
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d812ea495d6259b4f88de497330472b5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Demo.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e208d19544b64384ca5013d77029abc5
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoAutoAssign.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Text;
3 | using MolecularLib.AutoAssign;
4 | using UnityEngine;
5 |
6 | namespace MolecularLib.Demo
7 | {
8 | // Remember to add this attribute here on the class and call this.AutoAssign()
9 | // if you don't derive it from AutoAssignMonoBehaviour!
10 | //[UseAutoAssign]
11 | public class DemoAutoAssign : AutoAssignMonoBehaviour
12 | {
13 | [GetComponent] private Rigidbody2D _rigidbody2D;
14 | [GetComponent] private Rigidbody2D Rigidbody2DProp { get; set; }
15 |
16 | [GetComponents(typeof(BoxCollider2D))] private List _colliders;
17 | [GetComponents(typeof(BoxCollider2D))] private List CollidersProp { get; set; }
18 |
19 | [GetComponentInChildren] private Collider2D _collider;
20 | [GetComponentInChildren] private Collider2D ColliderProp { get; set; }
21 |
22 | [GetComponentsInChildren] private List _transformList;
23 | [GetComponentsInChildren] private List TransformListProp { get; set; }
24 |
25 | [Find("DEMO DRAWERS")] private GameObject _drawers;
26 | [Find("DEMO DRAWERS")] private GameObject DrawersProp { get; set; }
27 |
28 | [FindWithTag("MainCamera")] private GameObject _camera;
29 | [FindWithTag("MainCamera")] private GameObject CameraProp { get; set; }
30 |
31 | [FindGameObjectsWithTag("GameController")] private GameObject[] _gameControllers;
32 | [FindGameObjectsWithTag("GameController")] private GameObject[] GameControllersProp { get; set; }
33 |
34 | [FindObjectOfType(typeof(DemoDrawersScript))] private DemoDrawersScript _drawersScript;
35 | [FindObjectOfType(typeof(DemoDrawersScript))] private DemoDrawersScript DrawersScriptProp { get; set; }
36 |
37 | [FindObjectsOfType(typeof(DemoDrawersScript))] private DemoDrawersScript[] _drawersScripts;
38 | [FindObjectsOfType(typeof(DemoDrawersScript))] private DemoDrawersScript[] DrawersScriptsProp { get; set; }
39 |
40 | [LoadResource("ArgsInstantiated")] private GameObject _gameObject;
41 | [LoadResource("ArgsInstantiated")] private GameObject GameObjectProp { get; set; }
42 |
43 |
44 | /* If you can't derive from AutoAssignMonoBehaviour, you can just call the function below like that
45 | private void Awake()
46 | {
47 | this.AutoAssign();
48 | }*/
49 |
50 |
51 |
52 | [ContextMenu("Test")]
53 | public void Test()
54 | {
55 | var builder = new StringBuilder();
56 | builder.AppendLine("Demo AutoAssign:");
57 | builder.AppendLine($"GetComponent: Field {_rigidbody2D} | Prop {Rigidbody2DProp}");
58 | builder.AppendLine($"GetComponents: Field {_colliders} ({_colliders.Count}) | Prop {CollidersProp} ({CollidersProp.Count})");
59 | builder.AppendLine($"GetComponentInChildren: Field {_collider} | Prop {ColliderProp}");
60 | builder.AppendLine($"GetComponentsInChildren: Field {_transformList} ({_transformList.Count}) | Prop {TransformListProp} ({TransformListProp.Count})");
61 | builder.AppendLine($"Find: Field {_drawers} | Prop {DrawersProp}");
62 | builder.AppendLine($"FindWithTag: Field {_camera} | Prop {CameraProp}");
63 | builder.AppendLine(
64 | $"FindGameObjectsWithTag: Field {_gameControllers} ({_gameControllers.Length}) | Prop {GameControllersProp} ({GameControllersProp.Length})");
65 | builder.AppendLine($"FindObjectOfType: Field {_drawersScript} | Prop {DrawersScriptProp}");
66 | builder.AppendLine(
67 | $"FindObjectsOfType: Field {_drawersScripts} ({_drawersScripts.Length}) | Prop {DrawersScriptsProp} ({DrawersScriptsProp.Length})");
68 | builder.AppendLine($"LoadResource: Field {_gameObject.name} | Prop {GameObjectProp.name}");
69 |
70 | Debug.Log(builder.ToString());
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoAutoAssign.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3cf94bd87a7442d39e706fffbac24cf2
3 | timeCreated: 1658441587
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoDrawersScript.cs:
--------------------------------------------------------------------------------
1 | // Because this is a script just demonstrating the drawers of the types, it has lots of warnings from ReSharper about unused fields or inefficient code, this line just hide those warnings so they don't clog up the screen.
2 | // ReSharper disable NotAccessedField.Local
3 | // ReSharper disable Unity.InefficientPropertyAccess
4 | // ReSharper disable RedundantNameQualifier
5 | // ReSharper disable UnusedVariable
6 | // ReSharper disable InconsistentNaming
7 |
8 | using System.Collections.Generic;
9 | using MolecularLib.Helpers;
10 | using MolecularLib.PolymorphismSupport;
11 | using UnityEngine;
12 | using Timer = MolecularLib.Timers.Timer;
13 |
14 | namespace MolecularLib.Demo
15 | {
16 | public class DemoDrawersScript : MonoBehaviour
17 | {
18 | [Header("Sprite, Tag and Type variable editor drawers")]
19 | [SerializeField] private Sprite sprite;
20 | [SerializeField] private Tag tagTest;
21 | [SerializeField, TypeVariableBaseType(typeof(MonoBehaviour))] private TypeVariable type;
22 | [Space]
23 | [Header("Range variables and editor drawers")]
24 | [SerializeField] private MolecularLib.Helpers.Range doubleRange;
25 | [SerializeField] private MolecularLib.Helpers.Range genericFloatRange;
26 | [SerializeField] private MolecularLib.Helpers.Range floatRange;
27 | [SerializeField] private MolecularLib.Helpers.Range intRange;
28 | [SerializeField, MinMaxRange(-30.6345f, 24.34634f)] private MolecularLib.Helpers.Range minMaxFloatRange;
29 | [SerializeField, MinMaxRange(-30, 20)] private RangeInteger minMaxIntRange;
30 | [SerializeField] private RangeVector2 vec2Range;
31 | [SerializeField] private RangeVector3 vec3Range;
32 | [SerializeField] private RangeVector2Int vec2IntRange;
33 | [SerializeField] private RangeVector3Int vec3IntRange;
34 | [Space]
35 | [Header("Serializable Dictionary examples")]
36 | [SerializeField] private SerializableDictionary stringToInt;
37 | [SerializeField] private SerializableDictionary flagsToColor;
38 | [SerializeField] private SerializableDictionary myStructs;
39 | [SerializeField] private SerializableDictionary myStructsOpposite;
40 | [SerializeField] private SerializableDictionary myStructsBoth;
41 | [SerializeField] private SerializableDictionary stringToSprite;
42 | [Space]
43 | [Header("Polymorphic variable examples")]
44 | [SerializeField]
45 | private PolymorphicVariable myPolymorphicVariable;
46 | [Space]
47 | [Header("Optional variable examples")]
48 | [SerializeField] private Optional myOptionalString;
49 | [SerializeField] private Optional> myList;
50 | [SerializeField] private Optional> myOptionalDictionary;
51 | [SerializeField] private Optional myOptionalRange;
52 |
53 | public PolymorphicVariable PolymorphicVariable => myPolymorphicVariable;
54 |
55 |
56 | [ContextMenu("Demos")]
57 | public void Demos()
58 | {
59 | // Coroutine Timer (can also be used outside of a MonoBehaviour)
60 | var timer = Timer.Create(5, () => Debug.Log("Timer finished"));
61 | Debug.Log(timer.ElapsedSeconds);
62 |
63 |
64 | // Async Timers
65 | Timer.TimerAsync(2, () => Debug.Log("TimerAsync finished"));
66 |
67 |
68 | var timerReference = Timer.TimerAsyncReference(3, repeat: true);
69 | timerReference.OnFinish += () => Debug.Log("TimerAsyncReference finished");
70 |
71 | floatRange.Random();
72 |
73 | var min = floatRange.Min;
74 | var max = floatRange.Max;
75 |
76 | var middle = floatRange.MidPoint;
77 |
78 | var patrolPos = vec3Range.Random();
79 |
80 | if (vec2Range.IsInRange(transform.position))
81 | {
82 | // Do something...
83 | }
84 |
85 |
86 | transform.position = transform.position.WithoutX().WithZ(1);
87 |
88 | var myVector = transform.position;
89 | var myTileMapPos = myVector.ToVec2Int();
90 |
91 | Color titleColor = "Hello World".ToColor();
92 | "This green string is in bold".Color(Color.green).Bold();
93 | "This string will be cut to fit the container".Ellipsis(30, "Label");
94 |
95 | var backgroundColor = ColorHelper.NormalizeToColor(28, 28, 28);
96 | var textColor = backgroundColor.TextForegroundColor();
97 | textColor.WithR(1f);
98 | var textColorHexString = textColor.ToHexString();
99 |
100 |
101 | if (myOptionalString.HasValue)
102 | Debug.Log(myOptionalString.Value);
103 |
104 | // Or simply (Using implicit operators)
105 |
106 | if (myOptionalString)
107 | Debug.Log(myOptionalString);
108 |
109 |
110 | if (myPolymorphicVariable.As(out var asA))
111 | Debug.Log($"As A | aClassInt: {asA.aClassInt}");
112 | else if (myPolymorphicVariable.As(out var asB))
113 | Debug.Log($"As B | bClassInt: {asB.bClassInt} | bClassRange: {asB.bClassRange.Min} - {asB.bClassRange.Max}");
114 | else if (myPolymorphicVariable.As(out var asC))
115 | Debug.Log($"As C | cClassFloat: {asC.cClassFloat}");
116 | else
117 | Debug.Log($"As Base | myBaseString: {myPolymorphicVariable.Value.myBaseString}");
118 |
119 | myPolymorphicVariable.Value.myBaseString = "Hey, I changed it!";
120 |
121 |
122 | stringToInt.Add("Hello", 1);
123 | flagsToColor.Add(HideFlags.HideAndDontSave, Color.red);
124 | stringToSprite.Add("Hello", sprite);
125 |
126 | stringToInt["Hello"] = 2;
127 | if (!stringToInt.TryGetValue("Nonexistent", out var value))
128 | stringToInt.Add("Nonexistent", 0);
129 |
130 |
131 |
132 | myStructs.Add("Hello", new TestStruct());
133 | myStructsOpposite.Add(new TestStruct(), "Hello");
134 | myStructsBoth.Add(new TestStruct(), new TestStruct());
135 | }
136 | }
137 |
138 | [System.Serializable]
139 | public struct TestStruct
140 | {
141 | public int MyInt;
142 | public bool MyBool;
143 | public List MyStringList;
144 | }
145 |
146 | [System.Serializable]
147 | public class Base
148 | {
149 | public string myBaseString;
150 | }
151 |
152 | [System.Serializable]
153 | public class A : Base
154 | {
155 | public int aClassInt;
156 | [SerializeField] private SerializableDictionary aPrivateDictionary; // can be public as well ;)
157 | [SerializeField, TextArea] protected string protectedString;
158 | }
159 |
160 | [System.Serializable]
161 | public class B : Base
162 | {
163 | public MolecularLib.Helpers.Range bClassRange;
164 | public int bClassInt;
165 | [SerializeField] private float bClassPrivateFloat;
166 | [SerializeField] protected float bClassProtectedFloat;
167 | }
168 |
169 | [System.Serializable]
170 | public class C : B
171 | {
172 | public float cClassFloat;
173 | }
174 |
175 | [System.Serializable]
176 | public class WithUnityObject : A
177 | {
178 | public Sprite sprite;
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoDrawersScript.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 84465904cbf52b94e8d88b26cdf23bba
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoSceneController.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.AutoAssign;
2 | using MolecularLib.Helpers;
3 | using MolecularLib.PolymorphismSupport;
4 | using MolecularLib.Timers;
5 | using UnityEngine;
6 | using UnityEngine.UI;
7 |
8 | namespace MolecularLib.Demo
9 | {
10 | public class DemoSceneController : AutoAssignMonoBehaviour
11 | {
12 | [Header("Timers")]
13 | [SerializeField] private InputField timerDelay;
14 | [SerializeField] private Text timerTimeText;
15 |
16 | [Header("Instantiate With Args")]
17 | [SerializeField] private InputField stringArgument;
18 | [SerializeField] private InstantiateWithArgsDemoObject instantiateWithArgsDemoObject;
19 | [SerializeField] private RangeVector3 instantiatePosRange;
20 |
21 | [Header("Polymorphic Variable")]
22 | [SerializeField] private DemoDrawersScript demoDrawersScript;
23 | [SerializeField] private Text polymorphicVariableText;
24 |
25 | [FindObjectOfType(typeof(DemoAutoAssign))] private DemoAutoAssign _demoAutoAssign;
26 |
27 | private PolymorphicVariable PolymorphicVariable => demoDrawersScript.PolymorphicVariable;
28 |
29 | private TimerReference _timerAsync;
30 | private Timer _timer;
31 |
32 | public void AsyncTimer()
33 | {
34 | if (float.TryParse(timerDelay.text, out var delay))
35 | {
36 | _timerAsync = Timer.TimerAsyncReference(delay);
37 | _timerAsync.OnFinish += () => timerTimeText.text = "Timer finished";
38 | return;
39 | }
40 |
41 | timerTimeText.text = "Invalid delay provided";
42 | }
43 |
44 | public void CoroutineTimer()
45 | {
46 | if (float.TryParse(timerDelay.text, out var delay))
47 | {
48 | _timer = Timer.Create(delay, () => timerTimeText.text = "Timer finished");
49 | }
50 |
51 | timerTimeText.text = "Invalid delay provided";
52 | }
53 |
54 | public void InstantiateWithArgs()
55 | {
56 | Molecular.Instantiate(instantiateWithArgsDemoObject, instantiatePosRange.Random(),
57 | Quaternion.identity, stringArgument.text);
58 |
59 | Molecular.Instantiate(instantiateWithArgsDemoObject, stringArgument.text);
60 | }
61 |
62 | public void TestPoly()
63 | {
64 | if (PolymorphicVariable.As(out var asA))
65 | polymorphicVariableText.text = $"As A | aClassInt: {asA.aClassInt}";
66 | else if (PolymorphicVariable.As(out var asB))
67 | polymorphicVariableText.text = $"As B | bClassInt: {asB.bClassInt}";
68 | else if (PolymorphicVariable.As(out var asC))
69 | polymorphicVariableText.text = $"As C | cClassFloat: {asC.cClassFloat}";
70 | else
71 | polymorphicVariableText.text = $"As Base | myBaseString: {PolymorphicVariable.Value.myBaseString}";
72 | }
73 |
74 | public void TestAutoAssign()
75 | {
76 | _demoAutoAssign.Test();
77 | }
78 |
79 | public void Update()
80 | {
81 | var showTimerAsync = _timerAsync is {HasFinished: false};
82 | var showTimerCoroutine = _timer is {HasFinished: false};
83 |
84 | switch (showTimerAsync)
85 | {
86 | case true when showTimerCoroutine:
87 | timerTimeText.text = $"Timer time: {_timer.ElapsedSeconds}s";
88 | timerTimeText.text += $"\nAsync timer time: {_timerAsync.ElapsedSeconds}s";
89 | break;
90 | case true:
91 | timerTimeText.text = $"Async Timer time: {_timerAsync.ElapsedSeconds}s";
92 | break;
93 | case false when showTimerCoroutine:
94 | timerTimeText.text = $"Coroutine Timer time: {_timer.ElapsedSeconds}s";
95 | break;
96 | }
97 | }
98 |
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/DemoSceneController.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 25c6f47e6bda1c940b1145227d606a0c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/InstantiateWithArgsDemoObject.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using UnityEngine.UI;
3 |
4 | namespace MolecularLib.Demo
5 | {
6 | // For any class that you want to have a Initialize method, you will inherit from this interface, IArgsInstantiable<> with up to 10 generic arguments.
7 | // The type of the generic method will match the types of the parameters received in the Initialize method.
8 | // You can have more than one of these interfaces and methods per class.
9 | // To use it, call Molecular.Instantiate(originalObj, arg0, arg1, ...), where the originalObj is this, or any other with the interface, class.
10 | // There are also other overloads of the method like Molecular.Instantiate(originalObject, position, rotation, arg0, arg1, ...) and others.
11 | // The way this works under the hood does NOT use reflection, so it is very fast.
12 | // Beware that the Initialize method will be called after the Awake method but before Start, since the Initialize method is called right after the object is instantiated.
13 | public class InstantiateWithArgsDemoObject : MonoBehaviour, IArgsInstantiable
14 | {
15 | public string myString;
16 | public Text stringText;
17 |
18 | public void Initialize(string str)
19 | {
20 | myString = str;
21 | stringText.text = myString;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/InstantiateWithArgsDemoObject.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 446249d12754beb4bb3d68b94146aa7d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Resources.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a1a8f6d1d35621c48a3a738c5e749ab5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Resources/ArgsInstantiated.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1 &5747279090678464793
4 | GameObject:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | serializedVersion: 6
10 | m_Component:
11 | - component: {fileID: 8886319612611127114}
12 | - component: {fileID: 4802031293593000960}
13 | - component: {fileID: 122409809310661593}
14 | m_Layer: 5
15 | m_Name: MyText
16 | m_TagString: Untagged
17 | m_Icon: {fileID: 0}
18 | m_NavMeshLayer: 0
19 | m_StaticEditorFlags: 0
20 | m_IsActive: 1
21 | --- !u!224 &8886319612611127114
22 | RectTransform:
23 | m_ObjectHideFlags: 0
24 | m_CorrespondingSourceObject: {fileID: 0}
25 | m_PrefabInstance: {fileID: 0}
26 | m_PrefabAsset: {fileID: 0}
27 | m_GameObject: {fileID: 5747279090678464793}
28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29 | m_LocalPosition: {x: 0, y: 0, z: 0}
30 | m_LocalScale: {x: 0.019954382, y: 0.019954382, z: 0.019954382}
31 | m_Children: []
32 | m_Father: {fileID: 560662158733646529}
33 | m_RootOrder: 0
34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35 | m_AnchorMin: {x: 0.5, y: 0.5}
36 | m_AnchorMax: {x: 0.5, y: 0.5}
37 | m_AnchoredPosition: {x: 0, y: 0}
38 | m_SizeDelta: {x: 70.6549, y: 24.1322}
39 | m_Pivot: {x: 0.5, y: 0.5}
40 | --- !u!222 &4802031293593000960
41 | CanvasRenderer:
42 | m_ObjectHideFlags: 0
43 | m_CorrespondingSourceObject: {fileID: 0}
44 | m_PrefabInstance: {fileID: 0}
45 | m_PrefabAsset: {fileID: 0}
46 | m_GameObject: {fileID: 5747279090678464793}
47 | m_CullTransparentMesh: 1
48 | --- !u!114 &122409809310661593
49 | MonoBehaviour:
50 | m_ObjectHideFlags: 0
51 | m_CorrespondingSourceObject: {fileID: 0}
52 | m_PrefabInstance: {fileID: 0}
53 | m_PrefabAsset: {fileID: 0}
54 | m_GameObject: {fileID: 5747279090678464793}
55 | m_Enabled: 1
56 | m_EditorHideFlags: 0
57 | m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
58 | m_Name:
59 | m_EditorClassIdentifier:
60 | m_Material: {fileID: 0}
61 | m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
62 | m_RaycastTarget: 1
63 | m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
64 | m_Maskable: 1
65 | m_OnCullStateChanged:
66 | m_PersistentCalls:
67 | m_Calls: []
68 | m_FontData:
69 | m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
70 | m_FontSize: 12
71 | m_FontStyle: 0
72 | m_BestFit: 0
73 | m_MinSize: 0
74 | m_MaxSize: 40
75 | m_Alignment: 0
76 | m_AlignByGeometry: 0
77 | m_RichText: 1
78 | m_HorizontalOverflow: 0
79 | m_VerticalOverflow: 0
80 | m_LineSpacing: 1
81 | m_Text: New Text
82 | --- !u!1 &6556522220951380086
83 | GameObject:
84 | m_ObjectHideFlags: 0
85 | m_CorrespondingSourceObject: {fileID: 0}
86 | m_PrefabInstance: {fileID: 0}
87 | m_PrefabAsset: {fileID: 0}
88 | serializedVersion: 6
89 | m_Component:
90 | - component: {fileID: 560662158733646529}
91 | - component: {fileID: 8903419655956398742}
92 | - component: {fileID: 1011056889332365681}
93 | - component: {fileID: 5853361471697940029}
94 | m_Layer: 5
95 | m_Name: Canvas
96 | m_TagString: Untagged
97 | m_Icon: {fileID: 0}
98 | m_NavMeshLayer: 0
99 | m_StaticEditorFlags: 0
100 | m_IsActive: 1
101 | --- !u!224 &560662158733646529
102 | RectTransform:
103 | m_ObjectHideFlags: 0
104 | m_CorrespondingSourceObject: {fileID: 0}
105 | m_PrefabInstance: {fileID: 0}
106 | m_PrefabAsset: {fileID: 0}
107 | m_GameObject: {fileID: 6556522220951380086}
108 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
109 | m_LocalPosition: {x: 0, y: 0, z: 0}
110 | m_LocalScale: {x: 1, y: 1, z: 1}
111 | m_Children:
112 | - {fileID: 8886319612611127114}
113 | m_Father: {fileID: 8131203684498247535}
114 | m_RootOrder: 0
115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
116 | m_AnchorMin: {x: 0, y: 0}
117 | m_AnchorMax: {x: 0, y: 0}
118 | m_AnchoredPosition: {x: 0, y: 0}
119 | m_SizeDelta: {x: 2.1963, y: 0.6883}
120 | m_Pivot: {x: 0.5, y: 0.5}
121 | --- !u!223 &8903419655956398742
122 | Canvas:
123 | m_ObjectHideFlags: 0
124 | m_CorrespondingSourceObject: {fileID: 0}
125 | m_PrefabInstance: {fileID: 0}
126 | m_PrefabAsset: {fileID: 0}
127 | m_GameObject: {fileID: 6556522220951380086}
128 | m_Enabled: 1
129 | serializedVersion: 3
130 | m_RenderMode: 2
131 | m_Camera: {fileID: 0}
132 | m_PlaneDistance: 100
133 | m_PixelPerfect: 0
134 | m_ReceivesEvents: 1
135 | m_OverrideSorting: 0
136 | m_OverridePixelPerfect: 0
137 | m_SortingBucketNormalizedSize: 0
138 | m_AdditionalShaderChannelsFlag: 0
139 | m_SortingLayerID: 0
140 | m_SortingOrder: 0
141 | m_TargetDisplay: 0
142 | --- !u!114 &1011056889332365681
143 | MonoBehaviour:
144 | m_ObjectHideFlags: 0
145 | m_CorrespondingSourceObject: {fileID: 0}
146 | m_PrefabInstance: {fileID: 0}
147 | m_PrefabAsset: {fileID: 0}
148 | m_GameObject: {fileID: 6556522220951380086}
149 | m_Enabled: 1
150 | m_EditorHideFlags: 0
151 | m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
152 | m_Name:
153 | m_EditorClassIdentifier:
154 | m_UiScaleMode: 0
155 | m_ReferencePixelsPerUnit: 100
156 | m_ScaleFactor: 1
157 | m_ReferenceResolution: {x: 800, y: 600}
158 | m_ScreenMatchMode: 0
159 | m_MatchWidthOrHeight: 0
160 | m_PhysicalUnit: 3
161 | m_FallbackScreenDPI: 96
162 | m_DefaultSpriteDPI: 96
163 | m_DynamicPixelsPerUnit: 1
164 | m_PresetInfoIsWorld: 1
165 | --- !u!114 &5853361471697940029
166 | MonoBehaviour:
167 | m_ObjectHideFlags: 0
168 | m_CorrespondingSourceObject: {fileID: 0}
169 | m_PrefabInstance: {fileID: 0}
170 | m_PrefabAsset: {fileID: 0}
171 | m_GameObject: {fileID: 6556522220951380086}
172 | m_Enabled: 1
173 | m_EditorHideFlags: 0
174 | m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
175 | m_Name:
176 | m_EditorClassIdentifier:
177 | m_IgnoreReversedGraphics: 1
178 | m_BlockingObjects: 0
179 | m_BlockingMask:
180 | serializedVersion: 2
181 | m_Bits: 4294967295
182 | --- !u!1 &8131203684498247533
183 | GameObject:
184 | m_ObjectHideFlags: 0
185 | m_CorrespondingSourceObject: {fileID: 0}
186 | m_PrefabInstance: {fileID: 0}
187 | m_PrefabAsset: {fileID: 0}
188 | serializedVersion: 6
189 | m_Component:
190 | - component: {fileID: 8131203684498247535}
191 | - component: {fileID: 8131203684498247532}
192 | m_Layer: 0
193 | m_Name: ArgsInstantiated
194 | m_TagString: Untagged
195 | m_Icon: {fileID: 0}
196 | m_NavMeshLayer: 0
197 | m_StaticEditorFlags: 0
198 | m_IsActive: 1
199 | --- !u!4 &8131203684498247535
200 | Transform:
201 | m_ObjectHideFlags: 0
202 | m_CorrespondingSourceObject: {fileID: 0}
203 | m_PrefabInstance: {fileID: 0}
204 | m_PrefabAsset: {fileID: 0}
205 | m_GameObject: {fileID: 8131203684498247533}
206 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
207 | m_LocalPosition: {x: -1.5298642, y: 2.3966742, z: 92.66532}
208 | m_LocalScale: {x: 1, y: 1, z: 1}
209 | m_Children:
210 | - {fileID: 560662158733646529}
211 | m_Father: {fileID: 0}
212 | m_RootOrder: 0
213 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
214 | --- !u!114 &8131203684498247532
215 | MonoBehaviour:
216 | m_ObjectHideFlags: 0
217 | m_CorrespondingSourceObject: {fileID: 0}
218 | m_PrefabInstance: {fileID: 0}
219 | m_PrefabAsset: {fileID: 0}
220 | m_GameObject: {fileID: 8131203684498247533}
221 | m_Enabled: 1
222 | m_EditorHideFlags: 0
223 | m_Script: {fileID: 11500000, guid: 446249d12754beb4bb3d68b94146aa7d, type: 3}
224 | m_Name:
225 | m_EditorClassIdentifier:
226 | myString:
227 | stringText: {fileID: 122409809310661593}
228 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Resources/ArgsInstantiated.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 936dda2a16d1e9a4887fac4dc0d12951
3 | PrefabImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/TestVolatileScriptableObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using MolecularLib.Helpers;
4 | using UnityEngine;
5 |
6 | namespace MolecularLib.Demo
7 | {
8 | [CreateAssetMenu(fileName = "Volatile SO", menuName = "New Volatile SO", order = 0)]
9 | public class TestVolatileScriptableObject
10 | : VolatileScriptableObject
11 | {
12 | // Here you will put all the data you want to be volatile
13 | [Serializable]
14 | public class Data
15 | {
16 | [TextArea] public string myString;
17 | public MonoBehaviour myBehaviour;
18 | public int myInt;
19 | public float myFloat;
20 | public List myList;
21 | public Optional> myOptionalDictionary;
22 | public ScriptableObject myScriptableObject;
23 | }
24 |
25 | // Here is a quick way of accessing the data. Can be done in other ways too.
26 | public Data VolatileData
27 | {
28 | get => Value;
29 | set => Value = value;
30 | }
31 |
32 | // Can be done like this too.
33 | public string MyString
34 | {
35 | get => Value.myString;
36 | set => Value.myString = value;
37 | }
38 | public int MyInt
39 | {
40 | get => Value.myInt;
41 | set => Value.myInt = value;
42 | }
43 | // ...etc...
44 |
45 | public static implicit operator Data(TestVolatileScriptableObject obj)
46 | {
47 | return obj.VolatileData;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/TestVolatileScriptableObject.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a5d5f408d2df495d90dd6f555abdeed1
3 | timeCreated: 1649699337
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/TimersTest.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Timers;
2 | using UnityEngine;
3 |
4 | namespace MolecularLib.Demo
5 | {
6 | public class TimersTest : MonoBehaviour
7 | {
8 | private TimerReference _timerReference;
9 | private Timer _timer;
10 |
11 | [ContextMenu("Timer Tests/TestTimerAsync")]
12 | private void TestTimerAsync()
13 | {
14 | Timer.TimerAsync(5, () => Debug.Log("Timer (5s) Async Finished"));
15 | }
16 |
17 | [ContextMenu("Timer Tests/TestTimerReferenceAsync")]
18 | private void TestTimerReferenceAsync()
19 | {
20 | _timerReference = Timer.TimerAsyncReference(6);
21 | _timerReference.OnFinish = () => Debug.Log("Timer Async (6s) Reference Finished");
22 | }
23 |
24 | [ContextMenu("Timer Tests/TestTimerReference REPEAT Async")]
25 | private void TestTimerReferenceRepeatAsync()
26 | {
27 | _timerReference = Timer.TimerAsyncReference(2, true);
28 | _timerReference.OnFinish = () => Debug.Log("Timer Async (2s) Reference Repeat Finished");
29 | }
30 |
31 | [ContextMenu("Timer Tests/Stop repeat")]
32 | private void TestTimerReferenceStopRepeatAsync()
33 | {
34 | _timerReference.StopOnNextCycle();
35 | }
36 |
37 | [ContextMenu("Timer Tests/Instance Timer Test")]
38 | private void InstanceTimerTest()
39 | {
40 | _timer = Timer.Create(5, () => Debug.Log("Timer (5s) Instance Finished"));
41 | }
42 |
43 | private void Update()
44 | {
45 | if (_timerReference is { HasFinished: false })
46 | {
47 | Debug.Log($"Async timer reference elapsed seconds: {_timerReference.ElapsedSeconds}");
48 | }
49 |
50 | if (_timer is { HasFinished: false })
51 | {
52 | Debug.Log($"Instance timer elapsed seconds: {_timer.ElapsedSeconds}");
53 | }
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/TimersTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1b2fab46488c4555a35c1a68d93c9acd
3 | timeCreated: 1647555079
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Volatile SO.asset:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!114 &11400000
4 | MonoBehaviour:
5 | m_ObjectHideFlags: 0
6 | m_CorrespondingSourceObject: {fileID: 0}
7 | m_PrefabInstance: {fileID: 0}
8 | m_PrefabAsset: {fileID: 0}
9 | m_GameObject: {fileID: 0}
10 | m_Enabled: 1
11 | m_EditorHideFlags: 0
12 | m_Script: {fileID: 11500000, guid: a5d5f408d2df495d90dd6f555abdeed1, type: 3}
13 | m_Name: Volatile SO
14 | m_EditorClassIdentifier:
15 | runtimeValue:
16 | myString: 'Hello, this is a volatile scriptable object: the values edited in
17 | play mode DO NOT remain when leaving play mode. Go ahed and test it! Enter
18 | play mode, edit some values, leave play mode, and compare the values you changed
19 | with what you have now!'
20 | myBehaviour: {fileID: 0}
21 | myInt: 1533
22 | myFloat: -139.37
23 | myList:
24 | - aergr
25 | - asd
26 | - asdfsdgsfd
27 | - ert
28 | myOptionalDictionary:
29 | value:
30 | keys:
31 | values: []
32 | useValue: 0
33 | myScriptableObject: {fileID: 0}
34 | editorSavedValue:
35 | myString: 'Hello, this is a volatile scriptable object: the values edited in
36 | play mode DO NOT remain when leaving play mode. Go ahed and test it! Enter
37 | play mode, edit some values, leave play mode, and compare the values you changed
38 | with what you have now!'
39 | myBehaviour: {fileID: 0}
40 | myInt: -177
41 | myFloat: 19.78
42 | myList:
43 | - aergr
44 | - asd
45 | - asdfsdgsfd
46 | - ert
47 | myOptionalDictionary:
48 | value:
49 | keys: 765edf011b0000002a000000ffffff7f
50 | values:
51 | - 10000000 times Pi
52 | - 10 timer e
53 | - The meaning of life
54 | - Int32 max value (2^31 - 1)
55 | useValue: 1
56 | myScriptableObject: {fileID: 0}
57 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Demo/Volatile SO.asset.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c4b36419ccaa9444c9a881288049e080
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 11400000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4f91e4bc9c0274146894d823e9fa6d7c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/BaseMolecularInspector.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 |
3 | namespace MolecularEditor
4 | {
5 | public class BaseMolecularInspector : Editor
6 | {
7 |
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/BaseMolecularInspector.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 342f7f3d5cfa4bce8b196c3ef4fedf6a
3 | timeCreated: 1646938536
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/EditorHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cdcb6ea0a88fd8e49a638034d2485a78
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/MolecularEditor.Core.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "MolecularEditor",
3 | "rootNamespace": "",
4 | "references": [
5 | "GUID:e0e168214d33d19489de2c3ad4339c12",
6 | "GUID:9e5a0ec676ae0684c98f3cc02d1c6c30"
7 | ],
8 | "includePlatforms": [
9 | "Editor"
10 | ],
11 | "excludePlatforms": [],
12 | "allowUnsafeCode": false,
13 | "overrideReferences": false,
14 | "precompiledReferences": [],
15 | "autoReferenced": true,
16 | "defineConstraints": [],
17 | "versionDefines": [],
18 | "noEngineReferences": false
19 | }
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/MolecularEditor.Core.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9e85a8282660e904eb0c3e3c3fdfcfcb
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/OptionalPropertyDrawer.cs:
--------------------------------------------------------------------------------
1 | using MolecularLib.Helpers;
2 | using UnityEditor;
3 | using UnityEngine;
4 |
5 | namespace MolecularEditor
6 | {
7 | [CustomPropertyDrawer(typeof(Optional<>))]
8 | public class OptionalPropertyDrawer : PropertyDrawer
9 | {
10 | private const float ToggleSize = 18f;
11 |
12 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
13 | {
14 | var valueHeight = EditorGUI.GetPropertyHeight(property.FindPropertyRelative("value"));
15 | var useValueHeight = EditorGUI.GetPropertyHeight(property.FindPropertyRelative("useValue"));
16 |
17 | return Mathf.Max(valueHeight, useValueHeight);
18 | }
19 |
20 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
21 | {
22 | var valueLabel = label.text;
23 |
24 | EditorGUI.BeginProperty(position, label, property);
25 | property.serializedObject.Update();
26 | EditorGUI.BeginChangeCheck();
27 |
28 | var valueProperty = property.FindPropertyRelative("value");
29 | var useValueProperty = property.FindPropertyRelative("useValue");
30 |
31 | EditorGUI.BeginDisabledGroup(!useValueProperty.boolValue);
32 | var valueRect = new Rect(position.x, position.y, position.width - ToggleSize - 3f, 0f)
33 | {
34 | height = EditorGUI.GetPropertyHeight(valueProperty)
35 | };
36 |
37 | EditorGUI.PropertyField(valueRect, valueProperty, new GUIContent(valueLabel));
38 | EditorGUI.EndDisabledGroup();
39 |
40 | var useValueRect = new Rect(valueRect.xMax + 3f, position.y, ToggleSize, EditorGUIUtility.singleLineHeight);
41 | EditorGUI.PropertyField(useValueRect, useValueProperty, GUIContent.none);
42 |
43 | if (EditorGUI.EndChangeCheck())
44 | {
45 | property.serializedObject.ApplyModifiedProperties();
46 |
47 | Undo.RecordObject(property.serializedObject.targetObject, "Optional Variable Changed");
48 | EditorUtility.SetDirty(property.serializedObject.targetObject);
49 | }
50 |
51 | EditorGUI.EndProperty();
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/OptionalPropertyDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6fc23ce9438a4ac69b8c18489c8ed2f3
3 | timeCreated: 1648867719
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/PolymorphicVariableDrawer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using MolecularLib.Helpers;
6 | using MolecularLib.PolymorphismSupport;
7 | using UnityEditor;
8 | using UnityEngine;
9 |
10 | namespace MolecularEditor
11 | {
12 | [CustomPropertyDrawer(typeof(PolymorphicVariable<>))]
13 | public class PolymorphicVariableDrawer : PropertyDrawer
14 | {
15 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
16 | {
17 | if (!property.isExpanded) return EditorGUIUtility.singleLineHeight;
18 |
19 | var targetObj = fieldInfo.GetValue(EditorHelper.GetTargetValue(property, 1));
20 | _typeField ??= fieldInfo.FieldType.GetField("selectedPolymorphicType", EditorHelper.UnitySerializesBindingFlags);
21 | if (_typeField is null)
22 | throw new Exception("selectedPolymorphicType field not found");
23 | var typeVar = _typeField.GetValue(targetObj) as TypeVariable;
24 |
25 | if (typeVar?.Type == null) return EditorGUIUtility.singleLineHeight;
26 |
27 | var (editProps, attrDatas) = GetEditablePolymorphicData(typeVar, targetObj);
28 |
29 | var height = 4f;
30 | for (var i = 0; i < editProps.fields.Count; i++)
31 | {
32 | var prop = editProps.fields[i];
33 | var attrData = attrDatas[i];
34 |
35 | height += EditorHelper.AutoTypeFieldGetHeight(prop.fieldType, prop.DeserializedValue, GetUniqueId(property, prop),
36 | ObjectNames.NicifyVariableName(prop.fieldName), attrData);
37 | }
38 |
39 | return EditorGUIUtility.singleLineHeight + height;
40 | }
41 |
42 | private FieldInfo _typeField;
43 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
44 | {
45 | EditorGUI.BeginProperty(position, label, property);
46 | EditorGUI.BeginChangeCheck();
47 |
48 | var typeProp = property.FindPropertyRelative("selectedPolymorphicType");
49 |
50 | var foldoutRect = position;
51 | foldoutRect.width = EditorGUIUtility.labelWidth;
52 | foldoutRect.height = EditorGUIUtility.singleLineHeight;
53 | property.isExpanded = EditorGUI.BeginFoldoutHeaderGroup(foldoutRect, property.isExpanded, "");
54 |
55 | var typeSelectionRect = EditorGUI.PrefixLabel(position, label);
56 | typeSelectionRect.height = EditorGUIUtility.singleLineHeight;
57 |
58 | var originalLabelWidth = EditorGUIUtility.labelWidth;
59 | EditorGUIUtility.labelWidth = 90;
60 | EditorGUI.PropertyField(typeSelectionRect, typeProp, new GUIContent("Instance Type"));
61 | EditorGUIUtility.labelWidth = originalLabelWidth;
62 |
63 | EditorGUI.EndFoldoutHeaderGroup();
64 |
65 | var targetObj = fieldInfo.GetValue(EditorHelper.GetTargetValue(property, 1));
66 | _typeField ??= fieldInfo.FieldType.GetField("selectedPolymorphicType", EditorHelper.UnitySerializesBindingFlags);
67 | if (_typeField is null)
68 | throw new Exception("selectedPolymorphicType field not found");
69 | var typeVar = _typeField.GetValue(targetObj) as TypeVariable;
70 | var (editProps, attrDatas) = GetEditablePolymorphicData(typeVar, targetObj);
71 |
72 | if (property.isExpanded)
73 | {
74 | var fieldRect = position;
75 | fieldRect.x += 15;
76 | fieldRect.width -= 15;
77 | fieldRect.height = EditorGUIUtility.singleLineHeight;
78 | for (var i = 0; i < editProps.fields.Count; i++)
79 | {
80 | var prop = editProps.fields[i];
81 | var attrData = attrDatas[i];
82 | fieldRect.y += fieldRect.height + 2;
83 | fieldRect.height = EditorGUIUtility.singleLineHeight;
84 |
85 | prop.DeserializedValue = EditorHelper.AutoTypeField(ref fieldRect, prop.fieldType,
86 | prop.DeserializedValue,
87 | GetUniqueId(property, prop),
88 | ObjectNames.NicifyVariableName(prop.fieldName), attrData);
89 |
90 | prop.OnBeforeSerialize();
91 | }
92 | }
93 |
94 | if (EditorGUI.EndChangeCheck())
95 | {
96 | SetSerializedPolymorphicData(editProps, targetObj);
97 | property.serializedObject.ApplyModifiedProperties();
98 |
99 | UpdateInstance(targetObj);
100 |
101 | Undo.RecordObject(property.serializedObject.targetObject, "Polymorphic Variable Changed");
102 | EditorUtility.SetDirty(property.serializedObject.targetObject);
103 | }
104 | EditorGUI.EndProperty();
105 | }
106 |
107 | private string GetUniqueId(SerializedProperty property, SerializedPolymorphicField prop) =>
108 | (property.propertyPath + prop.fieldType.Type + fieldInfo.GetHashCode() + prop.fieldName).GetHashCode().ToString();
109 |
110 | private (SerializedPolymorphicData, List>) GetEditablePolymorphicData(Type type, object targetObject)
111 | {
112 | var (idealTypePolyData, idealAttrDatas) = GetTypeIdealSerializedPolymorphicData(type);
113 |
114 | var polymorphicDataField = fieldInfo.FieldType.GetField("polymorphicData", EditorHelper.UnitySerializesBindingFlags);
115 | if (polymorphicDataField is null)
116 | throw new Exception("Could not find the polymorphicData field in the PolymorphicVariable class");
117 |
118 | var definedTypePolyData = polymorphicDataField.GetValue(targetObject) as SerializedPolymorphicData;
119 | //Debug.Log($"[GENERATION] DefinedPlyData: {definedTypePolyData.fields[0].serializedValue}");
120 | var editableProps = new SerializedPolymorphicData();
121 |
122 | if (definedTypePolyData is null || definedTypePolyData.fields.Count == 0) return (idealTypePolyData, idealAttrDatas);
123 |
124 | for (var i = 0; i < idealTypePolyData.fields.Count; i++)
125 | {
126 | SerializedPolymorphicField fieldData;
127 |
128 | var idealTypeCurrentField = idealTypePolyData.fields[i];
129 |
130 | var targetCurrentField = definedTypePolyData.fields.Find(f => f.fieldName == idealTypeCurrentField.fieldName && f.fieldType.Type == idealTypeCurrentField.fieldType.Type);
131 |
132 | if (targetCurrentField is null)
133 | {
134 | fieldData = new SerializedPolymorphicField
135 | {
136 | fieldName = idealTypeCurrentField.fieldName,
137 | fieldType = idealTypeCurrentField.fieldType,
138 | DeserializedValue = null,
139 | serializedValue = idealTypeCurrentField.serializedValue,
140 | unityObjectValue = idealTypeCurrentField.unityObjectValue,
141 | };
142 | }
143 | else
144 | {
145 | fieldData = new SerializedPolymorphicField
146 | {
147 | fieldName = targetCurrentField.fieldName,
148 | fieldType = targetCurrentField.fieldType,
149 | DeserializedValue = targetCurrentField.DeserializedValue,
150 | serializedValue = targetCurrentField.serializedValue,
151 | unityObjectValue = targetCurrentField.unityObjectValue,
152 | };
153 | }
154 |
155 | fieldData.OnAfterDeserialize();
156 |
157 | //Debug.Log($"[GENERATION] DeserializedValue: {fieldData.DeserializedValue} | Type: {fieldData.fieldType.Type} | FieldName: {fieldData.fieldName} | SerializedVal: {fieldData.serializedValue}");
158 | editableProps.fields.Add(fieldData);
159 | }
160 |
161 | return (editableProps, idealAttrDatas);
162 | }
163 |
164 | private static (SerializedPolymorphicData, List>) GetTypeIdealSerializedPolymorphicData(Type type)
165 | {
166 | //Debug.Log($"[GENERATION] Type: {type}");
167 | var fields = type.GetFields(EditorHelper.UnitySerializesBindingFlags);
168 | var attrDatas = new List>();
169 |
170 | var serializedData = new SerializedPolymorphicData();
171 | foreach (var field in fields)
172 | {
173 | var polymorphicField = new SerializedPolymorphicField
174 | {
175 | fieldName = field.Name,
176 | fieldType = field.FieldType,
177 | DeserializedValue = null
178 | };
179 |
180 | serializedData.fields.Add(polymorphicField);
181 |
182 | attrDatas.Add(field.GetCustomAttributesData());
183 | }
184 |
185 | return (serializedData, attrDatas);
186 | }
187 |
188 | private MethodInfo _cachedOnAfterDeserializeMethod;
189 | private FieldInfo _cachedPolymorphicDataField;
190 | private Type _cachedFieldType;
191 | private void SetSerializedPolymorphicData(SerializedPolymorphicData newData, object targetObj)
192 | {
193 | _cachedFieldType ??= fieldInfo.FieldType;
194 | _cachedPolymorphicDataField ??= _cachedFieldType.GetField("polymorphicData", EditorHelper.UnitySerializesBindingFlags);
195 | if (_cachedPolymorphicDataField is null)
196 | throw new Exception("Could not find the polymorphicData field in the PolymorphicVariable class");
197 |
198 | //Debug.Log($"[REFLECTION SAVING] (Before) Current value {(polymorphicDataField.GetValue(targetObj) as SerializedPolymorphicData).fields[0].serializedValue}");
199 | _cachedPolymorphicDataField.SetValue(targetObj, newData);
200 | //Debug.Log($"[REFLECTION SAVING] (After) Current value {(polymorphicDataField.GetValue(targetObj) as SerializedPolymorphicData).fields[0].serializedValue}");
201 | }
202 |
203 | private void UpdateInstance(object targetObj)
204 | {
205 | _cachedFieldType ??= fieldInfo.FieldType;
206 | _cachedOnAfterDeserializeMethod ??= _cachedFieldType.GetMethod("OnAfterDeserialize", EditorHelper.UnitySerializesBindingFlags);
207 |
208 | if (_cachedOnAfterDeserializeMethod is null)
209 | throw new Exception("Could not find the polymorphicData method for updating the values");
210 |
211 | _cachedOnAfterDeserializeMethod?.Invoke(targetObj, null);
212 |
213 | }
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/PolymorphicVariableDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 44f072604d6a4d4fb2dd72498552f133
3 | timeCreated: 1649723850
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/RangeEditorDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 58aa6cd82ccdf504298d88ee2029583a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/SerializableDictionaryEditorDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b410ff5bb894a39bb5f5c2400dc7fa7
3 | timeCreated: 1648591475
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/SpriteEditorDrawer.cs:
--------------------------------------------------------------------------------
1 | using UnityEditor;
2 | using UnityEngine;
3 |
4 | namespace MolecularEditor
5 | {
6 | [CustomPropertyDrawer(typeof(Sprite))]
7 | public class SpriteEditorDrawer : PropertyDrawer
8 | {
9 | private float _spriteDisplaySize = MinSpriteDisplaySize;
10 | private const float MinSpriteDisplaySize = 54f;
11 |
12 | private bool _isDragging;
13 | private Rect _sizeEditRect = Rect.zero;
14 |
15 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
16 | {
17 | return property.isExpanded
18 | ? EditorGUIUtility.singleLineHeight + _spriteDisplaySize + 8f
19 | : EditorGUIUtility.singleLineHeight;
20 | }
21 |
22 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
23 | {
24 | property.serializedObject.Update();
25 | EditorGUI.BeginProperty(position, label, property);
26 | EditorGUI.BeginChangeCheck();
27 |
28 | if (!(property.objectReferenceValue is Sprite sp))
29 | {
30 | property.isExpanded = false;
31 | EditorGUI.ObjectField(position, property, label);
32 | property.serializedObject.ApplyModifiedProperties();
33 | EditorGUI.EndProperty();
34 | return;
35 | }
36 |
37 | var tex = sp != null ? sp.texture : null;
38 |
39 | var foldoutRect = DoFoldoutLabel(position, property, label);
40 |
41 | var objectSelectionRect = position;
42 | objectSelectionRect.width -= foldoutRect.width;
43 | objectSelectionRect.height = EditorGUIUtility.singleLineHeight;
44 | objectSelectionRect.x += foldoutRect.width;
45 | EditorGUI.ObjectField(objectSelectionRect, property, GUIContent.none);
46 |
47 | if (tex != null && property.isExpanded)
48 | {
49 | HandleExpandedArea(position, tex, sp, property);
50 | }
51 |
52 | if (EditorGUI.EndChangeCheck())
53 | property.serializedObject.ApplyModifiedProperties();
54 |
55 | EditorGUI.EndProperty();
56 | }
57 |
58 | private static Rect DoFoldoutLabel(Rect position, SerializedProperty property, GUIContent label)
59 | {
60 | var foldoutRect = position;
61 | foldoutRect.width = label == GUIContent.none ? 0 : EditorGUIUtility.labelWidth;
62 | foldoutRect.height = EditorGUIUtility.singleLineHeight;
63 | property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label, true);
64 |
65 | return foldoutRect;
66 | }
67 |
68 | private void HandleExpandedArea(Rect position, Texture tex, Sprite sp, SerializedProperty property)
69 | {
70 | var ratio = _spriteDisplaySize / tex.height;
71 |
72 | var displayTextureRect = position;
73 | displayTextureRect.height = _spriteDisplaySize;
74 | displayTextureRect.width = tex.width * ratio;
75 | displayTextureRect.y += EditorGUIUtility.singleLineHeight;
76 | EditorGUI.DrawTextureTransparent(displayTextureRect, tex);
77 |
78 | var labelRect = position;
79 | labelRect.x += displayTextureRect.width;
80 | labelRect.width = position.width - displayTextureRect.width;
81 | labelRect.height = EditorGUIUtility.singleLineHeight;
82 |
83 | labelRect.y += EditorGUIUtility.singleLineHeight;
84 | EditorGUI.LabelField(labelRect, $"Size: (x: {tex.width}, y: {tex.height})");
85 |
86 | labelRect.y += EditorGUIUtility.singleLineHeight;
87 | EditorGUI.LabelField(labelRect, $"Pixels Per Unit: {sp.pixelsPerUnit}");
88 |
89 | if (_sizeEditRect == Rect.zero)
90 | {
91 | _sizeEditRect = displayTextureRect;
92 | }
93 |
94 | _sizeEditRect.height = 20;
95 | _sizeEditRect.width = 20;
96 | _sizeEditRect.x = displayTextureRect.x + displayTextureRect.width;
97 | _sizeEditRect.y = displayTextureRect.y + displayTextureRect.height - _sizeEditRect.height;
98 |
99 | GUI.Box(_sizeEditRect, EditorGUIUtility.FindTexture("d_ViewToolZoom On@2x"), GUIStyle.none);
100 |
101 | _isDragging = Event.current.type switch
102 | {
103 | EventType.MouseDown when Event.current.button == 0 && _sizeEditRect.Contains(Event.current.mousePosition) => true,
104 | EventType.MouseUp when _isDragging => false,
105 | _ => _isDragging
106 | };
107 |
108 | if (!_isDragging) return;
109 |
110 | var mousePos = Event.current.mousePosition;
111 | if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.MouseUp)
112 | Event.current.Use();
113 |
114 | _spriteDisplaySize = (mousePos.y + _sizeEditRect.height / 2) - displayTextureRect.y;
115 |
116 | if (_spriteDisplaySize < MinSpriteDisplaySize) _spriteDisplaySize = MinSpriteDisplaySize;
117 |
118 | EditorUtility.SetDirty(property.serializedObject.targetObject);
119 | }
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/SpriteEditorDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a4c52311a215a2c489d20f3a6cb81200
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/TagEditorDrawer.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using MolecularLib.Helpers;
3 | using UnityEditor;
4 | using UnityEditorInternal;
5 | using UnityEngine;
6 |
7 | namespace MolecularEditor
8 | {
9 | [CustomPropertyDrawer(typeof(Tag))]
10 | public class TagEditorDrawer : PropertyDrawer
11 | {
12 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
13 | {
14 | property.serializedObject.Update();
15 |
16 | var tag = property.FindPropertyRelative("tag");
17 |
18 | var pos = EditorGUI.PrefixLabel(position, label);
19 |
20 | var index = InternalEditorUtility.tags.ToList().IndexOf(tag.stringValue);
21 | tag.stringValue = InternalEditorUtility.tags[EditorGUI.Popup(pos, index, InternalEditorUtility.tags)];
22 |
23 | property.serializedObject.ApplyModifiedProperties();
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/TagEditorDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 410df71f6b18fd64f8acb7d0023207b6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Assets/HandsomeDinosaur/MolecularLib/Core/Editor/TypeVariableDrawer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Reflection;
4 | using MolecularLib;
5 | using MolecularLib.Helpers;
6 | using UnityEditor;
7 | using UnityEngine;
8 |
9 | namespace MolecularEditor
10 | {
11 | [CustomPropertyDrawer(typeof(TypeVariable), true)]
12 | public class TypeVariableDrawer : PropertyDrawer
13 | {
14 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
15 | {
16 | EditorGUI.BeginProperty(position, label, property);
17 |
18 | EditorGUI.BeginChangeCheck();
19 |
20 | var typeNameProp = property.FindPropertyRelative("typeName");
21 | var assemblyNameProp = property.FindPropertyRelative("assemblyName");
22 |
23 | var type = GetType(assemblyNameProp.stringValue, typeNameProp.stringValue);
24 |
25 | Type selectedType;
26 | var typeAtt = fieldInfo.GetCustomAttributes(typeof(TypeVariableBaseTypeAttribute), true);
27 | if (typeAtt.Any())
28 | {
29 | var baseType = (typeAtt.FirstOrDefault() as TypeVariableBaseTypeAttribute)?.Type;
30 |
31 | selectedType = EditorHelper.TypeField(position, label.text, type, baseType, true);
32 | }
33 | else if (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.BaseType == typeof(TypeVariable) && fieldInfo.FieldType.GetGenericTypeDefinition().ToString().Contains("TBase"))
34 | {
35 | var baseType = fieldInfo.FieldType.GetGenericArguments()[0];
36 |
37 | selectedType = EditorHelper.TypeField(position, label.text, type, baseType, true);
38 | }
39 | else
40 | {
41 | selectedType = EditorHelper.TypeField