Finished argument inputs for Method/Props, some UI cleanups and fixes

This commit is contained in:
sinaioutlander 2020-11-14 19:51:16 +11:00
parent 755eae293e
commit 2819ced303
18 changed files with 613 additions and 183 deletions

View File

@ -21,20 +21,6 @@ namespace UnityExplorer.Helpers
{
public static BF CommonFlags = BF.Public | BF.Instance | BF.NonPublic | BF.Static;
#if CPP
public static ILType GameObjectType => Il2CppType.Of<GameObject>();
public static ILType TransformType => Il2CppType.Of<Transform>();
public static ILType ObjectType => Il2CppType.Of<UnityEngine.Object>();
public static ILType ComponentType => Il2CppType.Of<Component>();
public static ILType BehaviourType => Il2CppType.Of<Behaviour>();
#else
public static Type GameObjectType => typeof(GameObject);
public static Type TransformType => typeof(Transform);
public static Type ObjectType => typeof(UnityEngine.Object);
public static Type ComponentType => typeof(Component);
public static Type BehaviourType => typeof(Behaviour);
#endif
public static Type GetTypeByName(string fullName)
{
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
@ -78,10 +64,13 @@ namespace UnityExplorer.Helpers
if (obj is ILType)
return typeof(ILType);
// Il2CppSystem-namespace objects should just return GetType,
// because using GetIl2CppType returns the System namespace type instead.
if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem."))
return ilObject.GetType();
if (!string.IsNullOrEmpty(type.Namespace))
{
// Il2CppSystem-namespace objects should just return GetType,
// because using GetIl2CppType returns the System namespace type instead.
if (type.Namespace.StartsWith("System.") || type.Namespace.StartsWith("Il2CppSystem."))
return ilObject.GetType();
}
var il2cppType = ilObject.GetIl2CppType();

View File

@ -21,12 +21,15 @@ namespace UnityExplorer.Inspectors.GameObjects
}
public static PageHandler s_childListPageHandler;
private static GameObject s_childListContent;
private static GameObject[] s_allChildren = new GameObject[0];
private static readonly List<GameObject> s_childrenShortlist = new List<GameObject>();
private static GameObject s_childListContent;
private static readonly List<Text> s_childListTexts = new List<Text>();
private static int s_lastChildCount;
private static readonly List<Text> s_childListTexts = new List<Text>();
private static readonly List<Toggle> s_childListToggles = new List<Toggle>();
internal void RefreshChildObjectList()
{
var go = GameObjectInspector.ActiveInstance.TargetGO;
@ -86,6 +89,9 @@ namespace UnityExplorer.Inspectors.GameObjects
text.text = name;
text.color = obj.activeSelf ? Color.green : Color.red;
var tog = s_childListToggles[i];
tog.isOn = obj.activeSelf;
var label = text.transform.parent.parent.gameObject;
if (!label.activeSelf)
{
@ -117,6 +123,18 @@ namespace UnityExplorer.Inspectors.GameObjects
Instance.RefreshChildObjectList();
}
internal static void OnToggleClicked(int index, bool newVal)
{
if (GameObjectInspector.ActiveInstance == null)
return;
if (index >= s_childrenShortlist.Count || !s_childrenShortlist[index])
return;
var obj = s_childrenShortlist[index];
obj.SetActive(newVal);
}
#region UI CONSTRUCTION
internal void ConstructChildList(GameObject parent)
@ -166,6 +184,15 @@ namespace UnityExplorer.Inspectors.GameObjects
btnLayout.flexibleHeight = 0;
btnGroupObj.AddComponent<Mask>();
var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText, new Color(0.3f, 0.3f, 0.3f));
var toggleLayout = toggleObj.AddComponent<LayoutElement>();
toggleLayout.minHeight = 25;
toggleLayout.minWidth = 25;
toggleText.text = "";
toggle.isOn = false;
s_childListToggles.Add(toggle);
toggle.onValueChanged.AddListener((bool val) => { OnToggleClicked(thisIndex, val); });
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
mainBtnLayout.minHeight = 25;

View File

@ -183,20 +183,14 @@ namespace UnityExplorer.Inspectors.GameObjects
// Behaviour enabled toggle
var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText);
var togBg = toggleObj.transform.Find("Background").GetComponent<Image>();
togBg.color = new Color(0.1f, 0.1f, 0.1f, 1);
var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText, new Color(0.3f, 0.3f, 0.3f));
var toggleLayout = toggleObj.AddComponent<LayoutElement>();
toggleLayout.minWidth = 25;
toggleLayout.flexibleWidth = 0;
toggleLayout.minHeight = 25;
toggleLayout.flexibleHeight = 0;
var checkImg = toggleObj.transform.Find("Background/Checkmark").GetComponent<Image>();
checkImg.color = UISyntaxHighlight.Class_Instance.ToColor();
checkImg.color *= 0.66f;
toggle.onValueChanged.AddListener((bool val) => { OnCompToggleClicked(thisIndex, val); });
toggleLayout.minWidth = 25;
toggleText.text = "";
toggle.isOn = false;
s_compToggles.Add(toggle);
toggle.onValueChanged.AddListener((bool val) => { OnCompToggleClicked(thisIndex, val); });
// Main component button

View File

@ -314,15 +314,15 @@ namespace UnityExplorer.Inspectors.GameObjects
}
}
// set parent
ConstructSetParent(contentObj);
// transform controls
ConstructVector3Editor(contentObj, "Position", ControlType.position, out s_positionControl);
ConstructVector3Editor(contentObj, "Local Position", ControlType.localPosition, out s_localPosControl);
ConstructVector3Editor(contentObj, "Rotation", ControlType.eulerAngles, out s_rotationControl);
ConstructVector3Editor(contentObj, "Scale", ControlType.localScale, out s_scaleControl);
// set parent
ConstructSetParent(contentObj);
// bottom row buttons
ConstructBottomButtons(contentObj);

View File

