mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-22 08:08:51 -05:00
parent
76ba614e96
commit
55d96c2250
@ -18,13 +18,13 @@ GameObject:
|
||||
- component: {fileID: 2421445419809145569}
|
||||
- component: {fileID: 4909826835678234752}
|
||||
- component: {fileID: -2978108162882953924}
|
||||
- component: {fileID: 3464795203355677658}
|
||||
- component: {fileID: 1740680909}
|
||||
- component: {fileID: 1740680910}
|
||||
- component: {fileID: 1637442682690422268}
|
||||
- component: {fileID: 4095674729113015293}
|
||||
- component: {fileID: 5231109137669188302}
|
||||
- component: {fileID: 3219820094781281706}
|
||||
- component: {fileID: 3464795203355677658}
|
||||
- component: {fileID: 9113883788723746504}
|
||||
- component: {fileID: 880247903186001704}
|
||||
m_Layer: 0
|
||||
@ -159,7 +159,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_tags:
|
||||
- {fileID: 11400000, guid: 548d717e096e245aa93d91687b22e1f7, type: 2}
|
||||
- {fileID: 0}
|
||||
--- !u!114 &2421445419809145581
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -265,6 +264,28 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_inMemoryCopy: {fileID: 0}
|
||||
_base: {fileID: 11400000, guid: 16bf069429937474390ce1ed7d17a8bf, type: 2}
|
||||
--- !u!114 &3464795203355677658
|
||||
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: 84fa545dc2b5d4429a502d265e32b9e1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_variableInstancer: {fileID: -2978108162882953924}
|
||||
_syncToCollection:
|
||||
_usage: 1
|
||||
_collection: {fileID: 0}
|
||||
_instancer: {fileID: 5231109137669188302}
|
||||
_syncToCollectionKey: Health
|
||||
_syncToList:
|
||||
_usage: 0
|
||||
_list: {fileID: 0}
|
||||
_instancer: {fileID: 0}
|
||||
--- !u!114 &1740680909
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -300,7 +321,7 @@ MonoBehaviour:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1740680909}
|
||||
m_MethodName: DestroyIfZeroOfBelow
|
||||
m_MethodName: DestroyIfZeroOrBelow
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
@ -377,28 +398,6 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_list: {fileID: 11400000, guid: 118b16031adba41c2921b637788fa016, type: 2}
|
||||
--- !u!114 &3464795203355677658
|
||||
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: 84fa545dc2b5d4429a502d265e32b9e1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_variableInstancer: {fileID: -2978108162882953924}
|
||||
_syncToCollection:
|
||||
_usage: 1
|
||||
_collection: {fileID: 0}
|
||||
_instancer: {fileID: 5231109137669188302}
|
||||
_syncToCollectionKey: Health
|
||||
_syncToList:
|
||||
_usage: 0
|
||||
_list: {fileID: 0}
|
||||
_instancer: {fileID: 0}
|
||||
--- !u!114 &9113883788723746504
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1037,7 +1037,7 @@ MonoBehaviour:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- m_Target: {fileID: 854994187}
|
||||
m_MethodName: DestroyIfZeroOfBelow
|
||||
m_MethodName: DestroyIfZeroOrBelow
|
||||
m_Mode: 0
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d924290f3a1de45a0882839da4339084
|
||||
guid: b0b3181b8a944476e9f2d52b0923be70
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,97 @@
|
||||
using UnityEditor;
|
||||
using UnityAtoms.Editor;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom property drawer for AtomBaseVariable BaseEventReferences. Makes it possible to choose between an Event, Event Instancer, Collection Added, Collection Removed, List Added, List Removed, Collection Instancer Added, Collection Instancer Removed, List Instancer Added or List Instancer Removed.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(AtomBaseVariableBaseEventReference), true)]
|
||||
public class AtomBaseVariableBaseEventReferenceDrawer : AtomBaseReferenceDrawer
|
||||
{
|
||||
protected class UsageEvent : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.EVENT; }
|
||||
public override string PropertyName { get => "_event"; }
|
||||
public override string DisplayName { get => "Use Event"; }
|
||||
}
|
||||
|
||||
protected class UsageEventInstancer : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.EVENT_INSTANCER; }
|
||||
public override string PropertyName { get => "_eventInstancer"; }
|
||||
public override string DisplayName { get => "Use Event Instancer"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionAdded : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.COLLECTION_ADDED_EVENT; }
|
||||
public override string PropertyName { get => "_collection"; }
|
||||
public override string DisplayName { get => "Use Collection Added Event"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionRemoved : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.COLLECTION_REMOVED_EVENT; }
|
||||
public override string PropertyName { get => "_collection"; }
|
||||
public override string DisplayName { get => "Use Collection Removed Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListAdded : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.LIST_ADDED_EVENT; }
|
||||
public override string PropertyName { get => "_list"; }
|
||||
public override string DisplayName { get => "Use List Added Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListRemoved : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.LIST_REMOVED_EVENT; }
|
||||
public override string PropertyName { get => "_list"; }
|
||||
public override string DisplayName { get => "Use List Removed Event"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionInstancerAdded : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_ADDED_EVENT; }
|
||||
public override string PropertyName { get => "_collectionInstancer"; }
|
||||
public override string DisplayName { get => "Use Collection Instancer Added Event"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionInstancerRemoved : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_REMOVED_EVENT; }
|
||||
public override string PropertyName { get => "_collectionInstancer"; }
|
||||
public override string DisplayName { get => "Use Collection Instancer Removed Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListInstancerAdded : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_ADDED_EVENT; }
|
||||
public override string PropertyName { get => "_listInstancer"; }
|
||||
public override string DisplayName { get => "Use List Instancer Added Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListInstancerRemoved : UsageData
|
||||
{
|
||||
public override int Value { get => AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_REMOVED_EVENT; }
|
||||
public override string PropertyName { get => "_listInstancer"; }
|
||||
public override string DisplayName { get => "Use List Instancer Removed Event"; }
|
||||
}
|
||||
|
||||
private readonly UsageData[] _usages = new UsageData[10] {
|
||||
new UsageEvent(),
|
||||
new UsageEventInstancer(),
|
||||
new UsageCollectionAdded(),
|
||||
new UsageCollectionRemoved(),
|
||||
new UsageListAdded(),
|
||||
new UsageListRemoved(),
|
||||
new UsageCollectionInstancerAdded(),
|
||||
new UsageCollectionInstancerRemoved(),
|
||||
new UsageListInstancerAdded(),
|
||||
new UsageListInstancerRemoved()
|
||||
};
|
||||
|
||||
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce341bcb48e534eaca61dee05d7d3807
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,65 @@
|
||||
using UnityEditor;
|
||||
using UnityAtoms.Editor;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// A custom property drawer for Void BaseEventReferences. Makes it possible to choose between an Event, Event Instancer, Collection Cleared, List Cleared, Collection Instancer Cleared or List Instancer Cleared.
|
||||
/// </summary>
|
||||
[CustomPropertyDrawer(typeof(VoidBaseEventReference), true)]
|
||||
public class VoidBaseEventReferenceDrawer : AtomBaseReferenceDrawer
|
||||
{
|
||||
protected class UsageEvent : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.EVENT; }
|
||||
public override string PropertyName { get => "_event"; }
|
||||
public override string DisplayName { get => "Use Event"; }
|
||||
}
|
||||
|
||||
protected class UsageEventInstancer : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.EVENT_INSTANCER; }
|
||||
public override string PropertyName { get => "_eventInstancer"; }
|
||||
public override string DisplayName { get => "Use Event Instancer"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionCleared : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.COLLECTION_CLEARED_EVENT; }
|
||||
public override string PropertyName { get => "_collection"; }
|
||||
public override string DisplayName { get => "Use Collection Cleared Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListCleared : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.LIST_CLEARED_EVENT; }
|
||||
public override string PropertyName { get => "_list"; }
|
||||
public override string DisplayName { get => "Use List Cleared Event"; }
|
||||
}
|
||||
|
||||
protected class UsageCollectionInstancerCleared : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.COLLECTION_INSTANCER_CLEARED_EVENT; }
|
||||
public override string PropertyName { get => "_collectionInstancer"; }
|
||||
public override string DisplayName { get => "Use Collection Instancer Cleared Event"; }
|
||||
}
|
||||
|
||||
protected class UsageListInstancerCleared : UsageData
|
||||
{
|
||||
public override int Value { get => VoidBaseEventReferenceUsage.LIST_INSTANCER_CLEARED_EVENT; }
|
||||
public override string PropertyName { get => "_listInstancer"; }
|
||||
public override string DisplayName { get => "Use List Instancer Cleared Event"; }
|
||||
}
|
||||
|
||||
private readonly UsageData[] _usages = new UsageData[6] {
|
||||
new UsageEvent(),
|
||||
new UsageEventInstancer(),
|
||||
new UsageCollectionCleared(),
|
||||
new UsageListCleared(),
|
||||
new UsageCollectionInstancerCleared(),
|
||||
new UsageListInstancerCleared()
|
||||
};
|
||||
|
||||
protected override UsageData[] GetUsages(SerializedProperty prop = null) => _usages;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efa0fcf087b6b4686b558a9c7269846a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms
|
||||
{
|
||||
/// <summary>
|
||||
/// Event Reference Listener of type `AtomBaseVariable`. Inherits from `AtomEventReferenceListener<AtomBaseVariable, AtomBaseVariableEvent, AtomBaseVariableBaseEventReference, AtomBaseVariableUnityEvent>`.
|
||||
/// </summary>
|
||||
[EditorIcon("atom-icon-orange")]
|
||||
[AddComponentMenu("Unity Atoms/Listeners/AtomBaseVariable Base Event Reference Listener")]
|
||||
public sealed class AtomBaseVariableBaseEventReferenceListener : AtomEventReferenceListener<
|
||||
AtomBaseVariable,
|
||||
AtomBaseVariableEvent,
|
||||
AtomBaseVariableBaseEventReference,
|
||||
AtomBaseVariableUnityEvent>
|
||||
{ }
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d78396a243a52473ea10f585128d364a
|
||||
guid: 8a8189547b41a4313a0844752c4e715a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms
|
||||
{
|
||||
/// <summary>
|
||||
/// Different types of Event Reference usages.
|
||||
/// </summary>
|
||||
public class AtomBaseVariableEventReferenceUsage
|
||||
{
|
||||
public const int EVENT = 0;
|
||||
public const int EVENT_INSTANCER = 1;
|
||||
public const int COLLECTION_ADDED_EVENT = 2;
|
||||
public const int COLLECTION_REMOVED_EVENT = 3;
|
||||
public const int LIST_ADDED_EVENT = 4;
|
||||
public const int LIST_REMOVED_EVENT = 5;
|
||||
public const int COLLECTION_INSTANCER_ADDED_EVENT = 6;
|
||||
public const int COLLECTION_INSTANCER_REMOVED_EVENT = 7;
|
||||
public const int LIST_INSTANCER_ADDED_EVENT = 8;
|
||||
public const int LIST_INSTANCER_REMOVED_EVENT = 9;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Reference of type `AtomBaseVariable`. Inherits from `AtomBaseEventReference<AtomBaseVariable, AtomBaseVariableEvent, AtomBaseVariableEventInstancer>`.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class AtomBaseVariableBaseEventReference : AtomBaseEventReference<
|
||||
AtomBaseVariable,
|
||||
AtomBaseVariableEvent,
|
||||
AtomBaseVariableEventInstancer>, IGetEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// Get or set the Event used by the Event Reference.
|
||||
/// </summary>
|
||||
/// <value>The event of type `E`.</value>
|
||||
public override AtomBaseVariableEvent Event
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_usage)
|
||||
{
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_ADDED_EVENT): return _collection != null ? _collection.Added : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_REMOVED_EVENT): return _collection != null ? _collection.Removed : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_ADDED_EVENT): return _list != null ? _list.Added : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_REMOVED_EVENT): return _list != null ? _list.Removed : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_ADDED_EVENT): return _collectionInstancer != null ? _collectionInstancer.Added : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_REMOVED_EVENT): return _collectionInstancer != null ? _collectionInstancer.Removed : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_ADDED_EVENT): return _listInstancer != null ? _listInstancer.Added : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_REMOVED_EVENT): return _listInstancer != null ? _listInstancer.Removed : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.EVENT_INSTANCER): return _eventInstancer != null ? _eventInstancer.Event : null;
|
||||
case (AtomBaseVariableEventReferenceUsage.EVENT):
|
||||
default:
|
||||
return _event;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (_usage)
|
||||
{
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_ADDED_EVENT):
|
||||
{
|
||||
_collection.Added = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_REMOVED_EVENT):
|
||||
{
|
||||
_collection.Removed = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_ADDED_EVENT):
|
||||
{
|
||||
_list.Added = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_REMOVED_EVENT):
|
||||
{
|
||||
_list.Removed = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_ADDED_EVENT):
|
||||
{
|
||||
_collectionInstancer.Added = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.COLLECTION_INSTANCER_REMOVED_EVENT):
|
||||
{
|
||||
_collectionInstancer.Removed = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_ADDED_EVENT):
|
||||
{
|
||||
_listInstancer.Added = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.LIST_INSTANCER_REMOVED_EVENT):
|
||||
{
|
||||
_listInstancer.Removed = value;
|
||||
break;
|
||||
}
|
||||
case (AtomBaseVariableEventReferenceUsage.EVENT):
|
||||
{
|
||||
_event = value;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotSupportedException($"Event not reassignable for usage {_usage}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collection used if `Usage` is set to `COLLECTION_ADDED_EVENT` or `COLLECTION_REMOVED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomCollection _collection = default(AtomCollection);
|
||||
|
||||
/// <summary>
|
||||
/// List used if `Usage` is set to `LIST_ADDED_EVENT` or `LIST_REMOVED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomList _list = default(AtomList);
|
||||
|
||||
/// <summary>
|
||||
/// Collection Instancer used if `Usage` is set to `COLLECTION_INSTANCER_ADDED_EVENT` or `COLLECTION_INSTANCER_REMOVED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomCollectionInstancer _collectionInstancer = default(AtomCollectionInstancer);
|
||||
|
||||
/// <summary>
|
||||
/// List Instancer used if `Usage` is set to `LIST_INSTANCER_ADDED_EVENT` or `LIST_INSTANCER_REMOVED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomListInstancer _listInstancer = default(AtomListInstancer);
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5bd6cdaa6f0f4ff7b5a68046e184e20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +1,18 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms
|
||||
{
|
||||
public class VoidBaseEventReferenceUsage
|
||||
{
|
||||
public const int EVENT = 0;
|
||||
public const int EVENT_INSTANCER = 1;
|
||||
public const int COLLECTION_CLEARED_EVENT = 2;
|
||||
public const int LIST_CLEARED_EVENT = 3;
|
||||
public const int COLLECTION_INSTANCER_CLEARED_EVENT = 4;
|
||||
public const int LIST_INSTANCER_CLEARED_EVENT = 5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event Reference of type `Void`. Inherits from `AtomBaseEventReference<Void, VoidEvent, VoidEventInstancer>`.
|
||||
/// </summary>
|
||||
@ -10,5 +21,84 @@ namespace UnityAtoms.BaseAtoms
|
||||
Void,
|
||||
VoidEvent,
|
||||
VoidEventInstancer>, IGetEvent
|
||||
{ }
|
||||
{
|
||||
/// <summary>
|
||||
/// Get or set the Event used by the Event Reference.
|
||||
/// </summary>
|
||||
/// <value>The event of type `E`.</value>
|
||||
public override VoidEvent Event
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (_usage)
|
||||
{
|
||||
case (VoidBaseEventReferenceUsage.COLLECTION_CLEARED_EVENT): return _collection != null ? _collection.Cleared : null;
|
||||
case (VoidBaseEventReferenceUsage.LIST_CLEARED_EVENT): return _list != null ? _list.Cleared : null;
|
||||
case (VoidBaseEventReferenceUsage.COLLECTION_INSTANCER_CLEARED_EVENT): return _collectionInstancer != null ? _collectionInstancer.Cleared : null;
|
||||
case (VoidBaseEventReferenceUsage.LIST_INSTANCER_CLEARED_EVENT): return _listInstancer != null ? _listInstancer.Cleared : null;
|
||||
case (VoidBaseEventReferenceUsage.EVENT_INSTANCER): return _eventInstancer != null ? _eventInstancer.Event : null;
|
||||
case (VoidBaseEventReferenceUsage.EVENT):
|
||||
default:
|
||||
return _event;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
switch (_usage)
|
||||
{
|
||||
case (VoidBaseEventReferenceUsage.COLLECTION_CLEARED_EVENT):
|
||||
{
|
||||
_collection.Cleared = value;
|
||||
break;
|
||||
}
|
||||
case (VoidBaseEventReferenceUsage.LIST_CLEARED_EVENT):
|
||||
{
|
||||
_list.Cleared = value;
|
||||
break;
|
||||
}
|
||||
case (VoidBaseEventReferenceUsage.COLLECTION_INSTANCER_CLEARED_EVENT):
|
||||
{
|
||||
_collectionInstancer.Cleared = value;
|
||||
break;
|
||||
}
|
||||
case (VoidBaseEventReferenceUsage.LIST_INSTANCER_CLEARED_EVENT):
|
||||
{
|
||||
_listInstancer.Cleared = value;
|
||||
break;
|
||||
}
|
||||
case (VoidBaseEventReferenceUsage.EVENT):
|
||||
{
|
||||
_event = value;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new NotSupportedException($"Event not reassignable for usage {_usage}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collection used if `Usage` is set to `COLLECTION_CLEARED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomCollection _collection = default(AtomCollection);
|
||||
|
||||
/// <summary>
|
||||
/// List used if `Usage` is set to `LIST_CLEARED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomList _list = default(AtomList);
|
||||
|
||||
/// <summary>
|
||||
/// Collection Instancer used if `Usage` is set to `COLLECTION_INSTANCER_CLEARED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomCollectionInstancer _collectionInstancer = default(AtomCollectionInstancer);
|
||||
|
||||
/// <summary>
|
||||
/// List Instancer used if `Usage` is set to `LIST_INSTANCER_CLEARED_EVENT`.
|
||||
/// </summary>
|
||||
[SerializeField]
|
||||
private AtomListInstancer _listInstancer = default(AtomListInstancer);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,24 @@ namespace UnityAtoms.BaseAtoms
|
||||
public abstract class AtomBaseCollectionInstancer<T, V> : AtomBaseVariableInstancer<T, V>
|
||||
where V : AtomBaseVariable<T>, IWithCollectionEvents
|
||||
{
|
||||
public AtomBaseVariableEvent Added
|
||||
{
|
||||
get => ((V)_inMemoryCopy).Added;
|
||||
set => ((V)_inMemoryCopy).Added = value;
|
||||
}
|
||||
|
||||
public AtomBaseVariableEvent Removed
|
||||
{
|
||||
get => ((V)_inMemoryCopy).Removed;
|
||||
set => ((V)_inMemoryCopy).Removed = value;
|
||||
}
|
||||
|
||||
public VoidEvent Cleared
|
||||
{
|
||||
get => ((V)_inMemoryCopy).Cleared;
|
||||
set => ((V)_inMemoryCopy).Cleared = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates in memory copies of the Added, Removed and Cleared Events on OnEnable.
|
||||
/// </summary>
|
||||
|
@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms
|
||||
{
|
||||
/// <summary>
|
||||
/// Event Instancer of type `AtomBaseVariable`. Inherits from `AtomEventInstancer<AtomBaseVariable, AtomBaseVariableEvent>`.
|
||||
/// </summary>
|
||||
[EditorIcon("atom-icon-sign-blue")]
|
||||
[AddComponentMenu("Unity Atoms/Event Instancers/AtomBaseVariable Event Instancer")]
|
||||
public class AtomBaseVariableEventInstancer : AtomEventInstancer<AtomBaseVariable, AtomBaseVariableEvent> { }
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da3fe64164a874a1e827e119ff66695f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 8c25ac30c7b7d4e3b90bed61d900d244, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,15 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityAtoms.BaseAtoms
|
||||
{
|
||||
/// <summary>
|
||||
/// Event Listener of type `AtomBaseVariable`. Inherits from `AtomEventListener<AtomBaseVariable, AtomBaseVariableEvent, AtomBaseVariableUnityEvent>`.
|
||||
/// </summary>
|
||||
[EditorIcon("atom-icon-orange")]
|
||||
[AddComponentMenu("Unity Atoms/Listeners/AtomBaseVariable Event Listener")]
|
||||
public sealed class AtomBaseVariableEventListener : AtomEventListener<
|
||||
AtomBaseVariable,
|
||||
AtomBaseVariableEvent,
|
||||
AtomBaseVariableUnityEvent>
|
||||
{ }
|
||||
}
|
@ -86,7 +86,7 @@ namespace UnityAtoms.Editor
|
||||
valueType: "AtomBaseVariable",
|
||||
baseWritePath: Path.Combine(path, "BaseAtoms"),
|
||||
isValueEquatable: false,
|
||||
atomTypesToGenerate: new List<AtomType>() { AtomTypes.EVENT, AtomTypes.ACTION, AtomTypes.UNITY_EVENT, AtomTypes.EVENT_LISTENER },
|
||||
atomTypesToGenerate: new List<AtomType>() { AtomTypes.EVENT, AtomTypes.ACTION, AtomTypes.UNITY_EVENT, AtomTypes.BASE_EVENT_REFERENCE, AtomTypes.EVENT_INSTANCER, AtomTypes.BASE_EVENT_REFERENCE_LISTENER },
|
||||
typeNamespace: "",
|
||||
subUnityAtomsNamespace: "BaseAtoms"
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user