Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
using System;
|
|
|
|
using UnityEngine;
|
2020-03-01 20:26:06 -05:00
|
|
|
using UnityAtoms;
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
|
2020-03-01 20:26:06 -05:00
|
|
|
namespace UnityAtoms.BaseAtoms
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A List of Atom Variables (AtomBaseVariable).
|
|
|
|
/// </summary>
|
2020-03-19 03:39:43 -04:00
|
|
|
[CreateAssetMenu(menuName = "Unity Atoms/Collections/List", fileName = "List")]
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
[EditorIcon("atom-icon-lime")]
|
2020-03-17 19:17:33 -04:00
|
|
|
public class AtomList : AtomBaseVariable<AtomBaseVariableList>, IGetValue<IAtomList>, IWithCollectionEvents
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
{
|
2020-03-01 20:26:06 -05:00
|
|
|
/// <summary>
|
|
|
|
/// Get value as an `IAtomList`. Needed in order to inject Lists into the Variable Instancer class.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The value as an `IAtomList`.</returns>
|
|
|
|
public IAtomList GetValue() => this.Value;
|
|
|
|
|
Added Variable Instancer, Event Reference, Atom Collection and Atom List (old Atom List renamed to Atom Value List) (#110)
AtomVariableInstancer
- Added AtomVariableInstancer as an option to AtomReference.
- Added AtomVariableInstancer to generator.
- Added editor icon for AtomVariableInstancer.
AtomEventReference
- Added an AtomEventReference class (and AtomEventX2Reference). It’s similar to an AtomReference, but for Events. Let’s you pick between an Event, Variable (will select the Changed event) and a VariableInstancer (see above).
- Added AtomEventReference and AtomEventX2Reference to generator.
- Added a drawer for AtomEventReference.
- Listeners are now using AtomEventReference instead of AtomEvent.
- Refactoring of VoidHooks since Listeners are now using AtomEventReference.
AtomCollection
- Created an AtomCollection - a collection of Atoms associated with key strings (AtomReferences).
- Added new editor icon for collections.
- Created a SerializableDictionary class, which AtomCollection is using.
- Custom property drawer for SerializableDictionary.
- SerializableDictionary supports nested structures meaning that a AtomCollection can have a KVP that is pointing to another AtomCollection.
- AtomCollections have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to collection - adding it to the collection when created (using gameObject’s instance id as key) and removing it from the collection when destroyed.
AtomList
- Renamed old AtomList to AtomValueList
- Added AtomList, like Collection, but a list
- Added new icon for AtomList
- Created a AtomBaseVariableList class, which AtomList is using.
- Custom property drawer for AtomBaseVariableList.
- AtomLists have 3 events: Added, Removed, Cleared.
- Added an option to sync an InstanceVariable to list - adding it to the list when created and removing it from the list when destroyed.
2020-02-22 20:39:43 -05:00
|
|
|
/// <summary>
|
|
|
|
/// Event for when and item is added to the list.
|
|
|
|
/// </summary>
|
|
|
|
public AtomBaseVariableEvent Added { get => _added; set => _added = value; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event for when and item is removed from the list.
|
|
|
|
/// </summary>
|
|
|
|
public AtomBaseVariableEvent Removed { get => _removed; set => _removed = value; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Event for when the list is cleared.
|
|
|
|
/// </summary>
|
|
|
|
public VoidEvent Cleared { get => _cleared; set => _cleared = value; }
|
|
|
|
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private AtomBaseVariableEvent _added;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private AtomBaseVariableEvent _removed;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private VoidEvent _cleared;
|
|
|
|
|
|
|
|
void OnEnable()
|
|
|
|
{
|
|
|
|
if (Value == null) return;
|
|
|
|
|
|
|
|
Value.Added += PropogateAdded;
|
|
|
|
Value.Removed += PropogateRemoved;
|
|
|
|
Value.Cleared += PropogateCleared;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnDisable()
|
|
|
|
{
|
|
|
|
if (Value == null) return;
|
|
|
|
|
|
|
|
Value.Added -= PropogateAdded;
|
|
|
|
Value.Removed -= PropogateRemoved;
|
|
|
|
Value.Cleared -= PropogateCleared;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropogateAdded(AtomBaseVariable baseVariable)
|
|
|
|
{
|
|
|
|
if (_added == null) return;
|
|
|
|
|
|
|
|
_added.Raise(baseVariable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropogateRemoved(AtomBaseVariable baseVariable)
|
|
|
|
{
|
|
|
|
if (_removed == null) return;
|
|
|
|
|
|
|
|
_removed.Raise(baseVariable);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropogateCleared()
|
|
|
|
{
|
|
|
|
if (_cleared == null) return;
|
|
|
|
|
|
|
|
_cleared.Raise();
|
|
|
|
}
|
|
|
|
|
|
|
|
#region Observable
|
|
|
|
/// <summary>
|
|
|
|
/// Make the add event into an `IObservable<T>`. Makes List's add Event compatible with for example UniRx.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The add Event as an `IObservable<T>`.</returns>
|
|
|
|
public IObservable<AtomBaseVariable> ObserveAdd()
|
|
|
|
{
|
|
|
|
if (Added == null)
|
|
|
|
{
|
|
|
|
throw new Exception("You must assign an Added event in order to observe when adding to the list.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ObservableEvent<AtomBaseVariable>(Added.Register, Added.Unregister);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Make the remove event into an `IObservable<T>`. Makes List's remove Event compatible with for example UniRx.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The remove Event as an `IObservable<T>`.</returns>
|
|
|
|
public IObservable<AtomBaseVariable> ObserveRemove()
|
|
|
|
{
|
|
|
|
if (Removed == null)
|
|
|
|
{
|
|
|
|
throw new Exception("You must assign a Removed event in order to observe when removing from the list.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ObservableEvent<AtomBaseVariable>(Removed.Register, Removed.Unregister);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Make the clear event into an `IObservable<Void>`. Makes List's clear Event compatible with for example UniRx.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The clear Event as an `IObservable<Void>`.</returns>
|
|
|
|
public IObservable<Void> ObserveClear()
|
|
|
|
{
|
|
|
|
if (Cleared == null)
|
|
|
|
{
|
|
|
|
throw new Exception("You must assign a Cleared event in order to observe when clearing the list.");
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ObservableVoidEvent(Cleared.Register, Cleared.Unregister);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion // Observable
|
|
|
|
}
|
|
|
|
}
|