@ -86,9 +86,7 @@ namespace UnityExplorer.Inspectors.Reflection
public object[] ParseArguments()
{
if (m_arguments.Length < 1)
{
return new object[0];
}
var parsedArgs = new List<object>();
for (int i = 0; i < m_arguments.Length; i++)
@ -97,9 +95,7 @@ namespace UnityExplorer.Inspectors.Reflection
var type = m_arguments[i].ParameterType;
if (type.IsByRef)
{
type = type.GetElementType();
}
if (!string.IsNullOrEmpty(input))
{
@ -120,7 +116,7 @@ namespace UnityExplorer.Inspectors.Reflection
}
catch
{
ExplorerCore.Log($"Argument #{i} '{m_arguments[i].Name}' ({type.Name}), could not parse input '{input}'.");
ExplorerCore.Log($"Could not parse input '{input}' for argument #{i} '{m_arguments[i].Name}' ({type.FullName})");
}
}
}
@ -300,46 +296,12 @@ namespace UnityExplorer.Inspectors.Reflection
rightGroup.padding.top = 2;
rightGroup.padding.bottom = 2;
// evaluate button
if (this is CacheMethod || HasParameters)
{
var color = HasParameters ? new Color(0.4f, 0.4f, 0.4f) : new Color(0.3f, 0.6f, 0.3f);
ConstructArgInput(out GameObject argsHolder);
var evalButtonObj = UIFactory.CreateButton(m_rightGroup, color);
var evalLayout = evalButtonObj.AddComponent<LayoutElement>();
evalLayout.minWidth = 100;
evalLayout.minHeight = 22;
evalLayout.flexibleWidth = 0;
var evalText = evalButtonObj.GetComponentInChildren<Text>();
evalText.text = HasParameters
? $"Evaluate ({ParamCount})"
: "Evaluate";
var evalButton = evalButtonObj.GetComponent<Button>();
var colors = evalButton.colors;
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
evalButton.colors = colors;
evalButton.onClick.AddListener(OnMainEvaluateButton);
void OnMainEvaluateButton()
{
if (HasParameters)
{
// todo show parameter input
ExplorerCore.Log("TODO params");
}
else
{
// method with no parameters
(this as CacheMethod).Evaluate();
}
}
}
ConstructEvaluateButtons(argsHolder);
// subcontent
// todo check if IValue actually has subcontent
m_subContent = UIFactory.CreateHorizontalGroup(m_parentContent, new Color(1, 1, 1, 0));
var subGroup = m_subContent.GetComponent<HorizontalLayoutGroup>();
subGroup.childForceExpandWidth = true;
@ -352,11 +314,174 @@ namespace UnityExplorer.Inspectors.Reflection
m_subContent.SetActive(false);
// Construct InteractiveValue UI
// Construct InteractiveValue's actual UI
IValue.ConstructUI(m_rightGroup, m_subContent);
}
internal void ConstructArgInput(out GameObject argsHolder)
{
argsHolder = null;
if (HasParameters)
{
argsHolder = UIFactory.CreateVerticalGroup(m_rightGroup, new Color(1, 1, 1, 0));
var argsGroup = argsHolder.GetComponent<VerticalLayoutGroup>();
argsGroup.spacing = 4;
if (this is CacheMethod cm && cm.GenericArgs.Length > 0)
{
cm.ConstructGenericArgInput(argsHolder);
}
// todo normal args
if (m_arguments.Length > 0)
{
var titleObj = UIFactory.CreateLabel(argsHolder, TextAnchor.MiddleLeft);
var titleText = titleObj.GetComponent<Text>();
titleText.text = "<b>Arguments:</b>";
for (int i = 0; i < m_arguments.Length; i++)
{
AddArgRow(i, argsHolder);
}
}
argsHolder.SetActive(false);
}
}
internal void AddArgRow(int i, GameObject parent)
{
var arg = m_arguments[i];
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowLayout = rowObj.AddComponent<LayoutElement>();
rowLayout.minHeight = 25;
rowLayout.flexibleWidth = 5000;
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandHeight = true;
rowGroup.spacing = 4;
var argLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
//var argLayout = argLabelObj.AddComponent<LayoutElement>();
//argLayout.minWidth = 20;
var argText = argLabelObj.GetComponent<Text>();
var argTypeTxt = UISyntaxHighlight.ParseFullSyntax(arg.ParameterType, false);
argText.text = $"{argTypeTxt} <color={UISyntaxHighlight.Local}>{arg.Name}</color>";
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
var argInputLayout = argInputObj.AddComponent<LayoutElement>();
argInputLayout.flexibleWidth = 1200;
var argInput = argInputObj.GetComponent<InputField>();
argInput.onValueChanged.AddListener((string val) => { m_argumentInput[i] = val; });
if (arg.IsOptional)
{
var phInput = argInput.placeholder.GetComponent<Text>();
phInput.text = " = " + arg.DefaultValue?.ToString() ?? "null";
}
}
internal void ConstructEvaluateButtons(GameObject argsHolder)
{
if (HasParameters)
{
var evalGroupObj = UIFactory.CreateHorizontalGroup(m_rightGroup, new Color(1, 1, 1, 0));
var evalGroup = evalGroupObj.GetComponent<HorizontalLayoutGroup>();
evalGroup.childForceExpandWidth = false;
evalGroup.childForceExpandHeight = false;
evalGroup.spacing = 5;
var evalGroupLayout = evalGroupObj.AddComponent<LayoutElement>();
evalGroupLayout.minHeight = 25;
evalGroupLayout.flexibleHeight = 0;
evalGroupLayout.flexibleWidth = 5000;
var evalButtonObj = UIFactory.CreateButton(evalGroupObj, new Color(0.4f, 0.4f, 0.4f));
var evalLayout = evalButtonObj.AddComponent<LayoutElement>();
evalLayout.minWidth = 100;
evalLayout.minHeight = 22;
evalLayout.flexibleWidth = 0;
var evalText = evalButtonObj.GetComponentInChildren<Text>();
evalText.text = $"Evaluate ({ParamCount})";
var evalButton = evalButtonObj.GetComponent<Button>();
var colors = evalButton.colors;
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
evalButton.colors = colors;
var cancelButtonObj = UIFactory.CreateButton(evalGroupObj, new Color(0.6f, 0.3f, 0.3f));
var cancelLayout = cancelButtonObj.AddComponent<LayoutElement>();
cancelLayout.minWidth = 100;
cancelLayout.minHeight = 22;
cancelLayout.flexibleWidth = 0;
var cancelText = cancelButtonObj.GetComponentInChildren<Text>();
cancelText.text = "Cancel";
cancelButtonObj.SetActive(false);
evalButton.onClick.AddListener(() =>
{
if (!m_isEvaluating)
{
argsHolder.SetActive(true);
m_isEvaluating = true;
evalText.text = "Evaluate";
colors = evalButton.colors;
colors.normalColor = new Color(0.3f, 0.6f, 0.3f);
evalButton.colors = colors;
cancelButtonObj.SetActive(true);
}
else
{
if (this is CacheMethod cm)
cm.Evaluate();
else
UpdateValue();
}
});
var cancelButton = cancelButtonObj.GetComponent<Button>();
cancelButton.onClick.AddListener(() =>
{
cancelButtonObj.SetActive(false);
argsHolder.SetActive(false);
m_isEvaluating = false;
evalText.text = $"Evaluate ({ParamCount})";
colors = evalButton.colors;
colors.normalColor = new Color(0.4f, 0.4f, 0.4f);
evalButton.colors = colors;
});
}
else if (this is CacheMethod)
{
// simple method evaluate button
var evalButtonObj = UIFactory.CreateButton(m_rightGroup, new Color(0.3f, 0.6f, 0.3f));
var evalLayout = evalButtonObj.AddComponent<LayoutElement>();
evalLayout.minWidth = 100;
evalLayout.minHeight = 22;
evalLayout.flexibleWidth = 0;
var evalText = evalButtonObj.GetComponentInChildren<Text>();
evalText.text = "Evaluate";
var evalButton = evalButtonObj.GetComponent<Button>();
var colors = evalButton.colors;
colors.highlightedColor = new Color(0.4f, 0.7f, 0.4f);
evalButton.colors = colors;
evalButton.onClick.AddListener(OnMainEvaluateButton);
void OnMainEvaluateButton()
{
(this as CacheMethod).Evaluate();
}
}
}
#endregion
}
}

