mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-23 08:38:23 -05:00
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
|
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);
|
||
|
}
|
||
|
}
|