diff --git a/README.md b/README.md index ba7222b..672d65d 100755 --- a/README.md +++ b/README.md @@ -1333,6 +1333,10 @@ Exemplifies how to bind to prefabs and the use of `PostConstruct` as a second co Exemplifies the use of commands through a simple spawner of a prefab. +### 6. Bindings Setup + +Exemplifies the use of bindings setups to better organize the bindings for a container. + ## Changelog Please see [CHANGELOG.txt](src/Assets/Adic/CHANGELOG.txt). diff --git a/src/Assets/Adic/CHANGELOG.txt b/src/Assets/Adic/CHANGELOG.txt index cec3cf7..cdd0fdd 100644 --- a/src/Assets/Adic/CHANGELOG.txt +++ b/src/Assets/Adic/CHANGELOG.txt @@ -9,8 +9,12 @@ Version 2.6 (2015-04-10) Framework - Added overloads to SetupBindings() method to setup bindings from namespaces. [Issue #5] -- Added BindingPriority attribute to indicate prioritary bindings setup when using SetupBindings() with namespaces. [Issue #6] +- Added BindingPriority attribute to indicate prioritary bindings setups when using SetupBindings() with namespaces. [Issue #6] - Removed factoryType property from Adic.IFactory. [Issue #6] +- Fixed comments in examples. + +Bindings Setup Extension +- Added Bindings Setup example. Version 2.5 (2015-04-02) diff --git a/src/Assets/Adic/Examples/02_BindingGameObjects/Scripts/GameObjectRotator.cs b/src/Assets/Adic/Examples/02_BindingGameObjects/Scripts/GameObjectRotator.cs index f65e92c..4fa1c34 100755 --- a/src/Assets/Adic/Examples/02_BindingGameObjects/Scripts/GameObjectRotator.cs +++ b/src/Assets/Adic/Examples/02_BindingGameObjects/Scripts/GameObjectRotator.cs @@ -10,6 +10,8 @@ public class GameObjectRotator : MonoBehaviour { public Transform objectToRotate; protected void Start() { + //Calls "Inject" to inject any dependencies to the component. + //In a production game, it's useful to place this in a base component. this.Inject(); } diff --git a/src/Assets/Adic/Examples/03_UsingConditions/Scripts/GameObjectRotator.cs b/src/Assets/Adic/Examples/03_UsingConditions/Scripts/GameObjectRotator.cs index 976535b..b2dcb03 100755 --- a/src/Assets/Adic/Examples/03_UsingConditions/Scripts/GameObjectRotator.cs +++ b/src/Assets/Adic/Examples/03_UsingConditions/Scripts/GameObjectRotator.cs @@ -13,6 +13,8 @@ public class GameObjectRotator : MonoBehaviour { public Transform objectToRotate; protected void Start() { + //Calls "Inject" to inject any dependencies to the component. + //On a production game, it's useful to place this in a base component. this.Inject(); } diff --git a/src/Assets/Adic/Examples/04_Prefabs/Scripts/CubeRotator.cs b/src/Assets/Adic/Examples/04_Prefabs/Scripts/CubeRotator.cs index 11dafec..d9e429b 100755 --- a/src/Assets/Adic/Examples/04_Prefabs/Scripts/CubeRotator.cs +++ b/src/Assets/Adic/Examples/04_Prefabs/Scripts/CubeRotator.cs @@ -28,7 +28,7 @@ protected void PostConstruct() { /// protected void Start() { //Calls "Inject" to inject any dependencies to the component. - //On a productin game, it's useful to place this in a base component. + //In a production game, it's useful to place this in a base component. this.Inject(); } diff --git a/src/Assets/Adic/Examples/06_BindingsSetup.meta b/src/Assets/Adic/Examples/06_BindingsSetup.meta new file mode 100644 index 0000000..1671741 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 80d5f17b3c359468bb0d1a8cada5be70 +folderAsset: yes +timeCreated: 1428687926 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity b/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity new file mode 100644 index 0000000..cf20565 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity @@ -0,0 +1,272 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: .25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: .5, g: .5, b: .5, a: 1} + m_FogMode: 3 + m_FogDensity: .00999999978 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: .5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_GIWorkflowMode: 1 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 1 + m_BakeResolution: 50 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_LightmapSnapshot: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: .5 + agentHeight: 2 + agentSlope: 45 + agentClimb: .400000006 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: .166666657 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &300725219 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 300725221} + - 108: {fileID: 300725220} + m_Layer: 0 + m_Name: Directional light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &300725220 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 300725219} + m_Enabled: 1 + serializedVersion: 6 + m_Type: 1 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + m_Resolution: -1 + m_Strength: 1 + m_Bias: .0500000007 + m_NormalBias: .400000006 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 1 + m_BounceIntensity: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 + m_AreaSize: {x: 1, y: 1} +--- !u!4 &300725221 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 300725219} + m_LocalRotation: {x: .408217937, y: -.234569728, z: .109381661, w: .875426114} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 +--- !u!1 &548564958 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 548564960} + - 114: {fileID: 548564959} + m_Layer: 0 + m_Name: GameRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &548564959 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 548564958} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 91388b33b41d145a293941230180e00f, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &548564960 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 548564958} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!1 &2052139624 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 2052139629} + - 20: {fileID: 2052139628} + - 92: {fileID: 2052139627} + - 124: {fileID: 2052139626} + - 81: {fileID: 2052139625} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &2052139625 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2052139624} + m_Enabled: 1 +--- !u!124 &2052139626 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2052139624} + m_Enabled: 1 +--- !u!92 &2052139627 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2052139624} + m_Enabled: 1 +--- !u!20 &2052139628 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2052139624} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: .300000012 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: .0219999999 +--- !u!4 &2052139629 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2052139624} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity.meta b/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity.meta new file mode 100644 index 0000000..c47f569 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/BindingsSetup.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bf208c596294d4a23910164033b155be +timeCreated: 1428687947 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Resources.meta new file mode 100644 index 0000000..9849013 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b68415798d826482cbc83a065f788d5b +folderAsset: yes +timeCreated: 1428687947 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab new file mode 100644 index 0000000..f1625ba --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab @@ -0,0 +1,98 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &153130 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 407836} + - 33: {fileID: 3346468} + - 65: {fileID: 6528884} + - 23: {fileID: 2339520} + - 114: {fileID: 11419896} + m_Layer: 0 + m_Name: CubeA + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &407836 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153130} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -2, y: 0, z: 5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2339520 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153130} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3346468 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153130} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6528884 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153130} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &11419896 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153130} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e6095a498a98d4797b9675d6aa3b2dd0, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 153130} + m_IsPrefabParent: 1 diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab.meta new file mode 100644 index 0000000..4ccf769 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeA.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e11c84ec13f37432bbbef8aa7799e275 +timeCreated: 1428689168 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab new file mode 100644 index 0000000..0e54e73 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab @@ -0,0 +1,98 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &147034 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 495674} + - 33: {fileID: 3324902} + - 65: {fileID: 6573654} + - 23: {fileID: 2333596} + - 114: {fileID: 11497496} + m_Layer: 0 + m_Name: CubeB + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &495674 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 147034} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2333596 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 147034} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3324902 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 147034} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6573654 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 147034} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &11497496 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 147034} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e6095a498a98d4797b9675d6aa3b2dd0, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 147034} + m_IsPrefabParent: 1 diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab.meta new file mode 100644 index 0000000..6fda5a6 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeB.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e16073974706042208cccb5b62eb795e +timeCreated: 1428689171 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab new file mode 100644 index 0000000..1dd277e --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab @@ -0,0 +1,98 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &153284 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 458656} + - 33: {fileID: 3354288} + - 65: {fileID: 6593374} + - 23: {fileID: 2343510} + - 114: {fileID: 11464718} + m_Layer: 0 + m_Name: CubeC + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &458656 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153284} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2, y: 0, z: 5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2343510 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153284} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10302, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 0 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_ImportantGI: 0 + m_AutoUVMaxDistance: .5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3354288 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153284} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6593374 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153284} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &11464718 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 153284} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e6095a498a98d4797b9675d6aa3b2dd0, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 153284} + m_IsPrefabParent: 1 diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab.meta new file mode 100644 index 0000000..21c6d01 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Resources/CubeC.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70707abc0f785442080b3aea167fa719 +timeCreated: 1428689176 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts.meta new file mode 100644 index 0000000..b57f4a4 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f611efa5202fd4041af36c964ef5221d +folderAsset: yes +timeCreated: 1428687947 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours.meta new file mode 100644 index 0000000..15f1f87 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d51013117b2884d1a8e120cb13a04782 +folderAsset: yes +timeCreated: 1428688547 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs new file mode 100644 index 0000000..ae10e7f --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs @@ -0,0 +1,28 @@ +using UnityEngine; +using System.Collections; +using Adic.Examples.BindingsSetup.Data; + +namespace Adic.Examples.BindingsSetup.Behaviours { + /// + /// Cube rotator. + /// + public class CubeRotator : MonoBehaviour { + [Inject] + public CubeRotationSpeed speedData; + + /// The cached transform object. + protected Transform cachedTransform; + + protected void Start() { + this.cachedTransform = this.GetComponent(); + + //Calls "Inject" to inject any dependencies to the component. + //In a production game, it's useful to place this in a base component. + this.Inject(); + } + + protected void Update() { + this.cachedTransform.Rotate(this.speedData.speed, this.speedData.speed, this.speedData.speed); + } + } +} \ No newline at end of file diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs.meta new file mode 100644 index 0000000..be888f5 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Behaviours/CubeRotator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e6095a498a98d4797b9675d6aa3b2dd0 +timeCreated: 1428688553 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings.meta new file mode 100644 index 0000000..c89a4f3 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fc41939a1b31340409ff73e56cc3b424 +folderAsset: yes +timeCreated: 1428688073 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs new file mode 100644 index 0000000..e3ad7df --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs @@ -0,0 +1,31 @@ +using UnityEngine; +using Adic.Container; +using Adic.Examples.BindingsSetup.Data; + +namespace Adic.Examples.BindingsSetup.Bindings { + /// + /// Bindings for data related objects. + /// + /// + /// This bindings have priority because they must be in place before any prefab bindings. + /// + [BindingPriority] + public class DataBindings : Adic.IBindingsSetup { + public void SetupBindings(IInjectionContainer container) { + //Bind the rotation data for "CubeA". + container.Bind().To(new CubeRotationSpeed(0.5f)).When( + context => context.parentInstance is MonoBehaviour && + ((MonoBehaviour)context.parentInstance).name.Contains("CubeA")); + + //Bind the rotation data for "CubeB". + container.Bind().To(new CubeRotationSpeed(2.0f)).When( + context => context.parentInstance is MonoBehaviour && + ((MonoBehaviour)context.parentInstance).name.Contains("CubeB")); + + //Bind the rotation data for "CubeC". + container.Bind().To(new CubeRotationSpeed(4.5f)).When( + context => context.parentInstance is MonoBehaviour && + ((MonoBehaviour)context.parentInstance).name.Contains("CubeC")); + } + } +} \ No newline at end of file diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs.meta new file mode 100644 index 0000000..6dc59c5 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/DataBindings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 85ed8fdd8dc9b466abb3925fb2c47217 +timeCreated: 1428688288 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs new file mode 100644 index 0000000..35d88b4 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using Adic.Container; + +namespace Adic.Examples.BindingsSetup.Bindings { + /// + /// Bindings for prefabs. + /// + public class PrefabsBindings : Adic.IBindingsSetup { + public void SetupBindings(IInjectionContainer container) { + //Bind the "CubeA" prefab. + container.Bind().ToPrefabSingleton("CubeA"); + //Bind the "CubeB" prefab. + container.Bind().ToPrefabSingleton("CubeB"); + //Bind the "CubeC" prefab. + container.Bind().ToPrefabSingleton("CubeC"); + } + } +} \ No newline at end of file diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs.meta new file mode 100644 index 0000000..5c6dd33 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Bindings/PrefabsBindings.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9c0da09d33659428b8fcae60fcee00ec +timeCreated: 1428688080 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data.meta new file mode 100644 index 0000000..7f97515 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5b60985b2f88e48bd8cc0d0a0beee33e +folderAsset: yes +timeCreated: 1428688334 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs new file mode 100644 index 0000000..ad83976 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using System.Collections; + +namespace Adic.Examples.BindingsSetup.Data { + /// + /// Cube rotation speed value object. + /// + public class CubeRotationSpeed { + /// The rotation speed. + public float speed { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The rotation speed. + public CubeRotationSpeed(float speed) { + this.speed = speed; + } + } +} \ No newline at end of file diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs.meta new file mode 100644 index 0000000..8a1acb0 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/Data/CubeRotationSpeed.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9834c1623cd40497b8395b6019209f42 +timeCreated: 1428688449 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs new file mode 100755 index 0000000..c20bbe5 --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs @@ -0,0 +1,26 @@ +using UnityEngine; +using Adic; + +namespace Adic.Examples.BindingsSetup { + /// + /// Game context root. + /// + public class GameRoot : ContextRoot { + public override void SetupContainers() { + //Create the container. + var container = new InjectionContainer(); + //Register any extensions the container may use. + container.RegisterExtension(); + + //Setups bindins from a namespace. + container.SetupBindings("Adic.Examples.BindingsSetup.Bindings"); + + //Add the container to the context. + this.AddContainer(container); + } + + public override void Init() { + + } + } +} \ No newline at end of file diff --git a/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs.meta b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs.meta new file mode 100644 index 0000000..daa6a7a --- /dev/null +++ b/src/Assets/Adic/Examples/06_BindingsSetup/Scripts/GameRoot.cs.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 91388b33b41d145a293941230180e00f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/ProjectSettings/ProjectVersion.txt b/src/ProjectSettings/ProjectVersion.txt index b0ac510..de77f25 100644 --- a/src/ProjectSettings/ProjectVersion.txt +++ b/src/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 5.0.0f4 +m_EditorVersion: 5.0.1f1 m_StandardAssetsVersion: 0