View File

@ -3,7 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityExplorer.UI.Shared;
using UnityEngine.UI;
using UnityExplorer.UI;
using UnityExplorer.Helpers;
namespace UnityExplorer.Inspectors.Reflection
@ -28,6 +29,7 @@ namespace UnityExplorer.Inspectors.Reflection
GenericArgs = methodInfo.GetGenericArguments();
GenericConstraints = GenericArgs.Select(x => x.GetGenericParameterConstraints())
.Where(x => x != null)
.ToArray();
m_genericArgInput = new string[GenericArgs.Length];
@ -77,7 +79,7 @@ namespace UnityExplorer.Inspectors.Reflection
}
IValue.Value = ret;
IValue.UpdateValue();
IValue.OnValueUpdated();
//if (ret != null)
//{
@ -133,5 +135,68 @@ namespace UnityExplorer.Inspectors.Reflection
return mi;
}
#region UI CONSTRUCTION
internal void ConstructGenericArgInput(GameObject parent)
{
var titleObj = UIFactory.CreateLabel(parent, TextAnchor.MiddleLeft);
var titleText = titleObj.GetComponent<Text>();
titleText.text = "<b>Generic Arguments:</b>";
for (int i = 0; i < GenericArgs.Length; i++)
{
AddGenericArgRow(i, parent);
}
}
internal void AddGenericArgRow(int i, GameObject parent)
{
var arg = GenericArgs[i];
string constrainTxt = "";
if (this.GenericConstraints[i].Length > 0)
{
foreach (var constraint in this.GenericConstraints[i])
{
if (constrainTxt != "")
constrainTxt += ", ";
constrainTxt += $"{UISyntaxHighlight.ParseFullSyntax(constraint, false)}";
}
}
else
constrainTxt = $"Any";
var rowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var rowLayout = rowObj.AddComponent<LayoutElement>();
rowLayout.minHeight = 25;
rowLayout.flexibleWidth = 5000;
var rowGroup = rowObj.GetComponent<HorizontalLayoutGroup>();
rowGroup.childForceExpandHeight = true;
rowGroup.spacing = 4;
var argLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
//var argLayout = argLabelObj.AddComponent<LayoutElement>();
//argLayout.minWidth = 20;
var argText = argLabelObj.GetComponent<Text>();
argText.text = $"{constrainTxt} <color={UISyntaxHighlight.Enum}>{arg.Name}</color>";
var argInputObj = UIFactory.CreateInputField(rowObj, 14, (int)TextAnchor.MiddleLeft, 1);
var argInputLayout = argInputObj.AddComponent<LayoutElement>();
argInputLayout.flexibleWidth = 1200;
var argInput = argInputObj.GetComponent<InputField>();
argInput.onValueChanged.AddListener((string val) => { m_genericArgInput[i] = val; });
//var constraintLabelObj = UIFactory.CreateLabel(rowObj, TextAnchor.MiddleLeft);
//var constraintLayout = constraintLabelObj.AddComponent<LayoutElement>();
//constraintLayout.minWidth = 60;
//constraintLayout.flexibleWidth = 100;
//var constraintText = constraintLabelObj.GetComponent<Text>();
//constraintText.text = ;
}
#endregion
}
}

View File

@ -24,14 +24,18 @@ namespace UnityExplorer.Inspectors.Reflection
{
if (valueType == null && value == null)
{
ExplorerCore.LogWarning("CacheObjectBase: Trying to init with no default value or valueType!");
ExplorerCore.Log(Environment.StackTrace);
return;
}
// TEMP
IValue = new InteractiveValue
// temp (havent made rest of InteractiveValue classes yet, just using base class always)
valueType = ReflectionHelpers.GetActualType(value) ?? valueType;
IValue = new InteractiveValue(valueType)
{
OwnerCacheObject = this,
ValueType = ReflectionHelpers.GetActualType(value) ?? valueType,
OwnerCacheObject = this
};
UpdateValue();
}
@ -45,6 +49,7 @@ namespace UnityExplorer.Inspectors.Reflection
}
m_mainContent.SetActive(true);
m_mainContent.transform.SetAsLastSibling();
}
public virtual void Disable()
@ -54,7 +59,7 @@ namespace UnityExplorer.Inspectors.Reflection
public virtual void UpdateValue()
{
IValue.UpdateValue();
IValue.OnValueUpdated();
}
public virtual void SetValue() => throw new NotImplementedException();

