mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
Automatic code cleanup (no real changes)
- Use explicit type of var - Use 'new()' - Remove unnecessary usings - Sort usings - Apply formatting
This commit is contained in:
@ -2,18 +2,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniverseLib.Input;
|
||||
using UnityExplorer.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UnityExplorer.UI.Widgets;
|
||||
using UnityExplorer.UI.Widgets.AutoComplete;
|
||||
using UniverseLib.UI.Widgets;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UniverseLib.UI.Widgets;
|
||||
using UniverseLib.UI.Widgets.ScrollView;
|
||||
using UniverseLib.Utility;
|
||||
|
||||
@ -29,7 +26,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public TransformTree TransformTree;
|
||||
private ScrollPool<TransformCell> transformScroll;
|
||||
private readonly List<GameObject> cachedChildren = new List<GameObject>();
|
||||
private readonly List<GameObject> cachedChildren = new();
|
||||
|
||||
public ComponentList ComponentList;
|
||||
private ScrollPool<ComponentCell> componentScroll;
|
||||
@ -127,10 +124,10 @@ namespace UnityExplorer.Inspectors
|
||||
return cachedChildren;
|
||||
}
|
||||
|
||||
private readonly List<Component> componentEntries = new List<Component>();
|
||||
private readonly HashSet<int> compInstanceIDs = new HashSet<int>();
|
||||
private readonly List<Behaviour> behaviourEntries = new List<Behaviour>();
|
||||
private readonly List<bool> behaviourEnabledStates = new List<bool>();
|
||||
private readonly List<Component> componentEntries = new();
|
||||
private readonly HashSet<int> compInstanceIDs = new();
|
||||
private readonly List<Behaviour> behaviourEntries = new();
|
||||
private readonly List<bool> behaviourEnabledStates = new();
|
||||
|
||||
// ComponentList.GetRootEntriesMethod
|
||||
private List<Component> GetComponentEntries() => GOTarget ? componentEntries : Enumerable.Empty<Component>().ToList();
|
||||
@ -149,13 +146,13 @@ namespace UnityExplorer.Inspectors
|
||||
}
|
||||
|
||||
// Check if we actually need to refresh the component cells or not.
|
||||
var comps = GOTarget.GetComponents<Component>();
|
||||
var behaviours = GOTarget.GetComponents<Behaviour>();
|
||||
IEnumerable<Component> comps = GOTarget.GetComponents<Component>();
|
||||
IEnumerable<Behaviour> behaviours = GOTarget.GetComponents<Behaviour>();
|
||||
|
||||
bool needRefresh = false;
|
||||
|
||||
int count = 0;
|
||||
foreach (var comp in comps)
|
||||
foreach (Component comp in comps)
|
||||
{
|
||||
if (!comp)
|
||||
continue;
|
||||
@ -173,7 +170,7 @@ namespace UnityExplorer.Inspectors
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
foreach (var behaviour in behaviours)
|
||||
foreach (Behaviour behaviour in behaviours)
|
||||
{
|
||||
if (!behaviour)
|
||||
continue;
|
||||
@ -194,7 +191,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
componentEntries.Clear();
|
||||
compInstanceIDs.Clear();
|
||||
foreach (var comp in comps)
|
||||
foreach (Component comp in comps)
|
||||
{
|
||||
if (!comp) continue;
|
||||
componentEntries.Add(comp);
|
||||
@ -203,7 +200,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
behaviourEntries.Clear();
|
||||
behaviourEnabledStates.Clear();
|
||||
foreach (var behaviour in behaviours)
|
||||
foreach (Behaviour behaviour in behaviours)
|
||||
{
|
||||
if (!behaviour) continue;
|
||||
behaviourEntries.Add(behaviour);
|
||||
@ -217,7 +214,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void OnAddChildClicked(string input)
|
||||
{
|
||||
var newObject = new GameObject(input);
|
||||
GameObject newObject = new(input);
|
||||
newObject.transform.parent = GOTarget.transform;
|
||||
|
||||
TransformTree.RefreshData(true, false, true, false);
|
||||
@ -250,7 +247,7 @@ namespace UnityExplorer.Inspectors
|
||||
UIRoot = UIFactory.CreateVerticalGroup(parent, "GameObjectInspector", true, false, true, true, 5,
|
||||
new Vector4(4, 4, 4, 4), new Color(0.065f, 0.065f, 0.065f));
|
||||
|
||||
var scrollObj = UIFactory.CreateScrollView(UIRoot, "GameObjectInspector", out Content, out var scrollbar,
|
||||
GameObject scrollObj = UIFactory.CreateScrollView(UIRoot, "GameObjectInspector", out Content, out AutoSliderScrollbar scrollbar,
|
||||
new Color(0.065f, 0.065f, 0.065f));
|
||||
UIFactory.SetLayoutElement(scrollObj, minHeight: 250, preferredHeight: 300, flexibleHeight: 0, flexibleWidth: 9999);
|
||||
|
||||
@ -268,27 +265,27 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void ConstructLists()
|
||||
{
|
||||
var listHolder = UIFactory.CreateUIObject("ListHolders", UIRoot);
|
||||
GameObject listHolder = UIFactory.CreateUIObject("ListHolders", UIRoot);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(listHolder, false, true, true, true, 8, 2, 2, 2, 2);
|
||||
UIFactory.SetLayoutElement(listHolder, minHeight: 150, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||
|
||||
// Left group (Children)
|
||||
|
||||
var leftGroup = UIFactory.CreateUIObject("ChildrenGroup", listHolder);
|
||||
GameObject leftGroup = UIFactory.CreateUIObject("ChildrenGroup", listHolder);
|
||||
UIFactory.SetLayoutElement(leftGroup, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(leftGroup, false, false, true, true, 2);
|
||||
|
||||
var childrenLabel = UIFactory.CreateLabel(leftGroup, "ChildListTitle", "Children", TextAnchor.MiddleCenter, default, false, 16);
|
||||
Text childrenLabel = UIFactory.CreateLabel(leftGroup, "ChildListTitle", "Children", TextAnchor.MiddleCenter, default, false, 16);
|
||||
UIFactory.SetLayoutElement(childrenLabel.gameObject, flexibleWidth: 9999);
|
||||
|
||||
// Add Child
|
||||
var addChildRow = UIFactory.CreateUIObject("AddChildRow", leftGroup);
|
||||
GameObject addChildRow = UIFactory.CreateUIObject("AddChildRow", leftGroup);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(addChildRow, false, false, true, true, 2);
|
||||
|
||||
addChildInput = UIFactory.CreateInputField(addChildRow, "AddChildInput", "Enter a name...");
|
||||
UIFactory.SetLayoutElement(addChildInput.Component.gameObject, minHeight: 25, preferredWidth: 9999);
|
||||
|
||||
var addChildButton = UIFactory.CreateButton(addChildRow, "AddChildButton", "Add Child");
|
||||
ButtonRef addChildButton = UIFactory.CreateButton(addChildRow, "AddChildButton", "Add Child");
|
||||
UIFactory.SetLayoutElement(addChildButton.Component.gameObject, minHeight: 25, minWidth: 80);
|
||||
addChildButton.OnClick += () => { OnAddChildClicked(addChildInput.Text); };
|
||||
|
||||
@ -305,21 +302,21 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// Right group (Components)
|
||||
|
||||
var rightGroup = UIFactory.CreateUIObject("ComponentGroup", listHolder);
|
||||
GameObject rightGroup = UIFactory.CreateUIObject("ComponentGroup", listHolder);
|
||||
UIFactory.SetLayoutElement(rightGroup, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(rightGroup, false, false, true, true, 2);
|
||||
|
||||
var compLabel = UIFactory.CreateLabel(rightGroup, "CompListTitle", "Components", TextAnchor.MiddleCenter, default, false, 16);
|
||||
Text compLabel = UIFactory.CreateLabel(rightGroup, "CompListTitle", "Components", TextAnchor.MiddleCenter, default, false, 16);
|
||||
UIFactory.SetLayoutElement(compLabel.gameObject, flexibleWidth: 9999);
|
||||
|
||||
// Add Comp
|
||||
var addCompRow = UIFactory.CreateUIObject("AddCompRow", rightGroup);
|
||||
GameObject addCompRow = UIFactory.CreateUIObject("AddCompRow", rightGroup);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(addCompRow, false, false, true, true, 2);
|
||||
|
||||
addCompInput = UIFactory.CreateInputField(addCompRow, "AddCompInput", "Enter a Component type...");
|
||||
UIFactory.SetLayoutElement(addCompInput.Component.gameObject, minHeight: 25, preferredWidth: 9999);
|
||||
|
||||
var addCompButton = UIFactory.CreateButton(addCompRow, "AddCompButton", "Add Comp");
|
||||
ButtonRef addCompButton = UIFactory.CreateButton(addCompRow, "AddCompButton", "Add Comp");
|
||||
UIFactory.SetLayoutElement(addCompButton.Component.gameObject, minHeight: 25, minWidth: 80);
|
||||
addCompButton.OnClick += () => { OnAddComponentClicked(addCompInput.Text); };
|
||||
|
||||
@ -333,8 +330,10 @@ namespace UnityExplorer.Inspectors
|
||||
UIFactory.SetLayoutElement(compObj, flexibleHeight: 9999);
|
||||
UIFactory.SetLayoutElement(compContent, flexibleHeight: 9999);
|
||||
|
||||
ComponentList = new ComponentList(componentScroll, GetComponentEntries);
|
||||
ComponentList.Parent = this;
|
||||
ComponentList = new ComponentList(componentScroll, GetComponentEntries)
|
||||
{
|
||||
Parent = this
|
||||
};
|
||||
componentScroll.Initialize(ComponentList);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniverseLib;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UniverseLib.UI.Widgets.ButtonList;
|
||||
using UniverseLib;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
{
|
||||
@ -31,7 +28,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public override GameObject CreateContent(GameObject parent)
|
||||
{
|
||||
var root = base.CreateContent(parent);
|
||||
GameObject root = base.CreateContent(parent);
|
||||
|
||||
// Add mask to button so text doesnt overlap on Close button
|
||||
//this.Button.Component.gameObject.AddComponent<Mask>().showMaskGraphic = true;
|
||||
@ -39,7 +36,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// Behaviour toggle
|
||||
|
||||
var toggleObj = UIFactory.CreateToggle(UIRoot, "BehaviourToggle", out BehaviourToggle, out var behavText);
|
||||
GameObject toggleObj = UIFactory.CreateToggle(UIRoot, "BehaviourToggle", out BehaviourToggle, out Text behavText);
|
||||
UIFactory.SetLayoutElement(toggleObj, minHeight: 25, minWidth: 25);
|
||||
BehaviourToggle.onValueChanged.AddListener(BehaviourToggled);
|
||||
// put at first object
|
||||
|
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UniverseLib;
|
||||
using UniverseLib.UI.Widgets.ButtonList;
|
||||
@ -45,12 +43,12 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void OnComponentClicked(int index)
|
||||
{
|
||||
var entries = GetEntries();
|
||||
List<Component> entries = GetEntries();
|
||||
|
||||
if (index < 0 || index >= entries.Count)
|
||||
return;
|
||||
|
||||
var comp = entries[index];
|
||||
Component comp = entries[index];
|
||||
if (comp)
|
||||
InspectorManager.Inspect(comp);
|
||||
}
|
||||
@ -59,8 +57,8 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
try
|
||||
{
|
||||
var entries = GetEntries();
|
||||
var comp = entries[index];
|
||||
List<Component> entries = GetEntries();
|
||||
Component comp = entries[index];
|
||||
|
||||
if (comp.TryCast<Behaviour>() is Behaviour behaviour)
|
||||
behaviour.enabled = value;
|
||||
@ -75,8 +73,8 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
try
|
||||
{
|
||||
var entries = GetEntries();
|
||||
var comp = entries[index];
|
||||
List<Component> entries = GetEntries();
|
||||
Component comp = entries[index];
|
||||
|
||||
GameObject.DestroyImmediate(comp);
|
||||
|
||||
@ -88,16 +86,16 @@ namespace UnityExplorer.Inspectors
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Dictionary<string, string> compToStringCache = new Dictionary<string, string>();
|
||||
private static readonly Dictionary<string, string> compToStringCache = new();
|
||||
|
||||
// Called from ButtonListHandler.SetCell, will be valid
|
||||
private void SetComponentCell(ComponentCell cell, int index)
|
||||
{
|
||||
var entries = GetEntries();
|
||||
List<Component> entries = GetEntries();
|
||||
cell.Enable();
|
||||
|
||||
var comp = entries[index];
|
||||
var type = comp.GetActualType();
|
||||
Component comp = entries[index];
|
||||
Type type = comp.GetActualType();
|
||||
|
||||
if (!compToStringCache.ContainsKey(type.AssemblyQualifiedName))
|
||||
compToStringCache.Add(type.AssemblyQualifiedName, SignatureHighlighter.Parse(type, true));
|
||||
|
@ -1,14 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniverseLib.Input;
|
||||
using UnityExplorer.UI;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib;
|
||||
using UniverseLib.Input;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UniverseLib.Utility;
|
||||
|
||||
@ -176,14 +175,14 @@ namespace UnityExplorer.Inspectors
|
||||
else
|
||||
{
|
||||
// look for inactive objects
|
||||
var name = input.Split('/').Last();
|
||||
var allObjects = RuntimeHelper.FindObjectsOfTypeAll(typeof(GameObject));
|
||||
var shortList = new List<GameObject>();
|
||||
foreach (var obj in allObjects)
|
||||
string name = input.Split('/').Last();
|
||||
UnityEngine.Object[] allObjects = RuntimeHelper.FindObjectsOfTypeAll(typeof(GameObject));
|
||||
List<GameObject> shortList = new();
|
||||
foreach (UnityEngine.Object obj in allObjects)
|
||||
if (obj.name == name) shortList.Add(obj.TryCast<GameObject>());
|
||||
foreach (var go in shortList)
|
||||
foreach (GameObject go in shortList)
|
||||
{
|
||||
var path = go.transform.GetTransformPath(true);
|
||||
string path = go.transform.GetTransformPath(true);
|
||||
if (path.EndsWith("/"))
|
||||
path = path.Remove(path.Length - 1);
|
||||
if (path == input)
|
||||
@ -245,7 +244,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void OnExploreButtonClicked()
|
||||
{
|
||||
var panel = UIManager.GetPanel<UI.Panels.ObjectExplorerPanel>(UIManager.Panels.ObjectExplorer);
|
||||
ObjectExplorerPanel panel = UIManager.GetPanel<UI.Panels.ObjectExplorerPanel>(UIManager.Panels.ObjectExplorer);
|
||||
panel.SceneExplorer.JumpToTransform(this.Parent.GOTarget.transform);
|
||||
}
|
||||
|
||||
@ -259,7 +258,7 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
try
|
||||
{
|
||||
var enumVal = hideFlagsValues[FlagsDropdown.options[value].text];
|
||||
HideFlags enumVal = hideFlagsValues[FlagsDropdown.options[value].text];
|
||||
GOTarget.hideFlags = enumVal;
|
||||
|
||||
UpdateGameObjectInfo(false, true);
|
||||
@ -278,7 +277,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void OnInstantiateClicked()
|
||||
{
|
||||
var clone = GameObject.Instantiate(this.GOTarget);
|
||||
GameObject clone = GameObject.Instantiate(this.GOTarget);
|
||||
InspectorManager.Inspect(clone);
|
||||
}
|
||||
|
||||
@ -322,7 +321,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public void UpdateTransformControlValues(bool force)
|
||||
{
|
||||
var transform = GOTarget.transform;
|
||||
Transform transform = GOTarget.transform;
|
||||
if (force || (!PositionControl.Input.Component.isFocused && lastPosValue != transform.position))
|
||||
{
|
||||
PositionControl.Input.Text = ParseUtility.ToStringForInput(transform.position, typeof(Vector3));
|
||||
@ -404,7 +403,7 @@ namespace UnityExplorer.Inspectors
|
||||
return;
|
||||
}
|
||||
|
||||
var transform = GOTarget.transform;
|
||||
Transform transform = GOTarget.transform;
|
||||
|
||||
Vector3 vector = Vector2.zero;
|
||||
switch (currentSlidingVectorControl.parentControl.Type)
|
||||
@ -453,14 +452,14 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void ConstructTopInfo()
|
||||
{
|
||||
var topInfoHolder = UIFactory.CreateVerticalGroup(Parent.Content, "TopInfoHolder", false, false, true, true, 3,
|
||||
GameObject topInfoHolder = UIFactory.CreateVerticalGroup(Parent.Content, "TopInfoHolder", false, false, true, true, 3,
|
||||
new Vector4(3, 3, 3, 3), new Color(0.1f, 0.1f, 0.1f), TextAnchor.MiddleLeft);
|
||||
UIFactory.SetLayoutElement(topInfoHolder, minHeight: 100, flexibleWidth: 9999);
|
||||
topInfoHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
// first row (parent, path)
|
||||
|
||||
var firstRow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
GameObject firstRow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(firstRow, false, false, true, true, 5, 0, 0, 0, 0, default);
|
||||
UIFactory.SetLayoutElement(firstRow, minHeight: 25, flexibleWidth: 9999);
|
||||
|
||||
@ -475,7 +474,7 @@ namespace UnityExplorer.Inspectors
|
||||
UIFactory.SetLayoutElement(PathInput.UIRoot, minHeight: 25, minWidth: 100, flexibleWidth: 9999);
|
||||
PathInput.Component.lineType = InputField.LineType.MultiLineSubmit;
|
||||
|
||||
var copyButton = UIFactory.CreateButton(firstRow, "CopyButton", "Copy to Clipboard", new Color(0.2f, 0.2f, 0.2f, 1));
|
||||
ButtonRef copyButton = UIFactory.CreateButton(firstRow, "CopyButton", "Copy to Clipboard", new Color(0.2f, 0.2f, 0.2f, 1));
|
||||
copyButton.ButtonText.color = Color.yellow;
|
||||
UIFactory.SetLayoutElement(copyButton.Component.gameObject, minHeight: 25, minWidth: 120);
|
||||
copyButton.OnClick += OnCopyClicked;
|
||||
@ -488,10 +487,10 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// Title and update row
|
||||
|
||||
var titleRow = UIFactory.CreateUIObject("TitleRow", topInfoHolder);
|
||||
GameObject titleRow = UIFactory.CreateUIObject("TitleRow", topInfoHolder);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(titleRow, false, false, true, true, 5);
|
||||
|
||||
var titleLabel = UIFactory.CreateLabel(titleRow, "Title", SignatureHighlighter.Parse(typeof(GameObject), false),
|
||||
Text titleLabel = UIFactory.CreateLabel(titleRow, "Title", SignatureHighlighter.Parse(typeof(GameObject), false),
|
||||
TextAnchor.MiddleLeft, fontSize: 17);
|
||||
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 30, minWidth: 100);
|
||||
|
||||
@ -504,25 +503,25 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// second row (toggles, instanceID, tag, buttons)
|
||||
|
||||
var secondRow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
GameObject secondRow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(secondRow, false, false, true, true, 5, 0, 0, 0, 0, default);
|
||||
UIFactory.SetLayoutElement(secondRow, minHeight: 25, flexibleWidth: 9999);
|
||||
|
||||
// activeSelf
|
||||
var activeToggleObj = UIFactory.CreateToggle(secondRow, "ActiveSelf", out ActiveSelfToggle, out ActiveSelfText);
|
||||
GameObject activeToggleObj = UIFactory.CreateToggle(secondRow, "ActiveSelf", out ActiveSelfToggle, out ActiveSelfText);
|
||||
UIFactory.SetLayoutElement(activeToggleObj, minHeight: 25, minWidth: 100);
|
||||
ActiveSelfText.text = "ActiveSelf";
|
||||
ActiveSelfToggle.onValueChanged.AddListener(OnActiveSelfToggled);
|
||||
|
||||
// isStatic
|
||||
var isStaticObj = UIFactory.CreateToggle(secondRow, "IsStatic", out IsStaticToggle, out Text staticText);
|
||||
GameObject isStaticObj = UIFactory.CreateToggle(secondRow, "IsStatic", out IsStaticToggle, out Text staticText);
|
||||
UIFactory.SetLayoutElement(isStaticObj, minHeight: 25, minWidth: 80);
|
||||
staticText.text = "IsStatic";
|
||||
staticText.color = Color.grey;
|
||||
IsStaticToggle.interactable = false;
|
||||
|
||||
// InstanceID
|
||||
var instanceIdLabel = UIFactory.CreateLabel(secondRow, "InstanceIDLabel", "Instance ID:", TextAnchor.MiddleRight, Color.grey);
|
||||
Text instanceIdLabel = UIFactory.CreateLabel(secondRow, "InstanceIDLabel", "Instance ID:", TextAnchor.MiddleRight, Color.grey);
|
||||
UIFactory.SetLayoutElement(instanceIdLabel.gameObject, minHeight: 25, minWidth: 90);
|
||||
|
||||
InstanceIDInput = UIFactory.CreateInputField(secondRow, "InstanceIDInput", "error");
|
||||
@ -531,7 +530,7 @@ namespace UnityExplorer.Inspectors
|
||||
InstanceIDInput.Component.readOnly = true;
|
||||
|
||||
//Tag
|
||||
var tagLabel = UIFactory.CreateLabel(secondRow, "TagLabel", "Tag:", TextAnchor.MiddleRight, Color.grey);
|
||||
Text tagLabel = UIFactory.CreateLabel(secondRow, "TagLabel", "Tag:", TextAnchor.MiddleRight, Color.grey);
|
||||
UIFactory.SetLayoutElement(tagLabel.gameObject, minHeight: 25, minWidth: 40);
|
||||
|
||||
TagInput = UIFactory.CreateInputField(secondRow, "TagInput", "none");
|
||||
@ -540,29 +539,29 @@ namespace UnityExplorer.Inspectors
|
||||
TagInput.Component.GetOnEndEdit().AddListener((string val) => { OnTagEndEdit(val); });
|
||||
|
||||
// Instantiate
|
||||
var instantiateBtn = UIFactory.CreateButton(secondRow, "InstantiateBtn", "Instantiate", new Color(0.2f, 0.2f, 0.2f));
|
||||
ButtonRef instantiateBtn = UIFactory.CreateButton(secondRow, "InstantiateBtn", "Instantiate", new Color(0.2f, 0.2f, 0.2f));
|
||||
UIFactory.SetLayoutElement(instantiateBtn.Component.gameObject, minHeight: 25, minWidth: 120);
|
||||
instantiateBtn.OnClick += OnInstantiateClicked;
|
||||
|
||||
// Destroy
|
||||
var destroyBtn = UIFactory.CreateButton(secondRow, "DestroyBtn", "Destroy", new Color(0.3f, 0.2f, 0.2f));
|
||||
ButtonRef destroyBtn = UIFactory.CreateButton(secondRow, "DestroyBtn", "Destroy", new Color(0.3f, 0.2f, 0.2f));
|
||||
UIFactory.SetLayoutElement(destroyBtn.Component.gameObject, minHeight: 25, minWidth: 80);
|
||||
destroyBtn.OnClick += OnDestroyClicked;
|
||||
|
||||
// third row (scene, layer, flags)
|
||||
|
||||
var thirdrow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
GameObject thirdrow = UIFactory.CreateUIObject("ParentRow", topInfoHolder);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(thirdrow, false, false, true, true, 5, 0, 0, 0, 0, default);
|
||||
UIFactory.SetLayoutElement(thirdrow, minHeight: 25, flexibleWidth: 9999);
|
||||
|
||||
// Inspect in Explorer button
|
||||
var explorerBtn = UIFactory.CreateButton(thirdrow, "ExploreBtn", "Show in Explorer", new Color(0.15f, 0.15f, 0.15f));
|
||||
ButtonRef explorerBtn = UIFactory.CreateButton(thirdrow, "ExploreBtn", "Show in Explorer", new Color(0.15f, 0.15f, 0.15f));
|
||||
UIFactory.SetLayoutElement(explorerBtn.Component.gameObject, minHeight: 25, minWidth: 100);
|
||||
explorerBtn.ButtonText.fontSize = 12;
|
||||
explorerBtn.OnClick += OnExploreButtonClicked;
|
||||
|
||||
// Scene
|
||||
var sceneLabel = UIFactory.CreateLabel(thirdrow, "SceneLabel", "Scene:", TextAnchor.MiddleLeft, Color.grey);
|
||||
Text sceneLabel = UIFactory.CreateLabel(thirdrow, "SceneLabel", "Scene:", TextAnchor.MiddleLeft, Color.grey);
|
||||
UIFactory.SetLayoutElement(sceneLabel.gameObject, minHeight: 25, minWidth: 50);
|
||||
|
||||
SceneInput = UIFactory.CreateInputField(thirdrow, "SceneInput", "untitled");
|
||||
@ -571,29 +570,29 @@ namespace UnityExplorer.Inspectors
|
||||
SceneInput.Component.textComponent.color = new Color(0.7f, 0.7f, 0.7f);
|
||||
|
||||
// Layer
|
||||
var layerLabel = UIFactory.CreateLabel(thirdrow, "LayerLabel", "Layer:", TextAnchor.MiddleLeft, Color.grey);
|
||||
Text layerLabel = UIFactory.CreateLabel(thirdrow, "LayerLabel", "Layer:", TextAnchor.MiddleLeft, Color.grey);
|
||||
UIFactory.SetLayoutElement(layerLabel.gameObject, minHeight: 25, minWidth: 50);
|
||||
|
||||
var layerDrop = UIFactory.CreateDropdown(thirdrow, "LayerDropdown", out LayerDropdown, "0", 14, OnLayerDropdownChanged);
|
||||
GameObject layerDrop = UIFactory.CreateDropdown(thirdrow, "LayerDropdown", out LayerDropdown, "0", 14, OnLayerDropdownChanged);
|
||||
UIFactory.SetLayoutElement(layerDrop, minHeight: 25, minWidth: 110, flexibleWidth: 999);
|
||||
LayerDropdown.captionText.color = SignatureHighlighter.EnumGreen;
|
||||
if (layerToNames == null)
|
||||
GetLayerNames();
|
||||
foreach (var name in layerToNames)
|
||||
foreach (string name in layerToNames)
|
||||
LayerDropdown.options.Add(new Dropdown.OptionData(name));
|
||||
LayerDropdown.value = 0;
|
||||
LayerDropdown.RefreshShownValue();
|
||||
|
||||
// Flags
|
||||
var flagsLabel = UIFactory.CreateLabel(thirdrow, "FlagsLabel", "Flags:", TextAnchor.MiddleRight, Color.grey);
|
||||
Text flagsLabel = UIFactory.CreateLabel(thirdrow, "FlagsLabel", "Flags:", TextAnchor.MiddleRight, Color.grey);
|
||||
UIFactory.SetLayoutElement(flagsLabel.gameObject, minHeight: 25, minWidth: 50);
|
||||
|
||||
var flagsDrop = UIFactory.CreateDropdown(thirdrow, "FlagsDropdown", out FlagsDropdown, "None", 14, OnFlagsDropdownChanged);
|
||||
GameObject flagsDrop = UIFactory.CreateDropdown(thirdrow, "FlagsDropdown", out FlagsDropdown, "None", 14, OnFlagsDropdownChanged);
|
||||
FlagsDropdown.captionText.color = SignatureHighlighter.EnumGreen;
|
||||
UIFactory.SetLayoutElement(flagsDrop, minHeight: 25, minWidth: 135, flexibleWidth: 999);
|
||||
if (hideFlagsValues == null)
|
||||
GetHideFlagNames();
|
||||
foreach (var name in hideFlagsValues.Keys)
|
||||
foreach (string name in hideFlagsValues.Keys)
|
||||
FlagsDropdown.options.Add(new Dropdown.OptionData(name));
|
||||
FlagsDropdown.value = 0;
|
||||
FlagsDropdown.RefreshShownValue();
|
||||
@ -606,7 +605,7 @@ namespace UnityExplorer.Inspectors
|
||||
layerToNames = new List<string>();
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
var name = RuntimeHelper.LayerToName(i);
|
||||
string name = RuntimeHelper.LayerToName(i);
|
||||
if (string.IsNullOrEmpty(name))
|
||||
name = i.ToString();
|
||||
layerToNames.Add(name);
|
||||
@ -619,7 +618,7 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
hideFlagsValues = new Dictionary<string, HideFlags>();
|
||||
|
||||
var names = Enum.GetValues(typeof(HideFlags));
|
||||
Array names = Enum.GetValues(typeof(HideFlags));
|
||||
foreach (HideFlags value in names)
|
||||
{
|
||||
hideFlagsValues.Add(value.ToString(), value);
|
||||
@ -633,7 +632,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void ConstructTransformControls()
|
||||
{
|
||||
var transformGroup = UIFactory.CreateVerticalGroup(Parent.Content, "TransformControls", false, false, true, true, 2,
|
||||
GameObject transformGroup = UIFactory.CreateVerticalGroup(Parent.Content, "TransformControls", false, false, true, true, 2,
|
||||
new Vector4(2, 2, 0, 0), new Color(0.1f, 0.1f, 0.1f));
|
||||
UIFactory.SetLayoutElement(transformGroup, minHeight: 100, flexibleWidth: 9999);
|
||||
//transformGroup.SetActive(false);
|
||||
@ -650,19 +649,19 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private TransformControl AddTransformRow(GameObject transformGroup, string title, TransformType type)
|
||||
{
|
||||
var rowObj = UIFactory.CreateUIObject("Row_" + title, transformGroup);
|
||||
GameObject rowObj = UIFactory.CreateUIObject("Row_" + title, transformGroup);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(rowObj, false, false, true, true, 5, 0, 0, 0, 0, default);
|
||||
UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleWidth: 9999);
|
||||
|
||||
var titleLabel = UIFactory.CreateLabel(rowObj, "PositionLabel", title, TextAnchor.MiddleRight, Color.grey);
|
||||
Text titleLabel = UIFactory.CreateLabel(rowObj, "PositionLabel", title, TextAnchor.MiddleRight, Color.grey);
|
||||
UIFactory.SetLayoutElement(titleLabel.gameObject, minHeight: 25, minWidth: 110);
|
||||
|
||||
var inputField = UIFactory.CreateInputField(rowObj, "InputField", "...");
|
||||
InputFieldRef inputField = UIFactory.CreateInputField(rowObj, "InputField", "...");
|
||||
UIFactory.SetLayoutElement(inputField.Component.gameObject, minHeight: 25, minWidth: 100, flexibleWidth: 999);
|
||||
|
||||
inputField.Component.GetOnEndEdit().AddListener((string value) => { OnTransformInputEndEdit(type, value); });
|
||||
|
||||
var control = new TransformControl(type, inputField);
|
||||
TransformControl control = new(type, inputField);
|
||||
|
||||
AddVectorAxisSlider(rowObj, "X", 0, control);
|
||||
AddVectorAxisSlider(rowObj, "Y", 1, control);
|
||||
@ -673,16 +672,16 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private VectorSlider AddVectorAxisSlider(GameObject parent, string title, int axis, TransformControl control)
|
||||
{
|
||||
var label = UIFactory.CreateLabel(parent, "Label_" + title, title + ":", TextAnchor.MiddleRight, Color.grey);
|
||||
Text label = UIFactory.CreateLabel(parent, "Label_" + title, title + ":", TextAnchor.MiddleRight, Color.grey);
|
||||
UIFactory.SetLayoutElement(label.gameObject, minHeight: 25, minWidth: 30);
|
||||
|
||||
var sliderObj = UIFactory.CreateSlider(parent, "Slider_" + title, out var slider);
|
||||
GameObject sliderObj = UIFactory.CreateSlider(parent, "Slider_" + title, out Slider slider);
|
||||
UIFactory.SetLayoutElement(sliderObj, minHeight: 25, minWidth: 120, flexibleWidth: 0);
|
||||
slider.m_FillImage.color = Color.clear;
|
||||
|
||||
slider.minValue = -1;
|
||||
slider.maxValue = 1;
|
||||
var sliderControl = new VectorSlider(axis, slider, control);
|
||||
VectorSlider sliderControl = new(axis, slider, control);
|
||||
|
||||
slider.onValueChanged.AddListener((float val) =>
|
||||
{
|
||||
|
@ -1,13 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.ObjectPool;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
|
@ -1,16 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.CacheObject;
|
||||
using UnityExplorer.Inspectors;
|
||||
using UniverseLib.UI.Models;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.ObjectPool;
|
||||
using UniverseLib.Utility;
|
||||
|
||||
@ -50,7 +46,7 @@ namespace UnityExplorer
|
||||
|
||||
private static bool TryFocusActiveInspector(object target)
|
||||
{
|
||||
foreach (var inspector in Inspectors)
|
||||
foreach (InspectorBase inspector in Inspectors)
|
||||
{
|
||||
if (inspector.Target.ReferenceEqual(target))
|
||||
{
|
||||
@ -96,7 +92,7 @@ namespace UnityExplorer
|
||||
private static void CreateInspector<T>(object target, bool staticReflection = false,
|
||||
CacheObjectBase parentObject = null) where T : InspectorBase
|
||||
{
|
||||
var inspector = Pool<T>.Borrow();
|
||||
T inspector = Pool<T>.Borrow();
|
||||
Inspectors.Add(inspector);
|
||||
inspector.Target = target;
|
||||
|
||||
@ -164,7 +160,7 @@ namespace UnityExplorer
|
||||
{
|
||||
PanelWidth = width;
|
||||
|
||||
foreach (var obj in Inspectors)
|
||||
foreach (InspectorBase obj in Inspectors)
|
||||
{
|
||||
if (obj is ReflectionInspector inspector)
|
||||
{
|
||||
|
@ -1,15 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UnityExplorer.UI.Widgets;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.UI.Models;
|
||||
using UniverseLib.UI.ObjectPool;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
|
@ -1,19 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UniverseLib.Input;
|
||||
using UnityExplorer.Runtime;
|
||||
using UnityExplorer.Config;
|
||||
using UnityExplorer.Inspectors.MouseInspectors;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib;
|
||||
using UniverseLib.Input;
|
||||
using UniverseLib.UI;
|
||||
using UniverseLib.Utility;
|
||||
using UnityExplorer.Config;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
{
|
||||
@ -59,7 +52,7 @@ namespace UnityExplorer.Inspectors
|
||||
internal Text objPathLabel;
|
||||
internal Text mousePosLabel;
|
||||
|
||||
public MouseInspector()
|
||||
public MouseInspector()
|
||||
{
|
||||
Instance = this;
|
||||
worldInspector = new WorldInspector();
|
||||
@ -108,7 +101,7 @@ namespace UnityExplorer.Inspectors
|
||||
UIManager.NavBarRect.gameObject.SetActive(true);
|
||||
UIManager.PanelHolder.SetActive(true);
|
||||
|
||||
var drop = InspectorPanel.Instance.MouseInspectDropdown;
|
||||
Dropdown drop = InspectorPanel.Instance.MouseInspectDropdown;
|
||||
if (drop.transform.Find("Dropdown List") is Transform list)
|
||||
drop.DestroyDropdownList(list.gameObject);
|
||||
|
||||
@ -130,7 +123,7 @@ namespace UnityExplorer.Inspectors
|
||||
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||
Instance.StartInspect(MouseInspectMode.World);
|
||||
}
|
||||
|
||||
|
||||
if (Inspecting)
|
||||
UpdateInspect();
|
||||
|
||||
@ -152,7 +145,7 @@ namespace UnityExplorer.Inspectors
|
||||
return;
|
||||
}
|
||||
|
||||
var mousePos = InputManager.MousePosition;
|
||||
Vector3 mousePos = InputManager.MousePosition;
|
||||
if (mousePos != lastMousePos)
|
||||
UpdatePosition(mousePos);
|
||||
|
||||
@ -181,7 +174,7 @@ namespace UnityExplorer.Inspectors
|
||||
mousePos.y -= 10;
|
||||
|
||||
// calculate and set our UI position
|
||||
var inversePos = inspectorUIBase.RootObject.transform.InverseTransformPoint(mousePos);
|
||||
Vector3 inversePos = inspectorUIBase.RootObject.transform.InverseTransformPoint(mousePos);
|
||||
UIRoot.transform.localPosition = new Vector3(inversePos.x, inversePos.y, 0);
|
||||
}
|
||||
|
||||
@ -201,14 +194,14 @@ namespace UnityExplorer.Inspectors
|
||||
this.TitleBar.SetActive(false);
|
||||
this.UIRoot.transform.SetParent(UIManager.UIRoot.transform, false);
|
||||
|
||||
var inspectContent = UIFactory.CreateVerticalGroup(this.uiContent, "InspectContent", true, true, true, true, 3, new Vector4(2, 2, 2, 2));
|
||||
GameObject inspectContent = UIFactory.CreateVerticalGroup(this.uiContent, "InspectContent", true, true, true, true, 3, new Vector4(2, 2, 2, 2));
|
||||
UIFactory.SetLayoutElement(inspectContent, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||
|
||||
// Title text
|
||||
|
||||
var title = UIFactory.CreateLabel(inspectContent,
|
||||
Text title = UIFactory.CreateLabel(inspectContent,
|
||||
"InspectLabel",
|
||||
"<b>Mouse Inspector</b> (press <b>ESC</b> to cancel)",
|
||||
"<b>Mouse Inspector</b> (press <b>ESC</b> to cancel)",
|
||||
TextAnchor.MiddleCenter);
|
||||
UIFactory.SetLayoutElement(title.gameObject, flexibleWidth: 9999);
|
||||
|
||||
|
@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
{
|
||||
|
@ -1,29 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib;
|
||||
using UniverseLib.Input;
|
||||
|
||||
namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
{
|
||||
public class UiInspector : MouseInspectorBase
|
||||
{
|
||||
public static readonly List<GameObject> LastHitObjects = new List<GameObject>();
|
||||
public static readonly List<GameObject> LastHitObjects = new();
|
||||
|
||||
private static GraphicRaycaster[] graphicRaycasters;
|
||||
|
||||
private static readonly List<GameObject> currentHitObjects = new List<GameObject>();
|
||||
private static readonly List<GameObject> currentHitObjects = new();
|
||||
|
||||
private static readonly List<Graphic> wasDisabledGraphics = new List<Graphic>();
|
||||
private static readonly List<CanvasGroup> wasDisabledCanvasGroups = new List<CanvasGroup>();
|
||||
private static readonly List<GameObject> objectsAddedCastersTo = new List<GameObject>();
|
||||
private static readonly List<Graphic> wasDisabledGraphics = new();
|
||||
private static readonly List<CanvasGroup> wasDisabledCanvasGroups = new();
|
||||
private static readonly List<GameObject> objectsAddedCastersTo = new();
|
||||
|
||||
public override void OnBeginMouseInspect()
|
||||
{
|
||||
@ -46,7 +43,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
IEnumerator SetPanelActiveCoro()
|
||||
{
|
||||
yield return null;
|
||||
var panel = UIManager.GetPanel<MouseInspectorResultsPanel>(UIManager.Panels.UIInspectorResults);
|
||||
MouseInspectorResultsPanel panel = UIManager.GetPanel<MouseInspectorResultsPanel>(UIManager.Panels.UIInspectorResults);
|
||||
panel.SetActive(true);
|
||||
panel.ShowResults();
|
||||
}
|
||||
@ -55,28 +52,28 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
{
|
||||
currentHitObjects.Clear();
|
||||
|
||||
var ped = new PointerEventData(null)
|
||||
PointerEventData ped = new(null)
|
||||
{
|
||||
position = mousePos
|
||||
};
|
||||
|
||||
foreach (var gr in graphicRaycasters)
|
||||
foreach (GraphicRaycaster gr in graphicRaycasters)
|
||||
{
|
||||
if (!gr || !gr.canvas)
|
||||
continue;
|
||||
|
||||
var list = new List<RaycastResult>();
|
||||
|
||||
List<RaycastResult> list = new();
|
||||
RuntimeHelper.GraphicRaycast(gr, ped, list);
|
||||
if (list.Count > 0)
|
||||
{
|
||||
foreach (var hit in list)
|
||||
foreach (RaycastResult hit in list)
|
||||
{
|
||||
if (hit.gameObject)
|
||||
currentHitObjects.Add(hit.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (currentHitObjects.Any())
|
||||
MouseInspector.Instance.objNameLabel.text = $"Click to view UI Objects under mouse: {currentHitObjects.Count}";
|
||||
else
|
||||
@ -85,9 +82,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
|
||||
private static void SetupUIRaycast()
|
||||
{
|
||||
foreach (var obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(Canvas)))
|
||||
foreach (UnityEngine.Object obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(Canvas)))
|
||||
{
|
||||
var canvas = obj.TryCast<Canvas>();
|
||||
Canvas canvas = obj.TryCast<Canvas>();
|
||||
if (!canvas || !canvas.enabled || !canvas.gameObject.activeInHierarchy)
|
||||
continue;
|
||||
if (!canvas.GetComponent<GraphicRaycaster>())
|
||||
@ -99,7 +96,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
}
|
||||
|
||||
// recache Graphic Raycasters each time we start
|
||||
var casters = RuntimeHelper.FindObjectsOfTypeAll(typeof(GraphicRaycaster));
|
||||
UnityEngine.Object[] casters = RuntimeHelper.FindObjectsOfTypeAll(typeof(GraphicRaycaster));
|
||||
graphicRaycasters = new GraphicRaycaster[casters.Length];
|
||||
for (int i = 0; i < casters.Length; i++)
|
||||
{
|
||||
@ -107,9 +104,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
}
|
||||
|
||||
// enable raycastTarget on Graphics
|
||||
foreach (var obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(Graphic)))
|
||||
foreach (UnityEngine.Object obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(Graphic)))
|
||||
{
|
||||
var graphic = obj.TryCast<Graphic>();
|
||||
Graphic graphic = obj.TryCast<Graphic>();
|
||||
if (!graphic || !graphic.enabled || graphic.raycastTarget || !graphic.gameObject.activeInHierarchy)
|
||||
continue;
|
||||
graphic.raycastTarget = true;
|
||||
@ -118,9 +115,9 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
}
|
||||
|
||||
// enable blocksRaycasts on CanvasGroups
|
||||
foreach (var obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(CanvasGroup)))
|
||||
foreach (UnityEngine.Object obj in RuntimeHelper.FindObjectsOfTypeAll(typeof(CanvasGroup)))
|
||||
{
|
||||
var canvas = obj.TryCast<CanvasGroup>();
|
||||
CanvasGroup canvas = obj.TryCast<CanvasGroup>();
|
||||
if (!canvas || !canvas.gameObject.activeInHierarchy || canvas.blocksRaycasts)
|
||||
continue;
|
||||
canvas.blocksRaycasts = true;
|
||||
@ -131,16 +128,16 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
|
||||
public override void OnEndInspect()
|
||||
{
|
||||
foreach (var obj in objectsAddedCastersTo)
|
||||
foreach (GameObject obj in objectsAddedCastersTo)
|
||||
{
|
||||
if (obj.GetComponent<GraphicRaycaster>() is GraphicRaycaster raycaster)
|
||||
GameObject.Destroy(raycaster);
|
||||
}
|
||||
|
||||
foreach (var graphic in wasDisabledGraphics)
|
||||
foreach (Graphic graphic in wasDisabledGraphics)
|
||||
graphic.raycastTarget = false;
|
||||
|
||||
foreach (var canvas in wasDisabledCanvasGroups)
|
||||
foreach (CanvasGroup canvas in wasDisabledCanvasGroups)
|
||||
canvas.blocksRaycasts = false;
|
||||
|
||||
objectsAddedCastersTo.Clear();
|
||||
|
@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UniverseLib;
|
||||
using UnityEngine;
|
||||
using UniverseLib.Utility;
|
||||
|
||||
namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
@ -45,7 +40,7 @@ namespace UnityExplorer.Inspectors.MouseInspectors
|
||||
return;
|
||||
}
|
||||
|
||||
var ray = MainCamera.ScreenPointToRay(mousePos);
|
||||
Ray ray = MainCamera.ScreenPointToRay(mousePos);
|
||||
Physics.Raycast(ray, out RaycastHit hit, 1000f);
|
||||
|
||||
if (hit.transform)
|
||||
|
@ -107,7 +107,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public override void OnReturnToPool()
|
||||
{
|
||||
foreach (var member in members)
|
||||
foreach (CacheMember member in members)
|
||||
{
|
||||
member.UnlinkFromView();
|
||||
member.ReleasePooledObjects();
|
||||
@ -175,7 +175,7 @@ namespace UnityExplorer.Inspectors
|
||||
scopeFilterButtons[BindingFlags.Default].Component.gameObject.SetActive(!StaticOnly);
|
||||
scopeFilterButtons[BindingFlags.Instance].Component.gameObject.SetActive(!StaticOnly);
|
||||
|
||||
foreach (var toggle in memberTypeToggles)
|
||||
foreach (Toggle toggle in memberTypeToggles)
|
||||
toggle.isOn = true;
|
||||
|
||||
refreshWanted = true;
|
||||
@ -236,7 +236,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
if (flags != scopeFlagsFilter)
|
||||
{
|
||||
var btn = scopeFilterButtons[scopeFlagsFilter].Component;
|
||||
Button btn = scopeFilterButtons[scopeFlagsFilter].Component;
|
||||
RuntimeHelper.SetColorBlock(btn, disabledButtonColor, disabledButtonColor * 1.3f);
|
||||
|
||||
this.scopeFlagsFilter = flags;
|
||||
@ -259,7 +259,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
for (int i = 0; i < members.Count; i++)
|
||||
{
|
||||
var member = members[i];
|
||||
CacheMember member = members[i];
|
||||
|
||||
if (scopeFlagsFilter != BindingFlags.Default)
|
||||
{
|
||||
@ -284,11 +284,11 @@ namespace UnityExplorer.Inspectors
|
||||
private void UpdateDisplayedMembers()
|
||||
{
|
||||
bool shouldRefresh = false;
|
||||
foreach (var cell in MemberScrollPool.CellPool)
|
||||
foreach (CacheMemberCell cell in MemberScrollPool.CellPool)
|
||||
{
|
||||
if (!cell.Enabled || cell.Occupant == null)
|
||||
continue;
|
||||
var member = cell.MemberOccupant;
|
||||
CacheMember member = cell.MemberOccupant;
|
||||
if (member.ShouldAutoEvaluate)
|
||||
{
|
||||
shouldRefresh = true;
|
||||
@ -316,7 +316,7 @@ namespace UnityExplorer.Inspectors
|
||||
{
|
||||
CalculateLayouts();
|
||||
|
||||
foreach (var cell in MemberScrollPool.CellPool)
|
||||
foreach (CacheMemberCell cell in MemberScrollPool.CellPool)
|
||||
SetCellLayout(cell);
|
||||
}
|
||||
|
||||
@ -349,21 +349,21 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// Class name, assembly
|
||||
|
||||
var topRow = UIFactory.CreateHorizontalGroup(UIRoot, "TopRow", false, false, true, true, 4, default, new(1, 1, 1, 0), TextAnchor.MiddleLeft);
|
||||
GameObject topRow = UIFactory.CreateHorizontalGroup(UIRoot, "TopRow", false, false, true, true, 4, default, new(1, 1, 1, 0), TextAnchor.MiddleLeft);
|
||||
UIFactory.SetLayoutElement(topRow, minHeight: 25, flexibleWidth: 9999);
|
||||
|
||||
var titleHolder = UIFactory.CreateUIObject("TitleHolder", topRow);
|
||||
GameObject titleHolder = UIFactory.CreateUIObject("TitleHolder", topRow);
|
||||
UIFactory.SetLayoutElement(titleHolder, minHeight: 35, flexibleHeight: 0, flexibleWidth: 9999);
|
||||
|
||||
NameText = UIFactory.CreateLabel(titleHolder, "VisibleTitle", "NotSet", TextAnchor.MiddleLeft);
|
||||
var namerect = NameText.GetComponent<RectTransform>();
|
||||
RectTransform namerect = NameText.GetComponent<RectTransform>();
|
||||
namerect.anchorMin = new Vector2(0, 0);
|
||||
namerect.anchorMax = new Vector2(1, 1);
|
||||
NameText.fontSize = 17;
|
||||
UIFactory.SetLayoutElement(NameText.gameObject, minHeight: 35, flexibleHeight: 0, minWidth: 300, flexibleWidth: 9999);
|
||||
|
||||
HiddenNameText = UIFactory.CreateInputField(titleHolder, "Title", "not set");
|
||||
var hiddenrect = HiddenNameText.Component.gameObject.GetComponent<RectTransform>();
|
||||
RectTransform hiddenrect = HiddenNameText.Component.gameObject.GetComponent<RectTransform>();
|
||||
hiddenrect.anchorMin = new Vector2(0, 0);
|
||||
hiddenrect.anchorMax = new Vector2(1, 1);
|
||||
HiddenNameText.Component.readOnly = true;
|
||||
@ -374,7 +374,7 @@ namespace UnityExplorer.Inspectors
|
||||
HiddenNameText.Component.textComponent.color = Color.clear;
|
||||
UIFactory.SetLayoutElement(HiddenNameText.Component.gameObject, minHeight: 35, flexibleHeight: 0, flexibleWidth: 9999);
|
||||
|
||||
var copyButton = UIFactory.CreateButton(topRow, "CopyButton", "Copy to Clipboard", new Color(0.2f, 0.2f, 0.2f, 1));
|
||||
ButtonRef copyButton = UIFactory.CreateButton(topRow, "CopyButton", "Copy to Clipboard", new Color(0.2f, 0.2f, 0.2f, 1));
|
||||
copyButton.ButtonText.color = Color.yellow;
|
||||
UIFactory.SetLayoutElement(copyButton.Component.gameObject, minHeight: 25, minWidth: 120, flexibleWidth: 0);
|
||||
copyButton.OnClick += OnCopyClicked;
|
||||
@ -392,7 +392,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
// Member scroll pool
|
||||
|
||||
var memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2, 2, 2, 2),
|
||||
GameObject memberBorder = UIFactory.CreateVerticalGroup(mainContentHolder, "ScrollPoolHolder", false, false, true, true, padding: new Vector4(2, 2, 2, 2),
|
||||
bgColor: new Color(0.05f, 0.05f, 0.05f));
|
||||
UIFactory.SetLayoutElement(memberBorder, flexibleWidth: 9999, flexibleHeight: 9999);
|
||||
|
||||
@ -413,27 +413,27 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void ConstructFirstRow(GameObject parent)
|
||||
{
|
||||
var rowObj = UIFactory.CreateUIObject("FirstRow", parent);
|
||||
GameObject rowObj = UIFactory.CreateUIObject("FirstRow", parent);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(rowObj, true, true, true, true, 5, 2, 2, 2, 2);
|
||||
UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
||||
|
||||
var nameLabel = UIFactory.CreateLabel(rowObj, "NameFilterLabel", "Filter names:", TextAnchor.MiddleLeft, Color.grey);
|
||||
Text nameLabel = UIFactory.CreateLabel(rowObj, "NameFilterLabel", "Filter names:", TextAnchor.MiddleLeft, Color.grey);
|
||||
UIFactory.SetLayoutElement(nameLabel.gameObject, minHeight: 25, minWidth: 90, flexibleWidth: 0);
|
||||
|
||||
filterInputField = UIFactory.CreateInputField(rowObj, "NameFilterInput", "...");
|
||||
UIFactory.SetLayoutElement(filterInputField.UIRoot, minHeight: 25, flexibleWidth: 300);
|
||||
filterInputField.OnValueChanged += (string val) => { SetFilter(val); };
|
||||
|
||||
var spacer = UIFactory.CreateUIObject("Spacer", rowObj);
|
||||
GameObject spacer = UIFactory.CreateUIObject("Spacer", rowObj);
|
||||
UIFactory.SetLayoutElement(spacer, minWidth: 25);
|
||||
|
||||
// Update button and toggle
|
||||
|
||||
var updateButton = UIFactory.CreateButton(rowObj, "UpdateButton", "Update displayed values", new Color(0.22f, 0.28f, 0.22f));
|
||||
ButtonRef updateButton = UIFactory.CreateButton(rowObj, "UpdateButton", "Update displayed values", new Color(0.22f, 0.28f, 0.22f));
|
||||
UIFactory.SetLayoutElement(updateButton.Component.gameObject, minHeight: 25, minWidth: 175, flexibleWidth: 0);
|
||||
updateButton.OnClick += UpdateClicked;
|
||||
|
||||
var toggleObj = UIFactory.CreateToggle(rowObj, "AutoUpdateToggle", out autoUpdateToggle, out Text toggleText);
|
||||
GameObject toggleObj = UIFactory.CreateToggle(rowObj, "AutoUpdateToggle", out autoUpdateToggle, out Text toggleText);
|
||||
UIFactory.SetLayoutElement(toggleObj, minWidth: 125, minHeight: 25);
|
||||
autoUpdateToggle.isOn = false;
|
||||
toggleText.text = "Auto-update";
|
||||
@ -443,19 +443,19 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void ConstructSecondRow(GameObject parent)
|
||||
{
|
||||
var rowObj = UIFactory.CreateUIObject("SecondRow", parent);
|
||||
GameObject rowObj = UIFactory.CreateUIObject("SecondRow", parent);
|
||||
UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(rowObj, false, false, true, true, 5, 2, 2, 2, 2);
|
||||
UIFactory.SetLayoutElement(rowObj, minHeight: 25, flexibleHeight: 0, flexibleWidth: 9999);
|
||||
|
||||
// Scope buttons
|
||||
|
||||
var scopeLabel = UIFactory.CreateLabel(rowObj, "ScopeLabel", "Scope:", TextAnchor.MiddleLeft, Color.grey);
|
||||
Text scopeLabel = UIFactory.CreateLabel(rowObj, "ScopeLabel", "Scope:", TextAnchor.MiddleLeft, Color.grey);
|
||||
UIFactory.SetLayoutElement(scopeLabel.gameObject, minHeight: 25, minWidth: 60, flexibleWidth: 0);
|
||||
AddScopeFilterButton(rowObj, BindingFlags.Default, true);
|
||||
AddScopeFilterButton(rowObj, BindingFlags.Instance);
|
||||
AddScopeFilterButton(rowObj, BindingFlags.Static);
|
||||
|
||||
var spacer = UIFactory.CreateUIObject("Spacer", rowObj);
|
||||
GameObject spacer = UIFactory.CreateUIObject("Spacer", rowObj);
|
||||
UIFactory.SetLayoutElement(spacer, minWidth: 15);
|
||||
|
||||
// Member type toggles
|
||||
@ -469,9 +469,9 @@ namespace UnityExplorer.Inspectors
|
||||
private void AddScopeFilterButton(GameObject parent, BindingFlags flags, bool setAsActive = false)
|
||||
{
|
||||
string lbl = flags == BindingFlags.Default ? "All" : flags.ToString();
|
||||
var color = setAsActive ? enabledButtonColor : disabledButtonColor;
|
||||
Color color = setAsActive ? enabledButtonColor : disabledButtonColor;
|
||||
|
||||
var button = UIFactory.CreateButton(parent, "Filter_" + flags, lbl, color);
|
||||
ButtonRef button = UIFactory.CreateButton(parent, "Filter_" + flags, lbl, color);
|
||||
UIFactory.SetLayoutElement(button.Component.gameObject, minHeight: 25, flexibleHeight: 0, minWidth: 70, flexibleWidth: 0);
|
||||
scopeFilterButtons.Add(flags, button);
|
||||
|
||||
@ -480,7 +480,7 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
private void AddMemberTypeToggle(GameObject parent, MemberTypes type, int width)
|
||||
{
|
||||
var toggleObj = UIFactory.CreateToggle(parent, "Toggle_" + type, out Toggle toggle, out Text toggleText);
|
||||
GameObject toggleObj = UIFactory.CreateToggle(parent, "Toggle_" + type, out Toggle toggle, out Text toggleText);
|
||||
UIFactory.SetLayoutElement(toggleObj, minHeight: 25, minWidth: width);
|
||||
string color = type switch
|
||||
{
|
||||
|
Reference in New Issue
Block a user