├── CHANGELOG.md ├── Documentation ├── com.gameframe.scriptableobjects.md └── com.gameframe.scriptableobjects.md.meta ├── .gitattributes ├── Runtime ├── com.gameframe.scriptableobjects.asmdef ├── RuntimeSets │ ├── IRuntimeSet.cs.meta │ ├── RuntimeTable.cs.meta │ ├── GameObjectRuntimeSet.cs │ ├── RuntimeSet.cs.meta │ ├── GameObjectRuntimeSet.cs.meta │ ├── RuntimeSetInstance.cs.meta │ ├── IRuntimeSet.cs │ ├── RuntimeSetInstance.cs │ ├── RuntimeSet.cs │ └── RuntimeTable.cs ├── Events │ ├── IGameEventListener.cs │ ├── BaseGameEvent.cs.meta │ ├── GameEventManager.cs.meta │ ├── StringGameEvent.cs.meta │ ├── BaseGameEventListener.cs.meta │ ├── StringGameEventListener.cs.meta │ ├── GameEvent.cs.meta │ ├── GameEventListener.cs.meta │ ├── IGameEventListener.cs.meta │ ├── BaseGameEvent.cs │ ├── StringGameEvent.cs │ ├── GameEventListener.cs │ ├── BaseGameEventListener.cs │ ├── GameEvent.cs │ ├── StringGameEventListener.cs │ └── GameEventManager.cs ├── Events.meta ├── Locks.meta ├── RuntimeSets.meta ├── Variables.meta ├── BindingSupport.meta ├── com.gameframe.scriptableobjects.asmdef.meta ├── Variables │ ├── IVariable.cs │ ├── IntReference.cs │ ├── ColorReference.cs │ ├── FloatReference.cs │ ├── StringReference.cs │ ├── AssetVariable.cs.meta │ ├── BaseVariable.cs.meta │ ├── Vector2Reference.cs │ ├── Vector3Reference.cs │ ├── AssetReference.cs.meta │ ├── GameObjectVariable.cs.meta │ ├── IVariable.cs.meta │ ├── IntReference.cs.meta │ ├── IntVariable.cs.meta │ ├── ColorReference.cs.meta │ ├── ColorVariable.cs.meta │ ├── FloatReference.cs.meta │ ├── FloatVariable.cs.meta │ ├── StringReference.cs.meta │ ├── StringVariable.cs.meta │ ├── VariableReference.cs.meta │ ├── Vector2Reference.cs.meta │ ├── Vector2Variable.cs.meta │ ├── Vector3Reference.cs.meta │ ├── Vector3Variable.cs.meta │ ├── ScriptableVariableTest.cs.meta │ ├── ScriptableVariableTest.cs │ ├── IntVariable.cs │ ├── FloatVariable.cs │ ├── StringVariable.cs │ ├── Vector2Variable.cs │ ├── Vector3Variable.cs │ ├── ColorVariable.cs │ ├── GameObjectVariable.cs │ ├── VariableReference.cs │ ├── AssetVariable.cs │ ├── BaseVariable.cs │ └── AssetReference.cs ├── MenuNames.cs.meta ├── Locks │ ├── GameLock.cs.meta │ └── GameLock.cs ├── BindingSupport │ ├── BindableScriptableObject.cs.meta │ └── BindableScriptableObject.cs └── MenuNames.cs ├── CHANGELOG.md.meta ├── LICENSE.md.meta ├── README.md.meta ├── package.json.meta ├── Editor.meta ├── Runtime.meta ├── Tests.meta ├── Documentation.meta ├── Editor ├── Events.meta ├── Variables.meta ├── com.gameframe.scriptableobjects.Editor.asmdef ├── com.gameframe.scriptableobjects.Editor.asmdef.meta ├── Variables │ ├── AssetVariableEditor.cs.meta │ ├── AssetReferenceDrawer.cs.meta │ ├── VariableReferenceDrawer.cs.meta │ ├── AssetVariableEditor.cs │ ├── VariableReferenceDrawer.cs │ └── AssetReferenceDrawer.cs └── Events │ ├── GameEventEditor.cs.meta │ └── GameEventEditor.cs ├── Tests ├── Editor.meta ├── Runtime.meta ├── Runtime │ ├── com.gameframe.scriptableobjects.Tests.asmdef │ ├── com.gameframe.scriptableobjects.Tests.asmdef.meta │ ├── ScriptableObjectsRuntimeTests.cs.meta │ └── ScriptableObjectsRuntimeTests.cs └── Editor │ ├── com.gameframe.scriptableobjects.Editor.Tests.asmdef.meta │ ├── com.gameframe.scriptableobjects.Editor.Tests.asmdef │ ├── ScriptableObjectsEditorTests.cs.meta │ └── ScriptableObjectsEditorTests.cs ├── package.json ├── .gitignore ├── README.md └── LICENSE.md /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Created 8/27/2019 -------------------------------------------------------------------------------- /Documentation/com.gameframe.scriptableobjects.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Runtime/com.gameframe.scriptableobjects.asmdef: -------------------------------------------------------------------------------- 1 | { "name": "com.gameframe.scriptableobjects" } -------------------------------------------------------------------------------- /Runtime/RuntimeSets/IRuntimeSet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da68f1defd6e422eb79afad2fb38a481 3 | timeCreated: 1661391188 -------------------------------------------------------------------------------- /CHANGELOG.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3c7ce4b7c5254b27bc4c6d073d089ce 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /LICENSE.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ecef1fbbd78f47fca5e4b8094e43505 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9948815ae12054465a1e1fd831c8b04c 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Runtime/Events/IGameEventListener.cs: -------------------------------------------------------------------------------- 1 | namespace Gameframe.ScriptableObjects.Events 2 | { 3 | public interface IGameEventListener 4 | { 5 | void OnEventRaised(GameEvent gameEvent); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d64542bc471c345dfbaaf75a93f33a37 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef2e14784bc4e431b8a432e5ef33d72c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ca4b6e33387c643a1bdd59fd1fd0f935 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57a5264d10ba24846afcab66a03cc20e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Documentation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49d1c365ea6344c71a1d8d56c200b583 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Events.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3143dd1369da340149e161364420d64c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Events.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dec9e76ab168740c69ec93725037a6f7 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Locks.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db4f1c3415b4e41d7b88977946c16894 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Tests/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 84a564064fe2b4defac11a0f3db284ce 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Tests/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcecaaf125c644230a576a7f1fe9c5d8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Editor/Variables.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 19cb9fbea530243f7a692950bbfabfac 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3fa575d1e9454de98e56911bb384fa9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/Variables.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02729012f8002452d8d4d17720e01943 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Runtime/BindingSupport.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 054469add5e0b431fbf0596ecf29ad4d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Documentation/com.gameframe.scriptableobjects.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b028c8e7610eb4b0d91036005ae55f35 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/com.gameframe.scriptableobjects.Editor.asmdef: -------------------------------------------------------------------------------- 1 | { "name": "com.gameframe.scriptableobjects.Editor", "references": [ "com.gameframe.scriptableobjects" ], "optionalUnityReferences": [], "includePlatforms": [ "Editor" ], "excludePlatforms": [] } -------------------------------------------------------------------------------- /Runtime/com.gameframe.scriptableobjects.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71f96db21997f49acb0a891ff3620ec9 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Editor/com.gameframe.scriptableobjects.Editor.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 00a4b21cbbcb34e7e9289b5a158b6f73 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests/Runtime/com.gameframe.scriptableobjects.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { "name": "com.gameframe.scriptableobjects.Tests", "references": [ "com.gameframe.scriptableobjects" ], "optionalUnityReferences": ["TestAssemblies"], "includePlatforms": [], "excludePlatforms": [] } -------------------------------------------------------------------------------- /Tests/Runtime/com.gameframe.scriptableobjects.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57d369e7f3f534bcb971626642ef3b1e 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests/Editor/com.gameframe.scriptableobjects.Editor.Tests.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d720364d5c2c41fc9786fd7cb2f6da8 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Tests/Editor/com.gameframe.scriptableobjects.Editor.Tests.asmdef: -------------------------------------------------------------------------------- 1 | { "name": "com.gameframe.scriptableobjects.Editor.Tests", "references": [ "com.gameframe.scriptableobjects" ], "optionalUnityReferences": ["TestAssemblies"], "includePlatforms": [ "Editor" ], "excludePlatforms": [] } -------------------------------------------------------------------------------- /Runtime/Variables/IVariable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | public interface IVariable 8 | { 9 | T Value { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Runtime/Variables/IntReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [System.Serializable] 8 | public class IntReference : VariableReference 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/MenuNames.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bfd3526e303304f958dd0f85ded8611e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/ColorReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [System.Serializable] 8 | public class ColorReference : VariableReference 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Variables/FloatReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [System.Serializable] 8 | public class FloatReference : VariableReference 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Variables/StringReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | namespace Gameframe.ScriptableObjects.Variables 5 | { 6 | [System.Serializable] 7 | public class StringReference : VariableReference 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /Runtime/Locks/GameLock.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2f9d363031be4cfd986778d4bd761e1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/BaseGameEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a29b41214425d84e94c0b42807b5889 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/GameEventManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb663036a13cf498a933a66d176c8b03 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/StringGameEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 788f58922f497924eb8b63fc59439efc 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/AssetVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d3fab7e6cdf9c43d89cde7f6c3f29ba2 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/BaseVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a685c30b1adc146b88ad067d6f9e25fb 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/Vector2Reference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [System.Serializable] 8 | public class Vector2Reference : VariableReference 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Runtime/Variables/Vector3Reference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [System.Serializable] 8 | public class Vector3Reference : VariableReference 9 | { 10 | 11 | } 12 | } -------------------------------------------------------------------------------- /Editor/Variables/AssetVariableEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4042d5dfc1ee4a758803f2b9704a730 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/BaseGameEventListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7785994e3e2b6ab45a3ae639b41ab316 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeTable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92ec7610a033ce64e9c9aebb8572cdf8 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/AssetReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80d4dc79b9d8c4fb49db0eb6900c812f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Variables/GameObjectVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ebe439ea1f7f74b9796d8cc4224ff812 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/StringGameEventListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab1a883e17fdf3b41a60b0de108bc4f1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Tests/Editor/ScriptableObjectsEditorTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 29d59768ca1584ccaac72bb81881d1ca 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Tests/Runtime/ScriptableObjectsRuntimeTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 712a501cd6db847e58a73fbc7666d68b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.gameframe.scriptableobjects", 3 | "displayName": "Gameframe.ScriptableObjects", 4 | "version": "1.1.0", 5 | "author": { 6 | "name": "Cory Leach", 7 | "email": "cory.leach@gmail.com", 8 | "url": "https://coryleach.info" 9 | }, 10 | "description": "Library of scriptable object types" 11 | } -------------------------------------------------------------------------------- /Runtime/BindingSupport/BindableScriptableObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 789c0c6d52b1a401d815542c956e5a9b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Runtime/Events/GameEvent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3787c8f8a2bd42c49b05a9e73c5df141 3 | timeCreated: 1510507010 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/GameObjectRuntimeSet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.RuntimeSets 6 | { 7 | [CreateAssetMenu(menuName =MenuNames.RuntimeSetMenu+"GameObjectSet")] 8 | public class GameObjectRuntimeSet : RuntimeSet 9 | { 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /Editor/Events/GameEventEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6416704a5b8a6240a24c6d9d5538906 3 | timeCreated: 1510507428 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeSet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91d621c3222067243b44bcfa6cfa4341 3 | timeCreated: 1510506699 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/IVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 177bb4db013147843a5a44ff10b9319f 3 | timeCreated: 1511145165 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/IntReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d076a844e28fb844b7776c6bb448b8a 3 | timeCreated: 1510509706 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/IntVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc3b0a780f229b345b5fce9e3fd20401 3 | timeCreated: 1510508818 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Events/GameEventListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a878a3b803c9afc4ba62f66ac20b4ea9 3 | timeCreated: 1510507115 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Events/IGameEventListener.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e0827784cbba164c909d916445eb233 3 | timeCreated: 1511142068 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/ColorReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff4569abed6821843918488abe39acbf 3 | timeCreated: 1511144241 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/ColorVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2e07d6128ae3154438e2f3f3763bf012 3 | timeCreated: 1511144219 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/FloatReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08484c7d8dd3dcf439261814a134af99 3 | timeCreated: 1510509039 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/FloatVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc013a06823700b46a0442fef04fad7c 3 | timeCreated: 1510508614 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/StringReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 884026f40e92a614ea3beffd7151bd77 3 | timeCreated: 1510509716 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/StringVariable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5488467e8cec662429653f620e077421 3 | timeCreated: 1510508832 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/VariableReference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91f3fa223b7bf2349a0a0e588fc6a745 3 | timeCreated: 1511145016 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/Vector2Reference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11493a5ce8d0e96419059b3268a1ddae 3 | timeCreated: 1511144649 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/Vector2Variable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37f1a50e6357b6248bca90a26447c619 3 | timeCreated: 1511144635 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/Vector3Reference.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 033f8ba7858c67e44ac9d36691edb70f 3 | timeCreated: 1511144528 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/Vector3Variable.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ed4d303e93dd33429fd11c5fcfeab3b 3 | timeCreated: 1511144229 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Editor/Variables/AssetReferenceDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86704378f4f97496b8574c3b64f3c7b8 3 | timeCreated: 1510512036 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Editor/Variables/VariableReferenceDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bee5a21163f0f8349b89c1db1e1a5da2 3 | timeCreated: 1510512036 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/GameObjectRuntimeSet.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 145394c214c34b545a67bd790e452404 3 | timeCreated: 1510508036 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeSetInstance.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 082876efbf41eef46815c69fadad47b4 3 | timeCreated: 1512104748 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Variables/ScriptableVariableTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2ea1547742721e43b7d6a363a1d4238 3 | timeCreated: 1510509892 4 | licenseType: Pro 5 | MonoImporter: 6 | externalObjects: {} 7 | serializedVersion: 2 8 | defaultReferences: [] 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Runtime/Events/BaseGameEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Events 6 | { 7 | public abstract class BaseGameEvent : GameEvent 8 | { 9 | public abstract T Value { get; set; } 10 | 11 | public void Raise(T value) 12 | { 13 | Value = value; 14 | Raise(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/IRuntimeSet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine.Events; 3 | 4 | namespace Gameframe.ScriptableObjects.RuntimeSets 5 | { 6 | public interface IRuntimeSet 7 | { 8 | IReadOnlyList Items { get; } 9 | UnityEvent OnAdded { get; } 10 | UnityEvent OnRemoved { get; } 11 | void Add(T t); 12 | void Remove(T t); 13 | } 14 | } -------------------------------------------------------------------------------- /Runtime/Variables/ScriptableVariableTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | 8 | public class ScriptableVariableTest : MonoBehaviour 9 | { 10 | 11 | public FloatReference floatVariable; 12 | public StringReference stringVariable; 13 | public IntReference intVariable; 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /Runtime/Variables/IntVariable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | [CreateAssetMenu(menuName = MenuNames.Variables+"Int")] 6 | public class IntVariable : BaseVariable, IVariable 7 | { 8 | [SerializeField] 9 | private int value; 10 | public int Value 11 | { 12 | get => value; 13 | set => SetProperty(ref this.value, value); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Runtime/Variables/FloatVariable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | [CreateAssetMenu(menuName=MenuNames.Variables+"Float")] 6 | public class FloatVariable : BaseVariable, IVariable 7 | { 8 | [SerializeField] 9 | private float value; 10 | public float Value 11 | { 12 | get => value; 13 | set => SetProperty(ref this.value, value); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Variables/StringVariable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | [CreateAssetMenu(menuName = MenuNames.Variables+"String")] 6 | public class StringVariable : BaseVariable, IVariable 7 | { 8 | [SerializeField] 9 | private string value; 10 | public string Value 11 | { 12 | get => value; 13 | set => SetProperty(ref this.value, value); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Variables/Vector2Variable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | [CreateAssetMenu(menuName = MenuNames.Variables+"Vector2")] 6 | public class Vector2Variable : BaseVariable, IVariable 7 | { 8 | [SerializeField] 9 | private Vector2 value; 10 | public Vector2 Value 11 | { 12 | get => value; 13 | set => SetProperty(ref this.value, value); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/Variables/Vector3Variable.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | [CreateAssetMenu(menuName=MenuNames.Variables+"Vector3")] 6 | public class Vector3Variable : BaseVariable, IVariable 7 | { 8 | [SerializeField] 9 | private Vector3 value; 10 | public Vector3 Value 11 | { 12 | get => value; 13 | set => SetProperty(ref this.value, value); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeSetInstance.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Gameframe.ScriptableObjects.RuntimeSets 4 | { 5 | public class RuntimeSetInstance : MonoBehaviour 6 | { 7 | [SerializeField] 8 | private GameObjectRuntimeSet set = null; 9 | 10 | private void Awake() 11 | { 12 | set.Add(gameObject); 13 | } 14 | 15 | private void OnDestroy() 16 | { 17 | set.Remove(gameObject); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Runtime/MenuNames.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace Gameframe.ScriptableObjects 4 | { 5 | public static class MenuNames 6 | { 7 | public const string MenuBase = "Gameframe/"; 8 | public const string EventMenu = MenuBase + "Events/"; 9 | public const string LockMenu = MenuBase; 10 | public const string RuntimeSetMenu = MenuBase + "RuntimeSets/"; 11 | public const string Variables = MenuBase + "Variables/"; 12 | } 13 | } -------------------------------------------------------------------------------- /Runtime/Variables/ColorVariable.cs: -------------------------------------------------------------------------------- 1 | using Gameframe.ScriptableObjects.Events; 2 | using UnityEngine; 3 | 4 | namespace Gameframe.ScriptableObjects.Variables 5 | { 6 | [CreateAssetMenu(menuName=MenuNames.Variables+"Color")] 7 | public class ColorVariable : BaseVariable, IVariable 8 | { 9 | [SerializeField] 10 | private Color value; 11 | public Color Value 12 | { 13 | get => value; 14 | set => SetProperty(ref this.value, value); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Runtime/Events/StringGameEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Events 6 | { 7 | [CreateAssetMenu(menuName = MenuNames.EventMenu+"StringEvent")] 8 | public class StringGameEvent : BaseGameEvent 9 | { 10 | [SerializeField] 11 | private string _value; 12 | public override string Value 13 | { 14 | get => _value; 15 | set => _value = value; 16 | } 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /Editor/Events/GameEventEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace Gameframe.ScriptableObjects.Events 7 | { 8 | [CustomEditor(typeof(GameEvent))] 9 | public class GameEventEditor : UnityEditor.Editor 10 | { 11 | public override void OnInspectorGUI() 12 | { 13 | base.OnInspectorGUI(); 14 | if ( GUILayout.Button("Raise") ) 15 | { 16 | var gameEvent = target as GameEvent; 17 | gameEvent.Raise(); 18 | } 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Runtime/Events/GameEventListener.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | 6 | namespace Gameframe.ScriptableObjects.Events 7 | { 8 | public class GameEventListener : MonoBehaviour, IGameEventListener 9 | { 10 | public GameEvent gameEvent; 11 | public UnityEvent action; 12 | 13 | private void OnEnable() 14 | { 15 | gameEvent.AddListener(this); 16 | } 17 | 18 | private void OnDisable() 19 | { 20 | gameEvent.RemoveListener(this); 21 | } 22 | 23 | public void OnEventRaised(GameEvent gameEvent) 24 | { 25 | action.Invoke(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Events/BaseGameEventListener.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | 6 | namespace Gameframe.ScriptableObjects.Events 7 | { 8 | public abstract class BaseGameEventListener : MonoBehaviour, IGameEventListener 9 | { 10 | 11 | protected abstract GameEvent InternalEvent { get; } 12 | 13 | private void OnEnable() 14 | { 15 | InternalEvent.AddListener(this); 16 | } 17 | 18 | private void OnDisable() 19 | { 20 | InternalEvent.RemoveListener(this); 21 | } 22 | 23 | public virtual void OnEventRaised(GameEvent gameEvent) 24 | { 25 | 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Events/GameEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace Gameframe.ScriptableObjects.Events 5 | { 6 | [CreateAssetMenu(menuName=MenuNames.EventMenu+"GameEvent")] 7 | public class GameEvent : ScriptableObject 8 | { 9 | private readonly List _listeners = new List(); 10 | 11 | public void Raise() 12 | { 13 | for ( int i = _listeners.Count-1; i >= 0; i-- ) 14 | { 15 | _listeners[i].OnEventRaised(this); 16 | } 17 | } 18 | 19 | public void AddListener(IGameEventListener listener) 20 | { 21 | _listeners.Add(listener); 22 | } 23 | 24 | public void RemoveListener(IGameEventListener listener) 25 | { 26 | _listeners.Remove(listener); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeSet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | 5 | namespace Gameframe.ScriptableObjects.RuntimeSets 6 | { 7 | public class RuntimeSet : ScriptableObject, IRuntimeSet 8 | { 9 | public class RuntimeSetChangeEvent : UnityEvent {} 10 | 11 | private readonly List _items = new List(); 12 | public IReadOnlyList Items => _items; 13 | 14 | public UnityEvent OnAdded { get; } = new RuntimeSetChangeEvent(); 15 | public UnityEvent OnRemoved { get; } = new RuntimeSetChangeEvent(); 16 | 17 | public void Add(T t) 18 | { 19 | _items.Add(t); 20 | OnAdded.Invoke(t); 21 | } 22 | 23 | public void Remove(T t) 24 | { 25 | _items.Remove(t); 26 | OnRemoved.Invoke(t); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Runtime/Events/StringGameEventListener.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | using UnityEngine.Events; 6 | 7 | namespace Gameframe.ScriptableObjects.Events 8 | { 9 | 10 | public class StringGameEventListener : BaseGameEventListener 11 | { 12 | 13 | [SerializeField] 14 | private StringGameEvent stringGameEvent = null; 15 | 16 | [Serializable] 17 | public class StringEvent : UnityEvent { } 18 | 19 | [SerializeField] 20 | private StringEvent onEventRaised = null; 21 | 22 | protected override GameEvent InternalEvent 23 | { 24 | get { return stringGameEvent; } 25 | } 26 | 27 | public override void OnEventRaised(GameEvent gameEvent) 28 | { 29 | onEventRaised.Invoke(stringGameEvent.Value); 30 | } 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /Runtime/Variables/GameObjectVariable.cs: -------------------------------------------------------------------------------- 1 | using Gameframe.ScriptableObjects.Events; 2 | using UnityEngine; 3 | using UnityEngine.Events; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | [CreateAssetMenu(menuName=MenuNames.Variables+"GameObject")] 8 | public class GameObjectVariable : BaseVariable, IVariable 9 | { 10 | [SerializeField] 11 | private bool clearOnEnable = false; 12 | 13 | [SerializeField] 14 | private GameObject gameObject = null; 15 | 16 | public GameObject Value 17 | { 18 | get => gameObject; 19 | set 20 | { 21 | if (gameObject != value) 22 | { 23 | gameObject = value; 24 | OnPropertyChanged(); 25 | } 26 | } 27 | } 28 | 29 | private void OnEnable() 30 | { 31 | if (clearOnEnable) 32 | { 33 | Value = null; 34 | } 35 | } 36 | 37 | } 38 | } -------------------------------------------------------------------------------- /Tests/Editor/ScriptableObjectsEditorTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | 7 | namespace Gameframe.ScriptableObjects.Tests.Editor 8 | { 9 | public class ScriptableObjectsEditorTests 10 | { 11 | // A Test behaves as an ordinary method 12 | [Test] 13 | public void ScriptableObjectsEditorTestsSimplePasses() 14 | { 15 | // Use the Assert class to test conditions 16 | } 17 | 18 | // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use 19 | // `yield return null;` to skip a frame. 20 | [UnityTest] 21 | public IEnumerator ScriptableObjectsEditorTestsWithEnumeratorPasses() 22 | { 23 | // Use the Assert class to test conditions. 24 | // Use yield to skip a frame. 25 | yield return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tests/Runtime/ScriptableObjectsRuntimeTests.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | 7 | namespace Gameframe.ScriptableObjects.Test.Runtime 8 | { 9 | public class ScriptableObjectsRuntimeTests 10 | { 11 | // A Test behaves as an ordinary method 12 | [Test] 13 | public void ScriptableObjectsRuntimeTestsSimplePasses() 14 | { 15 | // Use the Assert class to test conditions 16 | } 17 | 18 | // A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use 19 | // `yield return null;` to skip a frame. 20 | [UnityTest] 21 | public IEnumerator ScriptableObjectsRuntimeTestsWithEnumeratorPasses() 22 | { 23 | // Use the Assert class to test conditions. 24 | // Use yield to skip a frame. 25 | yield return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Runtime/Variables/VariableReference.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Variables 6 | { 7 | 8 | public abstract class VariableReference where V : IVariable 9 | { 10 | 11 | public bool useLocalValue; 12 | public T localValue; 13 | public V variable; 14 | 15 | public bool HasValue 16 | { 17 | get 18 | { 19 | if (useLocalValue || variable != null) 20 | { 21 | return true; 22 | } 23 | return false; 24 | } 25 | } 26 | 27 | public T Value 28 | { 29 | get 30 | { 31 | return useLocalValue ? localValue : variable.Value; 32 | } 33 | set 34 | { 35 | if (useLocalValue) 36 | { 37 | localValue = value; 38 | } 39 | else 40 | { 41 | variable.Value = value; 42 | } 43 | } 44 | } 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /Runtime/Variables/AssetVariable.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using UnityEngine; 3 | 4 | namespace Gameframe.ScriptableObjects.Variables 5 | { 6 | [CreateAssetMenu(menuName=MenuNames.Variables+"Asset")] 7 | public class AssetVariable : ScriptableObject 8 | { 9 | [SerializeField] 10 | private string assetName = ""; 11 | public string AssetName => assetName; 12 | 13 | #if UNITY_EDITOR 14 | [SerializeField] 15 | private string assetPath = ""; 16 | #endif 17 | 18 | public virtual Task FetchAsync() 19 | { 20 | #if UNITY_EDITOR 21 | return Task.FromResult(UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath)); 22 | #else 23 | //TODO: Need runtime asset loader. Should integrate with addressable assets in the future 24 | return null; 25 | #endif 26 | } 27 | 28 | public virtual Task FetchAsync() where T : UnityEngine.Object 29 | { 30 | #if UNITY_EDITOR 31 | return Task.FromResult(UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath)); 32 | #else 33 | //TODO: Need runtime asset loader 34 | return null; 35 | #endif 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Editor/Variables/AssetVariableEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace Gameframe.ScriptableObjects.Variables 5 | { 6 | [CustomEditor( typeof( AssetVariable ) )] 7 | public class AssetVariableEditor : Editor 8 | { 9 | SerializedProperty assetName; 10 | SerializedProperty assetPath; 11 | 12 | protected void OnEnable() 13 | { 14 | assetName = serializedObject.FindProperty( "assetName" ); 15 | assetPath = serializedObject.FindProperty( "assetPath" ); 16 | } 17 | 18 | public override void OnInspectorGUI() 19 | { 20 | base.OnInspectorGUI(); 21 | serializedObject.Update(); 22 | 23 | var asset = AssetDatabase.LoadAssetAtPath( assetPath.stringValue ); 24 | asset = EditorGUILayout.ObjectField( "Asset (NotSerialized)", asset, typeof( GameObject ), false ); 25 | if ( asset != null ) 26 | { 27 | assetName.stringValue = asset.name; 28 | assetPath.stringValue = AssetDatabase.GetAssetPath( asset ); 29 | } 30 | else 31 | { 32 | assetPath.stringValue = string.Empty; 33 | } 34 | 35 | serializedObject.ApplyModifiedProperties(); 36 | } 37 | 38 | } 39 | 40 | } -------------------------------------------------------------------------------- /Runtime/Variables/BaseVariable.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.CompilerServices; 2 | using Gameframe.ScriptableObjects.BindingSupport; 3 | using Gameframe.ScriptableObjects.Events; 4 | using UnityEngine; 5 | 6 | namespace Gameframe.ScriptableObjects.Variables 7 | { 8 | public class BaseVariable : BindableScriptableObject 9 | { 10 | [SerializeField] 11 | protected GameEvent onValueChanged; 12 | 13 | public GameEvent OnValueChanged 14 | { 15 | get 16 | { 17 | if (onValueChanged == null) 18 | { 19 | onValueChanged = CreateInstance(); 20 | } 21 | return onValueChanged; 22 | } 23 | } 24 | 25 | /// 26 | /// INotifyPropertyChanged interface implemented to support Gameframe.Bindings 27 | /// 28 | #region INotifyPropertyChanged 29 | protected override void OnPropertyChanged([CallerMemberName] string propertyName = null) 30 | { 31 | base.OnPropertyChanged(propertyName); 32 | if (onValueChanged != null) 33 | { 34 | onValueChanged.Raise(); 35 | } 36 | } 37 | #endregion 38 | 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /Runtime/RuntimeSets/RuntimeTable.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace Gameframe.ScriptableObjects.RuntimeSets 5 | { 6 | public class RuntimeTable : ScriptableObject 7 | { 8 | [SerializeField] 9 | private bool allowOverwrite = true; 10 | 11 | [SerializeField] 12 | private bool throwExceptions = false; 13 | 14 | private readonly Dictionary _items = new Dictionary(); 15 | 16 | public IReadOnlyDictionary Items => _items; 17 | 18 | public TValue Get(TKey key) 19 | { 20 | if ( throwExceptions ) 21 | { 22 | return _items[key]; 23 | } 24 | 25 | if ( _items.TryGetValue(key,out var val)) 26 | { 27 | return val; 28 | } 29 | 30 | return default(TValue); 31 | } 32 | 33 | public void Add(TKey key, TValue val) 34 | { 35 | if ( allowOverwrite ) 36 | { 37 | _items[key] = val; 38 | } 39 | else 40 | { 41 | _items.Add(key, val); 42 | } 43 | } 44 | 45 | public bool Remove(TKey key) 46 | { 47 | return _items.Remove(key); 48 | } 49 | 50 | protected virtual void OnEnable() 51 | { 52 | _items.Clear(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # This .gitignore file should be placed at the root of your Unity project directory 2 | # 3 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore 4 | # 5 | /[Ll]ibrary/ 6 | /[Tt]emp/ 7 | /[Oo]bj/ 8 | /[Bb]uild/ 9 | /[Bb]uilds/ 10 | /[Ll]ogs/ 11 | /[Mm]emoryCaptures/ 12 | 13 | # Never ignore Asset meta data 14 | !/[Aa]ssets/**/*.meta 15 | 16 | # Uncomment this line if you wish to ignore the asset store tools plugin 17 | # /[Aa]ssets/AssetStoreTools* 18 | 19 | # TextMesh Pro files 20 | [Aa]ssets/TextMesh*Pro/ 21 | 22 | # Autogenerated Jetbrains Rider plugin 23 | [Aa]ssets/Plugins/Editor/JetBrains* 24 | 25 | # Visual Studio cache directory 26 | .vs/ 27 | 28 | # Gradle cache directory 29 | .gradle/ 30 | 31 | # Autogenerated VS/MD/Consulo solution and project files 32 | ExportedObj/ 33 | .consulo/ 34 | *.csproj 35 | *.unityproj 36 | *.sln 37 | *.suo 38 | *.tmp 39 | *.user 40 | *.userprefs 41 | *.pidb 42 | *.booproj 43 | *.svd 44 | *.pdb 45 | *.mdb 46 | *.opendb 47 | *.VC.db 48 | 49 | # Unity3D generated meta files 50 | *.pidb.meta 51 | *.pdb.meta 52 | *.mdb.meta 53 | 54 | # Unity3D generated file on crash reports 55 | sysinfo.txt 56 | 57 | # Builds 58 | *.apk 59 | *.unitypackage 60 | 61 | # Crashlytics generated file 62 | crashlytics-build.properties 63 | 64 | -------------------------------------------------------------------------------- /Runtime/BindingSupport/BindableScriptableObject.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.ComponentModel; 3 | using System.Runtime.CompilerServices; 4 | using UnityEngine; 5 | 6 | namespace Gameframe.ScriptableObjects.BindingSupport 7 | { 8 | public class BindableScriptableObject : ScriptableObject, INotifyPropertyChanged 9 | { 10 | public event PropertyChangedEventHandler PropertyChanged; 11 | 12 | protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) 13 | { 14 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 15 | } 16 | 17 | /// 18 | /// Use this inside property setters to raise property changed events which are needed by bindingssss 19 | /// 20 | /// field to which the value will be set 21 | /// value you want to assign to storage 22 | /// name of the property being set 23 | /// Type of the property being set 24 | /// True if property was set. False if it was already equal to the given value. 25 | protected bool SetProperty(ref T field, T value, [CallerMemberName] string propertyName = null ) 26 | { 27 | if (EqualityComparer.Default.Equals(field,value)) 28 | { 29 | return false; 30 | } 31 | field = value; 32 | OnPropertyChanged(propertyName); 33 | return true; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Runtime/Variables/AssetReference.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Gameframe.ScriptableObjects.Variables 4 | { 5 | using System; 6 | 7 | public enum AssetReferenceType : int 8 | { 9 | Direct = 0, //Maintain reference via Unity GUID 10 | Fetch = 1, //Fetch from disk using the path/asset name 11 | Variable = 2 //Link using a variable asset 12 | } 13 | 14 | [Serializable] 15 | public class AssetReference 16 | { 17 | public AssetReferenceType referenceType = AssetReferenceType.Direct; 18 | 19 | //Direct Reference 20 | //Indirect/Soft Reference (Save only asset name/path?) 21 | //TODO: Do we want to save off the path and not the actual asset reference? 22 | public UnityEngine.Object localValue; 23 | public string assetPath = string.Empty; 24 | public string assetName = string.Empty; 25 | 26 | public AssetVariable variable; 27 | 28 | public Task FetchAsync() 29 | { 30 | if ( referenceType == AssetReferenceType.Direct ) 31 | { 32 | return Task.FromResult(localValue); 33 | } 34 | 35 | if ( referenceType == AssetReferenceType.Fetch ) 36 | { 37 | //TODO: Fetch from someplace 38 | return null; 39 | } 40 | 41 | return variable.FetchAsync(); 42 | } 43 | 44 | public Task FetchAsync() where T : UnityEngine.Object 45 | { 46 | if ( referenceType == AssetReferenceType.Direct ) 47 | { 48 | return Task.FromResult(localValue as T); 49 | } 50 | 51 | if ( referenceType == AssetReferenceType.Fetch ) 52 | { 53 | //TODO: Fetch from someplace 54 | return null; 55 | } 56 | 57 | return variable.FetchAsync(); 58 | } 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Gameframe.ScriptableObjects 👋

2 |

3 | Version 4 | 5 | Twitter: coryleach 6 | 7 |

8 | 9 | Library of scriptable object types 10 | 11 | ## Quick Package Install 12 | 13 | #### Using UnityPackageManager (for Unity 2019.3 or later) 14 | Open the package manager window (menu: Window > Package Manager)
15 | Select "Add package from git URL...", fill in the pop-up with the following link:
16 | https://github.com/coryleach/UnityScriptableObjects.git#1.1.0
17 | 18 | #### Using UnityPackageManager (for Unity 2019.1 or later) 19 | 20 | Find the manifest.json file in the Packages folder of your project and edit it to look like this: 21 | ```js 22 | { 23 | "dependencies": { 24 | "com.gameframe.scriptableobjects": "https://github.com/coryleach/RepositoryName.git#1.1.0", 25 | ... 26 | }, 27 | } 28 | ``` 29 | 30 | 31 | 32 | Library of ScriptableObject types for Unity:
33 | 34 | > RuntimeSets
35 | > GameObjects can add themselves to RuntimeSet assets at runtime to quickly get sets of GameObjects
36 | 37 | > Variables
38 | > Use scriptable objects to share variable instances between objects. Subscribe for value change events.
39 | 40 | > GameEvents
41 | > Hook up events between scenes and prefabs using scriptable objects as game events
42 | 43 | 44 | 45 | ## Author 46 | 47 | 👤 **Cory Leach** 48 | 49 | * Twitter: [@coryleach](https://twitter.com/coryleach) 50 | * Github: [@coryleach](https://github.com/coryleach) 51 | 52 | 53 | ## Show your support 54 | 55 | Give a ⭐️ if this project helped you! 56 | 57 | *** 58 | _This README was generated with ❤️ by [Gameframe.Packages](https://github.com/coryleach/unitypackages)_ 59 | -------------------------------------------------------------------------------- /Editor/Variables/VariableReferenceDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace Gameframe.ScriptableObjects.Variables 7 | { 8 | 9 | [CustomPropertyDrawer(typeof(FloatReference))] 10 | [CustomPropertyDrawer(typeof(IntReference))] 11 | [CustomPropertyDrawer(typeof(StringReference))] 12 | [CustomPropertyDrawer(typeof(ColorReference))] 13 | [CustomPropertyDrawer(typeof(Vector3Reference))] 14 | [CustomPropertyDrawer(typeof(Vector2Reference))] 15 | public class VariableReferenceDrawer : PropertyDrawer 16 | { 17 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 18 | { 19 | EditorGUI.BeginProperty(position, label, property); 20 | 21 | // Draw label 22 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 23 | 24 | var useLocalValue = property.FindPropertyRelative("useLocalValue"); 25 | 26 | // Calculate rects 27 | Rect dropdownRect = new Rect(position.x, position.y, 85, position.height); 28 | Rect variableRect = new Rect(position.x + (dropdownRect.width), position.y, position.width - (dropdownRect.width), position.height); 29 | 30 | string[] options = { "Use Local", "Use Variable" }; 31 | if (EditorGUI.Popup(dropdownRect, useLocalValue.boolValue ? 0 : 1, options) == 0) 32 | { 33 | useLocalValue.boolValue = true; 34 | } 35 | else 36 | { 37 | useLocalValue.boolValue = false; 38 | } 39 | 40 | if (useLocalValue.boolValue) 41 | { 42 | //Draw Local variable editor 43 | EditorGUI.PropertyField(variableRect, property.FindPropertyRelative("localValue"), GUIContent.none); 44 | } 45 | else 46 | { 47 | //Draw reference editor 48 | EditorGUI.PropertyField(variableRect, property.FindPropertyRelative("variable"), GUIContent.none); 49 | } 50 | 51 | EditorGUI.EndProperty(); 52 | } 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /Editor/Variables/AssetReferenceDrawer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace Gameframe.ScriptableObjects.Variables 7 | { 8 | 9 | [CustomPropertyDrawer(typeof(AssetReference))] 10 | public class AssetReferenceDrawer : PropertyDrawer 11 | { 12 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 13 | { 14 | EditorGUI.BeginProperty(position, label, property); 15 | 16 | // Draw label 17 | position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label); 18 | 19 | var referenceType = property.FindPropertyRelative("referenceType"); 20 | var assetName = property.FindPropertyRelative("assetName"); 21 | var assetPath = property.FindPropertyRelative("assetPath"); 22 | var localValue = property.FindPropertyRelative("localValue"); 23 | 24 | // Calculate rects 25 | Rect dropdownRect = new Rect(position.x, position.y, 85, position.height); 26 | Rect variableRect = new Rect(position.x + (dropdownRect.width), position.y, position.width - (dropdownRect.width), position.height); 27 | 28 | string[] options = { "Direct", "Fetch", "Variable" }; 29 | 30 | referenceType.enumValueIndex = EditorGUI.Popup(dropdownRect, referenceType.enumValueIndex, options); 31 | 32 | switch(referenceType.enumValueIndex) 33 | { 34 | case 0: 35 | //Direct 36 | EditorGUI.PropertyField(variableRect, localValue, GUIContent.none); 37 | break; 38 | case 1: 39 | //Fetch 40 | var asset = AssetDatabase.LoadAssetAtPath(assetPath.stringValue); 41 | asset = EditorGUI.ObjectField(variableRect, asset, typeof(GameObject), false); 42 | if (asset != null) 43 | { 44 | assetName.stringValue = asset.name; 45 | assetPath.stringValue = AssetDatabase.GetAssetPath(asset); 46 | } 47 | else 48 | { 49 | assetPath.stringValue = string.Empty; 50 | } 51 | localValue.objectReferenceValue = null; 52 | break; 53 | default: 54 | EditorGUI.PropertyField(variableRect, property.FindPropertyRelative("variable"), GUIContent.none); 55 | break; 56 | } 57 | 58 | EditorGUI.EndProperty(); 59 | } 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /Runtime/Locks/GameLock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using Gameframe.ScriptableObjects.Events; 4 | using UnityEngine; 5 | 6 | namespace Gameframe.ScriptableObjects.Locks 7 | { 8 | 9 | /// 10 | /// GameLock maintains an internal count for the number of times it's been locked 11 | /// The Locked property will be true when the count is not equal to zero 12 | /// Events are generated on Lock and Unlock 13 | /// 14 | [CreateAssetMenu(menuName=MenuNames.LockMenu+"Lock")] 15 | public class GameLock : ScriptableObject, INotifyPropertyChanged 16 | { 17 | [NonSerialized] 18 | private int lockCount = 0; 19 | 20 | public bool Locked => lockCount != 0; 21 | 22 | /// 23 | /// OnValueChanged is raised when the state of the lock changes 24 | /// A value of True means the lock count is non-zero. 25 | /// 26 | public event Action OnValueChanged; 27 | 28 | [SerializeField] 29 | private GameEvent unlockedEvent; 30 | public GameEvent OnUnlocked 31 | { 32 | get 33 | { 34 | if (unlockedEvent == null) 35 | { 36 | unlockedEvent = CreateInstance(); 37 | } 38 | return unlockedEvent; 39 | } 40 | } 41 | 42 | [SerializeField] 43 | private GameEvent lockedEvent; 44 | public GameEvent OnLocked 45 | { 46 | get 47 | { 48 | if (lockedEvent == null) 49 | { 50 | lockedEvent = CreateInstance(); 51 | } 52 | return lockedEvent; 53 | } 54 | } 55 | 56 | private void OnEnable() 57 | { 58 | lockCount = 0; 59 | } 60 | 61 | /// 62 | /// Increment the internal counter which enables the lock 63 | /// 64 | public void Lock() 65 | { 66 | lockCount++; 67 | if (lockCount == 1) 68 | { 69 | RaiseValueChanged(); 70 | } 71 | } 72 | 73 | /// 74 | /// Decrement the internal counter which disables the lock if it hits zero 75 | /// 76 | public void Unlock() 77 | { 78 | lockCount--; 79 | if (lockCount == 0) 80 | { 81 | RaiseValueChanged(); 82 | } 83 | } 84 | 85 | private void RaiseValueChanged() 86 | { 87 | OnPropertyChanged(nameof(Locked)); 88 | } 89 | 90 | /// 91 | /// INotifyPropertyChanged interface implemented to support Gameframe.Bindings 92 | /// 93 | #region INotifyPropertyChanged 94 | 95 | public event PropertyChangedEventHandler PropertyChanged; 96 | 97 | private void OnPropertyChanged(string propertyName = null) 98 | { 99 | var value = Locked; 100 | 101 | if (value) 102 | { 103 | if (lockedEvent != null) 104 | { 105 | lockedEvent.Raise(); 106 | } 107 | } 108 | else 109 | { 110 | if (unlockedEvent != null) 111 | { 112 | unlockedEvent.Raise(); 113 | } 114 | } 115 | 116 | try 117 | { 118 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); 119 | } 120 | catch (Exception e) 121 | { 122 | Debug.LogException(e,this); 123 | } 124 | 125 | try 126 | { 127 | OnValueChanged?.Invoke(value); 128 | } 129 | catch (Exception e) 130 | { 131 | Debug.LogException(e,this); 132 | } 133 | } 134 | 135 | #endregion 136 | 137 | } 138 | } 139 | 140 | 141 | -------------------------------------------------------------------------------- /Runtime/Events/GameEventManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace Gameframe.ScriptableObjects.Events 6 | { 7 | [CreateAssetMenu(menuName = MenuNames.EventMenu+"EventManager")] 8 | public class GameEventManager : ScriptableObject 9 | { 10 | 11 | #region Invokable Callback Wrappers 12 | /// 13 | /// Serves as a wrapper for an invokable callback 14 | /// 15 | private interface IInvokable 16 | { 17 | void Invoke(params object[] args); 18 | } 19 | 20 | /// 21 | /// Invokable wrapper for a simple action callback 22 | /// 23 | private class Invokable : IInvokable 24 | { 25 | public Invokable(Action callback) 26 | { 27 | Callback = callback; 28 | } 29 | 30 | public Action Callback { get; } 31 | 32 | public void Invoke(params object[] args) 33 | { 34 | Callback.Invoke(); 35 | } 36 | } 37 | 38 | /// 39 | /// Invokable wrapper for a callback that takes a single arg 40 | /// 41 | /// 42 | private class Invokable : IInvokable 43 | { 44 | public Invokable(Action callback) 45 | { 46 | Callback = callback; 47 | } 48 | 49 | public Action Callback { get; } 50 | 51 | public void Invoke(params object[] args) 52 | { 53 | Callback.Invoke((T)args[0]); 54 | } 55 | } 56 | 57 | /// 58 | /// Invokable wrapper for a callback that takes a single arg 59 | /// 60 | /// 61 | private class Invokable : IInvokable 62 | { 63 | public Invokable(Action callback) 64 | { 65 | Callback = callback; 66 | } 67 | 68 | public Action Callback { get; } 69 | 70 | public void Invoke(params object[] args) 71 | { 72 | if ( args.Length < 2 ) 73 | { 74 | return; 75 | } 76 | 77 | if ( !(args[0] is T0) ) 78 | { 79 | return; 80 | } 81 | 82 | if ( !(args[1] is T1) ) 83 | { 84 | return; 85 | } 86 | 87 | var arg0 = (T0)args[0]; 88 | var arg1 = (T1)args[1]; 89 | Callback.Invoke(arg0,arg1); 90 | } 91 | } 92 | 93 | /// 94 | /// Internal representation of a single invokable event instance 95 | /// 96 | private class InternalEvent 97 | { 98 | private readonly List _invokables = new List(); 99 | 100 | public void Raise(params object[] args) 101 | { 102 | foreach (var invokable in _invokables) 103 | { 104 | invokable.Invoke(args); 105 | } 106 | } 107 | 108 | public void AddListener(Action callback) 109 | { 110 | _invokables.Add(new Invokable(callback)); 111 | } 112 | 113 | public void AddListener(Action callback) 114 | { 115 | _invokables.Add(new Invokable(callback)); 116 | } 117 | 118 | public void AddListener(Action callback) 119 | { 120 | _invokables.Add(new Invokable(callback)); 121 | } 122 | 123 | public void RemoveListener(Action callback) 124 | { 125 | for (var i = 0; i < _invokables.Count; i++) 126 | { 127 | if (_invokables[i] is Invokable invokable && invokable.Callback == callback) 128 | { 129 | _invokables.RemoveAt(i); 130 | return; 131 | } 132 | } 133 | } 134 | 135 | public void RemoveListener(Action callback) 136 | { 137 | for (var i = 0; i < _invokables.Count; i++) 138 | { 139 | if (_invokables[i] is Invokable invokable && invokable.Callback == callback) 140 | { 141 | _invokables.RemoveAt(i); 142 | return; 143 | } 144 | } 145 | } 146 | 147 | public void RemoveListener(Action callback) 148 | { 149 | for (var i = 0; i < _invokables.Count; i++) 150 | { 151 | if (_invokables[i] is Invokable invokable && invokable.Callback == callback) 152 | { 153 | _invokables.RemoveAt(i); 154 | return; 155 | } 156 | } 157 | } 158 | 159 | } 160 | #endregion 161 | 162 | private readonly Dictionary _eventDictionary = new Dictionary(); 163 | 164 | private void OnEnable() 165 | { 166 | //Ensure that dictionary is cleaned up in editor 167 | _eventDictionary.Clear(); 168 | } 169 | 170 | public void AddListener(string eventName, Action callback) 171 | { 172 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 173 | { 174 | @event = new InternalEvent(); 175 | _eventDictionary.Add(eventName,@event); 176 | } 177 | 178 | @event.AddListener(callback); 179 | } 180 | 181 | public void AddListener(string eventName, Action callback) 182 | { 183 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 184 | { 185 | @event = new InternalEvent(); 186 | _eventDictionary.Add(eventName,@event); 187 | } 188 | @event.AddListener(callback); 189 | } 190 | 191 | public void AddListener(string eventName, Action callback) 192 | { 193 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 194 | { 195 | @event = new InternalEvent(); 196 | _eventDictionary.Add(eventName,@event); 197 | } 198 | @event.AddListener(callback); 199 | } 200 | 201 | public void RemoveListener(string eventName, Action callback) 202 | { 203 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 204 | { 205 | return; 206 | } 207 | @event.RemoveListener(callback); 208 | } 209 | 210 | public void RemoveListener(string eventName, Action callback) 211 | { 212 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 213 | { 214 | return; 215 | } 216 | @event.RemoveListener(callback); 217 | } 218 | 219 | public void RemoveListener(string eventName, Action callback) 220 | { 221 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 222 | { 223 | return; 224 | } 225 | @event.RemoveListener(callback); 226 | } 227 | 228 | public void Raise(string eventName) 229 | { 230 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 231 | { 232 | return; 233 | } 234 | @event.Raise(); 235 | } 236 | 237 | public void Raise(string eventName, T payload) 238 | { 239 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 240 | { 241 | return; 242 | } 243 | @event.Raise(payload); 244 | } 245 | 246 | public void Raise(string eventName, T0 payload0, T1 payload1) 247 | { 248 | if (!_eventDictionary.TryGetValue(eventName, out var @event)) 249 | { 250 | return; 251 | } 252 | @event.Raise(payload0,payload1); 253 | } 254 | 255 | } 256 | 257 | } 258 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 Cory Leach 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------