Example WIP + Variable ID

This commit is contained in:
Adam Ramberg 2020-03-18 00:17:33 +01:00
parent f00c9be691
commit 74bfaf7086
103 changed files with 1192 additions and 379 deletions

View File

@ -0,0 +1,17 @@
using UnityEngine;
using UnityAtoms.BaseAtoms;
namespace UnityAtoms.Examples
{
public class SyncPositionWithVariable : MonoBehaviour
{
[SerializeField]
private Vector3Reference _reference;
void LateUpdate()
{
_reference.Value = transform.position;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a208484d52a9148f2b664132607d7deb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,11 +9,12 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ba615354262bb46d7add759502baf53f, type: 3}
m_Script: {fileID: 11500000, guid: ecd0f51e6cdda4338b8adc4542076829, type: 3}
m_Name: Enemies
m_EditorClassIdentifier:
_developerDescription:
Cleared: {fileID: 0}
Added: {fileID: 0}
Removed: {fileID: 0}
list: []
_value:
_serializedList: []
_added: {fileID: 11400000, guid: 1f43d5301a4b244c6873d8cf5e465083, type: 2}
_removed: {fileID: 11400000, guid: bbead2c649eb14ada9e9672807bbd0b2, type: 2}
_cleared: {fileID: 0}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2c1c7dbe7b14d458892c7621ea08daa5
guid: 17112074d7b52489893e5dce0c45df02
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

View File

@ -20,6 +20,9 @@ GameObject:
- component: {fileID: -2978108162882953924}
- component: {fileID: 1740680909}
- component: {fileID: 1740680910}
- component: {fileID: 1637442682690422268}
- component: {fileID: 4095674729113015293}
- component: {fileID: 5231109137669188302}
m_Layer: 0
m_Name: Enemy
m_TagString: Untagged
@ -200,8 +203,15 @@ MonoBehaviour:
m_EditorClassIdentifier:
_inMemoryCopy: {fileID: 0}
_base: {fileID: 11400000, guid: 574b826f5842e400eb4cb44d63b60077, type: 2}
_syncToCollection: {fileID: 0}
_syncToList: {fileID: 0}
_syncToCollection:
_usage: 0
_collection: {fileID: 0}
_instancer: {fileID: 0}
_syncToCollectionKey:
_syncToList:
_usage: 0
_list: {fileID: 0}
_instancer: {fileID: 0}
_fsmBase: {fileID: 11400000, guid: 574b826f5842e400eb4cb44d63b60077, type: 2}
--- !u!114 &2421445419809145569
MonoBehaviour:
@ -259,8 +269,15 @@ MonoBehaviour:
m_EditorClassIdentifier:
_inMemoryCopy: {fileID: 0}
_base: {fileID: 11400000, guid: 16bf069429937474390ce1ed7d17a8bf, type: 2}
_syncToCollection: {fileID: 0}
_syncToList: {fileID: 11400000, guid: a92988507b22a4bad8e15483d6e1695f, type: 2}
_syncToCollection:
_usage: 1
_collection: {fileID: 0}
_instancer: {fileID: 5231109137669188302}
_syncToCollectionKey: Health
_syncToList:
_usage: 1
_list: {fileID: 0}
_instancer: {fileID: 0}
--- !u!114 &1740680909
MonoBehaviour:
m_ObjectHideFlags: 0
@ -307,9 +324,68 @@ MonoBehaviour:
m_BoolArgument: 0
m_CallState: 2
_actionResponses: []
_replayEventBufferOnRegister: 1
_eventReference:
_usage: 3
_event: {fileID: 0}
_eventInstancer: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: -2978108162882953924}
--- !u!114 &1637442682690422268
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2421445419809145576}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 79f62ec04b1ce42df86b032e75c14ae2, type: 3}
m_Name:
m_EditorClassIdentifier:
_inMemoryCopy: {fileID: 0}
_base: {fileID: 11400000, guid: f133550ba7db7498c84c4b53cc471932, type: 2}
_syncToCollection:
_usage: 1
_collection: {fileID: 0}
_instancer: {fileID: 5231109137669188302}
_syncToCollectionKey: Position
_syncToList:
_usage: 1
_list: {fileID: 0}
_instancer: {fileID: 0}
--- !u!114 &4095674729113015293
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2421445419809145576}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a208484d52a9148f2b664132607d7deb, type: 3}
m_Name:
m_EditorClassIdentifier:
_reference:
_usage: 3
_value: {x: 0, y: 0, z: 0}
_constant: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 1637442682690422268}
--- !u!114 &5231109137669188302
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2421445419809145576}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b7eabd19e224f4a32801be9dfc6aa226, type: 3}
m_Name:
m_EditorClassIdentifier:
_inMemoryCopy: {fileID: 0}
_base: {fileID: 11400000, guid: 2c1c7dbe7b14d458892c7621ea08daa5, type: 2}
_syncToCollection: {fileID: 0}
_syncToCollectionKey:
_syncToList: {fileID: 11400000, guid: 17112074d7b52489893e5dce0c45df02, type: 2}

View File

@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10a2b6c04f1da42f0ba0b469ec86f689, type: 3}
m_Name: EnemyHealthAdded
m_Name: EnemyAdded
m_EditorClassIdentifier:
_developerDescription:
_replayBufferSize: 1

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a92988507b22a4bad8e15483d6e1695f
guid: 1f43d5301a4b244c6873d8cf5e465083
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10a2b6c04f1da42f0ba0b469ec86f689, type: 3}
m_Name: EnemyDataAdded
m_EditorClassIdentifier:
_developerDescription:
_replayBufferSize: 2
_inspectorRaiseValue: {fileID: 0}

View File

