Files
Ultimate-Fishing-Simulator-…/Assets/Plugins/Assembly-CSharp-firstpass/DebuggingEssentials/RuntimeInspector.cs
2026-03-04 09:37:33 +08:00

3934 lines
112 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace DebuggingEssentials
{
public class RuntimeInspector : MonoBehaviour
{
public enum DrawMode
{
Object = 0,
Assembly = 1
}
public delegate void FloatMethod(float newValue);
public enum WindowType
{
Hierarchy = 0,
Inspector = 1
}
public struct Bool3
{
public bool v1;
public bool v2;
public bool v3;
public void Reset()
{
v1 = (v2 = (v3 = false));
}
}
public class DrawInfo : CullItem
{
public static DrawInfo empty = new DrawInfo(foldout: false);
public bool foldout;
public int passSearch;
public DrawInfo(bool foldout)
: base(0)
{
this.foldout = foldout;
}
}
[NonSerialized]
public bool needHierarchySearch;
public bool enableCameraOnStart;
private GUIChangeBool pauseGame = new GUIChangeBool();
private GUIChangeBool useNavigationCamera = new GUIChangeBool();
private GUIChangeBool drawScenes = new GUIChangeBool(value: true);
private GUIChangeBool drawAssemblies = new GUIChangeBool();
private GUIChangeBool drawMemory = new GUIChangeBool();
private GUIChangeBool drawUnityAssemblies = new GUIChangeBool();
private GUIChangeBool drawSystemAssemblies = new GUIChangeBool();
private GUIChangeBool drawMonoAssemblies = new GUIChangeBool();
private GUIChangeBool drawOtherAssemblies = new GUIChangeBool(value: true);
private GUIChangeBool drawMonoBehaviourMemory = new GUIChangeBool(value: true);
private GUIChangeBool drawScriptableObjectMemory = new GUIChangeBool();
private GUIChangeBool drawComponentMemory = new GUIChangeBool();
private GUIChangeBool drawOtherMemory = new GUIChangeBool();
private GUIChangeBool drawCompareFilter = new GUIChangeBool();
private GUIChangeBool drawHideFlags = new GUIChangeBool(value: true);
private GUIChangeBool showHelp = new GUIChangeBool();
private GUIChangeBool showSettings = new GUIChangeBool();
private GUIChangeBool linkSelect = new GUIChangeBool(value: true);
private FastList<DrawInfo> selectList = new FastList<DrawInfo>(32);
private GameObject lastScreenRayedGO;
private static Dictionary<NamespaceTypes, DrawInfo> namespaceTypesLookup = new Dictionary<NamespaceTypes, DrawInfo>();
public static FastList<CustomAssembly> customAssemblies = new FastList<CustomAssembly>();
private static bool hasInitAssemblies;
public Dictionary<string, DrawInfo> memoryLookup = new Dictionary<string, DrawInfo>();
public Dictionary<MemoryObject, DrawInfo> memoryObjectLookup = new Dictionary<MemoryObject, DrawInfo>();
private SortedFastList<MemorySnapshot> memorySnapshots = new SortedFastList<MemorySnapshot>();
private MemorySnapshot selectedMemorySnapshot;
private MemorySnapshot difSnapshot = new MemorySnapshot();
private CompareMode memoryCompareMode;
private bool doMemorySnapshotCompare;
private FastList<Transform> transformList = new FastList<Transform>(4096);
private FastList<Transform> searchPassedList = new FastList<Transform>(4096);
private FastList<DrawInfo> searchFailedList = new FastList<DrawInfo>(4096);
private List<GameObject> searchRootList = new List<GameObject>(1024);
private bool isSearchingScenes;
private FastList<CustomType> searchTypePassedList = new FastList<CustomType>(4096);
private FastList<CustomType> searchTypeFailedList = new FastList<CustomType>(4096);
private int totalCount;
private bool isSearchingAssemblies;
private HashSet<DrawInfo> searchMemoryObjectPassedList = new HashSet<DrawInfo>();
private HashSet<DrawInfo> searchMemoryObjectFailedList = new HashSet<DrawInfo>();
private bool isSearchingMemory;
private int searchGameObjectsPerFrame;
private Vector2 settingsScrollView;
private float refreshHierarchySearch;
private bool scrollToSelected;
private const int prefix = 150;
public const BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy;
private Dictionary<Type, TypeData> typeDataLookup = new Dictionary<Type, TypeData>();
private Dictionary<MethodInfo, string> methodArgumentsLookup = new Dictionary<MethodInfo, string>();
private Dictionary<MemberInfo, MemberData> memberDataLookup = new Dictionary<MemberInfo, MemberData>();
private FastQueue<string> methodArgs = new FastQueue<string>(4);
private ScrollViewCullDrawOnce scrollViewCull = new ScrollViewCullDrawOnce();
private GUIChangeBool showFields = new GUIChangeBool(value: true);
private GUIChangeBool showProperties = new GUIChangeBool(value: true);
private GUIChangeBool showMethods = new GUIChangeBool(value: true);
private GUIChangeBool showInherited = new GUIChangeBool(value: true);
private GUIChangeBool showDeclared = new GUIChangeBool(value: true);
private GUIChangeBool showStatic = new GUIChangeBool(value: true);
private GUIChangeBool showInstance = new GUIChangeBool(value: true);
private GUIChangeBool showPublic = new GUIChangeBool(value: true);
private GUIChangeBool showPrivate = new GUIChangeBool(value: true);
private GUIChangeBool showProtected = new GUIChangeBool(value: true);
private FastList<object> searchObjectList = new FastList<object>(1024);
private List<Component> searchComponentList = new List<Component>(1024);
private FastList<SearchMember> searchMemberList = new FastList<SearchMember>(4096);
private FastList<SearchMember> searchMemberPassedList = new FastList<SearchMember>(4096);
private FastList<SearchMember> searchMemberFailedList = new FastList<SearchMember>(4096);
private HashSet<object> searchDoubles = new HashSet<object>();
private HashSet<object> skip = new HashSet<object>();
private HashSet<Type> searchTypes = new HashSet<Type>();
private bool isSearchingInspector;
private bool needInspectorSearch;
private float refreshInspectorSearch;
private int inspectorSearchLevel = 1;
private int localTotalSearched;
private int searchInspectorPerFrame;
private EditField editField = new EditField();
private string editText;
private int selectAllEditText;
private GameObject oldSelectedGO;
private object oldDrawObject;
private DrawMode drawMode;
private float fieldWidth;
private Type selectedStaticType;
private UnityEngine.Object selectedObject;
private float memberSeparationHeight = 15f;
private int totalSearched;
private int totalFound;
public static RuntimeInspector instance;
public static GameObject selectionIndicatorGO;
public static GameObject selectedGO;
public static NavigationCamera navigationCamera;
public static bool show;
public bool showOnStart;
public bool useSameEditorAsBuildShowKey = true;
public AdvancedKey showToggleKeyEditor = new AdvancedKey(KeyCode.F10);
public AdvancedKey showToggleKeyBuild = new AdvancedKey(KeyCode.F10);
public AdvancedKey gamePauseKey = new AdvancedKey(KeyCode.P, shift: true);
public AdvancedKey focusCameraKey = new AdvancedKey(KeyCode.F);
public AdvancedKey alignWithViewKey = new AdvancedKey(KeyCode.F, shift: true, control: true);
public AdvancedKey moveToViewKey = new AdvancedKey(KeyCode.F, shift: true, control: false, alt: true);
public AdvancedKey followCameraKey = new AdvancedKey(KeyCode.G);
public LayerMask selectLayerMask = 1;
public bool unfoldMultipleScenesOnStart;
public SO_Window windowData;
public SO_NavigationCamera navigationCameraData;
private Dictionary<CustomAssembly, DrawInfo> assemblyLookup = new Dictionary<CustomAssembly, DrawInfo>();
private Dictionary<CustomType, DrawInfo> typeLookup = new Dictionary<CustomType, DrawInfo>();
private Dictionary<Scene, DrawInfo> sceneLookup = new Dictionary<Scene, DrawInfo>();
private Dictionary<Transform, DrawInfo> tLookup = new Dictionary<Transform, DrawInfo>();
private static Dictionary<string, FastList<Type>> typeNameLookup = new Dictionary<string, FastList<Type>>(30000);
private FastList<Dictionary<object, DrawInfo>> memberLookups = new FastList<Dictionary<object, DrawInfo>>();
private List<GameObject> rootList = new List<GameObject>(1024);
private List<Component> components = new List<Component>(1024);
private Texture texArrowFolded;
private Texture texArrowUnfolded;
private GUISkin skin;
private const int memberLookupsCapacity = 128;
private Camera mainCam;
private Vector3 selectionIndicatorLocalPos;
private Quaternion selectionIndicatorLocalRot;
private Vector2 lastMousePos;
private Vector2 mousePos;
private Color colorInherited = new Color(1f, 0.5f, 0.2f, 1f);
private Color colorStatic = new Color(0.5f, 0.5f, 1f);
private Color colorPublic = new Color(0.25f, 1f, 0.25f, 1f);
private Color colorProtected = new Color(1f, 1f, 0.25f);
private Color colorPrivate = new Color(1f, 0.25f, 0.25f, 1f);
private Event currentEvent;
private float oldTimeScale;
private WindowSettings inspectorWindow;
private WindowSettings hierarchyWindow;
private ScrollViewCullData hierarchyCull;
private GUIStyle wrapButton;
private GUIStyle wrapTextField;
private DrawEnum drawEnum;
private int ActiveMemorySnapshotCount
{
get
{
int num = 0;
for (int i = 0; i < memorySnapshots.Count; i++)
{
if (memorySnapshots.items[i].selected.Value)
{
num++;
}
}
return num;
}
}
public static event FloatMethod onTimeScaleChanged;
public static event SetActiveMethod onSetActive;
private void Pause()
{
if (pauseGame.RealValue)
{
oldTimeScale = Time.timeScale;
Time.timeScale = float.Epsilon;
}
else
{
if (oldTimeScale == float.Epsilon)
{
oldTimeScale = 1f;
}
Time.timeScale = oldTimeScale;
}
if (RuntimeInspector.onTimeScaleChanged != null)
{
RuntimeInspector.onTimeScaleChanged(Time.timeScale);
}
}
private void DrawHierarchy(int windowId)
{
WindowManager.BeginRenderTextureGUI();
GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
GUI.color = Color.white;
DrawWindowTitle(Helper.GetGUIContent("Hierarchy", windowData.texHierarchy), hierarchyWindow);
if (hierarchyWindow.isMinimized)
{
GUILayout.Space(-2f);
HierarchyDragAndTooltip(windowId);
return;
}
BeginVerticalBox();
GUILayout.BeginHorizontal();
skin.button.fontSize = 10;
GUILayout.Label("Time Scale", GUILayout.Width(75f));
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Pause", windowData.texPause, "Toggles Time-Scale to 0 and before"), pauseGame, Color.green, 65f))
{
Pause();
}
float timeScale = Time.timeScale;
GUILayout.Label(Time.timeScale.ToString("F2"), GUILayout.Width(30f));
Time.timeScale = GUILayout.HorizontalSlider(Time.timeScale, float.Epsilon, 3f);
if (Time.timeScale == float.Epsilon)
{
pauseGame.Value = true;
}
else
{
pauseGame.Value = false;
}
if (GUILayout.Button(Helper.GetGUIContent("R", "Reset Time-Scale to 1"), GUILayout.Width(20f)))
{
Time.timeScale = 1f;
}
if (Time.timeScale != timeScale && RuntimeInspector.onTimeScaleChanged != null)
{
RuntimeInspector.onTimeScaleChanged(Time.timeScale);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (useNavigationCamera.Value)
{
GUILayout.Label("Fov " + NavigationCamera.fov.ToString("F0"), GUILayout.Width(55f));
NavigationCamera.fov = GUILayout.HorizontalSlider(NavigationCamera.fov, 2f, 90f);
if (GUILayout.Button(Helper.GetGUIContent("R", "Reset fov to 60"), GUILayout.Width(20f)))
{
NavigationCamera.fov = 60f;
}
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
Helper.DrawShowButton(windowData, Helper.GetGUIContent("Help", windowData.texHelp, "Show Controls"), showHelp, Color.green);
Helper.DrawShowButton(windowData, Helper.GetGUIContent("Settings", windowData.texSettings, "Change tooltip, search and Camera settings"), showSettings, Color.green);
Texture image = (NavigationCamera.followTarget ? windowData.texCameraFollow : windowData.texCamera);
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Camera", image, "Toggle navigation camera\n\nWhen enabled use:\n" + focusCameraKey?.ToString() + " to focus on the selected object\n" + followCameraKey?.ToString() + " to follow the selected object"), useNavigationCamera, Color.green))
{
if (useNavigationCamera.RealValue)
{
EnableCamControl();
}
else
{
DisableCamControl();
}
}
if (navigationCamera == null || NavigationCamera.cam == null)
{
navigationCamera = null;
useNavigationCamera.Value = false;
}
if (Application.isEditor)
{
Helper.DrawShowButton(windowData, Helper.GetGUIContent("Link Select", "Link selected to Unity's hierarchy window"), linkSelect, Color.green);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
Helper.DrawShowButton(windowData, Helper.GetGUIContent("Child Count", "Shows the child count for each GameObject"), windowData.showChildCount, Color.green);
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Scenes", windowData.texScene, "Scene Mode"), drawScenes, Color.green, -1f, onlyActivate: true))
{
GUIChangeBool gUIChangeBool = drawAssemblies;
bool value = (drawMemory.Value = false);
gUIChangeBool.Value = value;
if (selectedGO != null)
{
scrollViewCull.recalc = true;
}
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Assemblies", windowData.texAssembly, "Assembly Mode"), drawAssemblies, Color.green, -1f, onlyActivate: true))
{
GUIChangeBool gUIChangeBool2 = drawMemory;
bool value = (drawScenes.Value = false);
gUIChangeBool2.Value = value;
if (needHierarchySearch)
{
refreshHierarchySearch = 1f;
}
if (selectedStaticType != null)
{
scrollViewCull.recalc = true;
}
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Memory", windowData.texMemory, "Memory Mode"), drawMemory, Color.green, -1f, onlyActivate: true))
{
drawScenes.Value = false;
drawAssemblies.Value = false;
if (selectedObject != null)
{
scrollViewCull.recalc = true;
}
}
GUILayout.EndHorizontal();
if (drawAssemblies.Value)
{
GUILayout.BeginHorizontal();
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Unity", "Show/Hide Unity Assemblies\nShift click to multi select"), drawUnityAssemblies, Color.green))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool3 = drawSystemAssemblies;
GUIChangeBool gUIChangeBool4 = drawMonoAssemblies;
bool flag3 = (drawOtherAssemblies.Value = false);
bool value = (gUIChangeBool4.Value = flag3);
gUIChangeBool3.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("System", "Show/Hide System Assemblies\nShift click to multi select"), drawSystemAssemblies, Color.green))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool5 = drawUnityAssemblies;
GUIChangeBool gUIChangeBool6 = drawMonoAssemblies;
bool flag3 = (drawOtherAssemblies.Value = false);
bool value = (gUIChangeBool6.Value = flag3);
gUIChangeBool5.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Mono", "Show/Hide Mono Assemblies\nShift click to multi select"), drawMonoAssemblies, Color.green))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool7 = drawUnityAssemblies;
GUIChangeBool gUIChangeBool8 = drawSystemAssemblies;
bool flag3 = (drawOtherAssemblies.Value = false);
bool value = (gUIChangeBool8.Value = flag3);
gUIChangeBool7.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Other", "Show/Hide All Other Assemblies\nShift click to multi select"), drawOtherAssemblies, Color.green))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool9 = drawUnityAssemblies;
GUIChangeBool gUIChangeBool10 = drawSystemAssemblies;
bool flag3 = (drawMonoAssemblies.Value = false);
bool value = (gUIChangeBool10.Value = flag3);
gUIChangeBool9.Value = value;
}
refreshHierarchySearch = 1f;
}
GUILayout.EndHorizontal();
}
else if (drawMemory.Value)
{
bool flag12 = selectedMemorySnapshot == difSnapshot;
if (currentEvent.type == EventType.Layout)
{
if (doMemorySnapshotCompare)
{
doMemorySnapshotCompare = false;
DoMemorySnapshotCompare();
flag12 = selectedMemorySnapshot == difSnapshot;
}
if (flag12)
{
if (drawCompareFilter.Value)
{
if (!difSnapshot.hasCleanedDifCompare)
{
difSnapshot.CleanDifSnapshot(memoryCompareMode);
}
}
else if (difSnapshot.hasCleanedDifCompare)
{
doMemorySnapshotCompare = true;
}
}
}
GUILayout.BeginHorizontal();
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("MonoBehaviour", "Show/Hide Memory Objects that are MonoBehaviours\nShift click to multi select"), drawMonoBehaviourMemory, Color.green, -1f, !currentEvent.shift))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool11 = drawComponentMemory;
GUIChangeBool gUIChangeBool12 = drawScriptableObjectMemory;
bool flag3 = (drawOtherMemory.Value = false);
bool value = (gUIChangeBool12.Value = flag3);
gUIChangeBool11.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("ScriptableObject", "Show/Hide Memory Objects that are ScriptableObjects\nShift click to multi select"), drawScriptableObjectMemory, Color.green, -1f, !currentEvent.shift))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool13 = drawMonoBehaviourMemory;
GUIChangeBool gUIChangeBool14 = drawComponentMemory;
bool flag3 = (drawOtherMemory.Value = false);
bool value = (gUIChangeBool14.Value = flag3);
gUIChangeBool13.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Component", "Show/Hide Memory Objects that are Components\nShift click to multi select"), drawComponentMemory, Color.green, -1f, !currentEvent.shift))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool15 = drawMonoBehaviourMemory;
GUIChangeBool gUIChangeBool16 = drawScriptableObjectMemory;
bool flag3 = (drawOtherMemory.Value = false);
bool value = (gUIChangeBool16.Value = flag3);
gUIChangeBool15.Value = value;
}
refreshHierarchySearch = 1f;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Other", "Show/Hide other Memory Objects\nShift click to multi select"), drawOtherMemory, Color.green, -1f, !currentEvent.shift))
{
if (!currentEvent.shift)
{
GUIChangeBool gUIChangeBool17 = drawMonoBehaviourMemory;
GUIChangeBool gUIChangeBool18 = drawScriptableObjectMemory;
bool flag3 = (drawComponentMemory.Value = false);
bool value = (gUIChangeBool18.Value = flag3);
gUIChangeBool17.Value = value;
}
refreshHierarchySearch = 1f;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (GUILayout.Button(Helper.GetGUIContent("Take Snapshot", "Take Memory Snapshot"), GUILayout.Width(85f), GUILayout.Height(20f)))
{
ScanMemory();
}
if (GUILayout.Button(Helper.GetGUIContent("Sort", (memoryCompareMode == CompareMode.Key) ? windowData.texAlphabeticSort : windowData.texCountSort, "Toggle sorting between alphabetic and child count"), GUILayout.Width(50f), GUILayout.Height(20f)))
{
if (memoryCompareMode == CompareMode.Key)
{
memoryCompareMode = CompareMode.Value;
}
else
{
memoryCompareMode = CompareMode.Key;
}
if (flag12)
{
difSnapshot.memoryTypesLookup.Sort(memoryCompareMode);
}
else if (selectedMemorySnapshot != null)
{
selectedMemorySnapshot.memoryTypesLookup.Sort(memoryCompareMode);
}
}
Helper.DrawShowButton(windowData, Helper.GetGUIContent("Filter Compare", "Toggle Filter Compare\nRemoves 'added' and 'removed' Objects from a compare, when they have the same name"), drawCompareFilter, Color.green, 85f);
Helper.DrawShowButton(windowData, Helper.GetGUIContent("HideFlags", "Show HideFlags icons"), drawHideFlags, Color.green, 60f);
GUILayout.EndHorizontal();
int activeMemorySnapshotCount = ActiveMemorySnapshotCount;
if (memorySnapshots.Count > 0)
{
GUILayout.BeginHorizontal();
int num = 0;
for (int i = 0; i < memorySnapshots.Count; i++)
{
MemorySnapshot memorySnapshot = memorySnapshots.items[i];
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent(memorySnapshot.tStamp.ToString("F1"), "Shift Click => Compare\nControl Click => Delete"), memorySnapshot.selected, Color.green, 54.65f, onlyActivate: true))
{
refreshHierarchySearch = 1f;
if (currentEvent.shift)
{
if (activeMemorySnapshotCount == 1)
{
doMemorySnapshotCompare = true;
}
else if (memorySnapshot.selected.Value)
{
memorySnapshot.selected.Value = false;
}
else
{
SelectMemorySnapshot(i);
}
}
else if (currentEvent.control)
{
memorySnapshots.RemoveAt(i--);
if (memorySnapshot.selected.Value)
{
SelectFirstSelectedMemorySnapshot();
}
}
else
{
SelectMemorySnapshot(i);
}
}
if (++num >= 5)
{
num = 0;
GUILayout.EndHorizontal();
if (i < memorySnapshots.Count - 1)
{
GUILayout.BeginHorizontal();
}
}
}
if (num > 0)
{
GUILayout.EndHorizontal();
}
}
}
skin.button.fontSize = 0;
bool flag21 = showHelp.Value || showSettings.Value;
if (flag21)
{
float num2 = (showHelp.Value ? 252 : 0) + (showSettings.Value ? 372 : 0);
if (num2 > windowData.hierarchyWindow.rect.height - 250f)
{
num2 = windowData.hierarchyWindow.rect.height - 250f;
}
settingsScrollView = GUILayout.BeginScrollView(settingsScrollView, GUILayout.Height(num2));
}
if (showHelp.Value)
{
DrawHelp();
}
if (showSettings.Value)
{
DrawSettings();
}
if (flag21)
{
GUILayout.EndScrollView();
}
if (DrawSearch(hierarchyWindow, changeText2: false))
{
refreshHierarchySearch = 1f;
}
skin.button.alignment = TextAnchor.MiddleLeft;
if (currentEvent.type == EventType.Layout)
{
hierarchyWindow.UpdateScrollView();
}
hierarchyWindow.rectStartScroll = GUILayoutUtility.GetLastRect();
hierarchyWindow.scrollView = GUILayout.BeginScrollView(hierarchyWindow.scrollView);
hierarchyCull.Start(hierarchyWindow);
if (drawScenes.Value)
{
DrawScenes();
}
else if (drawAssemblies.Value)
{
DrawAssemblies();
}
else if (drawMemory.Value)
{
DrawMemory(selectedMemorySnapshot);
}
hierarchyCull.End();
GUILayout.EndScrollView();
GUILayout.EndVertical();
HierarchyDragAndTooltip(windowId);
WindowManager.EndRenderTextureGUI();
}
private void HierarchyDragAndTooltip(int windowId)
{
if (Helper.Drag(hierarchyWindow, inspectorWindow, hierarchyWindow, titleDrag: false) && inspectorWindow.isDocked.Value)
{
scrollViewCull.recalc = true;
}
WindowManager.SetToolTip(windowId);
}
private void DrawHelp()
{
BeginVerticalBox();
DrawPrefixLabel("Shift Click '>' button", "Foldout one level", 150);
DrawPrefixLabel("Control Click '>' button", "Fold one level", 150);
DrawPrefixLabel("Alt Click '>' button", "Foldout all up/down", 150);
DrawPrefixLabel("Shift Click GameObject", "Toggle Active", 150);
DrawPrefixLabel("Shift Click Inspector", "Dock", 150);
DrawPrefixLabel("Click Component in Inspector", "Search inside it", 150);
DrawPrefixLabel("Right Click Scene", "Set Active Scene", 150);
DrawPrefixLabel("Control Click 'D'", "Duplicate GameObject", 150);
DrawPrefixLabel("'Del'", "Delete GameObject", 150);
GUILayout.EndVertical();
}
private void DrawSettings()
{
WindowManager windowManager = WindowManager.instance;
BeginVerticalBox();
DrawToggleField("Show Tooltips", ref windowData.showTooltip);
GUILayout.Space(5f);
GUILayout.BeginHorizontal();
GUILayout.Label(Helper.GetGUIContent("Selection Sphere " + windowData.selectionSphereRadius.ToString("F2"), "The radius of the Selection Sphere"), GUILayout.Width(150f));
GUI.changed = false;
windowData.selectionSphereRadius = GUILayout.HorizontalSlider(windowData.selectionSphereRadius, 0.02f, 1f);
if (GUI.changed)
{
SetSelectionSphereRadius();
}
GUILayout.EndHorizontal();
GUILayout.Space(5f);
DrawInputField("GUI Scale", windowManager.windowData.guiScale);
if (windowManager.windowData.guiScale.value < 0.55f)
{
windowManager.windowData.guiScale.value = 0.55f;
}
if (windowManager.windowData.guiScale.value > 10f)
{
windowManager.windowData.guiScale.value = 10f;
}
GUILayout.Space(5f);
DrawBoldLabel(skin, "Search", 0f);
DrawInputField("GameObjects Per Frame", windowData.searchGameObjectsPerFrame);
DrawInputField("Assembly Per Frame", windowData.searchAssemblyPerFrame);
DrawInputField("Inspector Per Frame", windowData.searchInspectorPerFrame);
GUILayout.Space(5f);
DrawBoldLabel(skin, "Camera", 0f);
DrawInputField("Mouse Sensivity", navigationCameraData.mouseSensitity);
DrawInputField("Acceleration Multi", navigationCameraData.accelMulti);
DrawInputField("Deceleration Multi", navigationCameraData.decelMulti);
DrawInputField("Speed Slow", navigationCameraData.speedSlow);
DrawInputField("Speed Normal", navigationCameraData.speedNormal);
DrawInputField("Speed Fast", navigationCameraData.speedFast);
DrawInputField("Mouse ScrollWheel Multi", navigationCameraData.mouseScrollWheelMulti);
DrawInputField("Mouse Strafe Multi", navigationCameraData.mouseStrafeMulti);
GUILayout.EndVertical();
}
public static void InitAssemblies()
{
if (!hasInitAssemblies)
{
CustomAssembly.InitAssemblies(ref hasInitAssemblies, customAssemblies, namespaceTypesLookup, typeNameLookup);
}
}
private void DrawAssemblies()
{
for (int i = 0; i < customAssemblies.Count; i++)
{
CustomAssembly customAssembly = customAssemblies.items[i];
string text = customAssembly.name;
AssemblyType type = customAssembly.type;
if ((type == AssemblyType.Unity && !drawUnityAssemblies.Value) || (type == AssemblyType.System && !drawSystemAssemblies.Value) || (type == AssemblyType.Mono && !drawMonoAssemblies.Value) || (type == AssemblyType.Other && !drawOtherAssemblies.Value))
{
continue;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(assemblyLookup, customAssembly);
if (needHierarchySearch && objectDrawInfo.passSearch == 0)
{
continue;
}
if (!Helper.IsCulled(ref hierarchyCull))
{
GUI.backgroundColor = new Color(0.4f, 0.5f, 1f, 1f);
skin.button.fontStyle = FontStyle.Bold;
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, customAssembly.namespaceLookup.list.Count + customAssembly.types.Count, text);
skin.button.fontStyle = FontStyle.Normal;
if (@bool.v3)
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
}
}
if (PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass: true, hierarchyWindow.showSearchNonFound, isChild: false))
{
DrawAssembly(customAssembly, objectDrawInfo.foldout);
}
}
}
private void DrawAssembly(CustomAssembly assembly, bool hasSearchPass)
{
int num = 15;
FastList<ItemHolder<string, NamespaceTypes>> list = assembly.namespaceLookup.list;
for (int i = 0; i < list.Count; i++)
{
NamespaceTypes value = list.items[i].value;
DrawInfo objectDrawInfo = GetObjectDrawInfo(namespaceTypesLookup, value);
if (!PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: true))
{
continue;
}
if (!Helper.IsCulled(ref hierarchyCull))
{
GUI.backgroundColor = new Color(1f, 1f, 0.5f, 1f);
skin.button.fontStyle = FontStyle.Bold;
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, value.types.Count, value.name, null, string.Empty, isActive: true, num);
skin.button.fontStyle = FontStyle.Normal;
if (@bool.v3)
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
}
}
if (PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: false))
{
DrawAssemblyTypes(value.types, num + 15, objectDrawInfo.foldout);
}
}
if (assembly.types.Count > 0)
{
DrawAssemblyTypes(assembly.types, num, hasSearchPass);
}
}
private void DrawAssemblyTypes(FastList<CustomType> customTypes, int indent, bool hasSearchPass)
{
for (int i = 0; i < customTypes.Count; i++)
{
CustomType customType = customTypes.items[i];
DrawInfo objectDrawInfo = GetObjectDrawInfo(typeLookup, customType);
if (!PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: true) || Helper.IsCulled(ref hierarchyCull))
{
continue;
}
GUI.backgroundColor = GetColor(customType.type, selectedStaticType, needHierarchySearch, objectDrawInfo);
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, 0, customType.type.Name, null, string.Empty, isActive: true, indent);
GUI.backgroundColor = GetColor(Color.white);
if (@bool.v3)
{
if (selectedStaticType == customType.type)
{
selectedStaticType = null;
}
else
{
selectedStaticType = customType.type;
}
}
}
}
private void SelectMemorySnapshot(int snapshotIndex)
{
for (int i = 0; i < memorySnapshots.Count; i++)
{
memorySnapshots.items[i].selected.Value = false;
}
selectedMemorySnapshot = memorySnapshots.items[snapshotIndex];
selectedMemorySnapshot.selected.Value = true;
}
private void SelectFirstSelectedMemorySnapshot()
{
bool flag = false;
for (int i = 0; i < memorySnapshots.Count; i++)
{
MemorySnapshot memorySnapshot = memorySnapshots.items[i];
if (memorySnapshot.selected.Value)
{
selectedMemorySnapshot = memorySnapshot;
flag = true;
break;
}
}
if (!flag)
{
selectedMemorySnapshot = null;
}
}
private void DoMemorySnapshotCompare()
{
MemorySnapshot memorySnapshot = null;
MemorySnapshot memorySnapshot2 = null;
for (int i = 0; i < memorySnapshots.Count; i++)
{
if (memorySnapshots.items[i].selected.Value)
{
if (memorySnapshot != null)
{
memorySnapshot2 = memorySnapshots.items[i];
break;
}
memorySnapshot = memorySnapshots.items[i];
}
}
if (memorySnapshot != null && memorySnapshot2 != null)
{
MemorySnapshot.CompareMemorySnapshots(memorySnapshot, memorySnapshot2, difSnapshot, memoryCompareMode);
selectedMemorySnapshot = difSnapshot;
}
}
private void ScanMemory()
{
refreshHierarchySearch = 1f;
MemorySnapshot memorySnapshot = new MemorySnapshot();
memorySnapshots.Add(memorySnapshot);
SelectMemorySnapshot(memorySnapshots.Count - 1);
memorySnapshot.ScanMemory(memoryCompareMode);
selectedMemorySnapshot = memorySnapshot;
}
private void DrawMemory(MemorySnapshot memorySnapshot)
{
if (memorySnapshot == null)
{
return;
}
FastSortedDictionary<string, MemoryInstanceType> memoryTypesLookup = memorySnapshot.memoryTypesLookup;
for (int i = 0; i < memoryTypesLookup.list.Count; i++)
{
ItemHolder<string, MemoryInstanceType> itemHolder = memoryTypesLookup.list.items[i];
string key = itemHolder.key;
MemoryInstanceType value = itemHolder.value;
if ((value.memoryType == MemoryType.MonoBehaviour && !drawMonoBehaviourMemory.Value) || (value.memoryType == MemoryType.Component && !drawComponentMemory.Value) || (value.memoryType == MemoryType.ScriptableObject && !drawScriptableObjectMemory.Value) || (value.memoryType == MemoryType.Other && !drawOtherMemory.Value))
{
continue;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(memoryLookup, key);
if (needHierarchySearch && objectDrawInfo.passSearch == 0)
{
continue;
}
bool num = Helper.IsCulled(ref hierarchyCull);
Texture icon = windowData.componentIcons.GetIcon(value.type);
if (!num)
{
GUI.backgroundColor = new Color(0.4f, 0.5f, 1f, 1f);
skin.button.fontStyle = FontStyle.Bold;
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, value.instances.list.Count, key, icon);
skin.button.fontStyle = FontStyle.Normal;
GUI.backgroundColor = Color.white;
if (@bool.v3)
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
}
}
if (PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass: true, hierarchyWindow.showSearchNonFound, isChild: false))
{
DrawMemoryInstances(memorySnapshot, value, objectDrawInfo.foldout, icon);
}
}
}
private void DrawMemoryInstances(MemorySnapshot memorySnapshot, MemoryInstanceType memoryInstanceType, bool hasSearchPass, Texture icon)
{
int num = 15;
FastList<MemoryObject> list = memoryInstanceType.instances.list;
if (!memoryInstanceType.isSorted)
{
memoryInstanceType.Sort();
}
bool flag = memorySnapshot == difSnapshot;
if (flag)
{
num += 15;
}
bool value = drawHideFlags.Value;
for (int i = 0; i < list.Count; i++)
{
MemoryObject memoryObject = list.items[i];
UnityEngine.Object obj = Helper.FindObjectFromInstanceID(memoryObject.instanceId);
DrawInfo objectDrawInfo = GetObjectDrawInfo(memoryObjectLookup, memoryObject);
if (!PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: true))
{
continue;
}
bool num2 = Helper.IsCulled(ref hierarchyCull);
string tooltip = string.Empty;
if (num2)
{
continue;
}
if (obj == null)
{
tooltip = "Object is Destroyed";
}
GUI.backgroundColor = GetColor(obj, selectedObject, needHierarchySearch, objectDrawInfo);
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, 0, memoryObject.name, icon, tooltip, isActive: true, num);
if (memoryObject.hideFlags != HideFlags.None || memoryObject.isPrefab || obj == null)
{
DrawHideFlagsIcons(obj, value ? memoryObject.hideFlags : HideFlags.None, memoryObject.isPrefab, memoryObject.name);
}
GUI.backgroundColor = Color.white;
GUI.color = Color.white;
if (flag)
{
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.x = 37 + (windowData.showChildCount.Value ? 29 : 0);
lastRect.width = 20f;
if (memoryObject.compareResult == CompareResult.Removed)
{
GUI.backgroundColor = Color.red;
tooltip = "Compare Result => Object is removed";
}
else
{
GUI.backgroundColor = Color.green;
tooltip = "Compare Result => Object is new";
}
GUI.Button(lastRect, Helper.GetGUIContent(string.Empty, null, tooltip));
GUI.backgroundColor = Color.white;
}
if (@bool.v3 && obj != null)
{
if (selectedObject == obj)
{
selectedObject = null;
}
else
{
selectedObject = obj;
}
}
}
}
private void DrawScenes()
{
Scene activeScene = SceneManager.GetActiveScene();
int sceneCount = SceneManager.sceneCount;
for (int i = 0; i < sceneCount; i++)
{
Scene sceneAt = SceneManager.GetSceneAt(i);
DrawScene(sceneAt, activeScene, sceneCount);
}
if (WindowManager.instance.useDontDestroyOnLoadScene)
{
Scene sceneAt = WindowManager.instance.gameObject.scene;
DrawScene(sceneAt, activeScene, sceneCount);
}
}
private void DrawScene(Scene scene, Scene activeScene, int sceneCount)
{
DrawInfo objectDrawInfo = GetObjectDrawInfo(sceneLookup, scene, unfoldMultipleScenesOnStart || sceneCount == 1);
scene.GetRootGameObjects(rootList);
if (!Helper.IsCulled(ref hierarchyCull))
{
GUI.backgroundColor = ((scene == activeScene) ? GetColor(new Color(0.25f, 1f, 0.25f)) : GetColor(Color.yellow));
GUI.skin.button.fontStyle = FontStyle.Bold;
string text = scene.name;
if (text == string.Empty)
{
text = "Untitled";
}
if (DrawElement(hierarchyWindow, objectDrawInfo, rootList.Count, text, windowData.texScene).v3)
{
if (currentEvent.button == 1)
{
SceneManager.SetActiveScene(scene);
}
else if (currentEvent.shift)
{
FoldOutScene(scene, rootList);
}
else if (currentEvent.control)
{
FoldInScene(scene, rootList);
}
else if (currentEvent.alt)
{
FoldScene(scene, rootList, !objectDrawInfo.foldout);
}
else
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
}
}
GUI.skin.button.fontStyle = FontStyle.Normal;
GUI.backgroundColor = GetColor(Color.white);
}
if (PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass: false, hierarchyWindow.showSearchNonFound, isChild: false))
{
DrawSceneGameObjects(rootList, objectDrawInfo.foldout);
}
}
private bool PassedFoldout(DrawInfo info, bool needSearch, bool hasSearchPass, bool showSearchNonFound, bool isChild)
{
if (!needSearch)
{
return info.foldout || isChild;
}
if (info.passSearch <= 0 && !(hasSearchPass && showSearchNonFound))
{
if (info.foldout)
{
return info.passSearch > 0;
}
return false;
}
return true;
}
private void DrawSceneGameObjects(List<GameObject> goList, bool hasSearchPass)
{
int indent = 20;
for (int i = 0; i < goList.Count; i++)
{
DrawGameObject(goList[i], ref indent, hasSearchPass);
}
}
private void DrawGameObjects(Transform t, int indent, bool hasSearchPass)
{
indent += 15;
int childCount = t.childCount;
for (int i = 0; i < childCount; i++)
{
DrawGameObject(t.GetChild(i).gameObject, ref indent, hasSearchPass);
}
}
private void DrawGameObject(GameObject go, ref int indent, bool hasSearchPass)
{
Transform transform = go.transform;
DrawInfo objectDrawInfo = GetObjectDrawInfo(tLookup, transform);
if (!PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: true))
{
return;
}
int childCount = transform.childCount;
bool flag = childCount > 0;
bool flag2 = Helper.IsCulled(ref hierarchyCull);
if (scrollToSelected && go == selectedGO)
{
scrollToSelected = false;
hierarchyWindow.newScrollViewY = Mathf.Max(hierarchyCull.scrollWindowPosY - (hierarchyWindow.rect.height / 2f - (hierarchyWindow.rectStartScroll.y + 42f)), 0f);
}
if (!(!flag2 || flag))
{
return;
}
if (!flag2)
{
GUI.backgroundColor = GetColor(go, selectedGO, needHierarchySearch, objectDrawInfo);
Bool3 @bool = DrawElement(hierarchyWindow, objectDrawInfo, childCount, transform.name, windowData.componentIcons.gameObjectIcon, string.Empty, go.activeInHierarchy, indent);
GUI.backgroundColor = GetColor(Color.white);
if (@bool.v1)
{
if (currentEvent.shift)
{
go.SetActive(!go.activeInHierarchy);
}
else if (selectedGO == go)
{
SelectGameObject(null);
}
else
{
SelectGameObject(go);
}
}
else if (@bool.v2)
{
if (currentEvent.shift)
{
FoldOutGameObjects(transform);
}
else if (currentEvent.control)
{
FoldInGameObjects(transform);
}
else if (currentEvent.alt)
{
FoldGameObject(transform, !objectDrawInfo.foldout);
}
else
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
}
}
}
if (flag && PassedFoldout(objectDrawInfo, needHierarchySearch, hasSearchPass, hierarchyWindow.showSearchNonFound, isChild: false))
{
DrawGameObjects(transform, indent, objectDrawInfo.foldout);
}
}
private void FoldScene(Scene scene, List<GameObject> rootList, bool foldout)
{
int count = rootList.Count;
if (count != 0)
{
GetObjectDrawInfo(sceneLookup, scene).foldout = foldout;
for (int i = 0; i < count; i++)
{
FoldGameObject(rootList[i].transform, foldout);
}
}
}
private bool FoldOutScene(Scene scene, List<GameObject> rootList)
{
int count = rootList.Count;
if (count == 0)
{
return false;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(sceneLookup, scene);
if (objectDrawInfo.foldout)
{
for (int i = 0; i < count; i++)
{
FoldOutGameObjects(rootList[i].transform);
}
}
else
{
objectDrawInfo.foldout = true;
}
return true;
}
private bool FoldInScene(Scene scene, List<GameObject> rootList)
{
int count = rootList.Count;
if (count == 0)
{
return false;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(sceneLookup, scene);
if (objectDrawInfo.foldout)
{
bool flag = false;
for (int i = 0; i < count; i++)
{
if (FoldInGameObjects(rootList[i].transform))
{
flag = true;
}
}
if (!flag)
{
objectDrawInfo.foldout = false;
}
return true;
}
return false;
}
private void FoldGameObject(Transform t, bool foldout)
{
int childCount = t.childCount;
if (childCount != 0)
{
GetObjectDrawInfo(tLookup, t).foldout = foldout;
for (int i = 0; i < childCount; i++)
{
FoldGameObject(t.GetChild(i), foldout);
}
}
}
private bool FoldOutGameObjects(Transform t)
{
int childCount = t.childCount;
if (childCount == 0)
{
return false;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(tLookup, t);
if (objectDrawInfo.foldout)
{
for (int i = 0; i < childCount; i++)
{
FoldOutGameObjects(t.GetChild(i));
}
}
else
{
objectDrawInfo.foldout = true;
}
return true;
}
private bool FoldInGameObjects(Transform t)
{
int childCount = t.childCount;
if (childCount == 0)
{
return false;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(tLookup, t);
if (objectDrawInfo.foldout)
{
bool flag = false;
for (int i = 0; i < childCount; i++)
{
if (FoldInGameObjects(t.GetChild(i)))
{
flag = true;
}
}
if (!flag)
{
objectDrawInfo.foldout = false;
}
return true;
}
return false;
}
private void SearchMemory()
{
if (refreshHierarchySearch != 0f && !isSearchingMemory && selectedMemorySnapshot != null)
{
StartCoroutine(SearchMemoryCR());
}
}
private IEnumerator SearchMemoryCR()
{
yield return null;
refreshHierarchySearch = 0f;
isSearchingMemory = true;
searchMemoryObjectPassedList.Clear();
searchMemoryObjectFailedList.Clear();
int count = 0;
totalCount = 0;
FastList<ItemHolder<string, MemoryInstanceType>> list = selectedMemorySnapshot.memoryTypesLookup.list;
int i = 0;
while (true)
{
if (i < list.Count)
{
MemoryInstanceType mit = list.items[i].value;
if ((mit.memoryType != MemoryType.Component || drawComponentMemory.RealValue) && (mit.memoryType != MemoryType.MonoBehaviour || drawMonoBehaviourMemory.RealValue) && (mit.memoryType != MemoryType.ScriptableObject || drawScriptableObjectMemory.RealValue) && (mit.memoryType != MemoryType.Other || drawOtherMemory.RealValue))
{
DrawInfo mitInfo = GetObjectDrawInfo(memoryLookup, mit.type.Name);
FastList<MemoryObject> instances = mit.instances.list;
for (int j = 0; j < instances.Count; j++)
{
if (!needHierarchySearch)
{
goto end_IL_0284;
}
MemoryObject memoryObject = instances.items[j];
DrawInfo objectDrawInfo = GetObjectDrawInfo(memoryObjectLookup, memoryObject);
if (PassSearch(WindowType.Hierarchy, null, memoryObject.name, mit.type))
{
objectDrawInfo.passSearch = 2;
searchMemoryObjectPassedList.Add(mitInfo);
}
else
{
objectDrawInfo.passSearch = 0;
searchMemoryObjectFailedList.Add(mitInfo);
}
if (count++ > windowData.searchGameObjectsPerFrame.value)
{
count = 0;
yield return null;
}
}
}
i++;
continue;
}
foreach (DrawInfo searchMemoryObjectFailed in searchMemoryObjectFailedList)
{
searchMemoryObjectFailed.passSearch = 0;
}
foreach (DrawInfo searchMemoryObjectPassed in searchMemoryObjectPassedList)
{
searchMemoryObjectPassed.passSearch = 1;
}
break;
continue;
end_IL_0284:
break;
}
isSearchingMemory = false;
}
private void SearchAssemblies()
{
if (hasInitAssemblies && refreshHierarchySearch != 0f && !isSearchingAssemblies)
{
StartCoroutine(SearchAssembliesCR());
}
}
private IEnumerator SearchAssembliesCR()
{
refreshHierarchySearch = 0f;
isSearchingAssemblies = true;
searchTypePassedList.Clear();
searchTypeFailedList.Clear();
int count = 0;
totalCount = 0;
int i = 0;
while (true)
{
if (i < customAssemblies.Count)
{
CustomAssembly customAssembly = customAssemblies.items[i];
if ((customAssembly.type != AssemblyType.Unity || drawUnityAssemblies.RealValue) && (customAssembly.type != AssemblyType.System || drawSystemAssemblies.RealValue) && (customAssembly.type != AssemblyType.Mono || drawMonoAssemblies.RealValue) && (customAssembly.type != AssemblyType.Other || drawOtherAssemblies.RealValue))
{
int startIndex = 0;
while (startIndex >= 0)
{
startIndex = SearchThroughTypes(customAssembly.types, startIndex, ref count);
if (startIndex >= 0)
{
yield return null;
}
}
if (startIndex == -2)
{
break;
}
FastList<ItemHolder<string, NamespaceTypes>> namespaceList = customAssembly.namespaceLookup.list;
for (int j = 0; j < namespaceList.Count; j++)
{
NamespaceTypes namespaceTypes = namespaceList.items[j].value;
startIndex = 0;
while (startIndex >= 0)
{
startIndex = SearchThroughTypes(namespaceTypes.types, startIndex, ref count);
if (startIndex >= 0)
{
yield return null;
}
}
if (startIndex == -2)
{
goto end_IL_024b;
}
}
}
i++;
continue;
}
for (int k = 0; k < searchTypeFailedList.Count; k++)
{
SetFound(searchTypeFailedList.items[k], found: false);
}
for (int l = 0; l < searchTypePassedList.Count; l++)
{
SetFound(searchTypePassedList.items[l], found: true);
}
break;
continue;
end_IL_024b:
break;
}
isSearchingAssemblies = false;
}
private void SetFound(CustomType customType, bool found)
{
CustomAssembly obj;
DrawInfo objectDrawInfo;
if (customType.parent is NamespaceTypes namespaceTypes)
{
objectDrawInfo = GetObjectDrawInfo(namespaceTypesLookup, namespaceTypes);
if (found)
{
if (objectDrawInfo.passSearch == 0)
{
objectDrawInfo.passSearch = 1;
}
}
else
{
objectDrawInfo.passSearch = 0;
}
obj = (CustomAssembly)namespaceTypes.parent;
}
else
{
obj = (CustomAssembly)customType.parent;
}
objectDrawInfo = GetObjectDrawInfo(assemblyLookup, obj);
if (found)
{
if (objectDrawInfo.passSearch == 0)
{
objectDrawInfo.passSearch = 1;
}
}
else
{
objectDrawInfo.passSearch = 0;
}
}
private int SearchThroughTypes(FastList<CustomType> types, int startIndex, ref int count)
{
for (int i = startIndex; i < types.Count; i++)
{
if (!needHierarchySearch)
{
return -2;
}
CustomType customType = types.items[i];
totalCount++;
DrawInfo objectDrawInfo = GetObjectDrawInfo(typeLookup, customType);
if (PassSearch(WindowType.Hierarchy, null, customType.type.Name, customType.type))
{
objectDrawInfo.passSearch = 2;
searchTypePassedList.Add(customType);
}
else
{
objectDrawInfo.passSearch = 0;
searchTypeFailedList.Add(customType);
}
if (count++ > windowData.searchAssemblyPerFrame.value)
{
count = 0;
return i + 1;
}
}
return -1;
}
private void SearchScenes()
{
if (!isSearchingScenes)
{
StartCoroutine(SearchScenesCR());
}
}
private void SetSearchObjectsPerFrame()
{
searchGameObjectsPerFrame = Mathf.Max(Mathf.CeilToInt((float)windowData.searchGameObjectsPerFrame.value * refreshHierarchySearch), 1);
}
private IEnumerator SearchScenesCR()
{
isSearchingScenes = true;
searchPassedList.Clear();
searchFailedList.Clear();
transformList.Clear();
int count = 0;
SetSearchObjectsPerFrame();
int i = 0;
while (true)
{
if (i < SceneManager.sceneCount)
{
SceneManager.GetSceneAt(i).GetRootGameObjects(searchRootList);
for (int j = 0; j < searchRootList.Count; j++)
{
transformList.Add(searchRootList[j].transform);
}
yield return null;
for (int k = 0; k < transformList.Count; k++)
{
if (!needHierarchySearch)
{
goto end_IL_029a;
}
Transform t = transformList.items[k];
if (t == null)
{
continue;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(tLookup, t);
if (PassSearch(WindowType.Hierarchy, t, null, null))
{
objectDrawInfo.passSearch = 2;
searchPassedList.Add(t);
}
else
{
searchFailedList.Add(objectDrawInfo);
}
if (t.childCount > 0)
{
for (int l = 0; l < t.childCount; l++)
{
transformList.Add(t.GetChild(l));
if (count++ > searchGameObjectsPerFrame)
{
count = 0;
yield return null;
SetSearchObjectsPerFrame();
if (t == null)
{
break;
}
}
}
}
if (count++ > searchGameObjectsPerFrame)
{
count = 0;
yield return null;
SetSearchObjectsPerFrame();
}
}
transformList.Clear();
i++;
continue;
}
for (int m = 0; m < searchFailedList.Count; m++)
{
searchFailedList.items[m].passSearch = 0;
}
for (int n = 0; n < searchPassedList.Count; n++)
{
Transform transform = searchPassedList.items[n];
if (transform == null)
{
continue;
}
DrawInfo objectDrawInfo2;
while (transform.parent != null)
{
transform = transform.parent;
objectDrawInfo2 = GetObjectDrawInfo(tLookup, transform);
if (objectDrawInfo2.passSearch == 0)
{
objectDrawInfo2.passSearch = 1;
}
}
objectDrawInfo2 = GetObjectDrawInfo(sceneLookup, transform.gameObject.scene);
objectDrawInfo2.passSearch = 1;
}
break;
continue;
end_IL_029a:
break;
}
isSearchingScenes = false;
refreshHierarchySearch = 0.5f;
}
private void DrawInspector(int windowId)
{
WindowManager.BeginRenderTextureGUI();
DrawWindowTitle(Helper.GetGUIContent("Deep Inspector", windowData.texInspector), inspectorWindow);
if (inspectorWindow.drag == 1)
{
inspectorWindow.isDocked.Value = false;
}
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.position += inspectorWindow.rect.position;
if (currentEvent.type == EventType.MouseDown && currentEvent.shift && lastRect.Contains(mousePos))
{
inspectorWindow.isDocked.Value = true;
inspectorWindow.position = new Vector2((hierarchyWindow.rect.xMax + 0f) / (float)Screen.width, hierarchyWindow.position.y);
}
if (inspectorWindow.isMinimized)
{
GUILayout.Space(-2f);
InspectorDragAndTooltip(windowId);
return;
}
fieldWidth = (inspectorWindow.rect.width - 150f) / 3f;
BeginVerticalBox();
GUILayout.BeginHorizontal();
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Fields", "Show/Hide Fields"), showFields, Color.green))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Properties", "Show/Hide Properties"), showProperties, Color.green))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Methods", "Show/Hide Methods"), showMethods, Color.green))
{
scrollViewCull.recalc = true;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Inherited", "Show/Hide Inherited Members"), showInherited, colorInherited))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Declared", "Show/Hide Declared Members"), showDeclared, Color.green))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Static", "Show/Hide Static Members"), showStatic, colorStatic))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Instance", "Show/Hide Instance Members"), showInstance, Color.green))
{
scrollViewCull.recalc = true;
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Public", "Show/Hide Public Members"), showPublic, colorPublic))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Protected", "Show/Hide Protected Members"), showProtected, colorProtected))
{
scrollViewCull.recalc = true;
}
if (Helper.DrawShowButton(windowData, Helper.GetGUIContent("Private", "Sow/Hide Private Members"), showPrivate, colorPrivate))
{
scrollViewCull.recalc = true;
}
GUILayout.EndHorizontal();
if (DrawSearch(inspectorWindow, changeText2: true))
{
scrollViewCull.recalc = true;
refreshInspectorSearch = 1f;
}
if (needInspectorSearch)
{
GUILayout.Space(-2f);
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label("Search Level " + inspectorSearchLevel, GUILayout.Width(90f));
GUI.changed = false;
int num = inspectorSearchLevel;
inspectorSearchLevel = (int)GUILayout.HorizontalSlider(inspectorSearchLevel, 1f, 7f, GUILayout.Width(82f));
if (GUI.changed && inspectorSearchLevel != num)
{
if (inspectorSearchLevel > num)
{
refreshInspectorSearch = 1f;
}
ClearMemberLookups(inspectorSearchLevel + 1);
}
if (searchTypes.Count == 0 && drawScenes.Value)
{
GUI.color = GetColor(Helper.AnimateColor(Color.magenta, 2f));
GUILayout.Label("Click on a Component to search inside it");
GUI.color = GetColor(Color.white);
}
else
{
GUILayout.Label("Found " + totalFound + " / " + totalSearched);
}
GUILayout.EndHorizontal();
}
else
{
totalFound = (totalSearched = 0);
}
GUILayout.Space(3f);
if (selectedStaticType != null && drawAssemblies.Value)
{
DrawSelected(selectedStaticType, DrawMode.Assembly);
}
else if (selectedObject != null && drawMemory.Value)
{
DrawSelected(selectedObject, DrawMode.Object);
}
else if ((bool)selectedGO)
{
DrawGameObject(selectedGO);
}
GUILayout.EndVertical();
InspectorDragAndTooltip(windowId);
WindowManager.EndRenderTextureGUI();
}
private void InspectorDragAndTooltip(int windowId)
{
if (Helper.Drag(inspectorWindow, inspectorWindow, hierarchyWindow, titleDrag: false))
{
scrollViewCull.recalc = true;
}
if (!DrawEnum.draw)
{
WindowManager.SetToolTip(windowId);
}
}
private void ClearMemberLookups(int startLevel)
{
for (int i = startLevel; i < memberLookups.Count; i++)
{
memberLookups.items[i].Clear();
}
}
private void DrawSelected(object obj, DrawMode drawMode)
{
if (obj != oldDrawObject)
{
oldDrawObject = obj;
scrollViewCull.ResetAndRecalc();
}
this.drawMode = drawMode;
GameObject gameObject = obj as GameObject;
if ((bool)gameObject)
{
DrawGameObject(gameObject);
return;
}
DrawObject(obj, (drawMode == DrawMode.Assembly) ? windowData.componentIcons.csScriptIcon : null);
BeginVerticalBox(0.75f);
scrollViewCull.BeginScrollView();
DrawObjectMembers(null, obj, 1, needInspectorSearch, hasSearchPass: false, drawMode == DrawMode.Assembly, 15f);
scrollViewCull.EndScrollView();
GUILayout.EndVertical();
}
private void ClearEdit()
{
editField.Reset();
}
private bool SubmitEdit()
{
if (currentEvent.type == EventType.Layout)
{
return false;
}
if (currentEvent.keyCode == KeyCode.Escape)
{
ClearEdit();
}
if (currentEvent.keyCode != KeyCode.Return)
{
return currentEvent.keyCode == KeyCode.KeypadEnter;
}
return true;
}
private void DrawObject(object obj, Texture icon = null)
{
float num = 0f;
float num2 = 0f;
Texture texture = obj as Texture;
string text;
if (texture != null)
{
text = obj.ToString();
icon = texture;
num = Mathf.Clamp(icon.height, 23, 150);
num2 = (float)(icon.width / icon.height) * num - 8f;
if (num2 > 256f)
{
num2 = 256f;
}
}
else
{
bool flag = false;
GameObject gameObject = obj as GameObject;
text = (gameObject ? gameObject.name : ((!flag) ? obj.ToString() : obj.GetType().Name));
num = 23f;
num2 = 16f;
}
if (icon == null)
{
icon = windowData.componentIcons.GetIcon(obj);
num = 23f;
num2 = 16f;
}
GUI.backgroundColor = new Color(0.25f, 0.25f, 0.25f, windowData.boxAlpha);
GUILayout.BeginVertical("Box");
GUILayout.Space(-4f);
GUI.backgroundColor = Color.white;
GUILayout.BeginHorizontal();
if (icon != null)
{
GUILayout.Label(Helper.GetGUIContent(icon), GUILayout.Width(num2), GUILayout.Height(num));
}
skin.label.fontStyle = FontStyle.Bold;
float y = skin.label.CalcSize(Helper.GetGUIContent(text)).y;
GUILayout.Label(text, GUILayout.Height(Mathf.Max(num, y)));
skin.label.fontStyle = FontStyle.Normal;
GUILayout.EndHorizontal();
GUILayout.Space(-4f);
GUILayout.EndVertical();
}
private void DrawGameObject(GameObject go)
{
if (go != oldSelectedGO)
{
scrollViewCull.recalc = true;
oldSelectedGO = go;
}
DrawObject(go);
GUILayout.Space(-26f);
GUILayout.BeginHorizontal();
GUILayout.Space(6f);
GUILayout.Label(string.Empty);
string text = LayerMask.LayerToName(go.layer);
skin.button.alignment = TextAnchor.MiddleCenter;
skin.button.fontStyle = FontStyle.Bold;
if (GUILayout.Button(text, GUILayout.Width(150f)))
{
drawEnum.InitEnumWindow(go, mousePos);
}
skin.button.fontStyle = FontStyle.Normal;
skin.button.alignment = TextAnchor.MiddleLeft;
GUILayout.Space(6f);
skin.label.fontStyle = FontStyle.Normal;
GUILayout.EndHorizontal();
skin.box.alignment = TextAnchor.MiddleCenter;
BeginVerticalBox(0.75f);
scrollViewCull.BeginScrollView();
go.GetComponents(components);
for (int i = 0; i < components.Count; i++)
{
Component component = components[i];
if ((bool)component)
{
DrawComponent(component, 0);
}
}
scrollViewCull.EndScrollView();
GUILayout.EndVertical();
}
private void DrawComponent(Component component, int level)
{
if (memberLookups.Count == 0)
{
memberLookups.Add(new Dictionary<object, DrawInfo>(128));
}
int num = -1;
Behaviour behaviour = null;
Renderer renderer = null;
Collider collider = null;
behaviour = component as Behaviour;
if (behaviour != null)
{
num = (behaviour.enabled ? 1 : 0);
}
else
{
renderer = component as Renderer;
if (renderer != null)
{
num = (renderer.enabled ? 1 : 0);
}
else
{
collider = component as Collider;
if (collider != null)
{
num = (collider.enabled ? 1 : 0);
}
}
}
float num2 = ((num != 0) ? 1f : 0.5f);
Type type = component.GetType();
DrawInfo objectDrawInfo = GetObjectDrawInfo(memberLookups.items[level], type);
bool flag = searchTypes.Contains(type);
if (scrollViewCull.StartCull())
{
GUI.backgroundColor = ((component is MonoBehaviour) ? GetColor(new Color(0.5f, 0.75f, 1f) * num2) : GetColor(new Color(1f, 1f, 1f) * num2));
skin.button.fontStyle = FontStyle.Bold;
GUILayout.BeginHorizontal();
if (flag)
{
GUI.backgroundColor = GetColor(Color.magenta);
}
string tooltip = (flag ? "Click to stop searching inside\nControl click to stop searching in all\nShift click to enable/disable" : "Click to search inside\nShift click to enable/disable");
Bool3 @bool = DrawElement(inspectorWindow, objectDrawInfo, -1, component.GetType().Name, windowData.componentIcons.GetIcon(component), tooltip, num != 0);
if (@bool.v2)
{
objectDrawInfo.foldout = !objectDrawInfo.foldout;
scrollViewCull.recalc = true;
return;
}
if (@bool.v1)
{
if (currentEvent.control)
{
searchTypes.Clear();
}
else if (currentEvent.shift)
{
if (behaviour != null)
{
behaviour.enabled = !behaviour.enabled;
}
else if (renderer != null)
{
renderer.enabled = !renderer.enabled;
}
else if (collider != null)
{
collider.enabled = !collider.enabled;
}
}
else if (!searchTypes.Contains(type))
{
refreshInspectorSearch = 1f;
searchTypes.Add(type);
}
else
{
searchTypes.Remove(type);
}
}
GUI.backgroundColor = GetColor(Color.white);
GUILayout.EndHorizontal();
skin.button.fontStyle = FontStyle.Normal;
GUI.backgroundColor = GetColor(Color.white);
}
scrollViewCull.EndCull();
if (!needInspectorSearch)
{
flag = false;
}
if (PassedFoldout(objectDrawInfo, flag, hasSearchPass: false, inspectorWindow.showSearchNonFound, isChild: false))
{
DrawObjectMembers(null, component, level + 1, flag, objectDrawInfo.foldout, isType: false, 15f);
}
}
private bool DrawObjectMembers(MemberInfo parentMember, object obj, int level, bool needSearch, bool hasSearchPass, bool isType, float indent)
{
if (level >= memberLookups.Count)
{
memberLookups.Add(new Dictionary<object, DrawInfo>(128));
}
Type objType = ((!isType) ? obj.GetType() : ((Type)obj));
TypeData typeData = GetTypeData(objType);
FastList<SubTypeData> subTypeDatas = typeData.subTypeDatas;
bool flag = false;
bool didDraw = false;
bool flag2 = false;
bool flag3 = false;
if (showFields.Value)
{
for (int i = 0; i < subTypeDatas.Count && (showInherited.Value || i < 1); i++)
{
SubTypeData subTypeData = subTypeDatas.items[i];
FieldInfo[] fields = subTypeData.fields;
if (fields.Length != 0)
{
bool num = flag;
MemberInfo[] members = fields;
flag = num | DrawMembers(parentMember, obj, typeData, subTypeData, members, MemberType.Field, level, needSearch, hasSearchPass, indent, out didDraw);
flag2 = true;
}
}
}
bool flag4 = false;
if (showProperties.Value)
{
for (int j = 0; j < subTypeDatas.Count && (showInherited.Value || j < 1); j++)
{
SubTypeData subTypeData2 = subTypeDatas.items[j];
PropertyInfo[] properties = subTypeData2.properties;
if (properties.Length == 0)
{
continue;
}
if (!flag4 && showFields.Value && flag2 && !needSearch && didDraw)
{
flag4 = true;
if (scrollViewCull.StartCull())
{
GUILayout.Space(memberSeparationHeight);
}
scrollViewCull.EndCull();
}
bool num2 = flag;
MemberInfo[] members = properties;
flag = num2 | DrawMembers(parentMember, obj, typeData, subTypeData2, members, MemberType.Property, level, needSearch, hasSearchPass, indent, out didDraw);
flag3 = true;
}
}
if (showMethods.Value)
{
flag4 = false;
for (int k = 0; k < subTypeDatas.Count && (showInherited.Value || k < 1); k++)
{
SubTypeData subTypeData3 = subTypeDatas.items[k];
MethodInfo[] methods = subTypeData3.methods;
if (methods.Length == 0)
{
continue;
}
if (!flag4 && ((showFields.Value && flag2) || (showProperties.Value && flag3)) && !needSearch && didDraw)
{
flag4 = true;
if (scrollViewCull.StartCull())
{
GUILayout.Space(memberSeparationHeight);
}
scrollViewCull.EndCull();
}
bool num3 = flag;
MemberInfo[] members = methods;
flag = num3 | DrawMembers(parentMember, obj, typeData, subTypeData3, members, MemberType.Method, level, needSearch, hasSearchPass, indent, out didDraw);
}
}
return flag;
}
private bool DrawMembers(MemberInfo parentMember, object obj, TypeData typeData, SubTypeData subTypeData, MemberInfo[] members, MemberType memberType, int level, bool needSearch, bool hasSearchPass, float indent, out bool didDraw)
{
if (!needSearch)
{
string text = memberType switch
{
MemberType.Field => "Fields ",
MemberType.Property => "Properties ",
MemberType.Method => "Methods ",
_ => "",
};
if (scrollViewCull.StartCull())
{
GUILayout.BeginHorizontal();
GUILayout.Space(indent);
GUI.backgroundColor = GetColor(new Color(0.2f, 0.2f, 0.2f, 0.5f));
GUI.skin.box.alignment = TextAnchor.MiddleLeft;
GUILayout.Box(text + members.Length + " " + subTypeData.typeName);
GUI.backgroundColor = GetColor(Color.white);
GUI.skin.box.alignment = TextAnchor.MiddleCenter;
GUILayout.EndHorizontal();
}
scrollViewCull.EndCull();
}
didDraw = false;
bool flag = false;
for (int i = 0; i < members.Length; i++)
{
MemberInfo memberInfo = members[i];
if (memberInfo != null)
{
flag |= DrawMember(parentMember, obj, typeData, subTypeData, memberInfo, memberType, level, needSearch, hasSearchPass, ref didDraw, i == members.Length - 1, indent);
}
}
return flag;
}
private TypeData GetTypeData(Type objType)
{
if (!typeDataLookup.TryGetValue(objType, out var value))
{
value = new TypeData(objType, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
typeDataLookup.Add(objType, value);
}
return value;
}
private MemberData GetMemberData(Type objType, MemberInfo member, MemberType memberType)
{
if (!memberDataLookup.TryGetValue(member, out var value))
{
value = new MemberData(objType, member, memberType, colorPublic, colorProtected, colorPrivate);
memberDataLookup.Add(member, value);
}
return value;
}
private bool DrawMember(MemberInfo parentMember, object obj, TypeData typeData, SubTypeData subTypeData, MemberInfo member, MemberType memberType, int level, bool needSearch, bool hasSearchPass, ref bool didDraw, bool isLastMember, float indent, Array array = null, int arrayIndex = -1)
{
while (level >= memberLookups.Count)
{
memberLookups.Add(new Dictionary<object, DrawInfo>(128));
}
DrawInfo drawInfo = GetObjectDrawInfo(obj: (!(member == null)) ? member : ((arrayIndex == -1) ? obj : ((object)arrayIndex)), lookup: memberLookups.items[level]);
if (!PassedFoldout(drawInfo, needSearch, hasSearchPass, inspectorWindow.showSearchNonFound, isChild: true))
{
return false;
}
Type type = subTypeData.type;
MemberData memberData = ((arrayIndex != -1) ? null : GetMemberData(type, member, memberType));
FieldInfo fieldInfo;
PropertyInfo propertyInfo;
MethodInfo key;
Type type2;
bool flag;
bool flag2;
bool flag3;
Scope scope;
if (arrayIndex == -1)
{
fieldInfo = memberData.field;
propertyInfo = memberData.prop;
key = memberData.method;
type2 = memberData.type;
flag = memberData.isStatic;
flag2 = subTypeData.index > 0;
flag3 = memberData.isConstant;
scope = memberData.scope;
typeData = null;
}
else
{
fieldInfo = null;
propertyInfo = null;
key = null;
flag3 = false;
flag = false;
flag2 = false;
type2 = type;
scope = Scope.Public;
}
bool result = false;
if (arrayIndex == -1)
{
if ((!flag2 && !showDeclared.Value) || (!flag && !showInstance.Value))
{
return result;
}
if ((flag2 && !showInherited.Value) || (flag && !showStatic.Value))
{
return result;
}
if ((scope == Scope.Public && !showPublic.Value) || (scope == Scope.Protected && !showProtected.Value) || (scope == Scope.Private && !showPrivate.Value))
{
return result;
}
}
bool isString;
bool isClass;
bool isStruct;
bool isArray;
bool isInterface;
string text;
string typeName;
if (arrayIndex == -1)
{
isString = memberData.isString;
isClass = memberData.isClass;
isStruct = memberData.isStruct;
isArray = memberData.isArray;
isInterface = memberData.isInterface;
text = memberData.name;
typeName = memberData.typeName;
}
else
{
isString = typeData.isString;
isClass = typeData.isClass;
isStruct = typeData.isStruct;
isArray = typeData.isArray;
isInterface = typeData.isInterface;
text = string.Empty;
typeName = subTypeData.typeName;
}
object obj2 = null;
switch (memberType)
{
case MemberType.Field:
if (drawMode == DrawMode.Object || flag || level >= 1)
{
try
{
obj2 = fieldInfo.GetValue(obj);
}
catch (Exception)
{
skip.Add(fieldInfo);
}
}
break;
case MemberType.Property:
{
if (propertyInfo.IsDefined(typeof(ObsoleteAttribute), inherit: true))
{
return false;
}
if (propertyInfo.GetIndexParameters().Length != 0)
{
break;
}
PropertyInfo propertyInfo2 = (PropertyInfo)member;
if (skip.Contains(propertyInfo2))
{
break;
}
try
{
bool flag4 = true;
if (type == typeof(MeshFilter) && text == "mesh")
{
flag4 = false;
}
else if (type == typeof(MeshRenderer) && (text == "material" || text == "materials"))
{
flag4 = false;
}
if (flag4)
{
obj2 = propertyInfo2.GetValue(obj, null);
}
}
catch (Exception)
{
skip.Add(propertyInfo2);
}
break;
}
default:
if (arrayIndex != -1)
{
text = "Element " + arrayIndex;
obj2 = obj;
}
break;
}
if (isArray && obj2 != null && !obj2.Equals(null))
{
array = (Array)obj2;
text = text + " [" + array.Length + "]";
}
bool flag5 = arrayIndex == -1 && obj2 == obj;
bool flag6 = memberType != MemberType.Method && (isClass || isArray || isStruct || isInterface) && obj2 != null && !flag5;
bool flag7 = false;
didDraw = true;
Color backgroundColor;
string tooltip;
if (arrayIndex != -1)
{
backgroundColor = Color.white;
tooltip = string.Empty;
}
else
{
backgroundColor = memberData.scopeColor;
tooltip = memberData.scopeToolTip;
}
UnityEngine.Object obj3;
string text2;
if (scrollViewCull.StartCull())
{
if (needSearch && drawInfo.passSearch == 2)
{
GUI.skin.box.overflow.left -= (int)indent - 8;
GUI.color = Color.magenta * windowData.boxAlpha * 0.85f;
GUILayout.BeginVertical("Box");
GUI.skin.box.overflow.left += (int)indent - 8;
GUI.color = Color.white;
}
GUILayout.BeginHorizontal();
if (needSearch && drawInfo.passSearch == 2)
{
indent -= 8f;
}
GUILayout.Space(indent);
if (needSearch && drawInfo.passSearch == 2)
{
indent += 8f;
}
GUI.backgroundColor = backgroundColor;
if (memberType == MemberType.Method)
{
if (flag2)
{
DrawDot(colorInherited, "Is Inherited", windowData.texDot2, minusSpace: true);
}
else
{
GUILayout.Space(10f);
}
if (flag)
{
DrawDot(colorStatic, "Is Static", windowData.texDot2, minusSpace: true);
}
else
{
GUILayout.Space(10f);
}
GUILayout.Space(-3f);
DrawElement(inspectorWindow, drawInfo, flag6 ? 1 : 0, text, -1f, windowData.texDot2, tooltip);
ParameterInfo[] parameters = memberData.parameters;
if (memberData.validInvokeParameters && (bool)RuntimeConsole.instance)
{
string value = string.Empty;
if (parameters.Length != 0)
{
if (!methodArgumentsLookup.TryGetValue(key, out value))
{
value = string.Empty;
}
float num = 15f;
if (value.Length > 0)
{
num += skin.textField.CalcSize(Helper.GetGUIContent(value)).x;
if (num > 200f)
{
num = 200f;
}
}
value = GUILayout.TextField(value, GUILayout.Width(num));
methodArgumentsLookup[key] = value;
}
if (GUILayout.Button("Invoke", GUILayout.Width(55f)))
{
string argumentString = value.Replace(',', ' ');
if (parameters.Length != 0)
{
RuntimeConsole.GetArguments(argumentString, methodArgs);
}
string logString = obj.ToString() + " => " + text + " " + value;
if (RuntimeConsole.instance.showConsoleWhenInvokingMethod)
{
RuntimeConsole.SetActive(active: true);
}
RuntimeConsole.Log(new LogEntry(logString, null, LogType.Log, EntryType.Command, Color.green, RuntimeConsole.instance.logFontSize, FontStyle.Bold));
if ((bool)HtmlDebug.instance)
{
HtmlDebug.instance.UnityDebugLog(logString, null, LogType.Log, isMainThread: true, -1, null, EntryType2.Command, closeLi: false);
}
new RuntimeConsole.CommandData(null, obj, "", RuntimeConsole.MemberType.Method, member, parameters, isStatic: true).Execute(methodArgs, argumentString);
}
}
}
else
{
if (DrawElement(inspectorWindow, drawInfo, flag6 ? 1 : 0, text, fieldWidth, windowData.texDot, tooltip).v2)
{
drawInfo.foldout = !drawInfo.foldout;
scrollViewCull.recalc = true;
return false;
}
GUI.backgroundColor = GetColor(Color.white);
if (flag2)
{
DrawDot(colorInherited, "Is Inherited", windowData.texDot2, minusSpace: true);
}
else
{
GUILayout.Space(10f);
}
if (flag)
{
DrawDot(colorStatic, "Is Static", windowData.texDot2, minusSpace: true);
}
else
{
GUILayout.Space(10f);
}
GUILayout.Space(3f);
GUILayout.Label(typeName, GUILayout.Width(fieldWidth));
}
GUI.backgroundColor = GetColor(Color.white);
if (memberType == MemberType.Property)
{
if (propertyInfo.CanRead)
{
GUI.color = Color.green;
GUILayout.Toggle(true, Helper.GetGUIContent(string.Empty, "Has a Getter"), GUILayout.Width(10f));
}
else
{
GUILayout.Space(14f);
}
if (propertyInfo.CanWrite)
{
GUI.color = Color.red;
GUILayout.Toggle(true, Helper.GetGUIContent(string.Empty, "Has a Setter"), GUILayout.Width(10f));
}
else
{
GUILayout.Space(14f);
}
GUI.color = Color.white;
}
text2 = string.Empty;
if (obj2 != null)
{
bool isEnum = type2.IsEnum;
if (!(type2.IsPrimitive || isString || isEnum) || (memberType == MemberType.Property && !propertyInfo.CanWrite) || flag3)
{
obj3 = obj2 as UnityEngine.Object;
if (obj3 != null)
{
text2 = obj3.name;
}
else
{
if (memberType == MemberType.Field)
{
FieldInfo field = obj2.GetType().GetField("name", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
if (field != null)
{
object value2 = field.GetValue(obj2);
if (value2 != null)
{
text2 = value2.ToString();
goto IL_0b95;
}
}
}
if (type2.IsGenericType)
{
Type[] genericArguments = type2.GetGenericArguments();
text2 += "<";
for (int i = 0; i < genericArguments.Length; i++)
{
text2 = ((i >= genericArguments.Length - 1) ? (text2 + type2.GetGenericArguments()[i].Name) : (text2 + type2.GetGenericArguments()[i].Name + ", "));
}
text2 += ">";
}
else if (!isClass)
{
text2 = obj2.ToString();
}
}
goto IL_0b95;
}
if (editField.IsThisEdit(parentMember, member, arrayIndex))
{
GUI.SetNextControlName("InspectorEditText");
editText = GUILayout.TextField(editText, wrapTextField);
if (selectAllEditText > 0)
{
GUI.FocusControl("InspectorEditText");
((TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl)).SelectAll();
selectAllEditText = 0;
}
if (SubmitEdit())
{
ClearEdit();
object value3;
if (isEnum)
{
int.TryParse(editText, out var result2);
value3 = Enum.ToObject(type2, result2);
}
else
{
value3 = Convert.ChangeType(editText, type2);
}
if (arrayIndex != -1)
{
array.SetValue(value3, arrayIndex);
}
else if (memberType == MemberType.Field)
{
fieldInfo.SetValue(obj, value3);
}
else
{
propertyInfo.SetValue(obj, value3, null);
}
result = true;
}
}
else
{
if (isEnum)
{
GUI.backgroundColor = GetColor(new Color(1f, 1f, 0.55f, 1f));
}
GUILayout.Space(-1f);
if (GUILayout.Button(obj2.ToString(), wrapButton))
{
if (isEnum)
{
drawEnum.InitEnumWindow(obj, member, (Enum)obj2, mousePos);
}
else if (type2 == typeof(bool))
{
if (arrayIndex != -1)
{
array.SetValue(true, arrayIndex);
}
else if (memberType == MemberType.Field)
{
fieldInfo.SetValue(obj, !(bool)obj2);
}
else
{
propertyInfo.SetValue(obj, !(bool)obj2, null);
}
}
else
{
editField.Set(parentMember, member, arrayIndex);
editText = obj2.ToString();
selectAllEditText = 200;
}
}
GUI.backgroundColor = GetColor(Color.white);
}
}
else if (memberType != MemberType.Method)
{
GUI.color = Color.red;
GUILayout.Label("null");
GUI.color = Color.white;
}
goto IL_0d3b;
}
goto IL_0dc0;
IL_0d3b:
GUILayout.EndHorizontal();
if (needSearch && drawInfo.passSearch == 2)
{
GUILayout.EndVertical();
}
if (!isLastMember)
{
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.x += indent;
lastRect.y += lastRect.height + 1f;
lastRect.height = 2f;
GUI.color = new Color(0.1f, 0.1f, 0.1f, 1f);
GUI.DrawTexture(lastRect, Texture2D.whiteTexture);
GUI.color = Color.white;
}
goto IL_0dc0;
IL_0b95:
if (flag5)
{
GUI.color = Color.green;
GUILayout.Label(Helper.GetGUIContent("this", null, "value references to itself"));
GUI.color = Color.white;
}
else if (obj3 != null && (obj3 is Component || obj3 is GameObject))
{
GUI.backgroundColor = GetColor(new Color(0.25f, 0.75f, 1f, 1f));
GUILayout.Space(-1f);
if (Helper.DrawButton(Helper.GetGUIContent(text2, windowData.componentIcons.GetIcon(obj3)), wrapButton))
{
if (obj3 is GameObject)
{
SelectGameObject((GameObject)obj3, unfold: true);
}
else if (obj3 is Component)
{
SelectGameObject(((Component)obj3).gameObject, unfold: true);
}
}
GUI.backgroundColor = GetColor(Color.white);
}
else if (flag7 && text2.Length > 0)
{
GUILayout.EndHorizontal();
if (text2.Length > 8192)
{
text2 = text2.Substring(0, 8192);
}
GUILayout.Label(text2);
}
else if (flag3)
{
GUI.color = Color.yellow;
GUILayout.Label(Helper.GetGUIContent(text2, null, "is Constant"));
GUI.color = Color.white;
}
else
{
GUILayout.Label(text2);
}
goto IL_0d3b;
IL_0dc0:
scrollViewCull.EndCull();
if (flag6 && obj2 != null)
{
hasSearchPass = drawInfo.foldout && (hasSearchPass || drawInfo.passSearch == 2);
if (PassedFoldout(drawInfo, needSearch, hasSearchPass, inspectorWindow.showSearchNonFound, isChild: false))
{
if (isArray)
{
DrawArray(member, array, level + 1, needSearch, hasSearchPass, indent + 15f);
}
else if (DrawObjectMembers(member, obj2, level + 1, needSearch, drawInfo.foldout, isType: false, indent + 15f))
{
if (arrayIndex != -1)
{
array.SetValue(obj2, arrayIndex);
}
else if (memberType == MemberType.Field)
{
fieldInfo.SetValue(obj, obj2);
}
else
{
propertyInfo.SetValue(obj, obj2, null);
}
}
return false;
}
}
return result;
}
private void DrawArray(MemberInfo parentMember, Array array, int level, bool needSearch, bool hasSearchPass, float indent)
{
int num = 0;
int num2 = 0;
bool didDraw = false;
if (array.GetType().GetArrayRank() == 1)
{
for (int i = 0; i < array.Length; i++)
{
object value = array.GetValue(i);
if (value != null)
{
if (num2 > num)
{
if (scrollViewCull.StartCull())
{
DrawLabelIndent(num + " .. " + num2 + " = null", indent);
}
scrollViewCull.EndCull();
}
Type type = value.GetType();
TypeData typeData = GetTypeData(type);
SubTypeData subTypeData = typeData.subTypeDatas.items[0];
DrawMember(parentMember, value, typeData, subTypeData, null, MemberType.ArrayElement, level + 1, needSearch, hasSearchPass, ref didDraw, isLastMember: false, indent, array, i);
num2 = ++num;
}
else
{
num2++;
}
}
if (num2 > num)
{
didDraw = true;
if (scrollViewCull.StartCull())
{
DrawLabelIndent(num + " .. " + num2 + " = null", indent);
}
scrollViewCull.EndCull();
}
}
else
{
didDraw = true;
if (scrollViewCull.StartCull())
{
DrawLabelIndent("Multi dimensional arrays will be supported soon", indent);
}
scrollViewCull.EndCull();
}
if (didDraw)
{
if (scrollViewCull.StartCull())
{
GUILayout.Space(memberSeparationHeight);
}
scrollViewCull.EndCull();
}
DrawObjectMembers(parentMember, array, level++, needSearch, hasSearchPass, isType: false, indent);
}
private void DrawLabelIndent(string text, float indent)
{
GUILayout.BeginHorizontal();
GUILayout.Space(indent);
GUILayout.Label(text);
GUILayout.EndHorizontal();
}
private void SearchInsideGameObject(GameObject go)
{
if (refreshInspectorSearch != 0f && !isSearchingInspector)
{
go.GetComponents(searchComponentList);
searchObjectList.Clear();
for (int i = 0; i < searchComponentList.Count; i++)
{
searchObjectList.Add(searchComponentList[i]);
}
StartCoroutine(SearchInspectorCR(checkSearchType: true));
}
}
private void SearchInspector(object obj)
{
if (refreshInspectorSearch != 0f && !isSearchingInspector)
{
searchObjectList.Clear();
searchObjectList.Add(obj);
StartCoroutine(SearchInspectorCR(checkSearchType: false));
}
}
private void AddSearchMembers(object obj, Type objType, SearchMember searchMember, MemberInfo[] members, MemberType memberType, int level)
{
for (int i = 0; i < members.Length; i++)
{
searchMemberList.Add(new SearchMember(searchMember, obj, objType, members[i], memberType, null, level));
}
}
private void AddAllSearchMembers(object searchObj, Type objType, SearchMember searchMember, int level)
{
FastList<SubTypeData> subTypeDatas = GetTypeData(objType).subTypeDatas;
for (int i = 0; i < subTypeDatas.Count; i++)
{
SubTypeData subTypeData = subTypeDatas.items[i];
if (showFields.Value)
{
MemberInfo[] fields = subTypeData.fields;
AddSearchMembers(searchObj, objType, searchMember, fields, MemberType.Field, level);
}
if (showProperties.Value)
{
MemberInfo[] fields = subTypeData.properties;
AddSearchMembers(searchObj, objType, searchMember, fields, MemberType.Property, level);
}
if (showMethods.Value)
{
MemberInfo[] fields = subTypeData.methods;
AddSearchMembers(searchObj, objType, searchMember, fields, MemberType.Method, level);
}
}
}
private void SetSearchInspectorPerFrame()
{
searchInspectorPerFrame = Mathf.CeilToInt((float)windowData.searchInspectorPerFrame.value * refreshInspectorSearch);
}
private IEnumerator SearchInspectorCR(bool checkSearchType)
{
isSearchingInspector = true;
searchMemberList.Clear();
searchMemberPassedList.Clear();
searchMemberFailedList.Clear();
searchDoubles.Clear();
int oldInspectorSearchLevel = inspectorSearchLevel;
if (memberLookups.Count == 0)
{
memberLookups.Add(new Dictionary<object, DrawInfo>(128));
}
localTotalSearched = 0;
int count = 0;
SetSearchInspectorPerFrame();
int i = 0;
while (true)
{
if (i < searchObjectList.Count)
{
object obj = searchObjectList.items[i];
if (searchDoubles.Add(obj))
{
Type type = ((!(obj is Type)) ? obj.GetType() : ((Type)obj));
DrawInfo objectDrawInfo = GetObjectDrawInfo(memberLookups.items[0], type);
if (!checkSearchType || searchTypes.Contains(type))
{
SearchMember searchMember = new SearchMember(null, obj, type, null, (!(obj is Behaviour)) ? MemberType.Property : MemberType.Field, objectDrawInfo, 0);
searchMemberFailedList.Add(searchMember);
AddAllSearchMembers(obj, type, searchMember, 1);
if (count++ > windowData.searchInspectorPerFrame.value)
{
count = 0;
yield return null;
SetSearchInspectorPerFrame();
}
if (oldInspectorSearchLevel != inspectorSearchLevel)
{
break;
}
for (int j = 0; j < searchMemberList.Count; j++)
{
searchMember = searchMemberList.items[j];
object obj2 = searchMember.obj;
if (skip.Contains(searchMember.member))
{
continue;
}
MemberInfo member = searchMember.member;
int level = searchMember.level;
if (level >= memberLookups.Count)
{
memberLookups.Add(new Dictionary<object, DrawInfo>(128));
}
MemberType memberType = searchMember.memberType;
MemberData memberData = GetMemberData(searchMember.objType, member, memberType);
FieldInfo field = null;
PropertyInfo prop = null;
if (searchMember.memberType == MemberType.Field)
{
field = memberData.field;
}
else if (searchMember.memberType == MemberType.Property)
{
prop = memberData.prop;
}
Type type2 = memberData.type;
string name = memberData.name;
localTotalSearched++;
if (count++ > searchInspectorPerFrame)
{
count = 0;
yield return null;
SetSearchInspectorPerFrame();
}
if (oldInspectorSearchLevel != inspectorSearchLevel)
{
goto end_IL_0582;
}
object obj3 = null;
switch (memberType)
{
case MemberType.Field:
try
{
obj3 = field.GetValue(obj2);
}
catch (Exception)
{
skip.Add(searchMember.member);
}
break;
case MemberType.Property:
if (prop.IsDefined(typeof(ObsoleteAttribute), inherit: true))
{
continue;
}
if (prop.GetIndexParameters().Length != 0)
{
break;
}
try
{
if (prop.GetGetMethod(nonPublic: true) != null)
{
obj3 = prop.GetValue(obj2, null);
}
}
catch (Exception)
{
skip.Add(searchMember.member);
}
break;
}
bool isClass = memberData.isClass;
bool isStruct = memberData.isStruct;
bool isArray = memberData.isArray;
bool flag = (isClass || isStruct || isArray) && obj3 != null && !obj3.Equals(null);
objectDrawInfo = GetObjectDrawInfo(memberLookups.items[level], member);
searchMember.info = objectDrawInfo;
if (!needInspectorSearch)
{
goto end_IL_0582;
}
if (PassSearch(WindowType.Inspector, null, name, type2))
{
searchMemberPassedList.Add(searchMember);
}
else
{
searchMemberFailedList.Add(searchMember);
}
if (level < inspectorSearchLevel && (!(flag && isClass) || searchDoubles.Add(obj3)) && flag)
{
Type type3 = obj3.GetType();
AddAllSearchMembers(obj3, type3, searchMember, level + 1);
}
}
}
}
i++;
continue;
}
for (int k = 0; k < searchMemberFailedList.Count; k++)
{
searchMemberFailedList.items[k].info.passSearch = 0;
}
for (int l = 0; l < searchMemberPassedList.Count; l++)
{
SearchMember searchMember2 = searchMemberPassedList.items[l];
searchMember2.info.passSearch = 2;
while (searchMember2.parent != null)
{
searchMember2 = (SearchMember)searchMember2.parent;
if (searchMember2.info.passSearch == 0)
{
searchMember2.info.passSearch = 1;
}
}
}
scrollViewCull.recalc = true;
totalFound = searchMemberPassedList.Count;
totalSearched = localTotalSearched;
break;
continue;
end_IL_0582:
break;
}
isSearchingInspector = false;
if (inspectorSearchLevel > 1)
{
refreshInspectorSearch = 0.25f;
}
else
{
refreshInspectorSearch = 0f;
}
}
public static void ResetStatic()
{
RuntimeInspector.onTimeScaleChanged = null;
selectionIndicatorGO = null;
selectedGO = null;
navigationCamera = null;
namespaceTypesLookup.Clear();
typeNameLookup.Clear();
show = false;
}
private void Awake()
{
instance = this;
selectionIndicatorGO = base.transform.GetChild(0).gameObject;
SetSelectionSphereRadius();
skin = windowData.skin;
texArrowFolded = windowData.texArrowFolded;
texArrowUnfolded = windowData.texArrowUnfolded;
inspectorWindow = windowData.inspectorWindow;
hierarchyWindow = windowData.hierarchyWindow;
SetActive(showOnStart);
if (enableCameraOnStart)
{
useNavigationCamera.Value = true;
EnableCamControl();
}
wrapButton = new GUIStyle(skin.button);
wrapButton.wordWrap = true;
wrapTextField = new GUIStyle(skin.textField);
wrapTextField.wordWrap = true;
drawEnum = new DrawEnum(skin);
RuntimeConsole.Register(this);
refreshHierarchySearch = 1f;
refreshInspectorSearch = 1f;
}
private void OnEnable()
{
instance = this;
}
private void OnDisable()
{
isSearchingScenes = (isSearchingAssemblies = (isSearchingMemory = (isSearchingInspector = false)));
}
private void OnDestroy()
{
RuntimeConsole.Unregister(this);
if (instance == this)
{
instance = null;
}
}
[ConsoleCommand("search.HiearchyType", "", AccessLevel.Admin)]
public static void SearchHierarchyType(string type)
{
SetSearch(instance.hierarchyWindow, type, SearchMode.Type, 0, setActive: true);
}
[ConsoleCommand("search.HierarchyName", "", AccessLevel.Admin)]
public static void SearchHierarchyName(string name)
{
SetSearch(instance.hierarchyWindow, name, SearchMode.Name, 0, setActive: true);
}
public static void SetSearch(WindowSettings window, string text, SearchMode searchMode, int searchIndex, bool setActive)
{
if (setActive)
{
instance.SetActive(active: true);
}
window.searchList[searchIndex].useSearch = true;
window.searchList[searchIndex].text = text;
window.searchList[searchIndex].mode = searchMode;
}
private void SetSelectionSphereRadius()
{
float selectionSphereRadius = windowData.selectionSphereRadius;
selectionIndicatorGO.transform.localScale = new Vector3(selectionSphereRadius, selectionSphereRadius, selectionSphereRadius);
}
private void EnableCamControl()
{
if (mainCam == null)
{
mainCam = Camera.main;
}
if (mainCam == null)
{
Debug.LogError("Cannot find the Main Camera. Please tag your Main Camera with the 'MainCamera' tag.");
useNavigationCamera.Value = false;
}
else
{
navigationCamera = mainCam.gameObject.AddComponent<NavigationCamera>();
navigationCamera.data = navigationCameraData;
}
}
private void DisableCamControl()
{
UnityEngine.Object.Destroy(navigationCamera);
}
public void SetActive(bool active)
{
hierarchyWindow.drag = (inspectorWindow.drag = 0);
if (RuntimeConsole.accessLevel != AccessLevel.Admin)
{
active = false;
}
show = active;
selectionIndicatorGO.SetActive(show);
base.gameObject.SetActive(show);
if (RuntimeInspector.onSetActive != null)
{
RuntimeInspector.onSetActive(active);
}
WindowManager.CheckMouseCursorState();
}
public void ManualUpdate()
{
if (!WindowManager.instance.onlyUseViewToggleKeys && EventInput.isGamePauseKeyDown)
{
pauseGame.Value = !pauseGame.Value;
Pause();
}
if (!show)
{
return;
}
if (mainCam == null)
{
mainCam = Camera.main;
}
selectionIndicatorGO.SetActive(show && selectedGO != null);
if (useNavigationCamera.Value && EventInput.isMouseButtonDown0)
{
SelectGameObjectFromScreenRay();
}
if (EventInput.isMouseButtonUp0)
{
hierarchyWindow.drag = (inspectorWindow.drag = 0);
}
needHierarchySearch = NeedSearch(hierarchyWindow.searchList);
if (needHierarchySearch)
{
if (drawAssemblies.Value)
{
SearchAssemblies();
}
else if (drawMemory.Value)
{
SearchMemory();
}
else
{
SearchScenes();
}
}
needInspectorSearch = NeedSearch(inspectorWindow.searchList);
if (needInspectorSearch)
{
if (drawScenes.Value)
{
if ((bool)selectedGO)
{
SearchInsideGameObject(selectedGO);
}
}
else if (drawAssemblies.Value)
{
if (selectedStaticType != null)
{
SearchInspector(selectedStaticType);
}
}
else if (drawMemory.Value && selectedObject != null)
{
SearchInspector(selectedObject);
}
}
if ((bool)selectedGO && !WindowManager.instance.onlyUseViewToggleKeys)
{
if (EventInput.isControlKey && EventInput.isKeyDownD)
{
UnityEngine.Object.Instantiate(selectedGO, selectedGO.transform.position, selectedGO.transform.rotation, selectedGO.transform.parent);
}
if (EventInput.isKeyDownDelete)
{
UnityEngine.Object.Destroy(selectedGO);
selectedGO = null;
}
}
}
private void LateUpdate()
{
if (selectedGO != null)
{
UpdateSelectedIndicatorTransform();
}
}
public static void UpdateSelectedIndicatorTransform()
{
if (selectedGO != null)
{
selectionIndicatorGO.transform.position = selectedGO.transform.TransformPoint(instance.selectionIndicatorLocalPos);
selectionIndicatorGO.transform.rotation = selectedGO.transform.rotation * instance.selectionIndicatorLocalRot;
}
}
private bool NeedSearch(List<Search> searchList)
{
bool result = false;
for (int i = 0; i < searchList.Count; i++)
{
Search search = searchList[i];
if (search.useSearch && search.hasSearch)
{
result = true;
break;
}
}
return result;
}
public void MyOnGUI()
{
currentEvent = Event.current;
if (Helper.IsShowKeyPressed(currentEvent, useSameEditorAsBuildShowKey, showToggleKeyEditor, showToggleKeyBuild))
{
if (show || RuntimeConsole.accessLevel == AccessLevel.Admin)
{
SetActive(!show);
}
}
else if (show)
{
GUI.skin = skin;
mousePos = currentEvent.mousePosition;
skin.box.fontStyle = FontStyle.Bold;
if (WindowManager.instance.useCanvas)
{
GUI.backgroundColor = new Color(1f, 1f, 1f, 0f);
}
else
{
GUI.backgroundColor = windowData.color;
}
hierarchyWindow.Update(311f, 260f);
inspectorWindow.Update(270f, 260f);
if (inspectorWindow.isDocked.Value)
{
inspectorWindow.rect.yMax = hierarchyWindow.rect.yMax;
inspectorWindow.rect.yMin = hierarchyWindow.rect.yMin;
inspectorWindow.position.y = hierarchyWindow.position.y;
inspectorWindow.position.x = hierarchyWindow.position.x + hierarchyWindow.rect.width / (float)Screen.width;
}
Helper.DrawWindow(3242340, hierarchyWindow, DrawHierarchy);
if (ShouldInspectorWindowShow())
{
Helper.DrawWindow(2342341, inspectorWindow, DrawInspector);
}
drawEnum.Draw(windowData.boxAlpha, windowData.backgroundAlpha);
}
}
public static bool ShouldInspectorWindowShow()
{
if ((!selectedGO || !instance.drawScenes.Value) && (!(instance.selectedStaticType != null) || !instance.drawAssemblies.Value))
{
if (instance.selectedObject != null)
{
return instance.drawMemory.Value;
}
return false;
}
return true;
}
private bool DrawSearch(WindowSettings window, bool changeText2)
{
List<Search> searchList = window.searchList;
if (searchList.Count == 0)
{
searchList.Add(new Search());
}
bool result = false;
for (int i = 0; i < searchList.Count; i++)
{
Search search = searchList[i];
SearchMode mode = search.mode;
if (!search.useSearch)
{
GUI.color = Color.grey;
}
else if (search.hasSearch)
{
GUI.backgroundColor = GetColor(Color.magenta);
}
GUILayout.BeginHorizontal();
if (GUILayout.Button(Helper.GetGUIContent("Search", windowData.texSearch, "Toggle Search On/Off"), GUILayout.Width(75f), GUILayout.Height(21f)))
{
search.useSearch = !search.useSearch;
result = true;
}
GUI.backgroundColor = GetColor(Color.white);
if (i == 0)
{
if (GUILayout.Button(Helper.GetGUIContent("+", "Add another Search Condition"), GUILayout.Width(20f)))
{
searchList.Add(new Search());
}
}
else if (GUILayout.Button(Helper.GetGUIContent("-", "Remove this Search Condition"), GUILayout.Width(20f)))
{
if (search.useSearch && search.hasSearch)
{
result = true;
}
searchList.RemoveAt(i--);
continue;
}
if (GUILayout.Button(Helper.GetGUIContent(mode.ToString(), "Toggle between searching for Names/Types"), GUILayout.Width(47f)))
{
if (mode == SearchMode.Name)
{
search.mode = SearchMode.Type;
}
else
{
search.mode = SearchMode.Name;
}
if (search.useSearch && search.hasSearch)
{
result = true;
}
}
if (i == 0)
{
if (GUILayout.Button(Helper.GetGUIContent(window.showSearchNonFound ? windowData.texVisible : windowData.texInvisible, "Enabled: Shows all if parent object is unfolded.\n\nDisabled: Shows only found results."), GUILayout.Width(25f)))
{
window.showSearchNonFound = !window.showSearchNonFound;
}
}
else
{
skin.button.alignment = TextAnchor.MiddleCenter;
if (GUILayout.Button(Helper.GetGUIContent((search.condition == SearchCondition.Or) ? "||" : "&", "|| = Or\n& = And"), GUILayout.Width(25f)))
{
if (search.useSearch && search.hasSearch)
{
result = true;
}
if (search.condition == SearchCondition.Or)
{
search.condition = SearchCondition.And;
}
else
{
search.condition = SearchCondition.Or;
}
}
skin.button.alignment = TextAnchor.MiddleLeft;
}
if (GUILayout.Button(Helper.GetGUIContent("X", "Delete search text"), GUILayout.Width(22f)))
{
search.text = string.Empty;
search.hasSearch = false;
}
if (search.hasSearch && search.mode == SearchMode.Type && search.types.Count == 0)
{
GUI.color = Color.red;
}
GUI.changed = false;
search.text = GUILayout.TextField(search.text);
if (search.useSearch || GUI.changed)
{
if (GUI.changed)
{
result = true;
}
search.hasSearch = search.text != string.Empty;
if (search.mode == SearchMode.Type)
{
FastList<Type> value;
if (search.text.Contains("[]"))
{
if (typeNameLookup.TryGetValue(search.text.Replace("[]", ""), out value))
{
search.types.FastClear();
search.types.AddRange(value);
search.MakeArrayTypes();
}
}
else if (typeNameLookup.TryGetValue(search.text, out value))
{
search.types.FastClear();
search.types.AddRange(value);
}
else
{
search.types.FastClear();
}
if (search.types.Count > 0 && window == hierarchyWindow && !drawAssemblies.Value && !drawMemory.Value)
{
for (int j = 0; j < search.types.Count; j++)
{
if (!search.types.items[j].IsSubclassOf(typeof(Component)))
{
search.types.RemoveAt(j--);
}
}
}
}
}
GUILayout.EndHorizontal();
GUI.color = Color.white;
}
return result;
}
private bool PassSearch(WindowType windowType, Transform t, string name, Type type)
{
int num = 0;
List<Search> list = ((windowType != WindowType.Hierarchy) ? inspectorWindow.searchList : hierarchyWindow.searchList);
bool flag = false;
bool flag2 = true;
for (int i = 0; i < list.Count; i++)
{
Search search = list[i];
if (search.useSearch && search.hasSearch)
{
bool flag3 = false;
if (search.mode == SearchMode.Name)
{
if (t != null)
{
name = t.name;
}
flag3 = name.IndexOf(search.text, 0, StringComparison.CurrentCultureIgnoreCase) != -1;
}
else if (t != null)
{
for (int j = 0; j < search.types.Count; j++)
{
Type type2 = search.types.items[j];
flag3 = type2 != null && type2.IsSubclassOf(typeof(Component)) && t.GetComponent(type2) != null;
if (flag3)
{
break;
}
}
}
else
{
for (int k = 0; k < search.types.Count; k++)
{
Type type3 = search.types.items[k];
flag3 = type3 != null && type3 == type;
if (flag3)
{
break;
}
}
}
flag = ((!(search.condition == SearchCondition.Or || flag2)) ? (flag && flag3) : (flag || flag3));
flag2 = false;
}
else
{
num++;
}
}
if (!flag)
{
return num == list.Count;
}
return true;
}
public DrawInfo GetObjectDrawInfo<T>(Dictionary<T, DrawInfo> lookup, T obj, bool defaultFoldout = false)
{
if (!lookup.TryGetValue(obj, out var value))
{
value = (lookup[obj] = new DrawInfo(defaultFoldout));
}
return value;
}
public void DrawDot(Color color, string tooltip, Texture tex, bool minusSpace = false)
{
GUI.color = color;
GUILayout.Space(10f);
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.y += 7f;
lastRect.width = 16f;
lastRect.height = 16f;
GUI.Label(lastRect, Helper.GetGUIContent(string.Empty, tex, tooltip));
GUI.color = GetColor(Color.white);
}
public Bool3 DrawElement(WindowSettings window, DrawInfo info, int childCount, string name, float width, Texture tex, string tooltip = "")
{
Bool3 result = default(Bool3);
if (childCount > 0)
{
GUILayout.Space(-1f);
result.v2 = GUILayout.Button(Helper.GetGUIContent(string.Empty, tooltip), GUILayout.Width(21f), GUILayout.Height(21f));
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.x += (info.foldout ? 4 : 5);
lastRect.y += (info.foldout ? 7 : 6);
float width2 = (lastRect.height = 8f);
lastRect.width = width2;
GUI.DrawTexture(lastRect, info.foldout ? texArrowUnfolded : texArrowFolded);
GUILayout.Space(-4f);
}
else
{
GUILayout.Space(5f);
DrawDot(GUI.backgroundColor, tooltip, tex);
GUILayout.Space(5f);
}
GUILayout.Space(2f);
if (width == -1f)
{
GUILayout.Label(name);
}
else
{
GUILayout.Label(name, GUILayout.Width(width));
}
result.v3 = result.v1 || result.v2;
return result;
}
public Bool3 DrawElement(WindowSettings window, DrawInfo info, int childCount, string text = "", Texture image = null, string tooltip = "", bool isActive = true, int prefix = 0)
{
Bool3 result = default(Bool3);
GUI.color = (isActive ? Color.white : new Color(0.25f, 0.25f, 0.25f, 1f));
GUILayout.BeginHorizontal();
if (prefix != 0)
{
GUILayout.Space(prefix);
}
if (childCount > 0 || childCount == -1)
{
if (windowData.showChildCount.Value && childCount > 0)
{
result.v2 = GUILayout.Button(Helper.GetGUIContent(childCount.ToString(), info.foldout ? texArrowUnfolded : texArrowFolded), GUILayout.Width(55f), GUILayout.Height(21f));
}
else
{
result.v2 = GUILayout.Button(Helper.GetGUIContent(string.Empty, info.foldout ? texArrowUnfolded : texArrowFolded), GUILayout.Width(25f), GUILayout.Height(21f));
}
}
else
{
GUILayout.Label(string.Empty, GUILayout.Width(windowData.showChildCount.Value ? 55 : 25), GUILayout.Height(21f));
}
result.v1 = GUILayout.Button(Helper.GetGUIContent(text, image, tooltip), GUILayout.Height(21f));
GUILayout.EndHorizontal();
GUI.color = Color.white;
result.v3 = result.v1 || result.v2;
return result;
}
private Color GetColor(Color color)
{
color.a *= windowData.backgroundAlpha;
return color;
}
private Color GetColor(object obj, object selectedObj, bool needSearch, DrawInfo info)
{
if (obj == selectedObj && obj != null)
{
return GetColor(Color.green);
}
if (needSearch && info.passSearch == 2)
{
return GetColor(Color.magenta);
}
return GetColor(Color.white);
}
public void DrawBoldLabel(GUISkin skin, string name, float space = -3f)
{
if (space != 0f)
{
GUILayout.Space(space);
}
skin.label.fontStyle = FontStyle.Bold;
GUILayout.Label(name);
skin.label.fontStyle = FontStyle.Normal;
if (space != 0f)
{
GUILayout.Space(space);
}
}
public void DrawBoldLabel(GUISkin skin, string name)
{
skin.label.fontStyle = FontStyle.Bold;
GUILayout.Label(name);
skin.label.fontStyle = FontStyle.Normal;
}
private void DrawPrefixLabel(string prefixName, string name, int prefix)
{
GUILayout.BeginHorizontal();
GUILayout.Label(prefixName, GUILayout.Width(prefix));
GUILayout.Label(name);
GUILayout.EndHorizontal();
}
private void DrawInputField<T>(string prefixName, T inputField) where T : BaseInputField
{
GUILayout.BeginHorizontal();
GUILayout.Label(prefixName, GUILayout.Width(150f));
GUI.changed = false;
inputField.text = GUILayout.TextField(inputField.text);
if (GUI.changed)
{
inputField.TryParse(logError: false);
}
GUILayout.EndHorizontal();
}
private void DrawToggleField(string prefixName, ref bool toggle)
{
GUILayout.BeginHorizontal();
GUILayout.Label(prefixName, GUILayout.Width(150f));
GUI.changed = false;
toggle = GUILayout.Toggle(toggle, GUIContent.none);
GUILayout.EndHorizontal();
}
private void DrawLastRectOffset(string name, int offset)
{
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.xMin += offset;
GUI.Label(lastRect, name);
}
private Texture2D ReadBackTexture(Texture2D tex)
{
RenderTexture temporary = RenderTexture.GetTemporary(tex.width, tex.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);
Graphics.Blit(tex, temporary);
RenderTexture active = RenderTexture.active;
RenderTexture.active = temporary;
Texture2D texture2D = new Texture2D(tex.width, tex.height);
texture2D.ReadPixels(new Rect(0f, 0f, temporary.width, temporary.height), 0, 0);
texture2D.Apply();
RenderTexture.active = active;
RenderTexture.ReleaseTemporary(temporary);
return texture2D;
}
private Texture2D CopyAndRemoveAlphaFromTexture(Texture2D texRead, float colorMulti = 1f)
{
Texture2D texture2D = ReadBackTexture(texRead);
Color[] pixels = texture2D.GetPixels();
for (int i = 0; i < pixels.Length; i++)
{
if (pixels[i].a > 0f)
{
pixels[i].a = 1f;
}
pixels[i].r *= colorMulti;
pixels[i].g *= colorMulti;
pixels[i].b *= colorMulti;
}
texture2D.SetPixels(pixels);
texture2D.Apply();
return texture2D;
}
private void DrawBox(GUIContent guiContent, Color color)
{
color.a *= windowData.boxAlpha;
GUI.backgroundColor = color;
GUILayout.Box(guiContent);
color.a = 1f;
GUI.backgroundColor = Color.white;
}
private void BeginVerticalBox(float alphaMulti = 1f)
{
GUI.backgroundColor = new Color(0f, 0f, 0f, windowData.boxAlpha * alphaMulti);
GUILayout.BeginVertical("Box");
GUI.backgroundColor = GetColor(Color.white);
}
private void SelectGameObjectFromScreenRay()
{
if (!WindowManager.DoWindowsContainMousePos())
{
navigationCamera.SetCam();
Ray ray = mainCam.ScreenPointToRay(EventInput.mousePosInvY);
navigationCamera.RestoreCam();
if (Physics.Raycast(ray, out var hitInfo, 10000f, selectLayerMask))
{
SelectGameObject(hitInfo.transform.gameObject, unfold: true);
selectionIndicatorLocalPos = hitInfo.transform.InverseTransformPoint(hitInfo.point);
selectionIndicatorLocalRot = Quaternion.LookRotation(hitInfo.transform.InverseTransformDirection(-hitInfo.normal));
UpdateSelectedIndicatorTransform();
navigationCamera.ResetFollowPosRot();
}
}
}
private void SelectGameObject(GameObject go, bool unfold = false)
{
if (selectedGO == lastScreenRayedGO && unfold)
{
RevertSelectionFoldout();
}
else
{
selectList.Clear();
}
if ((bool)go)
{
selectionIndicatorLocalPos = Vector3.zero;
selectionIndicatorLocalRot = Quaternion.LookRotation(Vector3.forward);
}
selectedGO = (lastScreenRayedGO = go);
if (!unfold)
{
return;
}
Transform parent = go.transform;
while (true)
{
parent = parent.parent;
if (parent == null)
{
break;
}
DrawInfo objectDrawInfo = GetObjectDrawInfo(tLookup, parent);
if (!objectDrawInfo.foldout)
{
selectList.Add(objectDrawInfo);
}
objectDrawInfo.foldout = true;
}
GetObjectDrawInfo(sceneLookup, go.scene).foldout = true;
scrollToSelected = true;
}
private void RevertSelectionFoldout()
{
for (int i = 0; i < selectList.Count; i++)
{
selectList.items[i].foldout = false;
}
selectList.Clear();
}
private void DrawWindowTitle(GUIContent guiContent, WindowSettings window)
{
GUILayout.BeginHorizontal();
DrawBox(guiContent, Color.black);
Helper.Drag(window, inspectorWindow, hierarchyWindow, titleDrag: true);
skin.button.fontStyle = FontStyle.Bold;
if (GUILayout.Button(window.isMinimized ? "[]" : "_", GUILayout.Width(21f)))
{
window.isMinimized = !window.isMinimized;
}
if (GUILayout.Button("X", GUILayout.Width(21f)))
{
SetActive(active: false);
}
skin.button.fontStyle = FontStyle.Normal;
GUILayout.EndHorizontal();
}
private void DrawHideFlagsIcons(object obj, HideFlags hideFlags, bool isPrefab, string name)
{
Rect lastRect = GUILayoutUtility.GetLastRect();
lastRect.x = lastRect.xMax - 24f;
lastRect.width = 24f;
GUI.color = Color.red * 20f;
float num = -24f;
if (hideFlags != HideFlags.None)
{
if ((hideFlags & HideFlags.DontUnloadUnusedAsset) != HideFlags.None)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texLoad, "DontUnloadUnusedAsset"), Color.white);
lastRect.x += num;
}
if ((hideFlags & HideFlags.NotEditable) != HideFlags.None)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texEdit, "NotEditable"), Color.white);
lastRect.x += num;
}
HideFlags hideFlags2 = hideFlags & HideFlags.HideAndDontSave & ~(HideFlags.HideInHierarchy | HideFlags.HideInInspector | HideFlags.NotEditable);
if (hideFlags2 != HideFlags.None)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texSave, hideFlags2.ToString()), Color.white);
lastRect.x += num;
}
if ((hideFlags & HideFlags.HideInInspector) != HideFlags.None)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texInspector, "HideInInspector"), Color.white);
lastRect.x += num;
}
if ((hideFlags & HideFlags.HideInHierarchy) != HideFlags.None)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texHierarchy, "HideInHierarchy"), Color.white);
lastRect.x += num;
}
}
if (isPrefab)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texPrefab, "Is Prefab"), Color.white);
lastRect.x += num;
}
if (obj == null)
{
DrawIcon(lastRect, Helper.GetGUIContent(windowData.texDestroyed, "Object is Destroyed"), Color.red);
lastRect.x += num;
}
else
{
Texture texture = obj as Texture;
if (texture != null)
{
lastRect.y++;
lastRect.height -= 2f;
lastRect.width = lastRect.height / (float)texture.height * (float)texture.width;
if (lastRect.width > 64f)
{
lastRect.width = 64f;
}
float num2 = lastRect.width - lastRect.height;
lastRect.x -= num2;
DrawIcon(lastRect, Helper.GetGUIContent(texture), Color.white, label: false);
lastRect.x += num;
}
}
GUI.color = Color.white;
}
private void DrawIcon(Rect rect, GUIContent guiContent, Color color, bool label = true)
{
GUI.color = color;
GUI.backgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.85f);
if (label)
{
GUI.Label(rect, guiContent, skin.box);
}
else
{
GUI.DrawTexture(rect, guiContent.image);
}
}
}
}