2020-11-09 21:38:25 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityExplorer.UI;
|
|
|
|
|
using UnityExplorer.UI.Shared;
|
|
|
|
|
using UnityExplorer.Helpers;
|
2020-11-11 20:16:43 +11:00
|
|
|
|
using UnityEngine.UI;
|
2020-11-09 21:38:25 +11:00
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.Inspectors.Reflection
|
|
|
|
|
{
|
|
|
|
|
public class CacheObjectBase
|
|
|
|
|
{
|
|
|
|
|
public InteractiveValue IValue;
|
|
|
|
|
|
|
|
|
|
public virtual bool CanWrite => false;
|
|
|
|
|
public virtual bool HasParameters => false;
|
|
|
|
|
public virtual bool IsMember => false;
|
2020-11-11 20:16:43 +11:00
|
|
|
|
public virtual bool HasEvaluated => true;
|
2020-11-09 21:38:25 +11:00
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
public virtual void InitValue(object value, Type valueType)
|
|
|
|
|
{
|
|
|
|
|
if (valueType == null && value == null)
|
|
|
|
|
{
|
2020-11-14 19:51:16 +11:00
|
|
|
|
ExplorerCore.LogWarning("CacheObjectBase: Trying to init with no default value or valueType!");
|
|
|
|
|
ExplorerCore.Log(Environment.StackTrace);
|
2020-11-09 21:38:25 +11:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-14 19:51:16 +11:00
|
|
|
|
// temp (havent made rest of InteractiveValue classes yet, just using base class always)
|
|
|
|
|
|
|
|
|
|
valueType = ReflectionHelpers.GetActualType(value) ?? valueType;
|
|
|
|
|
|
|
|
|
|
IValue = new InteractiveValue(valueType)
|
2020-11-11 20:16:43 +11:00
|
|
|
|
{
|
2020-11-14 19:51:16 +11:00
|
|
|
|
OwnerCacheObject = this
|
2020-11-11 20:16:43 +11:00
|
|
|
|
};
|
|
|
|
|
UpdateValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Enable()
|
|
|
|
|
{
|
|
|
|
|
if (!m_constructedUI)
|
|
|
|
|
{
|
|
|
|
|
ConstructUI();
|
|
|
|
|
UpdateValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_mainContent.SetActive(true);
|
2020-11-14 19:51:16 +11:00
|
|
|
|
m_mainContent.transform.SetAsLastSibling();
|
2020-11-09 21:38:25 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-11 20:16:43 +11:00
|
|
|
|
public virtual void Disable()
|
2020-11-09 21:38:25 +11:00
|
|
|
|
{
|
2020-11-11 20:16:43 +11:00
|
|
|
|
m_mainContent.SetActive(false);
|
2020-11-09 21:38:25 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void UpdateValue()
|
|
|
|
|
{
|
2020-11-14 19:51:16 +11:00
|
|
|
|
IValue.OnValueUpdated();
|
2020-11-09 21:38:25 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void SetValue() => throw new NotImplementedException();
|
2020-11-11 20:16:43 +11:00
|
|
|
|
|
|
|
|
|
#region UI CONSTRUCTION
|
|
|
|
|
|
|
|
|
|
internal bool m_constructedUI;
|
|
|
|
|
internal GameObject m_parentContent;
|
|
|
|
|
internal GameObject m_mainContent;
|
|
|
|
|
|
|
|
|
|
// Make base UI holder for CacheObject, this doesnt actually display anything.
|
|
|
|
|
internal virtual void ConstructUI()
|
|
|
|
|
{
|
|
|
|
|
m_constructedUI = true;
|
|
|
|
|
|
|
|
|
|
m_mainContent = UIFactory.CreateVerticalGroup(m_parentContent, new Color(0.1f, 0.1f, 0.1f));
|
|
|
|
|
var rowGroup = m_mainContent.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
rowGroup.childForceExpandWidth = true;
|
|
|
|
|
rowGroup.childControlWidth = true;
|
|
|
|
|
rowGroup.childForceExpandHeight = false;
|
|
|
|
|
rowGroup.childControlHeight = true;
|
|
|
|
|
var rowLayout = m_mainContent.AddComponent<LayoutElement>();
|
|
|
|
|
rowLayout.minHeight = 25;
|
2020-11-12 16:15:41 +11:00
|
|
|
|
rowLayout.flexibleHeight = 500;
|
2020-11-11 20:16:43 +11:00
|
|
|
|
rowLayout.minWidth = 200;
|
|
|
|
|
rowLayout.flexibleWidth = 5000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2020-11-09 21:38:25 +11:00
|
|
|
|
}
|
|
|
|
|
}
|