View File

@ -10,7 +10,7 @@ namespace UnityExplorer.Inspectors.Reflection
{
public class CacheProperty : CacheMember
{
public override bool IsStatic => (MemInfo as PropertyInfo).GetAccessors()[0].IsStatic;
public override bool IsStatic => (MemInfo as PropertyInfo).GetAccessors(true)[0].IsStatic;
public CacheProperty(PropertyInfo propertyInfo, object declaringInstance) : base(propertyInfo, declaringInstance)
{
@ -41,12 +41,9 @@ namespace UnityExplorer.Inspectors.Reflection
m_evaluated = true;
ReflectionException = null;
}
else // create a dummy value for Write-Only properties.
else
{
if (IValue.ValueType == typeof(string))
IValue.Value = "";
else
IValue.Value = Activator.CreateInstance(IValue.ValueType);
// todo write-only properties
}
}

View File

@ -1,26 +1,123 @@
using System;
using System.Reflection;
using UnityEngine;
using UnityExplorer.Helpers;
using UnityExplorer.UI;
using UnityEngine.UI;
namespace UnityExplorer.Inspectors.Reflection
{
public enum MemberScopes
{
All,
Instance,
Static
}
public class InstanceInspector : ReflectionInspector
{
public override string TabLabel => $" <color=cyan>[R]</color> {base.TabLabel}";
public InstanceInspector(object target) : base(target)
internal MemberScopes m_scopeFilter;
internal Button m_lastActiveScopeButton;
public InstanceInspector(object target) : base(target) { }
private void OnScopeFilterClicked(MemberScopes type, Button button)
{
// needed?
if (m_lastActiveScopeButton)
{
var lastColors = m_lastActiveScopeButton.colors;
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
m_lastActiveScopeButton.colors = lastColors;
}
m_scopeFilter = type;
m_lastActiveScopeButton = button;
var colors = m_lastActiveScopeButton.colors;
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
m_lastActiveScopeButton.colors = colors;
FilterMembers(null, true);
m_sliderScroller.m_slider.value = 1f;
}
public void ConstructInstanceHelpers(GameObject parent)
public void ConstructInstanceHelpers()
{
// todo
// On second thought, I'm not sure about this, seems unnecessary (and bloaty)
// I might do the Texture2D helper (view/save image) but idk about anything else.
//if (typeof(Component).IsAssignableFrom(m_targetType))
//{
// // component helpers (ref GO)
// var tempObj = UIFactory.CreateLabel(Content, TextAnchor.MiddleLeft);
// var text = tempObj.GetComponent<Text>();
// text.text = "TODO comp helpers";
//}
//else if (typeof(UnityEngine.Object).IsAssignableFrom(m_targetType))
//{
// // unityengine.object helpers (name, instantiate, destroy?)
// var tempObj = UIFactory.CreateLabel(Content, TextAnchor.MiddleLeft);
// var text = tempObj.GetComponent<Text>();
// text.text = "TODO unity object helpers";
//}
}
public void ConstructInstanceFilters(GameObject parent)
{
// todo
var memberFilterRowObj = UIFactory.CreateHorizontalGroup(parent, new Color(1, 1, 1, 0));
var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>();
memFilterGroup.childForceExpandHeight = false;
memFilterGroup.childForceExpandWidth = false;
memFilterGroup.childControlWidth = true;
memFilterGroup.childControlHeight = true;
memFilterGroup.spacing = 5;
var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>();
memFilterLayout.minHeight = 25;
memFilterLayout.flexibleHeight = 0;
memFilterLayout.flexibleWidth = 5000;
var memLabelObj = UIFactory.CreateLabel(memberFilterRowObj, TextAnchor.MiddleLeft);
var memLabelLayout = memLabelObj.AddComponent<LayoutElement>();
memLabelLayout.minWidth = 100;
memLabelLayout.minHeight = 25;
memLabelLayout.flexibleWidth = 0;
var memLabelText = memLabelObj.GetComponent<Text>();
memLabelText.text = "Filter scope:";
memLabelText.color = Color.grey;
AddFilterButton(memberFilterRowObj, MemberScopes.All, true);
AddFilterButton(memberFilterRowObj, MemberScopes.Instance);
AddFilterButton(memberFilterRowObj, MemberScopes.Static);
}
private void AddFilterButton(GameObject parent, MemberScopes type, bool setEnabled = false)
{
var btnObj = UIFactory.CreateButton(parent, new Color(0.2f, 0.2f, 0.2f));
var btnLayout = btnObj.AddComponent<LayoutElement>();
btnLayout.minHeight = 25;
btnLayout.minWidth = 70;
var text = btnObj.GetComponentInChildren<Text>();
text.text = type.ToString();
var btn = btnObj.GetComponent<Button>();
btn.onClick.AddListener(() => { OnScopeFilterClicked(type, btn); });
var colors = btn.colors;
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
if (setEnabled)
{
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
m_scopeFilter = type;
m_lastActiveScopeButton = btn;
}
btn.colors = colors;
}
}
}

View File

@ -7,17 +7,20 @@ using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityExplorer.Helpers;
using UnityExplorer.UI;
using UnityExplorer.UI.Shared;
using UnityExplorer.Unstrip;
namespace UnityExplorer.Inspectors.Reflection
{
public class InteractiveValue
{
public InteractiveValue(Type valueType)
{
this.ValueType = valueType;
}
public CacheObjectBase OwnerCacheObject;
public object Value { get; set; }
public Type ValueType;
public readonly Type ValueType;
// might not need
public virtual bool HasSubContent => false;
@ -31,10 +34,10 @@ namespace UnityExplorer.Inspectors.Reflection
public virtual void Init()
{
UpdateValue();
OnValueUpdated();
}
public virtual void UpdateValue()
public virtual void OnValueUpdated()
{
if (!m_text)
return;
@ -55,10 +58,9 @@ namespace UnityExplorer.Inspectors.Reflection
public string GetLabelForValue()
{
if (Value != null)
ValueType = Value.GetType();
var valueType = Value?.GetType() ?? this.ValueType;
m_richValueType = UISyntaxHighlight.ParseFullSyntax(ValueType, true);
m_richValueType = UISyntaxHighlight.ParseFullSyntax(valueType, true);
if (OwnerCacheObject is CacheMember cm && !cm.HasEvaluated)
return $"<i><color=grey>Not yet evaluated</color> ({m_richValueType})</i>";
@ -67,7 +69,7 @@ namespace UnityExplorer.Inspectors.Reflection
string label;
if (ValueType == typeof(TextAsset) && Value is TextAsset textAsset)
if (valueType == typeof(TextAsset) && Value is TextAsset textAsset)
{
label = textAsset.text;
@ -76,7 +78,7 @@ namespace UnityExplorer.Inspectors.Reflection
label = $"\"{label}\" {textAsset.name} ({m_richValueType})";
}
else if (ValueType == typeof(EventSystem))
else if (valueType == typeof(EventSystem))
{
label = m_richValueType;
}
@ -84,7 +86,7 @@ namespace UnityExplorer.Inspectors.Reflection
{
var toString = (string)ToStringMethod.Invoke(Value, null);
var fullnametemp = ValueType.ToString();
var fullnametemp = valueType.ToString();
if (fullnametemp.StartsWith("Il2CppSystem"))
fullnametemp = fullnametemp.Substring(6, fullnametemp.Length - 6);
@ -101,7 +103,7 @@ namespace UnityExplorer.Inspectors.Reflection
label = toString;
var unityType = $"({ValueType.FullName})";
var unityType = $"({valueType.FullName})";
if (Value is UnityEngine.Object && label.Contains(unityType))
label = label.Replace(unityType, $"({m_richValueType})");
else

View File

@ -58,22 +58,22 @@ namespace UnityExplorer.Inspectors
#endregion
#region INSTANCE
#region INSTANCE
public override string TabLabel => m_targetTypeShortName;
public bool AutoUpdate { get; set; }
internal readonly Type m_targetType;
internal readonly string m_targetTypeShortName;
// all cached members of the target
internal CacheMember[] m_allMembers;
// filtered members based on current filters
internal CacheMember[] m_membersFiltered;
internal readonly List<CacheMember> m_membersFiltered = new List<CacheMember>();
// actual shortlist of displayed members
internal readonly CacheMember[] m_displayedMembers = new CacheMember[ModConfig.Instance.Default_Page_Limit];
internal bool m_autoUpdate;
// UI members
private GameObject m_content;
@ -84,6 +84,8 @@ namespace UnityExplorer.Inspectors
}
internal Text m_nameFilterText;
internal MemberTypes m_memberFilter;
internal Button m_lastActiveMemButton;
internal PageHandler m_pageHandler;
internal SliderScrollbar m_sliderScroller;
@ -138,14 +140,35 @@ namespace UnityExplorer.Inspectors
RefreshDisplay();
}
private void OnMemberFilterClicked(MemberTypes type, Button button)
{
if (m_lastActiveMemButton)
{
var lastColors = m_lastActiveMemButton.colors;
lastColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
m_lastActiveMemButton.colors = lastColors;
}
m_memberFilter = type;
m_lastActiveMemButton = button;
var colors = m_lastActiveMemButton.colors;
colors.normalColor = new Color(0.2f, 0.6f, 0.2f);
m_lastActiveMemButton.colors = colors;
FilterMembers(null, true);
m_sliderScroller.m_slider.value = 1f;
}
public override void Update()
{
base.Update();
if (AutoUpdate)
if (m_autoUpdate)
{
foreach (var member in m_displayedMembers)
{
if (member == null) break;
member.UpdateValue();
}
}
@ -163,32 +186,42 @@ namespace UnityExplorer.Inspectors
}
}
public void FilterMembers(string nameFilter = null)
public void FilterMembers(string nameFilter = null, bool force = false)
{
var list = new List<CacheMember>();
int lastCount = m_membersFiltered.Count;
m_membersFiltered.Clear();
nameFilter = nameFilter?.ToLower() ?? m_nameFilterText.text.ToLower();
foreach (var mem in m_allMembers)
{
// name filter
if (!string.IsNullOrEmpty(nameFilter) && !mem.NameForFiltering.Contains(nameFilter))
// membertype filter
if (m_memberFilter != MemberTypes.All && mem.MemInfo.MemberType != m_memberFilter)
continue;
list.Add(mem);
if (this is InstanceInspector ii && ii.m_scopeFilter != MemberScopes.All)
{
if (mem.IsStatic && ii.m_scopeFilter != MemberScopes.Static)
continue;
else if (!mem.IsStatic && ii.m_scopeFilter != MemberScopes.Instance)
continue;
}
// name filter
if (!string.IsNullOrEmpty(nameFilter) && !mem.NameForFiltering.Contains(nameFilter))
continue;
m_membersFiltered.Add(mem);
}
if (m_membersFiltered == null || m_membersFiltered.Length != list.Count)
{
m_membersFiltered = list.ToArray();
if (force || lastCount != m_membersFiltered.Count)
RefreshDisplay();
}
}
public void RefreshDisplay()
{
var members = m_membersFiltered;
m_pageHandler.ListCount = members.Length;
m_pageHandler.ListCount = members.Count;
// disable current members
for (int i = 0; i < m_displayedMembers.Length; i++)
@ -200,12 +233,12 @@ namespace UnityExplorer.Inspectors
break;
}
if (members.Length < 1)
if (members.Count < 1)
return;
foreach (var itemIndex in m_pageHandler)
{
if (itemIndex >= members.Length)
if (itemIndex >= members.Count)
break;
CacheMember member = members[itemIndex];
@ -362,7 +395,7 @@ namespace UnityExplorer.Inspectors
// ExplorerCore.Log("Cached " + m_allMembers.Length + " members");
}
#region UI CONSTRUCTION
#region UI CONSTRUCTION
internal void ConstructUI()
{
@ -386,17 +419,7 @@ namespace UnityExplorer.Inspectors
internal void ConstructTopArea()
{
var topGroupObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
var topGroup = topGroupObj.GetComponent<VerticalLayoutGroup>();
topGroup.childForceExpandWidth = true;
topGroup.childForceExpandHeight = true;
topGroup.childControlWidth = true;
topGroup.childControlHeight = true;
topGroup.spacing = 8;
topGroup.padding.left = 4;
topGroup.padding.right = 4;
var nameRowObj = UIFactory.CreateHorizontalGroup(topGroupObj, new Color(1, 1, 1, 0));
var nameRowObj = UIFactory.CreateHorizontalGroup(Content, new Color(1, 1, 1, 0));
var nameRow = nameRowObj.GetComponent<HorizontalLayoutGroup>();
nameRow.childForceExpandWidth = true;
nameRow.childForceExpandHeight = true;
@ -429,20 +452,31 @@ namespace UnityExplorer.Inspectors
if (this is InstanceInspector)
{
(this as InstanceInspector).ConstructInstanceHelpers(topGroupObj);
(this as InstanceInspector).ConstructInstanceHelpers();
}
ConstructFilterArea();
ConstructOptionsArea();
}
internal void ConstructFilterArea()
{
// Filters
var filterAreaObj = UIFactory.CreateVerticalGroup(topGroupObj, new Color(1,1,1,0));
var filterAreaObj = UIFactory.CreateVerticalGroup(Content, new Color(0.1f, 0.1f, 0.1f));
var filterLayout = filterAreaObj.AddComponent<LayoutElement>();
filterLayout.minHeight = 60;
var filterGroup = filterAreaObj.GetComponent<VerticalLayoutGroup>();
filterGroup.childForceExpandWidth = true;
filterGroup.childForceExpandHeight = false;
filterGroup.childForceExpandHeight = true;
filterGroup.childControlWidth = true;
filterGroup.childControlHeight = true;
filterGroup.spacing = 4;
filterGroup.padding.left = 4;
filterGroup.padding.right = 4;
filterGroup.padding.top = 4;
filterGroup.padding.bottom = 4;
// name filter
@ -460,11 +494,12 @@ namespace UnityExplorer.Inspectors
var nameLabelObj = UIFactory.CreateLabel(nameFilterRowObj, TextAnchor.MiddleLeft);
var nameLabelLayout = nameLabelObj.AddComponent<LayoutElement>();
nameLabelLayout.minWidth = 130;
nameLabelLayout.minWidth = 100;
nameLabelLayout.minHeight = 25;
nameLabelLayout.flexibleWidth = 0;
var nameLabelText = nameLabelObj.GetComponent<Text>();
nameLabelText.text = "Name contains:";
nameLabelText.text = "Filter names:";
nameLabelText.color = Color.grey;
var nameInputObj = UIFactory.CreateInputField(nameFilterRowObj, 14, (int)TextAnchor.MiddleLeft, (int)HorizontalWrapMode.Overflow);
var nameInputLayout = nameInputObj.AddComponent<LayoutElement>();
@ -477,7 +512,31 @@ namespace UnityExplorer.Inspectors
// membertype filter
var memberFilterRowObj = UIFactory.CreateHorizontalGroup(filterAreaObj, new Color(1, 1, 1, 0));
var memFilterGroup = memberFilterRowObj.GetComponent<HorizontalLayoutGroup>();
memFilterGroup.childForceExpandHeight = false;
memFilterGroup.childForceExpandWidth = false;
memFilterGroup.childControlWidth = true;
memFilterGroup.childControlHeight = true;
memFilterGroup.spacing = 5;
var memFilterLayout = memberFilterRowObj.AddComponent<LayoutElement>();
memFilterLayout.minHeight = 25;
memFilterLayout.flexibleHeight = 0;
memFilterLayout.flexibleWidth = 5000;
var memLabelObj = UIFactory.CreateLabel(memberFilterRowObj, TextAnchor.MiddleLeft);
var memLabelLayout = memLabelObj.AddComponent<LayoutElement>();
memLabelLayout.minWidth = 100;
memLabelLayout.minHeight = 25;
memLabelLayout.flexibleWidth = 0;
var memLabelText = memLabelObj.GetComponent<Text>();
memLabelText.text = "Filter members:";
memLabelText.color = Color.grey;
AddFilterButton(memberFilterRowObj, MemberTypes.All);
AddFilterButton(memberFilterRowObj, MemberTypes.Method);
AddFilterButton(memberFilterRowObj, MemberTypes.Property, true);
AddFilterButton(memberFilterRowObj, MemberTypes.Field);
// Instance filters
@ -487,6 +546,73 @@ namespace UnityExplorer.Inspectors
}
}
private void AddFilterButton(GameObject parent, MemberTypes type, bool setEnabled = false)
{
var btnObj = UIFactory.CreateButton(parent, new Color(0.2f, 0.2f, 0.2f));
var btnLayout = btnObj.AddComponent<LayoutElement>();
btnLayout.minHeight = 25;
btnLayout.minWidth = 70;
var text = btnObj.GetComponentInChildren<Text>();
text.text = type.ToString();
var btn = btnObj.GetComponent<Button>();
btn.onClick.AddListener(() => { OnMemberFilterClicked(type, btn); });
var colors = btn.colors;
colors.highlightedColor = new Color(0.3f, 0.7f, 0.3f);
if (setEnabled)
{
colors.normalColor = new Color(0.2f, 0.4f, 0.2f);
m_memberFilter = type;
m_lastActiveMemButton = btn;
}
btn.colors = colors;
}
internal void ConstructOptionsArea()
{
var optionsRowObj = UIFactory.CreateHorizontalGroup(Content, new Color(1,1,1,0));
var optionsLayout = optionsRowObj.AddComponent<LayoutElement>();
optionsLayout.minHeight = 25;
var optionsGroup = optionsRowObj.GetComponent<HorizontalLayoutGroup>();
optionsGroup.childForceExpandHeight = true;
optionsGroup.childForceExpandWidth = false;
optionsGroup.childAlignment = TextAnchor.MiddleLeft;
optionsGroup.spacing = 10;
// update button
var updateButtonObj = UIFactory.CreateButton(optionsRowObj, new Color(0.2f, 0.2f, 0.2f));
var updateBtnLayout = updateButtonObj.AddComponent<LayoutElement>();
updateBtnLayout.minWidth = 110;
updateBtnLayout.flexibleWidth = 0;
var updateText = updateButtonObj.GetComponentInChildren<Text>();
updateText.text = "Update Values";
var updateBtn = updateButtonObj.GetComponent<Button>();
updateBtn.onClick.AddListener(() =>
{
bool orig = m_autoUpdate;
m_autoUpdate = true;
Update();
if (!orig) m_autoUpdate = orig;
});
// auto update
var autoUpdateObj = UIFactory.CreateToggle(optionsRowObj, out Toggle autoUpdateToggle, out Text autoUpdateText);
var autoUpdateLayout = autoUpdateObj.AddComponent<LayoutElement>();
autoUpdateLayout.minWidth = 150;
autoUpdateLayout.minHeight = 25;
autoUpdateText.text = "Auto-update?";
autoUpdateToggle.isOn = false;
autoUpdateToggle.onValueChanged.AddListener((bool val) => { m_autoUpdate = val; });
}
internal void ConstructMemberList()
{
var scrollobj = UIFactory.CreateScrollView(Content, out m_scrollContent, out m_sliderScroller, new Color(0.12f, 0.12f, 0.12f));
@ -503,8 +629,8 @@ namespace UnityExplorer.Inspectors
m_pageHandler.OnPageChanged += OnPageTurned;
}
#endregion
#endregion // end UI
#endregion
#endregion // end instance
}
}

View File

@ -6,9 +6,6 @@ namespace UnityExplorer.Inspectors.Reflection
{
public override string TabLabel => $" <color=cyan>[S]</color> {base.TabLabel}";
public StaticInspector(Type type) : base(type)
{
// needed?
}
public StaticInspector(Type type) : base(type) { }
}
}

