mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-19 23:37:39 +08:00

- Use explicit type of var - Use 'new()' - Remove unnecessary usings - Sort usings - Apply formatting
59 lines
1.7 KiB
C#
59 lines
1.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UniverseLib.UI.ObjectPool;
|
|
|
|
namespace UnityExplorer.CacheObject.IValues
|
|
{
|
|
public abstract class InteractiveValue : IPooledObject
|
|
{
|
|
public static Type GetIValueTypeForState(ValueState state)
|
|
{
|
|
return state switch
|
|
{
|
|
ValueState.Exception or ValueState.String => typeof(InteractiveString),
|
|
ValueState.Enum => typeof(InteractiveEnum),
|
|
ValueState.Collection => typeof(InteractiveList),
|
|
ValueState.Dictionary => typeof(InteractiveDictionary),
|
|
ValueState.ValueStruct => typeof(InteractiveValueStruct),
|
|
ValueState.Color => typeof(InteractiveColor),
|
|
_ => null,
|
|
};
|
|
}
|
|
|
|
public GameObject UIRoot { get; set; }
|
|
public float DefaultHeight => -1f;
|
|
|
|
public virtual bool CanWrite => this.CurrentOwner.CanWrite;
|
|
|
|
public CacheObjectBase CurrentOwner => owner;
|
|
private CacheObjectBase owner;
|
|
|
|
public bool PendingValueWanted;
|
|
|
|
public virtual void OnBorrowed(CacheObjectBase owner)
|
|
{
|
|
if (this.owner != null)
|
|
{
|
|
ExplorerCore.LogWarning("Setting an IValue's owner but there is already one set. Maybe it wasn't cleaned up?");
|
|
ReleaseFromOwner();
|
|
}
|
|
|
|
this.owner = owner;
|
|
}
|
|
|
|
public virtual void ReleaseFromOwner()
|
|
{
|
|
if (this.owner == null)
|
|
return;
|
|
|
|
this.owner = null;
|
|
}
|
|
|
|
public abstract void SetValue(object value);
|
|
|
|
public virtual void SetLayout() { }
|
|
|
|
public abstract GameObject CreateContent(GameObject parent);
|
|
}
|
|
}
|