@ -9,12 +9,14 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ecd0f51e6cdda4338b8adc4542076829, type: 3}
m_Name: EnemyHealth
m_Script: {fileID: 11500000, guid: f905a459d97c84162be2fdcd2bc3a39a, type: 3}
m_Name: EnemyDataBase
m_EditorClassIdentifier:
_developerDescription: List of enemies spawned at runtime.
_developerDescription:
_value:
_serializedList: []
_serializedKeys: []
_serializedValues: []
_duplicateKeyIndices:
_added: {fileID: 11400000, guid: e940aaaaaca2e4ccfa65f3159e6cf8ec, type: 2}
_removed: {fileID: 11400000, guid: 955d19fc5a0a9412a8e3444652119b2d, type: 2}
_cleared: {fileID: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c1c7dbe7b14d458892c7621ea08daa5
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10a2b6c04f1da42f0ba0b469ec86f689, type: 3}
m_Name: EnemyDataRemoved
m_EditorClassIdentifier:
_developerDescription:
_replayBufferSize: 2
_inspectorRaiseValue: {fileID: 0}

View File

@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: EnemyHealthBase
m_EditorClassIdentifier:
_developerDescription:
_id: Health
_value: 20
_initialValue: 20
_oldValue: 20

View File

@ -0,0 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f868f8b3380b47a38cf0b95f42c134b, type: 3}
m_Name: EnemyPositionBase
m_EditorClassIdentifier:
_developerDescription:
_id: Position
_value: {x: 0, y: 0, z: 0}
_initialValue: {x: 0, y: 0, z: 0}
_oldValue: {x: 0, y: 0, z: 0}
Changed: {fileID: 11400000, guid: d422efc48be6541469a4a6467ad76cd7, type: 2}
ChangedWithHistory: {fileID: 0}
_preChangeTransformers: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f133550ba7db7498c84c4b53cc471932
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c19800e64279c44e1ae4529ee6a2d780, type: 3}
m_Name: EnemyPositionChangedBase
m_EditorClassIdentifier:
_developerDescription:
_replayBufferSize: 1
_inspectorRaiseValue: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d422efc48be6541469a4a6467ad76cd7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 10a2b6c04f1da42f0ba0b469ec86f689, type: 3}
m_Name: EnemyHealthRemoved
m_Name: EnemyRemoved
m_EditorClassIdentifier:
_developerDescription:
_replayBufferSize: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bbead2c649eb14ada9e9672807bbd0b2
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyWaveManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cf3f2ed232a5d4421a7480d00f1ac6ed
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -255,6 +255,7 @@ MonoBehaviour:
_constant: {fileID: 11400000, guid: 41aa2296cd68a4b718a8fd1bd8ad5a95, type: 2}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
_image: {fileID: 0}
--- !u!114 &145633449
MonoBehaviour:
m_ObjectHideFlags: 0
@ -959,80 +960,6 @@ MonoBehaviour:
m_EditorClassIdentifier:
_variables:
- {fileID: 11400000, guid: 50206c000343d496fa82bd362e3b3b2b, type: 2}
--- !u!1 &916340589
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 916340590}
- component: {fileID: 916340592}
- component: {fileID: 916340591}
m_Layer: 0
m_Name: HealthBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &916340590
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 916340589}
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:
- {fileID: 1151106410}
m_Father: {fileID: 1299539879}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -253.5, y: 148}
m_SizeDelta: {x: 50, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &916340591
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 916340589}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.14901961, g: 0.14901961, b: 0.14901961, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &916340592
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 916340589}
m_CullTransparentMesh: 0
--- !u!1 &1067648696
GameObject:
m_ObjectHideFlags: 0
@ -1099,123 +1026,6 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1151106409
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1151106410}
- component: {fileID: 1151106412}
- component: {fileID: 1151106411}
- component: {fileID: 1151106414}
- component: {fileID: 1151106413}
m_Layer: 0
m_Name: Fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1151106410
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1151106409}
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: 916340590}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -2, y: -2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1151106411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1151106409}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.6117647, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1151106412
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1151106409}
m_CullTransparentMesh: 0
--- !u!114 &1151106413
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1151106409}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dbd80c08b2c1349c0839fcab63bcf9a3, type: 3}
m_Name:
m_EditorClassIdentifier:
_initialHealth:
_usage: 0
_value: 10
_constant: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
--- !u!114 &1151106414
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1151106409}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 050ff37b5550f4b7e9bdf8b985aff484, type: 3}
m_Name:
m_EditorClassIdentifier:
_developerDescription:
_unityEventResponse:
m_PersistentCalls:
m_Calls: []
_actionResponses: []
_replayEventBufferOnRegister: 1
_eventReference:
_usage: 0
_event: {fileID: 0}
_eventInstancer: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
--- !u!1 &1167381057
GameObject:
m_ObjectHideFlags: 0
@ -1425,6 +1235,8 @@ GameObject:
- component: {fileID: 1299539881}
- component: {fileID: 1299539882}
- component: {fileID: 1299539880}
- component: {fileID: 1299539884}
- component: {fileID: 1299539883}
m_Layer: 5
m_Name: EnemyHealthBars
m_TagString: Untagged
@ -1442,8 +1254,7 @@ RectTransform:
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:
- {fileID: 916340590}
m_Children: []
m_Father: {fileID: 1244410474}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -1471,6 +1282,11 @@ MonoBehaviour:
_constant: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
- _usage: 0
_value: GameOver
_constant: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
--- !u!222 &1299539881
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1491,6 +1307,52 @@ CanvasGroup:
m_Interactable: 1
m_BlocksRaycasts: 1
m_IgnoreParentGroups: 0
--- !u!114 &1299539883
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1299539878}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d78396a243a52473ea10f585128d364a, type: 3}
m_Name:
m_EditorClassIdentifier:
_developerDescription:
_unityEventResponse:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1299539884}
m_MethodName: SetupHealthBar
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
_actionResponses: []
_replayEventBufferOnRegister: 1
_event: {fileID: 11400000, guid: 1f43d5301a4b244c6873d8cf5e465083, type: 2}
--- !u!114 &1299539884
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1299539878}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e1b416f9725d24fe5b140a75157a371e, type: 3}
m_Name:
m_EditorClassIdentifier:
_enemies: {fileID: 11400000, guid: 17112074d7b52489893e5dce0c45df02, type: 2}
_healthBarPrefab: {fileID: 5962985845040392292, guid: 26027fcaed24946ab8ccd94d49977476,
type: 3}
_canvasRectTransform: {fileID: 1244410474}
--- !u!1 &1399228590
GameObject:
m_ObjectHideFlags: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03d72942856114a35806ff2918f7a3a5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,95 @@
using System;
using UnityAtoms.BaseAtoms;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.UI;
namespace UnityAtoms.Examples
{
public class EnemyHealthBarManager : MonoBehaviour
{
[SerializeField]
private AtomList _enemies;
[SerializeField]
private GameObject _healthBarPrefab;
[SerializeField]
private RectTransform _canvasRectTransform;
void Awake()
{
Assert.IsNotNull(_enemies);
Assert.IsNotNull(_healthBarPrefab);
Assert.IsNotNull(_canvasRectTransform);
}
public void SetupHealthBar(AtomBaseVariable enemyData)
{
var enemyDataCollection = (AtomCollection)enemyData;
var healthBar = Instantiate(_healthBarPrefab).GetComponent<HealthBar>();
healthBar.transform.SetParent(transform);
Action<Vector3> positionChangedHandler = default;
Action<AtomBaseVariable> varAddedHandler = (AtomBaseVariable baseVar) =>
{
switch (baseVar.Id)
{
case "Health":
var healthVar = (IntVariable)baseVar;
healthBar.InitialHealth.Value = healthVar.InitialValue;
healthVar.Changed.Register(healthBar.HealthChanged);
break;
case "Position":
var positionVar = (Vector3Variable)baseVar;
positionChangedHandler = (pos) =>
{
Vector2 viewportPos = Camera.main.WorldToViewportPoint(pos);
Vector2 healthBarPos = new Vector2(
(viewportPos.x * _canvasRectTransform.sizeDelta.x) - (_canvasRectTransform.sizeDelta.x * 0.5f),
(viewportPos.y * _canvasRectTransform.sizeDelta.y) - (_canvasRectTransform.sizeDelta.y * 0.5f) + 38f
);
healthBar.GetComponent<RectTransform>().anchoredPosition = healthBarPos;
};
positionVar.Changed.Register(positionChangedHandler);
break;
}
};
Action<AtomBaseVariable> varRemovedHandler = (AtomBaseVariable baseVar) =>
{
switch (baseVar.Id)
{
case "Health":
var healthVar = (IntVariable)baseVar;
healthVar.Changed.Unregister(healthBar.HealthChanged);
break;
case "Position":
var positionVar = (Vector3Variable)baseVar;
positionVar.Changed.Unregister(positionChangedHandler);
break;
}
};
enemyDataCollection.Added.Register(varAddedHandler);
enemyDataCollection.Removed.Register(varRemovedHandler);
Action<AtomBaseVariable> enemyDataRemovedHandler = default;
enemyDataRemovedHandler = (enemyDataToBeRemoved) =>
{
if (enemyDataToBeRemoved == enemyData)
{
enemyDataCollection.Added.Unregister(varAddedHandler);
enemyDataCollection.Removed.Unregister(varRemovedHandler);
_enemies.Removed.Unregister(enemyDataRemovedHandler);
if (healthBar != null && healthBar.gameObject != null)
{
Destroy(healthBar.gameObject);
}
}
};
_enemies.Removed.Register(enemyDataRemovedHandler);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e1b416f9725d24fe5b140a75157a371e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,194 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &5962985843664808544
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5962985843664808547}
- component: {fileID: 5962985843664808549}
- component: {fileID: 5962985843664808546}
m_Layer: 0
m_Name: Fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5962985843664808547
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985843664808544}
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: 5962985845040392295}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -2, y: -2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5962985843664808549
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985843664808544}
m_CullTransparentMesh: 0
--- !u!114 &5962985843664808546
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985843664808544}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.6117647, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: bcb9bdff5d4664c74a932c679135aff5, type: 3}
m_Type: 3
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 0
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &5962985845040392292
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5962985845040392295}
- component: {fileID: 5962985845040392313}
- component: {fileID: 5962985845040392294}
- component: {fileID: 672736024155512211}
- component: {fileID: 1195006272440714522}
m_Layer: 0
m_Name: HealthBar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &5962985845040392295
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985845040392292}
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:
- {fileID: 5962985843664808547}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -253.5, y: 148}
m_SizeDelta: {x: 50, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5962985845040392313
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985845040392292}
m_CullTransparentMesh: 0
--- !u!114 &5962985845040392294
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985845040392292}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.14901961, g: 0.14901961, b: 0.14901961, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &672736024155512211
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985845040392292}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dbd80c08b2c1349c0839fcab63bcf9a3, type: 3}
m_Name:
m_EditorClassIdentifier:
_initialHealth:
_usage: 0
_value: 0
_constant: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}
_image: {fileID: 5962985843664808546}
--- !u!114 &1195006272440714522
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5962985845040392292}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 050ff37b5550f4b7e9bdf8b985aff484, type: 3}
m_Name:
m_EditorClassIdentifier:
_developerDescription:
_unityEventResponse:
m_PersistentCalls:
m_Calls: []
_actionResponses: []
_replayEventBufferOnRegister: 1
_eventReference:
_usage: 0
_event: {fileID: 0}
_eventInstancer: {fileID: 0}
_variable: {fileID: 0}
_variableInstancer: {fileID: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 26027fcaed24946ab8ccd94d49977476
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 110fa57a940364e1dac4913625ffdedd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,6 +7,8 @@ namespace UnityAtoms.Examples
[AddComponentMenu("Unity Atoms/Examples/HealthBar")]
public class HealthBar : MonoBehaviour
{
public IntReference InitialHealth { get => _initialHealth; }
[SerializeField]
private IntReference _initialHealth = null;
@ -21,9 +23,6 @@ namespace UnityAtoms.Examples
}
}
public void HealthChanged(int health)
{
_image.fillAmount = 1.0f * health / _initialHealth.Value;
}
public void HealthChanged(int health) => _image.fillAmount = 1.0f * health / _initialHealth.Value;
}
}