View File

@ -430,23 +430,26 @@ namespace UnityExplorer.Inspectors
Hiding = true;
hideText.text = "►";
leftLayout.minWidth = 15;
titleObj.SetActive(false);
sceneDropdownObj.SetActive(false);
scenePathGroupObj.SetActive(false);
scrollObj.SetActive(false);
m_sceneListPageHandler.Hide();
leftLayout.minWidth = 15;
}
else
{
Hiding = false;
hideText.text = "Hide Scene Explorer";
leftLayout.minWidth = 350;
titleObj.SetActive(true);
sceneDropdownObj.SetActive(true);
scenePathGroupObj.SetActive(true);
scrollObj.SetActive(true);
leftLayout.minWidth = 350;
Update();
}

View File

@ -34,7 +34,7 @@ namespace UnityExplorer.Tests
}
private static bool m_setOnlyProperty;
public Texture2D TestTexture;
public Texture TestTexture;
public static Sprite TestSprite;
public static int StaticProperty => 5;
@ -54,7 +54,7 @@ namespace UnityExplorer.Tests
var r = new Rect(0, 0, TestTexture.width, TestTexture.height);
var v2 = Vector2.zero;
var v4 = Vector4.zero;
TestSprite = Sprite.CreateSprite_Injected(TestTexture, ref r, ref v2, 100f, 0u, SpriteMeshType.Tight, ref v4, false);
TestSprite = Sprite.CreateSprite_Injected((Texture2D)TestTexture, ref r, ref v2, 100f, 0u, SpriteMeshType.Tight, ref v4, false);
GameObject.DontDestroyOnLoad(TestTexture);
GameObject.DontDestroyOnLoad(TestSprite);
@ -70,7 +70,7 @@ namespace UnityExplorer.Tests
#endif
}
public static string TestRefInOutGeneric<T>(ref string arg0, in int arg1, out string arg2)
public static string TestRefInOutGeneric<T>(ref string arg0, in int arg1, out string arg2) where T : Component
{
arg2 = "this is arg2";

View File

@ -195,9 +195,7 @@ namespace UnityExplorer.UI
Text text = textObj.GetComponent<Text>();
text.text = $"<b>UnityExplorer</b> <i>v{ExplorerCore.VERSION}</i>";
text.resizeTextForBestFit = true;
text.resizeTextMinSize = 12;
text.resizeTextMaxSize = 20;
text.fontSize = 15;
LayoutElement textLayout = textObj.AddComponent<LayoutElement>();
textLayout.flexibleWidth = 5000;

View File

@ -4,6 +4,7 @@ using UnityEngine;
using UnityEngine.UI;
using UnityExplorer.Input;
using System.IO;
using UnityExplorer.Inspectors;
#if CPP
using UnityExplorer.Unstrip;
#endif
@ -27,6 +28,8 @@ namespace UnityExplorer.UI
Panel = panelToDrag;
UpdateResizeCache();
SceneExplorer.OnToggleShow += OnEndResize;
}
public void Update()
@ -133,7 +136,7 @@ namespace UnityExplorer.UI
private const int RESIZE_THICKNESS = 15;
private readonly Vector2 minResize = new Vector2(630, 540);
internal readonly Vector2 minResize = new Vector2(400, 400);
private bool WasResizing { get; set; }
private ResizeTypes m_currentResizeType = ResizeTypes.NONE;
@ -172,26 +175,20 @@ namespace UnityExplorer.UI
int halfThick = RESIZE_THICKNESS / 2;
int dblThick = RESIZE_THICKNESS * 2;
// calculate main outer rect
// the resize area is both outside and inside the panel,
// to give a bit of buffer and make it easier to use.
// outer rect is the outer-most bounds of our resize area
Rect outer = new Rect(Panel.rect.x - halfThick,
m_resizeRect = new Rect(Panel.rect.x - halfThick,
Panel.rect.y - halfThick,
Panel.rect.width + dblThick,
Panel.rect.height + dblThick);
m_resizeRect = outer;
// calculate the four cross sections to use as flags
m_resizeMask[ResizeTypes.Bottom] = new Rect(outer.x, outer.y, outer.width, RESIZE_THICKNESS);
m_resizeMask[ResizeTypes.Bottom] = new Rect(m_resizeRect.x, m_resizeRect.y, m_resizeRect.width, RESIZE_THICKNESS);
m_resizeMask[ResizeTypes.Left] = new Rect(outer.x, outer.y, RESIZE_THICKNESS, outer.height);
m_resizeMask[ResizeTypes.Left] = new Rect(m_resizeRect.x, m_resizeRect.y, RESIZE_THICKNESS, m_resizeRect.height);
m_resizeMask[ResizeTypes.Top] = new Rect(outer.x, outer.y + Panel.rect.height, outer.width, RESIZE_THICKNESS);
m_resizeMask[ResizeTypes.Top] = new Rect(m_resizeRect.x, m_resizeRect.y + Panel.rect.height, m_resizeRect.width, RESIZE_THICKNESS);
m_resizeMask[ResizeTypes.Right] = new Rect(outer.x + Panel.rect.width, outer.y, RESIZE_THICKNESS, outer.height);
m_resizeMask[ResizeTypes.Right] = new Rect(m_resizeRect.x + Panel.rect.width, m_resizeRect.y, RESIZE_THICKNESS, m_resizeRect.height);
}
private bool MouseInResizeArea(Vector2 mousePos)
@ -298,6 +295,9 @@ namespace UnityExplorer.UI
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
anchorMin.y -= diffY;
//Panel.anchorMin = new Vector2(anchorMin.x, anchorMin.y);
//Panel.anchorMax = new Vector2(anchorMax.x, anchorMax.y);
var newWidth = (anchorMax.x - anchorMin.x) * Screen.width;
var newHeight = (anchorMax.y - anchorMin.y) * Screen.height;

