├── .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 | 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(position, label.text, type, true); 42 | } 43 | 44 | assemblyNameProp.stringValue = selectedType.Assembly.GetName().Name; 45 | typeNameProp.stringValue = selectedType.FullName; 46 | 47 | if (EditorGUI.EndChangeCheck()) 48 | { 49 | Undo.RecordObject(property.serializedObject.targetObject, "TypeVariable changed"); 50 | 51 | property.serializedObject.ApplyModifiedProperties(); 52 | 53 | EditorUtility.SetDirty(property.serializedObject.targetObject); 54 | } 55 | 56 | EditorGUI.EndProperty(); 57 | } 58 | 59 | private Assembly _cachedAssembly; 60 | private Type _cachedType; 61 | private string _lastAssemblyName; 62 | private string _lastTypeName; 63 | private Type GetType(string assemblyName, string typeName) 64 | { 65 | if (assemblyName != "" && assemblyName == _lastAssemblyName) 66 | { 67 | //Debug.Log("Cached"); 68 | if (_lastTypeName != "" && _lastTypeName == typeName) 69 | { 70 | return _cachedType; 71 | } 72 | 73 | var type = _cachedAssembly.GetType(typeName); 74 | if (type != null) 75 | { 76 | _cachedType = type; 77 | _lastTypeName = typeName; 78 | return type; 79 | } 80 | } 81 | //Debug.Log($"Not Cached | {_lastAssemblyName} | {_lastTypeName} | {assemblyName} | {typeName}"); 82 | _lastAssemblyName = assemblyName; 83 | _lastTypeName = typeName; 84 | 85 | if (!TypeLibrary.AllAssemblies!.TryGetValue(assemblyName, out var assembly)) 86 | return !string.IsNullOrEmpty(typeName) ? 87 | (TypeLibrary.AllAssemblies.FirstOrDefault().Value.GetType(typeName) ?? TypeLibrary.AllAssemblies.FirstOrDefault().Value.GetTypes().FirstOrDefault()) 88 | : TypeLibrary.AllAssemblies.FirstOrDefault().Value.GetTypes().FirstOrDefault(); 89 | 90 | _cachedAssembly = assembly; 91 | _cachedType = assembly.GetType(typeName); 92 | return _cachedType; 93 | 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Editor/TypeVariableDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 72a526bb71a0f8a4797def2fd868f36b 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/VolatileScriptableObjectInspector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using MolecularLib; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace MolecularEditor 8 | { 9 | [CustomEditor(typeof(VolatileScriptableObject<>), true)] 10 | [CanEditMultipleObjects] 11 | public class VolatileScriptableObjectInspector : UnityEditor.Editor 12 | { 13 | private bool _editorValuesFoldout; 14 | private bool _editEditorValuesFoldout; 15 | 16 | private Type GetGenericTypeForVolatileScriptableObject() 17 | { 18 | var type = target.GetType(); 19 | 20 | var baseType = type.BaseType; 21 | if (baseType is null) throw new Exception("The type passed as the generic argument for VolatileScriptableObject<> is not Serializable by Unity. Maybe you forgot to add the [System.Serializable] attribute?"); 22 | 23 | var breakFlag = 0; 24 | while (!baseType.IsGenericType || baseType.GetGenericTypeDefinition() != typeof(VolatileScriptableObject<>)) 25 | { 26 | if (breakFlag >= 100000) throw new Exception("Infinite loop detected"); 27 | 28 | baseType = baseType.BaseType; 29 | 30 | if (baseType is null) throw new Exception("The type passed as the generic argument for VolatileScriptableObject<> is not Serializable by Unity. Maybe you forgot to add the [System.Serializable] attribute?"); 31 | breakFlag++; 32 | } 33 | 34 | return baseType.GetGenericArguments()[0]; 35 | } 36 | 37 | public override void OnInspectorGUI() 38 | { 39 | var isPlaying = Application.isPlaying; 40 | 41 | if (isPlaying) 42 | { 43 | DrawRuntimeDataProp(); 44 | 45 | _editorValuesFoldout = EditorGUILayout.Foldout(_editorValuesFoldout, "Show Editor Saved Values", true); 46 | } 47 | 48 | if (!isPlaying || _editorValuesFoldout) 49 | { 50 | if (isPlaying) 51 | _editEditorValuesFoldout = EditorGUILayout.Toggle("Edit Editor Saved Values", _editEditorValuesFoldout); 52 | 53 | EditorGUI.BeginDisabledGroup(isPlaying && !_editEditorValuesFoldout); 54 | 55 | if (isPlaying && GUILayout.Button("Copy Runtime values INTO Editor values (NON-REVERSIBLE)")) 56 | { 57 | var method = target.GetType().GetMethod("CopyRuntimeValuesToEditorSaved", 58 | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy); 59 | 60 | if (method is null) 61 | { 62 | Debug.LogError("An unexpected error occurred. Could not set the values."); 63 | return; 64 | } 65 | 66 | method.Invoke(target, null); 67 | } 68 | 69 | DrawEditorDataProp(); 70 | 71 | EditorGUI.EndDisabledGroup(); 72 | } 73 | 74 | serializedObject.ApplyModifiedProperties(); 75 | } 76 | 77 | private void DrawEditorDataProp() 78 | { 79 | var editorDataProp = serializedObject.FindProperty("editorSavedValue"); 80 | 81 | if (editorDataProp is null) 82 | { 83 | Debug.LogError( 84 | $"The provided data type {GetGenericTypeForVolatileScriptableObject()} is not serializable by Unity. By chance, haven't you forgotten to add the [System.Serializable] to the type?"); 85 | return; 86 | } 87 | 88 | editorDataProp.NextVisible(true); 89 | do 90 | { 91 | DrawProperty(editorDataProp); 92 | } while (editorDataProp.NextVisible(false)); 93 | } 94 | 95 | private void DrawRuntimeDataProp() 96 | { 97 | var runtimeDataProp = serializedObject.FindProperty("runtimeValue"); 98 | 99 | if (runtimeDataProp is null) 100 | { 101 | Debug.LogError( 102 | $"The provided data type {GetGenericTypeForVolatileScriptableObject()} is not serializable by Unity. By chance, haven't you forgotten to add the [System.Serializable] to the type?"); 103 | return; 104 | } 105 | 106 | runtimeDataProp.NextVisible(true); 107 | do 108 | { 109 | DrawProperty(runtimeDataProp); 110 | } while (runtimeDataProp.NextVisible(false) && runtimeDataProp.propertyPath != "editorSavedValue"); 111 | } 112 | 113 | private static void DrawProperty(SerializedProperty property) 114 | { 115 | EditorGUI.BeginChangeCheck(); 116 | 117 | EditorGUILayout.PropertyField(property, true); 118 | 119 | if (EditorGUI.EndChangeCheck()) 120 | property.serializedObject.ApplyModifiedProperties(); 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Editor/VolatileScriptableObjectInspector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 75542524954941b7a03bb43a8126571e 3 | timeCreated: 1649699766 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6cdf375d1644115856d6db4f5a1b571 3 | timeCreated: 1646866044 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/ColorHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 752f682a51234b1db5f6f49f4cba9ff0 3 | timeCreated: 1646936616 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/Maths.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3cad827e1f048e4ba392cbde77a643e 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/Helpers/Optional.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace MolecularLib.Helpers 5 | { 6 | [Serializable] 7 | public class Optional 8 | { 9 | [SerializeField] private T value; 10 | [SerializeField] private bool useValue; 11 | 12 | public Optional() 13 | { 14 | useValue = false; 15 | } 16 | 17 | public Optional(T value, bool useValue) 18 | { 19 | Value = value; 20 | UseValue = useValue; 21 | } 22 | 23 | public T Value 24 | { 25 | get => value; 26 | set => this.value = value; 27 | } 28 | 29 | public bool UseValue 30 | { 31 | get => useValue; 32 | set => useValue = value; 33 | } 34 | 35 | public bool HasValue => Value != null; 36 | 37 | public static implicit operator Optional(T value) => new Optional(value, true); 38 | 39 | public static implicit operator T(Optional optional) => optional.Value; 40 | public static implicit operator bool(Optional optional) => optional.UseValue; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/Optional.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4c96e45f8cb4ea1a5753fa7761081a7 3 | timeCreated: 1648867533 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/PlayStatus.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace MolecularLib.Helpers 4 | { 5 | public static class PlayStatus 6 | { 7 | public static bool IsPlaying { get; private set; } 8 | 9 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)] 10 | private static void Initialize() 11 | { 12 | IsPlaying = true; 13 | Application.quitting += () => IsPlaying = false; 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/PlayStatus.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a98283857244f55bbbd74fc79be2ea7 3 | timeCreated: 1648865297 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/Range.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97b0a6ee4f23f544289f9ce231665788 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/Helpers/StringExtensionMethods.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text; 3 | using UnityEngine; 4 | 5 | namespace MolecularLib.Helpers 6 | { 7 | public static class StringExtensionMethods 8 | { 9 | /// 10 | /// Gets a color based on the provided string 11 | /// 12 | /// The string to get the color from 13 | /// The minimum RGB values 14 | /// The maximum RGB values 15 | /// A color based from the provided string 16 | public static Color ToColor(this string str, byte minRGB = 0, byte maxRGB = 255) => ColorHelper.FromString(str, minRGB, maxRGB); 17 | 18 | /// 19 | /// Based on a GUIStyle and a max width, will generate a string that will just fit the width. When the string is shortened it will have "..." added to its end 20 | /// 21 | /// The text to ellipsis 22 | /// The maximum Width that the text can be 23 | /// A GUI style to calculate the text size 24 | /// A text that will always fit the maxWidth 25 | public static string Ellipsis(this string text, float maxWidth, GUIStyle style) 26 | { 27 | return text.Ellipsis(maxWidth, c => style.CalcSize(c).x); 28 | } 29 | 30 | /// 31 | /// Based on a function to calculate the text width and a max width, will generate a string that will just fit the width. When the string is shortened it will have "..." added to its end 32 | /// 33 | /// The text to ellipsis 34 | /// The maximum Width that the text can be 35 | /// A function to calculate the text size 36 | /// A text that will always fit the maxWidth 37 | public static string Ellipsis(this string text, float maxWidth, Func calcWidthFunc) 38 | { 39 | var textDimensions = calcWidthFunc(new GUIContent(text)); 40 | if (textDimensions <= maxWidth) return text; 41 | 42 | var newStr = text; 43 | var threeDotsSize = calcWidthFunc(new GUIContent("...")); 44 | while (calcWidthFunc(new GUIContent(newStr)) > maxWidth - threeDotsSize) 45 | { 46 | if (newStr.Length - 1 < 0) return "..."; 47 | newStr = newStr.Remove(newStr.Length - 1); 48 | } 49 | 50 | return newStr + "..."; 51 | } 52 | 53 | /// 54 | /// Will add the rich text tags for a colored text 55 | /// 56 | /// The string to be colored 57 | /// To color to apply to the string 58 | /// A rich text colored string 59 | public static string Color(this string str, Color color) => 60 | $"{str}"; 61 | 62 | /// 63 | /// Will add the rich text tags for a bold text 64 | /// 65 | /// The string to be in bold 66 | /// A rich text bold string 67 | public static string Bold(this string str) => $"{str}"; 68 | 69 | /// 70 | /// Will add the rich text tags for a italic text 71 | /// 72 | /// The string to be in italics 73 | /// A rich text italic string 74 | public static string Italic(this string str) => $"{str}"; 75 | 76 | /// 77 | /// Will add the rich text tags for controlling ths text size 78 | /// 79 | /// The string to be sized 80 | /// The size of the text 81 | /// A rich text sized string 82 | public static string Size(this string str, float pixelSize) => $"{str}"; 83 | 84 | /// 85 | /// Add "\n" to the end of the string 86 | /// 87 | /// The string to be new lined 88 | /// The provided string plus a new line at the end 89 | public static string NewLine(this string str) => str + "\n"; 90 | 91 | /// 92 | /// Get a string builder with the provided string already appended. Very useful for text manipulation, since StringBuilders are way faster than just adding or modifying strings. 93 | /// 94 | /// The string to append 95 | /// A string builder with the provided string already appended 96 | public static StringBuilder ToBuilder(this string str) 97 | { 98 | var builder = new StringBuilder(); 99 | 100 | builder.Append(str); 101 | 102 | return builder; 103 | } 104 | 105 | /// 106 | /// Will add the rich text tags for a colored text 107 | /// 108 | /// The builder to add the color to 109 | /// To color to apply to the string 110 | /// A rich text colored string in a string builder 111 | public static StringBuilder Color(this StringBuilder builder, Color color) 112 | => builder.Insert(0, $"").Append(""); 113 | 114 | /// 115 | /// Will add the rich text tags for a bold text 116 | /// 117 | /// The builder to add the bold to 118 | /// A rich text bold string in a string builder 119 | public static StringBuilder Bold(this StringBuilder builder) 120 | => builder.Insert(0, "").Append(""); 121 | 122 | /// 123 | /// Will add the rich text tags for a italic text 124 | /// 125 | /// The builder to add the italics to 126 | /// A rich text italic string in a string builder 127 | public static StringBuilder Italic(this StringBuilder builder) => builder.Insert(0, "").Append(""); 128 | 129 | /// 130 | /// Will add the rich text tags for controlling the size of the string 131 | /// 132 | /// The builder to add the color to 133 | /// The size of the text 134 | /// A rich text sized string in a string builder 135 | public static StringBuilder Size(this StringBuilder builder, float pixelSize) => builder.Insert(0, $"").Append(""); 136 | 137 | /// 138 | /// builder.AppendLine(); 139 | /// 140 | /// 141 | /// 142 | public static StringBuilder NewLine(this StringBuilder builder) => builder.AppendLine(); 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/StringExtensionMethods.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 771aed4c20af4b9685d33f58bbb7348e 3 | timeCreated: 1647384426 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/Tag.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace MolecularLib.Helpers 5 | { 6 | [System.Serializable] 7 | public class Tag 8 | { 9 | public static readonly Tag Untagged = new Tag("Untagged"); 10 | public static readonly Tag Respawn = new Tag("Respawn"); 11 | public static readonly Tag Finish = new Tag("Finish"); 12 | public static readonly Tag EditorOnly = new Tag("EditorOnly"); 13 | public static readonly Tag MainCamera = new Tag("MainCamera"); 14 | public static readonly Tag Player = new Tag("Player"); 15 | public static readonly Tag GameController = new Tag("GameController"); 16 | 17 | [SerializeField] private string tag; 18 | 19 | public string TagName { get => tag; set => tag = value; } 20 | 21 | public bool CompareTag(GameObject goToCompareTag) => goToCompareTag.CompareTag(TagName); 22 | 23 | public static implicit operator string(Tag tag) => tag.TagName; 24 | public static implicit operator Tag(string tag) => new Tag(tag); 25 | 26 | public static bool operator ==(Tag t1, Tag t2) 27 | { 28 | if (t1 is null && t2 is null) return true; 29 | if (t1 is null || t2 is null) return false; 30 | return t1.TagName == t2.TagName; 31 | } 32 | 33 | public static bool operator !=(Tag t1, Tag t2) 34 | { 35 | return !(t1 == t2); 36 | } 37 | 38 | protected bool Equals(Tag other) => tag == other.tag; 39 | 40 | public override bool Equals(object obj) 41 | { 42 | if (ReferenceEquals(null, obj)) return false; 43 | if (ReferenceEquals(this, obj)) return true; 44 | return obj.GetType() == this.GetType() && Equals((Tag)obj); 45 | } 46 | 47 | public override int GetHashCode() => tag != null ? tag.GetHashCode() : 0; 48 | 49 | 50 | public Tag(string tag) 51 | { 52 | TagName = tag; 53 | } 54 | 55 | public Tag() : this("Untagged") { } 56 | } 57 | 58 | public static class TagHelper 59 | { 60 | public static bool CompareTag(this GameObject go, Tag tagToBeEqual) => go.CompareTag(tagToBeEqual.TagName); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/Tag.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aac936ae7cf03ae458f09a376ff650da 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/Helpers/TimedScope.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace MolecularLib.Helpers 5 | { 6 | public class TimedScope : IDisposable 7 | { 8 | private readonly Stopwatch _stopwatch = new Stopwatch(); 9 | private readonly string _message; 10 | 11 | public TimedScope(string message = "") 12 | { 13 | _message = message; 14 | 15 | _stopwatch.Start(); 16 | } 17 | 18 | public void Dispose() 19 | { 20 | _stopwatch.Stop(); 21 | 22 | UnityEngine.Debug.Log($"{_message} completed in {_stopwatch.ElapsedMilliseconds}ms"); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/TimedScope.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a442d987fe504c1fade4cc77514cf485 3 | timeCreated: 1658290205 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/TypeVariable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Runtime.Serialization; 4 | using System.Xml.Serialization; 5 | using UnityEngine; 6 | 7 | namespace MolecularLib.Helpers 8 | { 9 | [Serializable, DataContract] 10 | public class TypeVariable : ISerializationCallbackReceiver 11 | { 12 | [SerializeField, DataMember] private string typeName; 13 | [SerializeField, DataMember] private string assemblyName; 14 | 15 | [XmlIgnore] private Type _type; 16 | 17 | [XmlIgnore] public Type Type 18 | { 19 | get 20 | { 21 | if (_type is null) OnAfterDeserialize(); 22 | return _type; 23 | } 24 | set => _type = value; 25 | } 26 | 27 | public TypeVariable() 28 | { 29 | _type = null; 30 | } 31 | 32 | public void OnAfterDeserialize() 33 | { 34 | if (string.IsNullOrEmpty(assemblyName) || string.IsNullOrEmpty(typeName)) return; 35 | #if UNITY_EDITOR 36 | if (TypeLibrary.AllAssemblies == null || TypeLibrary.AllAssemblies.Count == 0) 37 | { 38 | TypeLibrary.BootstrapEditor(); 39 | } 40 | #endif 41 | if (TypeLibrary.AllAssemblies != null && TypeLibrary.AllAssemblies.TryGetValue(assemblyName, out var assembly)) 42 | { 43 | Type = assembly.GetType(typeName); 44 | return; 45 | } 46 | 47 | assembly = TypeLibrary.AllAssemblies?.First().Value; 48 | Type = assembly?.GetType(typeName); 49 | } 50 | 51 | public void OnBeforeSerialize() 52 | { 53 | typeName = Type?.FullName; 54 | assemblyName = Type?.Assembly.GetName().Name; 55 | } 56 | 57 | public static implicit operator Type(TypeVariable typeVariable) => typeVariable.Type; 58 | public static implicit operator TypeVariable(Type type) => new TypeVariable { Type = type }; 59 | } 60 | 61 | [Serializable] 62 | public class TypeVariable : TypeVariable 63 | { 64 | 65 | } 66 | 67 | [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] 68 | public class TypeVariableBaseTypeAttribute : PropertyAttribute 69 | { 70 | public TypeVariableBaseTypeAttribute(Type type) 71 | { 72 | Type = type; 73 | } 74 | 75 | public Type Type { get; } 76 | } 77 | 78 | [Serializable, DataContract] 79 | public class MyClass 80 | { 81 | public int myPublicField; 82 | 83 | [SerializeField, DataMember] private int myPrivateField; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Helpers/TypeVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39971c7e8921f084d8f1897ce47c7960 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/Helpers/VectorHelpers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f31d8e156a448e08faad6c563119d97 3 | timeCreated: 1646866053 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/InstantiateHelpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f9337f6c17e4478d826e30cec1155b4b 3 | timeCreated: 1648494774 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/InstantiateHelpers/InstantiateWithArgsInterfaces.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by the MolecularCodeGenerator. 4 | // 5 | // Changes to this file may cause incorrect behavior and will be lost if 6 | // the code is regenerated. 7 | // 8 | // The generator code can be found here, in this github repository: 9 | // https://github.com/Heymity/MolecularLibCore/tree/main/MolecularAutomaticCodeGenerator 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | namespace MolecularLib 14 | { 15 | public interface IArgsInstantiable 16 | { 17 | public void Initialize(); 18 | } 19 | 20 | public interface IArgsInstantiable 21 | { 22 | public void Initialize(TArg0 arg0); 23 | } 24 | 25 | public interface IArgsInstantiable 26 | { 27 | public void Initialize(TArg0 arg0, TArg1 arg1); 28 | } 29 | 30 | public interface IArgsInstantiable 31 | { 32 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2); 33 | } 34 | 35 | public interface IArgsInstantiable 36 | { 37 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3); 38 | } 39 | 40 | public interface IArgsInstantiable 41 | { 42 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4); 43 | } 44 | 45 | public interface IArgsInstantiable 46 | { 47 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5); 48 | } 49 | 50 | public interface IArgsInstantiable 51 | { 52 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6); 53 | } 54 | 55 | public interface IArgsInstantiable 56 | { 57 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6, TArg7 arg7); 58 | } 59 | 60 | public interface IArgsInstantiable 61 | { 62 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6, TArg7 arg7, TArg8 arg8); 63 | } 64 | 65 | public interface IArgsInstantiable 66 | { 67 | public void Initialize(TArg0 arg0, TArg1 arg1, TArg2 arg2, TArg3 arg3, TArg4 arg4, TArg5 arg5, TArg6 arg6, TArg7 arg7, TArg8 arg8, TArg9 arg9); 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/InstantiateHelpers/InstantiateWithArgsInterfaces.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a2f4a2ef4be9bb41a850fe03ab00d55 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/InstantiateHelpers/InstantiateWithArgsMethods.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10ec0c65b59e4eb4eab5835e6a72610b 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/Molecular.cs: -------------------------------------------------------------------------------- 1 | namespace MolecularLib 2 | { 3 | public static partial class Molecular 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Molecular.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 826b85f488c045f2a5e8178b6b77559b 3 | timeCreated: 1648494405 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Heymity/UniversalInventorySystem/401a1073d5b37c8c4cc0e7bc86afb61fc594ce22/Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.docx -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.docx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a5d5a09b19f9e74aa82dceeae45ab3f 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Heymity/UniversalInventorySystem/401a1073d5b37c8c4cc0e7bc86afb61fc594ce22/Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.pdf -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib Docs.pdf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4f90dcc33787a094eaafc5a5d0bc9587 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Molecular.Core", 3 | "rootNamespace": "MolecularLib", 4 | "references": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [], 13 | "noEngineReferences": false 14 | } -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/MolecularLib.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e5a0ec676ae0684c98f3cc02d1c6c30 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9266da34f8494a2290955fdbdcf062ab 3 | timeCreated: 1649721246 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/IPolymorphicSerializationOverride.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace MolecularLib.PolymorphismSupport 4 | { 5 | public interface IPolymorphicSerializationOverride 6 | { 7 | void Deserialize(string reader); 8 | 9 | void Serialize(StringWriter writer); 10 | } 11 | } -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/IPolymorphicSerializationOverride.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94c8d712cc28429698d6ba24b074e7a5 3 | timeCreated: 1651245787 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/PolymorphicVariable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using MolecularLib.Helpers; 3 | using UnityEngine; 4 | 5 | namespace MolecularLib.PolymorphismSupport 6 | { 7 | [Serializable] 8 | public class PolymorphicVariable : ISerializationCallbackReceiver where TBase : class 9 | { 10 | [SerializeField] private TypeVariable selectedPolymorphicType; 11 | [SerializeField] private SerializedPolymorphicData polymorphicData; 12 | 13 | public TBase Value { get; private set; } 14 | public Type SelectedPolymorphicType => selectedPolymorphicType.Type; 15 | public Type ValueType => Value?.GetType(); 16 | 17 | public bool As(out TDerived value, bool onlyPerfectTypeMatch = true) where TDerived : class, TBase 18 | { 19 | switch (onlyPerfectTypeMatch) 20 | { 21 | case true when Value.GetType() == typeof(TDerived): 22 | value = Value as TDerived; 23 | return true; 24 | case false when Value is TDerived derivedValue: 25 | value = derivedValue; 26 | return true; 27 | default: 28 | value = null; 29 | return false; 30 | } 31 | } 32 | 33 | public void OnBeforeSerialize() 34 | { 35 | if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(TBase))) 36 | throw new Exception("PolymorphicVariable cannot be used with UnityEngine.Object types"); 37 | } 38 | 39 | public void OnAfterDeserialize() 40 | { 41 | if (typeof(UnityEngine.Object).IsAssignableFrom(typeof(TBase))) 42 | throw new Exception("PolymorphicVariable cannot be used with UnityEngine.Object types"); 43 | 44 | Value = Activator.CreateInstance(selectedPolymorphicType.Type) as TBase; 45 | 46 | Value = polymorphicData.SetValuesTo(Value, selectedPolymorphicType.Type); 47 | } 48 | 49 | public static implicit operator TBase(PolymorphicVariable variable) 50 | { 51 | return variable.Value; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/PolymorphicVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c889a18ff6b84719babdc463b138ce30 3 | timeCreated: 1649721260 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/SerializedPolymorphicData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace MolecularLib.PolymorphismSupport 6 | { 7 | [Serializable] 8 | public class SerializedPolymorphicData 9 | { 10 | private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy; 11 | 12 | public List fields; 13 | 14 | public SerializedPolymorphicData() 15 | { 16 | fields = new List(); 17 | } 18 | 19 | public T SetValuesTo(T target, Type targetType) 20 | { 21 | foreach (var field in fields) 22 | { 23 | var fieldInfo = targetType.GetField(field.fieldName, Flags); 24 | if (fieldInfo == null) 25 | continue; 26 | 27 | try 28 | { 29 | fieldInfo.SetValue(target, field.DeserializedValue); 30 | } 31 | catch(ArgumentException){ /*This means the type of the field was changed, should not throw*/ } 32 | } 33 | 34 | return target; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/SerializedPolymorphicData.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db01103c8a744e508f3c380e779cace4 3 | timeCreated: 1649721554 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/SerializedPolymorphicField.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Xml.Serialization; 4 | using MolecularLib.Helpers; 5 | using UnityEngine; 6 | using Object = UnityEngine.Object; 7 | 8 | namespace MolecularLib.PolymorphismSupport 9 | { 10 | [Serializable] 11 | public class SerializedPolymorphicField : ISerializationCallbackReceiver 12 | { 13 | private const string UnityObject = "--UNITYOBJECT--"; 14 | 15 | public string fieldName; 16 | public TypeVariable fieldType; 17 | [TextArea] public string serializedValue; 18 | public Object unityObjectValue; 19 | 20 | public object DeserializedValue { get; set; } 21 | 22 | private string SerializeData(object value) 23 | { 24 | using var writer = new StringWriter(); 25 | if (value is IPolymorphicSerializationOverride inter) 26 | { 27 | inter.Serialize(writer); 28 | return writer.ToString(); 29 | } 30 | 31 | if (value is Object unityObject) 32 | { 33 | unityObjectValue = unityObject; 34 | return UnityObject; 35 | } 36 | 37 | var serializer = new XmlSerializer(fieldType); 38 | serializer.Serialize(writer, value!); 39 | 40 | return writer.ToString(); 41 | } 42 | 43 | private object DeserializeData() 44 | { 45 | var inter = fieldType.Type.GetInterface("IPolymorphicSerializationOverride"); 46 | if (inter != null) 47 | { 48 | var deserialized = Activator.CreateInstance(fieldType.Type); 49 | (deserialized as IPolymorphicSerializationOverride)?.Deserialize(serializedValue); 50 | return deserialized; 51 | } 52 | 53 | if (serializedValue == UnityObject && typeof(Object).IsAssignableFrom(fieldType.Type)) 54 | { 55 | return unityObjectValue; 56 | } 57 | 58 | using var reader = new StringReader(serializedValue); 59 | var serializer = new XmlSerializer(fieldType.Type); 60 | try 61 | { 62 | return serializer.Deserialize(reader); 63 | } 64 | catch (Exception e) 65 | { 66 | Debug.LogWarning($"Could not deserialize PolymorphicVariable, reason: {e}\n\n\n XML:\n{serializedValue}\n\n Deleting XML data"); 67 | serializedValue = ""; 68 | return null; 69 | } 70 | } 71 | 72 | public void OnBeforeSerialize() 73 | { 74 | if (DeserializedValue is null) return; 75 | 76 | var valueToSerialize = DeserializedValue; 77 | 78 | fieldType.Type = valueToSerialize.GetType(); 79 | 80 | serializedValue = SerializeData(valueToSerialize!); 81 | } 82 | 83 | public void OnAfterDeserialize() 84 | { 85 | try 86 | { 87 | if (string.IsNullOrEmpty(serializedValue)) 88 | { 89 | DeserializedValue = null; 90 | return; 91 | } 92 | 93 | DeserializedValue = DeserializeData(); 94 | } 95 | catch (ArgumentNullException) 96 | { 97 | DeserializedValue = null; 98 | } 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/PolymorphismSupport/SerializedPolymorphicField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1239690b974967a6facad71ea13816 3 | timeCreated: 1649721595 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/SerializableDict.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e58cf1f36dcaef40aca9bf6f3949ce7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/SerializableDict/SerializableDictionary.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using System.Linq; 4 | using MolecularLib.PolymorphismSupport; 5 | using UnityEngine; 6 | 7 | namespace MolecularLib 8 | { 9 | [System.Serializable] 10 | public class SerializableDictionary : Dictionary, ISerializationCallbackReceiver, IPolymorphicSerializationOverride 11 | { 12 | [SerializeField] private List keys; 13 | [SerializeField] private List values; 14 | 15 | public new void Add(TKey key, TValue value) 16 | { 17 | base.Add(key, value); 18 | 19 | values.Add(value); 20 | keys.Add(key); 21 | } 22 | 23 | public new void Remove(TKey key) 24 | { 25 | base.Remove(key); 26 | 27 | values.RemoveAt(keys.IndexOf(key)); 28 | keys.Remove(key); 29 | } 30 | 31 | public new void Clear() 32 | { 33 | base.Clear(); 34 | 35 | keys.Clear(); 36 | values.Clear(); 37 | } 38 | 39 | public void OnBeforeSerialize() 40 | { 41 | keys ??= new List(); 42 | values ??= new List(); 43 | 44 | if (keys.Count != Keys.Count || values.Count != Keys.Count) return; 45 | for (var i = 0; i < keys.Count; i++) 46 | { 47 | if (Equals(keys[i], Keys.ElementAt(i)) && Equals(values[i], Values.ElementAt(i))) continue; 48 | 49 | keys = Keys.ToList(); 50 | values = Values.ToList(); 51 | break; 52 | } 53 | } 54 | 55 | public void OnAfterDeserialize() 56 | { 57 | base.Clear(); 58 | 59 | keys ??= new List(); 60 | values ??= new List(); 61 | 62 | if (keys.Count != values.Count) 63 | { 64 | Debug.LogWarning("The key and value array sizes are not the same"); 65 | return; 66 | } 67 | for (var i = 0; i < keys.Count; i++) 68 | { 69 | if (ContainsKey(keys[i])) 70 | continue; 71 | 72 | base.Add(keys[i], values[i]); 73 | } 74 | } 75 | 76 | public void Deserialize(string reader) 77 | { 78 | var deserialized = JsonUtility.FromJson>(reader); 79 | this.keys = deserialized.keys; 80 | this.values = deserialized.values; 81 | } 82 | 83 | public void Serialize(StringWriter writer) { writer.Write(JsonUtility.ToJson(this)); } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/SerializableDict/SerializableDictionary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c77373042d0740240857045ff7bc2d8e 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/Singletons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36f3ad18414144e5a4833ef57bf788aa 3 | timeCreated: 1647912929 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Singletons/AutoSingleton.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace MolecularLib 4 | { 5 | /// 6 | /// Derive from this class to have a Current (Singleton) property to your class. The Singleton will be assigned used the FindObjectOfType<T> method in a lazy way (will only call the method when used and then cache it for later use) 7 | /// 8 | /// Your MonoBehaviour derived singleton Type 9 | public class AutoSingleton : MonoBehaviour where T : MonoBehaviour 10 | { 11 | private static T _current; 12 | public static T Current => _current ??= FindObjectOfType() ?? CreateSingleton(); 13 | 14 | private static T CreateSingleton() 15 | { 16 | var singleton = new GameObject(typeof(T).Name); 17 | _current = singleton.AddComponent(); 18 | return _current; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Singletons/AutoSingleton.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87cfd37daef1495fa442e16d3cd46fdc 3 | timeCreated: 1647912937 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Timers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca6e727639854a149c3e6fda5426d5c8 3 | timeCreated: 1647556746 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Timers/TimerManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace MolecularLib.Timers 5 | { 6 | public class TimerManager : AutoSingleton 7 | { 8 | private readonly List _timers = new List(); 9 | 10 | private void Awake() 11 | { 12 | gameObject.hideFlags = HideFlags.HideAndDontSave; 13 | DontDestroyOnLoad(this); 14 | } 15 | 16 | internal void AddTimer(Timer timer) 17 | { 18 | _timers.Add(timer); 19 | 20 | StartCoroutine(timer.TimerCoroutine); 21 | 22 | timer.OnComplete += () => 23 | { 24 | if (timer.Repeat) 25 | { 26 | timer.RestartTimer(); 27 | StartCoroutine(timer.TimerCoroutine); 28 | return; 29 | } 30 | 31 | _timers.Remove(timer); 32 | }; 33 | } 34 | 35 | public bool HasTimer(Timer timer) 36 | { 37 | return _timers.Contains(timer); 38 | } 39 | 40 | public void RemoveTimer(Timer timer) 41 | { 42 | StopCoroutine(timer.TimerCoroutine); 43 | _timers.Remove(timer); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Timers/TimerManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f14dc09043c44e2a5afcae12fe7928d 3 | timeCreated: 1648865641 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Timers/Timers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Threading.Tasks; 4 | using MolecularLib.Helpers; 5 | using UnityEngine; 6 | 7 | namespace MolecularLib.Timers 8 | { 9 | public class Timer 10 | { 11 | public float StartTime { get; private set; } 12 | public bool Repeat { get; set; } 13 | 14 | public bool IsStopped { get; private set; } 15 | 16 | public float DurationInSeconds { get; private set; } 17 | 18 | public event Action OnComplete; 19 | 20 | public float ElapsedSeconds => Time.time - StartTime; 21 | public bool HasFinished => ElapsedSeconds >= DurationInSeconds; 22 | 23 | public IEnumerator TimerCoroutine { get; set; } 24 | 25 | public static Timer Create(float duration, Action callback, bool repeat = false) 26 | { 27 | var timer = new Timer 28 | { 29 | StartTime = Time.time, 30 | DurationInSeconds = duration, 31 | Repeat = repeat 32 | }; 33 | 34 | timer.OnComplete += callback; 35 | 36 | timer.TimerCoroutine = timer.StartTimer(); 37 | TimerManager.Current.AddTimer(timer); 38 | 39 | return timer; 40 | } 41 | 42 | public void RestartTimer() 43 | { 44 | IsStopped = false; 45 | 46 | StartTime = Time.time; 47 | TimerCoroutine = StartTimer(); 48 | 49 | if (!TimerManager.Current.HasTimer(this)) 50 | TimerManager.Current.AddTimer(this); 51 | } 52 | 53 | public void StopTimer() 54 | { 55 | TimerManager.Current.RemoveTimer(this); 56 | IsStopped = true; 57 | } 58 | 59 | public void ResumeTimer() 60 | { 61 | TimerCoroutine = StartTimer(); 62 | TimerManager.Current.AddTimer(this); 63 | } 64 | 65 | public IEnumerator StartTimer() 66 | { 67 | IsStopped = false; 68 | yield return new WaitForSeconds(DurationInSeconds); 69 | if (IsStopped) yield break; 70 | 71 | IsStopped = true; 72 | OnComplete?.Invoke(); 73 | } 74 | 75 | #region Async Timers 76 | 77 | /// 78 | /// Makes a timer using the await Task.Delay() method, not needing to create a MonoBehaviour 79 | /// 80 | /// The seconds to wait until call the callback 81 | /// The function to be called when the timer expires 82 | public static async void TimerAsync(float seconds, Action callback) 83 | { 84 | await Task.Delay((int) (seconds * 1000)); 85 | 86 | if (!PlayStatus.IsPlaying) 87 | return; 88 | 89 | callback?.Invoke(); 90 | } 91 | 92 | private static async void TimerAsyncReference(TimerReference timerReference, Action repeatCallback) 93 | { 94 | await Task.Delay(timerReference.DurationInMilliseconds); 95 | 96 | if (!PlayStatus.IsPlaying) 97 | return; 98 | 99 | timerReference.OnFinish?.Invoke(); 100 | repeatCallback?.Invoke(); 101 | } 102 | 103 | /// 104 | /// Makes a timer using the await Task.Delay() method, not needing to create a MonoBehaviour and returning a TimerReference, allowing to get the elapsed time, the Start Time, to make repeatable timers and reassign the callback 105 | /// 106 | /// The seconds to wait until call the callback 107 | /// Whether the timer should repeat after conclusion or not 108 | public static TimerReference TimerAsyncReference(float seconds, bool repeat = false) 109 | { 110 | var reference = new TimerReference 111 | { 112 | DurationInMilliseconds = (int) seconds * 1000, 113 | StartTime = Time.time, 114 | Repeat = repeat 115 | }; 116 | 117 | TimerAsyncReference(reference, !reference.Repeat ? reference.OnFinish : HandleRepeat); 118 | 119 | return reference; 120 | 121 | void HandleRepeat() 122 | { 123 | if (!PlayStatus.IsPlaying) 124 | return; 125 | 126 | if (!reference.Repeat) return; 127 | 128 | reference.OnFinish?.Invoke(); 129 | reference.StartTime = Time.time; 130 | TimerAsync(seconds, HandleRepeat); 131 | } 132 | } 133 | 134 | #endregion 135 | } 136 | 137 | public class TimerReference 138 | { 139 | public bool Repeat { get; internal set; } 140 | public float StartTime { get; internal set; } 141 | public int DurationInMilliseconds { get; internal set; } 142 | public bool HasFinished => ElapsedMilliseconds >= DurationInMilliseconds; 143 | public Action OnFinish; 144 | public float ElapsedSeconds => Time.time - StartTime; 145 | public int ElapsedMilliseconds => (int)ElapsedSeconds * 1000; 146 | 147 | public void StopOnNextCycle() => Repeat = false; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/Timers/Timers.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 197f03c28d79402bacbae1f798c96b92 3 | timeCreated: 1647554094 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/TypeLibrary.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | 7 | namespace MolecularLib 8 | { 9 | public static class TypeLibrary 10 | { 11 | public static bool IsInitialized { get; private set; } = false; 12 | 13 | private static IEnumerable _allNonUnityAssembliesTypes; 14 | private static IEnumerable _allAssembliesTypes; 15 | private static IDictionary _allAssemblies; 16 | 17 | public static IEnumerable AllAssembliesTypes 18 | { 19 | get 20 | { 21 | if (_allAssembliesTypes is null) Bootstrap(); 22 | return _allAssembliesTypes; 23 | } 24 | private set => _allAssembliesTypes = value; 25 | } 26 | 27 | public static IEnumerable AllNonUnityAssembliesTypes 28 | { 29 | get 30 | { 31 | if (_allNonUnityAssembliesTypes is null) Bootstrap(); 32 | return _allNonUnityAssembliesTypes; 33 | } 34 | private set => _allNonUnityAssembliesTypes = value; 35 | } 36 | 37 | public static IDictionary AllAssemblies 38 | { 39 | get 40 | { 41 | if (_allAssemblies is null) Bootstrap(); 42 | return _allAssemblies; 43 | } 44 | private set => _allAssemblies = value; 45 | } 46 | 47 | /*public static IEnumerable AllAssembliesTypes 48 | { 49 | get => throw new Exception("The USE_TYPE_LIBRARY precompiler symbol is disabled, therefore this feature is no enabled. To enable it add USE_TYPE_LIBRARY to the script define symbols in unity project settings"); 50 | set => throw new Exception("The USE_TYPE_LIBRARY precompiler symbol is disabled, therefore this feature is no enabled. To enable it add USE_TYPE_LIBRARY to the script define symbols in unity project settings"); 51 | } 52 | public static IEnumerable AllNonUnityAssembliesTypes 53 | { 54 | get => throw new Exception("The USE_TYPE_LIBRARY precompiler symbol is disabled, therefore this feature is no enabled. To enable it add USE_TYPE_LIBRARY to the script define symbols in unity project settings"); 55 | set => throw new Exception("The USE_TYPE_LIBRARY precompiler symbol is disabled, therefore this feature is no enabled. To enable it add USE_TYPE_LIBRARY to the script define symbols in unity project settings"); 56 | }*/ 57 | 58 | [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] 59 | private static void Bootstrap() 60 | { 61 | if (IsInitialized) return; 62 | 63 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 64 | 65 | AllAssembliesTypes = assemblies 66 | .Select(a => a.GetTypes()) 67 | .Aggregate(new List() as IEnumerable,(a, s) => a.Concat(s)); 68 | 69 | AllNonUnityAssembliesTypes = assemblies 70 | .Where(a => !IsAssemblyFromUnity(a.FullName)) 71 | .Select(a => a.GetTypes()) 72 | .Aggregate(new List() as IEnumerable,(a, s) => a.Concat(s)); 73 | 74 | var seenAssemblies = new HashSet(); 75 | AllAssemblies = assemblies 76 | .Select(a => (assembly: a, name: a.GetName().Name)) 77 | .Where(a => seenAssemblies.Add(a.name)) 78 | .ToDictionary(a => a.name, a => a.assembly); 79 | 80 | /*PlayerAssembliesTypes = CompilationPipeline 81 | .GetAssemblies(AssembliesType.Player).Select(a => a.) 82 | .Aggregate(new List() as IEnumerable,(a, s) => a.Concat(s));*/ 83 | 84 | bool IsAssemblyFromUnity(string assemblyName) 85 | { 86 | return assemblyName.Split('.')[0] == "Unity" 87 | || assemblyName.Contains("UnityEngine") 88 | || assemblyName.Contains("UnityEditor") 89 | || assemblyName.Contains("UnityEngineInternal") 90 | || assemblyName.Contains("UnityEditorInternal"); 91 | } 92 | 93 | IsInitialized = true; 94 | } 95 | 96 | #if UNITY_EDITOR 97 | [UnityEditor.InitializeOnLoadMethod] 98 | public static void BootstrapEditor() 99 | { 100 | Bootstrap(); 101 | } 102 | #endif 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/TypeLibrary.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 62bca250830842db9c9a89de1bf1a100 3 | timeCreated: 1646516513 -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/VolatileScriptableObject.cs: -------------------------------------------------------------------------------- 1 | using MolecularLib.Helpers; 2 | using UnityEngine; 3 | 4 | namespace MolecularLib 5 | { 6 | public class VolatileScriptableObject : ScriptableObject, ISerializationCallbackReceiver 7 | { 8 | [SerializeField] protected TData runtimeValue; 9 | 10 | [SerializeField] protected TData editorSavedValue; 11 | protected TData Value 12 | { 13 | get 14 | { 15 | #if UNITY_EDITOR 16 | if (!Application.isPlaying) 17 | return editorSavedValue; 18 | #endif 19 | return runtimeValue; 20 | } 21 | set 22 | { 23 | #if UNITY_EDITOR 24 | if (!Application.isPlaying) 25 | editorSavedValue = value; 26 | #endif 27 | runtimeValue = value; 28 | } 29 | } 30 | 31 | private void OnValidate() 32 | { 33 | if (!Application.isPlaying) 34 | runtimeValue = DeepCopy(editorSavedValue); 35 | } 36 | 37 | public void OnBeforeSerialize() 38 | { 39 | 40 | } 41 | 42 | protected void CopyRuntimeValuesToEditorSaved() 43 | { 44 | editorSavedValue = DeepCopy(runtimeValue); 45 | } 46 | 47 | public void OnAfterDeserialize() 48 | { 49 | if (PlayStatus.IsPlaying) return; 50 | 51 | runtimeValue = DeepCopy(editorSavedValue); 52 | } 53 | 54 | private static TData DeepCopy(TData objToCopy) 55 | { 56 | var json = JsonUtility.ToJson(objToCopy); 57 | var obj = JsonUtility.FromJson(json); 58 | return obj; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Assets/HandsomeDinosaur/MolecularLib/Core/VolatileScriptableObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d2c63e939c32994a9d6a515d4de6ff4 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /GetStarted.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Heymity/UniversalInventorySystem/401a1073d5b37c8c4cc0e7bc86afb61fc594ce22/GetStarted.gif -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": "1.0.0", 4 | "com.unity.2d.tilemap": "1.0.0", 5 | "com.unity.collab-proxy": "1.15.7", 6 | "com.unity.ide.rider": "2.0.7", 7 | "com.unity.ide.visualstudio": "2.0.12", 8 | "com.unity.ide.vscode": "1.2.4", 9 | "com.unity.test-framework": "1.1.29", 10 | "com.unity.textmeshpro": "3.0.6", 11 | "com.unity.timeline": "1.4.8", 12 | "com.unity.ugui": "1.0.0", 13 | "com.unity.modules.ai": "1.0.0", 14 | "com.unity.modules.androidjni": "1.0.0", 15 | "com.unity.modules.animation": "1.0.0", 16 | "com.unity.modules.assetbundle": "1.0.0", 17 | "com.unity.modules.audio": "1.0.0", 18 | "com.unity.modules.cloth": "1.0.0", 19 | "com.unity.modules.director": "1.0.0", 20 | "com.unity.modules.imageconversion": "1.0.0", 21 | "com.unity.modules.imgui": "1.0.0", 22 | "com.unity.modules.jsonserialize": "1.0.0", 23 | "com.unity.modules.particlesystem": "1.0.0", 24 | "com.unity.modules.physics": "1.0.0", 25 | "com.unity.modules.physics2d": "1.0.0", 26 | "com.unity.modules.screencapture": "1.0.0", 27 | "com.unity.modules.terrain": "1.0.0", 28 | "com.unity.modules.terrainphysics": "1.0.0", 29 | "com.unity.modules.tilemap": "1.0.0", 30 | "com.unity.modules.ui": "1.0.0", 31 | "com.unity.modules.uielements": "1.0.0", 32 | "com.unity.modules.umbra": "1.0.0", 33 | "com.unity.modules.unityanalytics": "1.0.0", 34 | "com.unity.modules.unitywebrequest": "1.0.0", 35 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 36 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 37 | "com.unity.modules.unitywebrequesttexture": "1.0.0", 38 | "com.unity.modules.unitywebrequestwww": "1.0.0", 39 | "com.unity.modules.vehicles": "1.0.0", 40 | "com.unity.modules.video": "1.0.0", 41 | "com.unity.modules.vr": "1.0.0", 42 | "com.unity.modules.wind": "1.0.0", 43 | "com.unity.modules.xr": "1.0.0" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.2d.sprite": { 4 | "version": "1.0.0", 5 | "depth": 0, 6 | "source": "builtin", 7 | "dependencies": {} 8 | }, 9 | "com.unity.2d.tilemap": { 10 | "version": "1.0.0", 11 | "depth": 0, 12 | "source": "builtin", 13 | "dependencies": {} 14 | }, 15 | "com.unity.collab-proxy": { 16 | "version": "1.15.7", 17 | "depth": 0, 18 | "source": "registry", 19 | "dependencies": { 20 | "com.unity.nuget.newtonsoft-json": "2.0.0", 21 | "com.unity.services.core": "1.0.1" 22 | }, 23 | "url": "https://packages.unity.com" 24 | }, 25 | "com.unity.ext.nunit": { 26 | "version": "1.0.6", 27 | "depth": 1, 28 | "source": "registry", 29 | "dependencies": {}, 30 | "url": "https://packages.unity.com" 31 | }, 32 | "com.unity.ide.rider": { 33 | "version": "2.0.7", 34 | "depth": 0, 35 | "source": "registry", 36 | "dependencies": { 37 | "com.unity.test-framework": "1.1.1" 38 | }, 39 | "url": "https://packages.unity.com" 40 | }, 41 | "com.unity.ide.visualstudio": { 42 | "version": "2.0.12", 43 | "depth": 0, 44 | "source": "registry", 45 | "dependencies": { 46 | "com.unity.test-framework": "1.1.9" 47 | }, 48 | "url": "https://packages.unity.com" 49 | }, 50 | "com.unity.ide.vscode": { 51 | "version": "1.2.4", 52 | "depth": 0, 53 | "source": "registry", 54 | "dependencies": {}, 55 | "url": "https://packages.unity.com" 56 | }, 57 | "com.unity.nuget.newtonsoft-json": { 58 | "version": "2.0.0", 59 | "depth": 1, 60 | "source": "registry", 61 | "dependencies": {}, 62 | "url": "https://packages.unity.com" 63 | }, 64 | "com.unity.services.core": { 65 | "version": "1.0.1", 66 | "depth": 1, 67 | "source": "registry", 68 | "dependencies": { 69 | "com.unity.modules.unitywebrequest": "1.0.0" 70 | }, 71 | "url": "https://packages.unity.com" 72 | }, 73 | "com.unity.test-framework": { 74 | "version": "1.1.29", 75 | "depth": 0, 76 | "source": "registry", 77 | "dependencies": { 78 | "com.unity.ext.nunit": "1.0.6", 79 | "com.unity.modules.imgui": "1.0.0", 80 | "com.unity.modules.jsonserialize": "1.0.0" 81 | }, 82 | "url": "https://packages.unity.com" 83 | }, 84 | "com.unity.textmeshpro": { 85 | "version": "3.0.6", 86 | "depth": 0, 87 | "source": "registry", 88 | "dependencies": { 89 | "com.unity.ugui": "1.0.0" 90 | }, 91 | "url": "https://packages.unity.com" 92 | }, 93 | "com.unity.timeline": { 94 | "version": "1.4.8", 95 | "depth": 0, 96 | "source": "registry", 97 | "dependencies": { 98 | "com.unity.modules.director": "1.0.0", 99 | "com.unity.modules.animation": "1.0.0", 100 | "com.unity.modules.audio": "1.0.0", 101 | "com.unity.modules.particlesystem": "1.0.0" 102 | }, 103 | "url": "https://packages.unity.com" 104 | }, 105 | "com.unity.ugui": { 106 | "version": "1.0.0", 107 | "depth": 0, 108 | "source": "builtin", 109 | "dependencies": { 110 | "com.unity.modules.ui": "1.0.0", 111 | "com.unity.modules.imgui": "1.0.0" 112 | } 113 | }, 114 | "com.unity.modules.ai": { 115 | "version": "1.0.0", 116 | "depth": 0, 117 | "source": "builtin", 118 | "dependencies": {} 119 | }, 120 | "com.unity.modules.androidjni": { 121 | "version": "1.0.0", 122 | "depth": 0, 123 | "source": "builtin", 124 | "dependencies": {} 125 | }, 126 | "com.unity.modules.animation": { 127 | "version": "1.0.0", 128 | "depth": 0, 129 | "source": "builtin", 130 | "dependencies": {} 131 | }, 132 | "com.unity.modules.assetbundle": { 133 | "version": "1.0.0", 134 | "depth": 0, 135 | "source": "builtin", 136 | "dependencies": {} 137 | }, 138 | "com.unity.modules.audio": { 139 | "version": "1.0.0", 140 | "depth": 0, 141 | "source": "builtin", 142 | "dependencies": {} 143 | }, 144 | "com.unity.modules.cloth": { 145 | "version": "1.0.0", 146 | "depth": 0, 147 | "source": "builtin", 148 | "dependencies": { 149 | "com.unity.modules.physics": "1.0.0" 150 | } 151 | }, 152 | "com.unity.modules.director": { 153 | "version": "1.0.0", 154 | "depth": 0, 155 | "source": "builtin", 156 | "dependencies": { 157 | "com.unity.modules.audio": "1.0.0", 158 | "com.unity.modules.animation": "1.0.0" 159 | } 160 | }, 161 | "com.unity.modules.imageconversion": { 162 | "version": "1.0.0", 163 | "depth": 0, 164 | "source": "builtin", 165 | "dependencies": {} 166 | }, 167 | "com.unity.modules.imgui": { 168 | "version": "1.0.0", 169 | "depth": 0, 170 | "source": "builtin", 171 | "dependencies": {} 172 | }, 173 | "com.unity.modules.jsonserialize": { 174 | "version": "1.0.0", 175 | "depth": 0, 176 | "source": "builtin", 177 | "dependencies": {} 178 | }, 179 | "com.unity.modules.particlesystem": { 180 | "version": "1.0.0", 181 | "depth": 0, 182 | "source": "builtin", 183 | "dependencies": {} 184 | }, 185 | "com.unity.modules.physics": { 186 | "version": "1.0.0", 187 | "depth": 0, 188 | "source": "builtin", 189 | "dependencies": {} 190 | }, 191 | "com.unity.modules.physics2d": { 192 | "version": "1.0.0", 193 | "depth": 0, 194 | "source": "builtin", 195 | "dependencies": {} 196 | }, 197 | "com.unity.modules.screencapture": { 198 | "version": "1.0.0", 199 | "depth": 0, 200 | "source": "builtin", 201 | "dependencies": { 202 | "com.unity.modules.imageconversion": "1.0.0" 203 | } 204 | }, 205 | "com.unity.modules.subsystems": { 206 | "version": "1.0.0", 207 | "depth": 1, 208 | "source": "builtin", 209 | "dependencies": { 210 | "com.unity.modules.jsonserialize": "1.0.0" 211 | } 212 | }, 213 | "com.unity.modules.terrain": { 214 | "version": "1.0.0", 215 | "depth": 0, 216 | "source": "builtin", 217 | "dependencies": {} 218 | }, 219 | "com.unity.modules.terrainphysics": { 220 | "version": "1.0.0", 221 | "depth": 0, 222 | "source": "builtin", 223 | "dependencies": { 224 | "com.unity.modules.physics": "1.0.0", 225 | "com.unity.modules.terrain": "1.0.0" 226 | } 227 | }, 228 | "com.unity.modules.tilemap": { 229 | "version": "1.0.0", 230 | "depth": 0, 231 | "source": "builtin", 232 | "dependencies": { 233 | "com.unity.modules.physics2d": "1.0.0" 234 | } 235 | }, 236 | "com.unity.modules.ui": { 237 | "version": "1.0.0", 238 | "depth": 0, 239 | "source": "builtin", 240 | "dependencies": {} 241 | }, 242 | "com.unity.modules.uielements": { 243 | "version": "1.0.0", 244 | "depth": 0, 245 | "source": "builtin", 246 | "dependencies": { 247 | "com.unity.modules.ui": "1.0.0", 248 | "com.unity.modules.imgui": "1.0.0", 249 | "com.unity.modules.jsonserialize": "1.0.0", 250 | "com.unity.modules.uielementsnative": "1.0.0" 251 | } 252 | }, 253 | "com.unity.modules.uielementsnative": { 254 | "version": "1.0.0", 255 | "depth": 1, 256 | "source": "builtin", 257 | "dependencies": { 258 | "com.unity.modules.ui": "1.0.0", 259 | "com.unity.modules.imgui": "1.0.0", 260 | "com.unity.modules.jsonserialize": "1.0.0" 261 | } 262 | }, 263 | "com.unity.modules.umbra": { 264 | "version": "1.0.0", 265 | "depth": 0, 266 | "source": "builtin", 267 | "dependencies": {} 268 | }, 269 | "com.unity.modules.unityanalytics": { 270 | "version": "1.0.0", 271 | "depth": 0, 272 | "source": "builtin", 273 | "dependencies": { 274 | "com.unity.modules.unitywebrequest": "1.0.0", 275 | "com.unity.modules.jsonserialize": "1.0.0" 276 | } 277 | }, 278 | "com.unity.modules.unitywebrequest": { 279 | "version": "1.0.0", 280 | "depth": 0, 281 | "source": "builtin", 282 | "dependencies": {} 283 | }, 284 | "com.unity.modules.unitywebrequestassetbundle": { 285 | "version": "1.0.0", 286 | "depth": 0, 287 | "source": "builtin", 288 | "dependencies": { 289 | "com.unity.modules.assetbundle": "1.0.0", 290 | "com.unity.modules.unitywebrequest": "1.0.0" 291 | } 292 | }, 293 | "com.unity.modules.unitywebrequestaudio": { 294 | "version": "1.0.0", 295 | "depth": 0, 296 | "source": "builtin", 297 | "dependencies": { 298 | "com.unity.modules.unitywebrequest": "1.0.0", 299 | "com.unity.modules.audio": "1.0.0" 300 | } 301 | }, 302 | "com.unity.modules.unitywebrequesttexture": { 303 | "version": "1.0.0", 304 | "depth": 0, 305 | "source": "builtin", 306 | "dependencies": { 307 | "com.unity.modules.unitywebrequest": "1.0.0", 308 | "com.unity.modules.imageconversion": "1.0.0" 309 | } 310 | }, 311 | "com.unity.modules.unitywebrequestwww": { 312 | "version": "1.0.0", 313 | "depth": 0, 314 | "source": "builtin", 315 | "dependencies": { 316 | "com.unity.modules.unitywebrequest": "1.0.0", 317 | "com.unity.modules.unitywebrequestassetbundle": "1.0.0", 318 | "com.unity.modules.unitywebrequestaudio": "1.0.0", 319 | "com.unity.modules.audio": "1.0.0", 320 | "com.unity.modules.assetbundle": "1.0.0", 321 | "com.unity.modules.imageconversion": "1.0.0" 322 | } 323 | }, 324 | "com.unity.modules.vehicles": { 325 | "version": "1.0.0", 326 | "depth": 0, 327 | "source": "builtin", 328 | "dependencies": { 329 | "com.unity.modules.physics": "1.0.0" 330 | } 331 | }, 332 | "com.unity.modules.video": { 333 | "version": "1.0.0", 334 | "depth": 0, 335 | "source": "builtin", 336 | "dependencies": { 337 | "com.unity.modules.audio": "1.0.0", 338 | "com.unity.modules.ui": "1.0.0", 339 | "com.unity.modules.unitywebrequest": "1.0.0" 340 | } 341 | }, 342 | "com.unity.modules.vr": { 343 | "version": "1.0.0", 344 | "depth": 0, 345 | "source": "builtin", 346 | "dependencies": { 347 | "com.unity.modules.jsonserialize": "1.0.0", 348 | "com.unity.modules.physics": "1.0.0", 349 | "com.unity.modules.xr": "1.0.0" 350 | } 351 | }, 352 | "com.unity.modules.wind": { 353 | "version": "1.0.0", 354 | "depth": 0, 355 | "source": "builtin", 356 | "dependencies": {} 357 | }, 358 | "com.unity.modules.xr": { 359 | "version": "1.0.0", 360 | "depth": 0, 361 | "source": "builtin", 362 | "dependencies": { 363 | "com.unity.modules.physics": "1.0.0", 364 | "com.unity.modules.jsonserialize": "1.0.0", 365 | "com.unity.modules.subsystems": "1.0.0" 366 | } 367 | } 368 | } 369 | } 370 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/InventorySystem/Example/Scenes/ExampleScene.unity 10 | guid: 2cda990e2423bbf4892e6590ba056729 11 | - enabled: 1 12 | path: Assets/InventorySystem/Example/Scenes/ExampleTransitionScene.unity 13 | guid: 16d25cf9f4d2073459cb8fc0208a0eb7 14 | m_configObjects: {} 15 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 1 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 4 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 34 | m_PreloadedShaders: [] 35 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 36 | type: 0} 37 | m_CustomRenderPipeline: {fileID: 0} 38 | m_TransparencySortMode: 0 39 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 40 | m_DefaultRenderingPath: 1 41 | m_DefaultMobileRenderingPath: 1 42 | m_TierSettings: [] 43 | m_LightmapStripping: 0 44 | m_FogStripping: 0 45 | m_InstancingStripping: 0 46 | m_LightmapKeepPlain: 1 47 | m_LightmapKeepDirCombined: 1 48 | m_LightmapKeepDynamicPlain: 1 49 | m_LightmapKeepDynamicDirCombined: 1 50 | m_LightmapKeepShadowMask: 1 51 | m_LightmapKeepSubtractive: 1 52 | m_FogKeepLinear: 1 53 | m_FogKeepExp: 1 54 | m_FogKeepExp2: 1 55 | m_AlbedoSwatchInfos: [] 56 | m_LightsUseLinearIntensity: 0 57 | m_LightsUseColorTemperature: 0 58 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 1 77 | agentHeight: 3 78 | agentSlope: 50 79 | agentClimb: 3.76 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 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: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreviewPackages: 0 16 | m_EnablePackageDependencies: 0 17 | m_AdvancedSettingsExpanded: 1 18 | m_ScopedRegistriesSettingsExpanded: 1 19 | oneTimeWarningShown: 0 20 | m_Registries: 21 | - m_Id: main 22 | m_Name: 23 | m_Url: https://packages.unity.com 24 | m_Scopes: [] 25 | m_IsDefault: 1 26 | m_Capabilities: 7 27 | m_UserSelectedRegistryName: 28 | m_UserAddingNewScopedRegistry: 0 29 | m_RegistryInfoDraft: 30 | m_ErrorMessage: 31 | m_Original: 32 | m_Id: 33 | m_Name: 34 | m_Url: 35 | m_Scopes: [] 36 | m_IsDefault: 0 37 | m_Capabilities: 0 38 | m_Modified: 0 39 | m_Name: 40 | m_Url: 41 | m_Scopes: 42 | - 43 | m_SelectedScopeIndex: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: [] 7 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2020.3.26f1 2 | m_EditorVersionWithRevision: 2020.3.26f1 (7298b473bc1a) 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 3 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Very Low 11 | pixelLightCount: 0 12 | shadows: 0 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 15 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | blendWeights: 1 22 | textureQuality: 1 23 | anisotropicTextures: 0 24 | antiAliasing: 0 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 0 30 | lodBias: 0.3 31 | maximumLODLevel: 0 32 | particleRaycastBudget: 4 33 | asyncUploadTimeSlice: 2 34 | asyncUploadBufferSize: 16 35 | resolutionScalingFixedDPIFactor: 1 36 | excludedTargetPlatforms: [] 37 | - serializedVersion: 2 38 | name: Low 39 | pixelLightCount: 0 40 | shadows: 0 41 | shadowResolution: 0 42 | shadowProjection: 1 43 | shadowCascades: 1 44 | shadowDistance: 20 45 | shadowNearPlaneOffset: 3 46 | shadowCascade2Split: 0.33333334 47 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 48 | shadowmaskMode: 0 49 | blendWeights: 2 50 | textureQuality: 0 51 | anisotropicTextures: 0 52 | antiAliasing: 0 53 | softParticles: 0 54 | softVegetation: 0 55 | realtimeReflectionProbes: 0 56 | billboardsFaceCameraPosition: 0 57 | vSyncCount: 0 58 | lodBias: 0.4 59 | maximumLODLevel: 0 60 | particleRaycastBudget: 16 61 | asyncUploadTimeSlice: 2 62 | asyncUploadBufferSize: 16 63 | resolutionScalingFixedDPIFactor: 1 64 | excludedTargetPlatforms: [] 65 | - serializedVersion: 2 66 | name: Medium 67 | pixelLightCount: 1 68 | shadows: 0 69 | shadowResolution: 0 70 | shadowProjection: 1 71 | shadowCascades: 1 72 | shadowDistance: 20 73 | shadowNearPlaneOffset: 3 74 | shadowCascade2Split: 0.33333334 75 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 76 | shadowmaskMode: 0 77 | blendWeights: 2 78 | textureQuality: 0 79 | anisotropicTextures: 0 80 | antiAliasing: 0 81 | softParticles: 0 82 | softVegetation: 0 83 | realtimeReflectionProbes: 0 84 | billboardsFaceCameraPosition: 0 85 | vSyncCount: 1 86 | lodBias: 0.7 87 | maximumLODLevel: 0 88 | particleRaycastBudget: 64 89 | asyncUploadTimeSlice: 2 90 | asyncUploadBufferSize: 16 91 | resolutionScalingFixedDPIFactor: 1 92 | excludedTargetPlatforms: [] 93 | - serializedVersion: 2 94 | name: High 95 | pixelLightCount: 2 96 | shadows: 0 97 | shadowResolution: 1 98 | shadowProjection: 1 99 | shadowCascades: 2 100 | shadowDistance: 40 101 | shadowNearPlaneOffset: 3 102 | shadowCascade2Split: 0.33333334 103 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 104 | shadowmaskMode: 1 105 | blendWeights: 2 106 | textureQuality: 0 107 | anisotropicTextures: 0 108 | antiAliasing: 0 109 | softParticles: 0 110 | softVegetation: 1 111 | realtimeReflectionProbes: 0 112 | billboardsFaceCameraPosition: 0 113 | vSyncCount: 1 114 | lodBias: 1 115 | maximumLODLevel: 0 116 | particleRaycastBudget: 256 117 | asyncUploadTimeSlice: 2 118 | asyncUploadBufferSize: 16 119 | resolutionScalingFixedDPIFactor: 1 120 | excludedTargetPlatforms: [] 121 | - serializedVersion: 2 122 | name: Very High 123 | pixelLightCount: 3 124 | shadows: 0 125 | shadowResolution: 2 126 | shadowProjection: 1 127 | shadowCascades: 2 128 | shadowDistance: 70 129 | shadowNearPlaneOffset: 3 130 | shadowCascade2Split: 0.33333334 131 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 132 | shadowmaskMode: 1 133 | blendWeights: 4 134 | textureQuality: 0 135 | anisotropicTextures: 0 136 | antiAliasing: 0 137 | softParticles: 0 138 | softVegetation: 1 139 | realtimeReflectionProbes: 0 140 | billboardsFaceCameraPosition: 0 141 | vSyncCount: 1 142 | lodBias: 1.5 143 | maximumLODLevel: 0 144 | particleRaycastBudget: 1024 145 | asyncUploadTimeSlice: 2 146 | asyncUploadBufferSize: 16 147 | resolutionScalingFixedDPIFactor: 1 148 | excludedTargetPlatforms: [] 149 | - serializedVersion: 2 150 | name: Ultra 151 | pixelLightCount: 4 152 | shadows: 0 153 | shadowResolution: 0 154 | shadowProjection: 1 155 | shadowCascades: 4 156 | shadowDistance: 150 157 | shadowNearPlaneOffset: 3 158 | shadowCascade2Split: 0.33333334 159 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 160 | shadowmaskMode: 1 161 | blendWeights: 4 162 | textureQuality: 0 163 | anisotropicTextures: 0 164 | antiAliasing: 0 165 | softParticles: 0 166 | softVegetation: 1 167 | realtimeReflectionProbes: 0 168 | billboardsFaceCameraPosition: 0 169 | vSyncCount: 1 170 | lodBias: 2 171 | maximumLODLevel: 0 172 | particleRaycastBudget: 4096 173 | asyncUploadTimeSlice: 2 174 | asyncUploadBufferSize: 16 175 | resolutionScalingFixedDPIFactor: 1 176 | excludedTargetPlatforms: [] 177 | m_PerPlatformDefaultQuality: 178 | Android: 2 179 | Nintendo 3DS: 5 180 | Nintendo Switch: 5 181 | PS4: 5 182 | PSM: 5 183 | PSP2: 2 184 | Stadia: 5 185 | Standalone: 5 186 | Tizen: 2 187 | WebGL: 3 188 | WiiU: 5 189 | Windows Store Apps: 5 190 | XboxOne: 5 191 | iPhone: 2 192 | tvOS: 2 193 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: 7 | - Drop 8 | layers: 9 | - Default 10 | - TransparentFX 11 | - Ignore Raycast 12 | - 13 | - Water 14 | - UI 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | - 41 | m_SortingLayers: 42 | - name: Default 43 | uniqueID: 0 44 | locked: 0 45 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_RenderPipeSettingsPath: 8 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_CollabEditorSettings: 8 | inProgressEnabled: 1 9 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Universal Inventory System · [![GitHub license](https://img.shields.io/badge/license-Apache2-blue.svg?style=flat)](https://github.com/Heymity/UniversalInventorySystem/blob/master/LICENSE) [![Unity 2020.3 or later](https://img.shields.io/badge/unity-2019.3%20or%20later-brigthgreen.svg?logo=unity&cacheSeconds=2592000&style=flat)](https://unity3d.com/get-unity/download/archive) [![Version](https://img.shields.io/github/v/release/Heymity/UniversalInventorySystem?label=stable%20release)](https://github.com/Heymity/UniversalInventorySystem/releases) 2 | 3 | ![](image.png) 4 | 5 | ## NOTE 6 | 7 | This project is being recreated in the 'main' branch, if you wish to use the older but incomplete and currently unsupported version, change to branch 'legacy'. Branch 'v4' is mostly broken, though it has some advancements on the 'legacy' branch, still not recommended for anything. 8 | 9 | Everything about the usage of the project in this file is, for now, FALSE, as it has not been implemented, but the goal is to make the project so that it resembles the legacy usage, which is showed here in this file. 10 | 11 | ## What is it? 12 | 13 | 14 | The Universal Inventory System is a unity package for making advanced and higly customizable inventories in a easy way. 15 | 16 | It's based on the idea of items as Scriptable Objects and an inventory controller to manipulate the inventories. 17 | 18 | It also is open source and free to use, since it is under the [Apache-2.0 Licese](https://github.com/Heymity/UniversalInventorySystem/blob/Updating-README/LICENSE) wich grants you the permissions of: 19 |
    20 |
  • 21 | Commercial Use 22 |
  • 23 |
  • 24 | Modification, as long as the changes are documented 25 |
  • 26 |
  • 27 | Distribution 28 |
  • 29 |
  • 30 | Patent use, wich means you are provided an express grant of patent rights from contributors (Read item 3 of the license for more details) 31 |
  • 32 |
  • 33 | Private use 34 |
  • 35 |
36 | 37 | This license requires you to have a copy of the license in your software and to state the changes that you made, if you made any. I strongly suggest you to fork the repository, maintaining it public, and state the changes in the README file. 38 | 39 | 40 | ## Getting Started 41 | 42 | You can see in more detail what is here by accesing our [documentation](https://heymity.github.io/UniversalInventorySystemDocs/) 43 | 44 | To get started open in the InventorySystem/Example the ExampleScene. There you will find a four UI pf inventories, you can interact with them using the keys A, D, B, V to add items, I, E, O and C to toggle the inventories. 45 | 46 | ![](GetStarted.gif) 47 | 48 | Now play with the values in the inspector and see how it goes. 49 | 50 | ### Coding 51 | 52 | To code with this system, you will need to import it in your code with this line: 53 | 54 | ```c# 55 | using UniversalInventorySystem; 56 | ``` 57 | 58 | Now you have access to all the functions from the UIS. To get started you can create an Inventory variable and initialize it. Make it public so you can see it in the inspector and understand what the InitializeInventory method does 59 | 60 | ```c# 61 | using UniversalInventorySystem; 62 | using UnityEngine; 63 | 64 | public class MyInventory : MonoBehaviour { 65 | public Inventory myInv; 66 | 67 | public void Start() { 68 | myInv.slotAmounts = 10; 69 | myInv.InitializeInventory(); 70 | } 71 | } 72 | ``` 73 | 74 | If you use an InventoryUI you will not need to initialize it or set the amout of slots, the UI does all that for you. Now if you want to add an item, just use this code: 75 | 76 | ```c# 77 | public Item item; 78 | 79 | public void Update() { 80 | if (Input.GetKeyDown(KeyCode.W)) myInv.AddItem(item, 1); 81 | } 82 | ``` 83 | 84 | You can create your own item by creating a new Item Asset in your project, or you can use one of the example ones. 85 | 86 | Congrats! You have just made your first UIS Inventory. 87 | 88 | 89 | -------------------------------------------------------------------------------- /UserSettings/EditorUserSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!162 &1 4 | EditorUserSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_ConfigSettings: 8 | RecentlyUsedScenePath-0: 9 | value: 22424703114646720318092c042c4d09250e0b3e2925691535281023eee57b0be1e238ecf4751a24380fff30010d023afc0f471ef8021e12 10 | flags: 0 11 | RecentlyUsedScenePath-1: 12 | value: 22424703114646720318092c042c4d09250e0b3e2925691535281023eee57b0be1e238ecf4751b39340ddc3f01300471e704001fef 13 | flags: 0 14 | RecentlyUsedScenePath-2: 15 | value: 22424703114646730c0008311f2e5a341f1917392d3d347f00261136e1f53839f0cb3feba819302e3c4dcb3909314e1bf7070645e305031f08 16 | flags: 0 17 | RecentlyUsedScenePath-3: 18 | value: 22424703114646730c0008311f2e5a341f1917392d3d347f04270b36ecf43b2afbd42ffaf33f32731d07e2334b0d023afc0f1a44d20e0704220df80014b1051d18d101 19 | flags: 0 20 | vcSharedLogLevel: 21 | value: 0d5e400f0650 22 | flags: 0 23 | m_VCAutomaticAdd: 1 24 | m_VCDebugCom: 0 25 | m_VCDebugCmd: 0 26 | m_VCDebugOut: 0 27 | m_SemanticMergeMode: 2 28 | m_VCShowFailedCheckout: 1 29 | m_VCOverwriteFailedCheckoutAssets: 1 30 | m_VCProjectOverlayIcons: 1 31 | m_VCHierarchyOverlayIcons: 1 32 | m_VCOtherOverlayIcons: 1 33 | m_VCAllowAsyncUpdate: 1 34 | -------------------------------------------------------------------------------- /image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Heymity/UniversalInventorySystem/401a1073d5b37c8c4cc0e7bc86afb61fc594ce22/image.png --------------------------------------------------------------------------------