View File

@ -0,0 +1,30 @@
using UnityEditor;
using UnityAtoms.Editor;
namespace UnityAtoms.BaseAtoms.Editor
{
/// <summary>
/// A custom property drawer for AtomCollectionReference. Makes it possible to choose between a Collection or a Collection Instancer.
/// </summary>
[CustomPropertyDrawer(typeof(AtomCollectionReference), true)]
public class AtomCollectionReferenceDrawer : AtomBaseReferenceDrawer
{
protected class UsageCollection : UsageData
{
public override int Value { get => AtomCollectionReferenceUsage.COLLECTION; }
public override string PropertyName { get => "_collection"; }
public override string DisplayName { get => "Use Collection"; }
}
protected class UsageCollectionInstancer : UsageData
{
public override int Value { get => AtomCollectionReferenceUsage.COLLECTION_INSTANCER; }
public override string PropertyName { get => "_instancer"; }
public override string DisplayName { get => "Use Collection Instancer"; }
}
private readonly UsageData[] _usages = new UsageData[2] { new UsageCollection(), new UsageCollectionInstancer() };
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7c2b3d95dce74420aa06efd3bead7ce2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,30 @@
using UnityEditor;
using UnityAtoms.Editor;
namespace UnityAtoms.BaseAtoms.Editor
{
/// <summary>
/// A custom property drawer for AtomListReference. Makes it possible to choose between a List or a List Instancer.
/// </summary>
[CustomPropertyDrawer(typeof(AtomListReference), true)]
public class AtomListReferenceDrawer : AtomBaseReferenceDrawer
{
protected class UsageList : UsageData
{
public override int Value { get => AtomListReferenceUsage.LIST; }
public override string PropertyName { get => "_list"; }
public override string DisplayName { get => "Use List"; }
}
protected class UsageListInstancer : UsageData
{
public override int Value { get => AtomListReferenceUsage.LIST_INSTANCER; }
public override string PropertyName { get => "_instancer"; }
public override string DisplayName { get => "Use List Instancer"; }
}
private readonly UsageData[] _usages = new UsageData[2] { new UsageList(), new UsageListInstancer() };
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 99332b5beeeec4ad1a9661c09bef8c38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
BoolPairEvent,
BoolBoolFunction,
BoolVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
Collider2DPairEvent,
Collider2DCollider2DFunction,
Collider2DVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
ColliderPairEvent,
ColliderColliderFunction,
ColliderVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
ColorPairEvent,
ColorColorFunction,
ColorVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
FloatPairEvent,
FloatFloatFunction,
FloatVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
GameObjectPairEvent,
GameObjectGameObjectFunction,
GameObjectVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
IntPairEvent,
IntIntFunction,
IntVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
StringPairEvent,
StringStringFunction,
StringVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
Vector2PairEvent,
Vector2Vector2Function,
Vector2VariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -18,7 +18,7 @@ namespace UnityAtoms.BaseAtoms
Vector3PairEvent,
Vector3Vector3Function,
Vector3VariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -0,0 +1,35 @@
using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
public abstract class AtomBaseCollectionInstancer<T, V> : AtomBaseVariableInstancer<T, V, AtomCollection, AtomList>
where V : AtomBaseVariable<T>, IWithCollectionEvents
{
/// <summary>
/// Override to add implementation specific setup on `OnEnable`.
/// </summary>
protected override void ImplSpecificSetup()
{
var baseCollection = (V)Base;
var inMemoryCopy = (V)_inMemoryCopy;
if (baseCollection.Added != null)
{
inMemoryCopy.Added = Instantiate(baseCollection.Added);
}
if (baseCollection.Removed != null)
{
inMemoryCopy.Removed = Instantiate(baseCollection.Removed);
}
if (baseCollection.Cleared != null)
{
inMemoryCopy.Cleared = Instantiate(baseCollection.Cleared);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f8f12996e39684f8ca46168abf5a3702
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4c59e5c7eed94aefa9f60ed1e800dfb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,7 +9,7 @@ namespace UnityAtoms.BaseAtoms
/// </summary>
[CreateAssetMenu(menuName = "Unity Atoms/Collection", fileName = "Collection")]
[EditorIcon("atom-icon-kingsyellow")]
public class AtomCollection : AtomBaseVariable<StringReferenceAtomBaseVariableDictionary>, IGetValue<IAtomCollection>
public class AtomCollection : AtomBaseVariable<StringReferenceAtomBaseVariableDictionary>, IGetValue<IAtomCollection>, IWithCollectionEvents
{
/// <summary>
/// Get value as an `IAtomCollection`. Needed in order to inject Collection into the Variable Instancer class.

View File

@ -0,0 +1,10 @@
using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
[AddComponentMenu("Unity Atoms/Instancers/Collection Instancer")]
public sealed class AtomCollectionInstancer : AtomBaseCollectionInstancer<StringReferenceAtomBaseVariableDictionary, AtomCollection> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b7eabd19e224f4a32801be9dfc6aa226
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4c59e5c7eed94aefa9f60ed1e800dfb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
public class AtomCollectionReferenceUsage
{
public const int COLLECTION = 0;
public const int COLLECTION_INSTANCER = 1;
}
/// <summary>
/// Reference of type `AtomCollection`. Inherits from `AtomBaseReference`.
/// </summary>
[Serializable]
public class AtomCollectionReference : AtomBaseReference, IGetValue<IAtomCollection>
{
/// <summary>
/// Get value as an `IAtomCollection`. Needed in order to inject Collection References into the Variable Instancer class.
/// </summary>
/// <returns>The value as an `IAtomList`.</returns>
public IAtomCollection GetValue() => Collection != null ? Collection.GetValue() : null;
/// <summary>
/// Get the value for the Reference.
/// </summary>
/// <value>The value of type `AtomCollection`.</value>
public AtomCollection Collection
{
get
{
switch (_usage)
{
case (AtomCollectionReferenceUsage.COLLECTION_INSTANCER):
return _instancer == null ? default(AtomCollection) : _instancer.Variable;
case (AtomCollectionReferenceUsage.COLLECTION):
default:
return _collection;
}
}
}
/// <summary>
/// Variable used if `Usage` is set to `COLLECTION`.
/// </summary>
[SerializeField]
private AtomCollection _collection = default(AtomCollection);
/// <summary>
/// Variable Instancer used if `Usage` is set to `COLLECTION_INSTANCER`.
/// </summary>
[SerializeField]
private AtomCollectionInstancer _instancer = default(AtomCollectionInstancer);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6fdd66ab994b4ffaa4709b0bdd34c9b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,7 +9,7 @@ namespace UnityAtoms.BaseAtoms
/// </summary>
[CreateAssetMenu(menuName = "Unity Atoms/List", fileName = "List")]
[EditorIcon("atom-icon-lime")]
public class AtomList : AtomBaseVariable<AtomBaseVariableList>, IGetValue<IAtomList>
public class AtomList : AtomBaseVariable<AtomBaseVariableList>, IGetValue<IAtomList>, IWithCollectionEvents
{
/// <summary>
/// Get value as an `IAtomList`. Needed in order to inject Lists into the Variable Instancer class.

View File

@ -0,0 +1,11 @@
using System;
using UnityEngine;
using UnityEngine.Assertions;
namespace UnityAtoms.BaseAtoms
{
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
[AddComponentMenu("Unity Atoms/Collections/List Instancer")]
public sealed class AtomListInstancer : AtomBaseCollectionInstancer<AtomBaseVariableList, AtomList> { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c8529991f5be64849bcc3a624cb593b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4c59e5c7eed94aefa9f60ed1e800dfb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
public class AtomListReferenceUsage
{
public const int LIST = 0;
public const int LIST_INSTANCER = 1;
}
/// <summary>
/// Reference of type `AtomList`. Inherits from `AtomBaseReference`.
/// </summary>
[Serializable]
public class AtomListReference : AtomBaseReference, IGetValue<IAtomList>
{
/// <summary>
/// Get value as an `IAtomList`. Needed in order to inject List References into the Variable Instancer class.
/// </summary>
/// <returns>The value as an `IAtomList`.</returns>
public IAtomList GetValue() => List != null ? List.GetValue() : null;
/// <summary>
/// Get the value for the Reference.
/// </summary>
/// <value>The value of type `AtomList`.</value>
public AtomList List
{
get
{
switch (_usage)
{
case (AtomListReferenceUsage.LIST_INSTANCER):
return _instancer == null ? default(AtomList) : _instancer.Variable;
case (AtomListReferenceUsage.LIST):
default:
return _list;
}
}
}
/// <summary>
/// Variable used if `Usage` is set to `LIST`.
/// </summary>
[SerializeField]
private AtomList _list = default(AtomList);
/// <summary>
/// Variable Instancer used if `Usage` is set to `LIST_INSTANCER`.
/// </summary>
[SerializeField]
private AtomListInstancer _instancer = default(AtomListInstancer);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d3769f972a9874b259a2bd3d03ac8d97
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
using System;
using UnityEngine;
namespace UnityAtoms.BaseAtoms
{
/// <summary>
/// Interface for all Atom Collection.
/// </summary>
public interface IWithCollectionEvents
{
AtomBaseVariableEvent Added { get; set; }
AtomBaseVariableEvent Removed { get; set; }
VoidEvent Cleared { get; set; }
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 556932aa0ea0540d29577316e07304d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -16,8 +16,8 @@ namespace UnityAtoms.BaseAtoms
BoolPairEvent,
BoolBoolFunction,
BoolVariableInstancer,
AtomCollection,
AtomList>, IEquatable<BoolReference>
AtomCollectionReference,
AtomListReference>, IEquatable<BoolReference>
{
public BoolReference() : base() { }
public BoolReference(bool value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
Collider2DPairEvent,
Collider2DCollider2DFunction,
Collider2DVariableInstancer,
AtomCollection,
AtomList>, IEquatable<Collider2DReference>
AtomCollectionReference,
AtomListReference>, IEquatable<Collider2DReference>
{
public Collider2DReference() : base() { }
public Collider2DReference(Collider2D value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
ColliderPairEvent,
ColliderColliderFunction,
ColliderVariableInstancer,
AtomCollection,
AtomList>, IEquatable<ColliderReference>
AtomCollectionReference,
AtomListReference>, IEquatable<ColliderReference>
{
public ColliderReference() : base() { }
public ColliderReference(Collider value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
ColorPairEvent,
ColorColorFunction,
ColorVariableInstancer,
AtomCollection,
AtomList>, IEquatable<ColorReference>
AtomCollectionReference,
AtomListReference>, IEquatable<ColorReference>
{
public ColorReference() : base() { }
public ColorReference(Color value) : base(value) { }

View File

@ -16,8 +16,8 @@ namespace UnityAtoms.BaseAtoms
FloatPairEvent,
FloatFloatFunction,
FloatVariableInstancer,
AtomCollection,
AtomList>, IEquatable<FloatReference>
AtomCollectionReference,
AtomListReference>, IEquatable<FloatReference>
{
public FloatReference() : base() { }
public FloatReference(float value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
GameObjectPairEvent,
GameObjectGameObjectFunction,
GameObjectVariableInstancer,
AtomCollection,
AtomList>, IEquatable<GameObjectReference>
AtomCollectionReference,
AtomListReference>, IEquatable<GameObjectReference>
{
public GameObjectReference() : base() { }
public GameObjectReference(GameObject value) : base(value) { }

View File

@ -16,8 +16,8 @@ namespace UnityAtoms.BaseAtoms
IntPairEvent,
IntIntFunction,
IntVariableInstancer,
AtomCollection,
AtomList>, IEquatable<IntReference>
AtomCollectionReference,
AtomListReference>, IEquatable<IntReference>
{
public IntReference() : base() { }
public IntReference(int value) : base(value) { }

View File

@ -16,8 +16,8 @@ namespace UnityAtoms.BaseAtoms
StringPairEvent,
StringStringFunction,
StringVariableInstancer,
AtomCollection,
AtomList>, IEquatable<StringReference>
AtomCollectionReference,
AtomListReference>, IEquatable<StringReference>
{
public StringReference() : base() { }
public StringReference(string value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
Vector2PairEvent,
Vector2Vector2Function,
Vector2VariableInstancer,
AtomCollection,
AtomList>, IEquatable<Vector2Reference>
AtomCollectionReference,
AtomListReference>, IEquatable<Vector2Reference>
{
public Vector2Reference() : base() { }
public Vector2Reference(Vector2 value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.BaseAtoms
Vector3PairEvent,
Vector3Vector3Function,
Vector3VariableInstancer,
AtomCollection,
AtomList>, IEquatable<Vector3Reference>
AtomCollectionReference,
AtomListReference>, IEquatable<Vector3Reference>
{
public Vector3Reference() : base() { }
public Vector3Reference(Vector3 value) : base(value) { }

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
BoolEvent,
BoolPairEvent,
BoolBoolFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
Collider2DEvent,
Collider2DPairEvent,
Collider2DCollider2DFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
ColliderEvent,
ColliderPairEvent,
ColliderColliderFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
ColorEvent,
ColorPairEvent,
ColorColorFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
FloatEvent,
FloatPairEvent,
FloatFloatFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
GameObjectEvent,
GameObjectPairEvent,
GameObjectGameObjectFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
IntEvent,
IntPairEvent,
IntIntFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
StringEvent,
StringPairEvent,
StringStringFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
Vector2Event,
Vector2PairEvent,
Vector2Vector2Function,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -15,7 +15,7 @@ namespace UnityAtoms.BaseAtoms
Vector3Event,
Vector3PairEvent,
Vector3Vector3Function,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -20,6 +20,8 @@ namespace UnityAtoms.Editor
EditorGUILayout.PropertyField(serializedObject.FindProperty("_developerDescription"));
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("_id"));
EditorGUILayout.BeginHorizontal();
EditorGUI.BeginDisabledGroup(_lockedInitialValue && EditorApplication.isPlayingOrWillChangePlaymode);
EditorGUILayout.PropertyField(serializedObject.FindProperty("_initialValue"), true);

View File

@ -22,8 +22,8 @@ namespace UnityAtoms
{VALUE_TYPE_NAME}PairEvent,
{VALUE_TYPE_NAME}{VALUE_TYPE_NAME}Function,
{VALUE_TYPE_NAME}VariableInstancer,
AtomCollection,
AtomList>, IEquatable<{VALUE_TYPE_NAME}Reference>
AtomCollectionReference,
AtomListReference>, IEquatable<{VALUE_TYPE_NAME}Reference>
{
public {VALUE_TYPE_NAME}Reference() : base() { }
public {VALUE_TYPE_NAME}Reference({VALUE_TYPE} value) : base(value) { }
@ -43,8 +43,8 @@ namespace UnityAtoms
{VALUE_TYPE_NAME}PairEvent,
{VALUE_TYPE_NAME}{VALUE_TYPE_NAME}Function,
{VALUE_TYPE_NAME}VariableInstancer,
AtomCollection,
AtomList>, IEquatable<{VALUE_TYPE_NAME}Reference>
AtomCollectionReference,
AtomListReference>, IEquatable<{VALUE_TYPE_NAME}Reference>
{
public {VALUE_TYPE_NAME}Reference() : base() { }
public {VALUE_TYPE_NAME}Reference({VALUE_TYPE} value) : base(value) { }

View File

@ -23,7 +23,7 @@ namespace UnityAtoms
{VALUE_TYPE_NAME}PairEvent,
{VALUE_TYPE_NAME}{VALUE_TYPE_NAME}Function,
{VALUE_TYPE_NAME}VariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -20,7 +20,7 @@ namespace UnityAtoms
{VALUE_TYPE_NAME}Event,
{VALUE_TYPE_NAME}PairEvent,
{VALUE_TYPE_NAME}{VALUE_TYPE_NAME}Function,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -0,0 +1,105 @@
using System;
using UnityEngine;
using UnityEngine.Assertions;
namespace UnityAtoms
{
/// <summary>
/// A Variable Instancer is a MonoBehaviour that takes a variable as a base and creates an in memory copy of it OnEnable.
/// This is handy when you want to use atoms for prefabs that are instantiated at runtime. Use together with AtomCollection to
/// react accordingly when a prefab with an assoicated atom is added or deleted to the scene.
/// </summary>
/// <typeparam name="V">Variable of type T.</typeparam>
/// <typeparam name="P">IPair of type `T`.</typeparam>
/// <typeparam name="T">The value type.</typeparam>
/// <typeparam name="E1">Event of type T.</typeparam>
/// <typeparam name="E2">Event x 2 of type T.</typeparam>
/// <typeparam name="F">Function of type T => T</typeparam>
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
public abstract class AtomBaseVariableInstancer<T, V, CO, L> : MonoBehaviour
where V : AtomBaseVariable<T>
where CO : IGetValue<IAtomCollection>
where L : IGetValue<IAtomList>
{
/// <summary>
/// Getter for retrieving the in memory runtime variable.
/// </summary>
public V Variable { get => _inMemoryCopy; }
/// <summary>
/// Getter for retrieving the value of the in memory runtime variable.
/// </summary>
public T Value { get => _inMemoryCopy.Value; set => _inMemoryCopy.Value = value; }
public virtual V Base { get => _base; }
[SerializeField]
[ReadOnly]
protected V _inMemoryCopy = default(V);
/// <summary>
/// The variable that the in memory copy will be based on when created at runtime.
/// </summary>
[SerializeField]
protected V _base = null;
/// <summary>
/// If assigned the in memory copy variable will be added to the collection on Start using the gameObject's instance id as key. The value will also be removed from the collection OnDestroy.
/// </summary>
[SerializeField]
private CO _syncToCollection = default(CO);
/// <summary>
/// If this string is not null or white space and if a Collection to sync to is defined, this is the key that will used when adding the Variable to the Collection. If not defined the key defaults to this GameObject's instance id.
/// </summary>
[SerializeField]
private String _syncToCollectionKey = default;
/// <summary>
/// If assigned the in memory copy variable will be added to the list on Start. The value will also be removed from the list OnDestroy.
/// </summary>
[SerializeField]
private L _syncToList = default(L);
/// <summary>
/// Override to add implementation specific setup on `OnEnable`.
/// </summary>
protected virtual void ImplSpecificSetup() { }
private void OnEnable()
{
Assert.IsNotNull(Base);
_inMemoryCopy = Instantiate(Base);
ImplSpecificSetup();
}
void Start()
{
// Adding to the collection on Start instead of OnEnable because of timing issues that otherwise occurs when listeners register themselves OnEnable.
// This is an issue when a Game Object has a Variable Instancer attached to it when the scene starts and at the same time their is an AtomBaseListener listening to the associated Added event to a Collection.
if (_syncToCollection != null && _syncToCollection.GetValue() != null)
{
_syncToCollection.GetValue().Add(String.IsNullOrWhiteSpace(_syncToCollectionKey) ? GetInstanceID().ToString() : _syncToCollectionKey, _inMemoryCopy);
}
if (_syncToList != null && _syncToList.GetValue() != null)
{
_syncToList.GetValue().Add(_inMemoryCopy);
}
}
private void OnDestroy()
{
if (_syncToCollection != null && _syncToCollection.GetValue() != null)
{
_syncToCollection.GetValue().Remove(GetInstanceID().ToString());
}
if (_syncToList != null && _syncToList.GetValue() != null)
{
_syncToList.GetValue().Remove(_inMemoryCopy);
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f936f6a7ac7c042399215b9602fe4037
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: f4c59e5c7eed94aefa9f60ed1e800dfb, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -17,7 +17,7 @@ namespace UnityAtoms
/// <typeparam name="F">Function of type T => T</typeparam>
[EditorIcon("atom-icon-hotpink")]
[DefaultExecutionOrder(Runtime.ExecutionOrder.VARIABLE_INSTANCER)]
public abstract class AtomVariableInstancer<V, P, T, E1, E2, F, CO, L> : MonoBehaviour, IGetEvent, ISetEvent
public abstract class AtomVariableInstancer<V, P, T, E1, E2, F, CO, L> : AtomBaseVariableInstancer<T, V, CO, L>, IGetEvent, ISetEvent
where V : AtomVariable<T, P, E1, E2, F>
where P : struct, IPair<T>
where E1 : AtomEvent<T>
@ -26,50 +26,11 @@ namespace UnityAtoms
where CO : IGetValue<IAtomCollection>
where L : IGetValue<IAtomList>
{
/// <summary>
/// Getter for retrieving the in memory runtime variable.
/// </summary>
public V Variable { get => _inMemoryCopy; }
/// <summary>
/// Getter for retrieving the value of the in memory runtime variable.
/// </summary>
public T Value { get => _inMemoryCopy.Value; set => _inMemoryCopy.Value = value; }
public virtual V Base { get => _base; }
[SerializeField]
[ReadOnly]
protected V _inMemoryCopy = default(V);
/// <summary>
/// The variable that the in memory copy will be based on when created at runtime.
/// </summary>
[SerializeField]
protected V _base = null;
/// <summary>
/// If assigned the in memory copy variable will be added to the collection on Start using the gameObject's instance id as key. The value will also be removed from the collection OnDestroy.
/// </summary>
[SerializeField]
private CO _syncToCollection = default(CO);
/// <summary>
/// If assigned the in memory copy variable will be added to the list on Start. The value will also be removed from the list OnDestroy.
/// </summary>
[SerializeField]
private L _syncToList = default(L);
/// <summary>
/// Override to add implementation specific setup on `OnEnable`.
/// </summary>
protected virtual void ImplSpecificSetup() { }
private void OnEnable()
protected override void ImplSpecificSetup()
{
Assert.IsNotNull(Base);
_inMemoryCopy = Instantiate(Base);
if (Base.Changed != null)
{
_inMemoryCopy.Changed = Instantiate(Base.Changed);
@ -79,36 +40,6 @@ namespace UnityAtoms
{
_inMemoryCopy.ChangedWithHistory = Instantiate(Base.ChangedWithHistory);
}
ImplSpecificSetup();
}
void Start()
{
// Adding to the collection on Start instead of OnEnable because of timing issues that otherwise occurs when listeners register themselves OnEnable.
// This is an issue when a Game Object has a Variable Instancer attached to it when the scene starts and at the same time their is an AtomBaseListener listening to the associated Added event to a Collection.
if (_syncToCollection != null)
{
_syncToCollection.GetValue().Add(GetInstanceID().ToString(), _inMemoryCopy);
}
if (_syncToList != null)
{
_syncToList.GetValue().Add(_inMemoryCopy);
}
}
private void OnDestroy()
{
if (_syncToCollection != null)
{
_syncToCollection.GetValue().Remove(GetInstanceID().ToString());
}
if (_syncToList != null)
{
_syncToList.GetValue().Remove(_inMemoryCopy);
}
}
/// <summary>

View File

@ -9,12 +9,17 @@ namespace UnityAtoms
[EditorIcon("atom-icon-teal")]
public abstract class AtomBaseVariable : BaseAtom
{
public String Id { get => _id; set => _id = value; }
/// <summary>
/// The Variable value as an `object`.abstract Beware of boxing! 🥊
/// </summary>
/// <value>The Variable value as an `object`.</value>
public abstract object BaseValue { get; set; }
[SerializeField]
private String _id = default;
/// <summary>
/// Abstract method that could be implemented to reset the Variable value.
/// </summary>

View File

@ -20,6 +20,8 @@ namespace UnityAtoms.FSM.Editor
EditorGUILayout.PropertyField(serializedObject.FindProperty("_developerDescription"));
EditorGUILayout.Space();
EditorGUILayout.PropertyField(serializedObject.FindProperty("_id"));
EditorGUI.BeginDisabledGroup(true);
EditorGUILayout.PropertyField(serializedObject.FindProperty("_initialValue"), true);
EditorGUI.EndDisabledGroup();

View File

@ -19,7 +19,7 @@ namespace UnityAtoms.Mobile
TouchUserInputPairEvent,
TouchUserInputTouchUserInputFunction,
TouchUserInputVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.Mobile
TouchUserInputPairEvent,
TouchUserInputTouchUserInputFunction,
TouchUserInputVariableInstancer,
AtomCollection,
AtomList>, IEquatable<TouchUserInputReference>
AtomCollectionReference,
AtomListReference>, IEquatable<TouchUserInputReference>
{
public TouchUserInputReference() : base() { }
public TouchUserInputReference(TouchUserInput value) : base(value) { }

View File

@ -16,7 +16,7 @@ namespace UnityAtoms.Mobile
TouchUserInputEvent,
TouchUserInputPairEvent,
TouchUserInputTouchUserInputFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -19,7 +19,7 @@ namespace UnityAtoms.MonoHooks
Collider2DGameObjectPairEvent,
Collider2DGameObjectCollider2DGameObjectFunction,
Collider2DGameObjectVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -19,7 +19,7 @@ namespace UnityAtoms.MonoHooks
ColliderGameObjectPairEvent,
ColliderGameObjectColliderGameObjectFunction,
ColliderGameObjectVariableInstancer,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.MonoHooks
Collider2DGameObjectPairEvent,
Collider2DGameObjectCollider2DGameObjectFunction,
Collider2DGameObjectVariableInstancer,
AtomCollection,
AtomList>, IEquatable<Collider2DGameObjectReference>
AtomCollectionReference,
AtomListReference>, IEquatable<Collider2DGameObjectReference>
{
public Collider2DGameObjectReference() : base() { }
public Collider2DGameObjectReference(Collider2DGameObject value) : base(value) { }

View File

@ -17,8 +17,8 @@ namespace UnityAtoms.MonoHooks
ColliderGameObjectPairEvent,
ColliderGameObjectColliderGameObjectFunction,
ColliderGameObjectVariableInstancer,
AtomCollection,
AtomList>, IEquatable<ColliderGameObjectReference>
AtomCollectionReference,
AtomListReference>, IEquatable<ColliderGameObjectReference>
{
public ColliderGameObjectReference() : base() { }
public ColliderGameObjectReference(ColliderGameObject value) : base(value) { }

View File

@ -16,7 +16,7 @@ namespace UnityAtoms.MonoHooks
Collider2DGameObjectEvent,
Collider2DGameObjectPairEvent,
Collider2DGameObjectCollider2DGameObjectFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

View File

@ -16,7 +16,7 @@ namespace UnityAtoms.MonoHooks
ColliderGameObjectEvent,
ColliderGameObjectPairEvent,
ColliderGameObjectColliderGameObjectFunction,
AtomCollection,
AtomList>
AtomCollectionReference,
AtomListReference>
{ }
}

Some files were not shown because too many files have changed in this diff Show More