View File

@ -93,6 +93,9 @@ namespace UnityExplorer.UI
rect.anchoredPosition = Vector2.zero;
rect.sizeDelta = Vector2.zero;
var img = panelObj.AddComponent<Image>();
img.color = Color.white;
VerticalLayoutGroup group = panelObj.AddComponent<VerticalLayoutGroup>();
group.childControlHeight = true;
group.childControlWidth = true;
@ -106,8 +109,6 @@ namespace UnityExplorer.UI
image2.type = Image.Type.Filled;
image2.color = new Color(0.1f, 0.1f, 0.1f);
content.gameObject.AddComponent<Mask>();
VerticalLayoutGroup group2 = content.AddComponent<VerticalLayoutGroup>();
group2.padding.left = 3;
group2.padding.right = 3;
@ -150,7 +151,8 @@ namespace UnityExplorer.UI
VerticalLayoutGroup horiGroup = groupObj.AddComponent<VerticalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = false;
horiGroup.childControlWidth = true;
horiGroup.childControlHeight = true;
Image image = groupObj.AddComponent<Image>();
if (color != default)
@ -171,7 +173,8 @@ namespace UnityExplorer.UI
HorizontalLayoutGroup horiGroup = groupObj.AddComponent<HorizontalLayoutGroup>();
horiGroup.childAlignment = TextAnchor.UpperLeft;
horiGroup.childControlWidth = false;
horiGroup.childControlWidth = true;
horiGroup.childControlHeight = true;
Image image = groupObj.AddComponent<Image>();
if (color != default)
@ -327,7 +330,7 @@ namespace UnityExplorer.UI
return scrollObj;
}
public static GameObject CreateToggle(GameObject parent, out Toggle toggle, out Text text)
public static GameObject CreateToggle(GameObject parent, out Toggle toggle, out Text text, Color bgColor = default)
{
GameObject toggleObj = CreateUIObject("Toggle", parent, thinSize);
@ -336,7 +339,7 @@ namespace UnityExplorer.UI
GameObject labelObj = CreateUIObject("Label", toggleObj);
toggle = toggleObj.AddComponent<Toggle>();
toggle.isOn = true;
//toggle.isOn = true;
Toggle toggleComp = toggle;
toggle.onValueChanged.AddListener(Deselect);
@ -346,11 +349,12 @@ namespace UnityExplorer.UI
}
Image bgImage = bgObj.AddComponent<Image>();
bgImage.type = Image.Type.Sliced;
bgImage.color = new Color(0.1f, 0.1f, 0.1f, 1.0f);
bgImage.color = bgColor == default
? new Color(0.2f, 0.2f, 0.2f, 1.0f)
: bgColor;
Image checkImage = checkObj.AddComponent<Image>();
checkImage.color = new Color(90f / 255f, 115f / 255f, 90f / 255f, 1.0f);
checkImage.color = new Color(0.3f, 0.5f, 0.3f, 1.0f);
text = labelObj.AddComponent<Text>();
text.text = "Toggle";
@ -363,7 +367,7 @@ namespace UnityExplorer.UI
RectTransform bgRect = bgObj.GetComponent<RectTransform>();
bgRect.anchorMin = new Vector2(0f, 1f);
bgRect.anchorMax = new Vector2(0f, 1f);
bgRect.anchoredPosition = new Vector2(10f, -10f);
bgRect.anchoredPosition = new Vector2(13f, -13f);
bgRect.sizeDelta = new Vector2(20f, 20f);
RectTransform checkRect = checkObj.GetComponent<RectTransform>();
@ -375,8 +379,8 @@ namespace UnityExplorer.UI
RectTransform labelRect = labelObj.GetComponent<RectTransform>();
labelRect.anchorMin = new Vector2(0f, 0f);
labelRect.anchorMax = new Vector2(1f, 1f);
labelRect.offsetMin = new Vector2(23f, 1f);
labelRect.offsetMax = new Vector2(-5f, -2f);
labelRect.offsetMin = new Vector2(28f, 2f);
labelRect.offsetMax = new Vector2(-5f, -5f);
return toggleObj;
}

View File

@ -1,14 +1,16 @@
#if CPP
using System;
using System;
using System.IO;
using UnityExplorer.Helpers;
using UnhollowerBaseLib;
using UnityEngine;
#if CPP
using UnhollowerBaseLib;
#endif
namespace UnityExplorer.Unstrip
{
public static class ImageConversionUnstrip
{
#if CPP
// byte[] ImageConversion.EncodeToPNG(this Texture2D image);
internal delegate IntPtr d_EncodeToPNG(IntPtr tex);
@ -36,6 +38,7 @@ namespace UnityExplorer.Unstrip
return ret;
}
#endif
// Helper for LoadImage from filepath
@ -50,6 +53,4 @@ namespace UnityExplorer.Unstrip
return tex.LoadImage(data, markNonReadable);
}
}
}
#endif
}