public static void OnSceneTreeReflectICollection(SceneExplorerState state, ReferenceChain refChain, object myProperty, TypeUtil.SmartType elementSmartType = TypeUtil.SmartType.Undefined) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (!(myProperty is ICollection collection)) { return; } var oldRefChain = refChain; var collectionSize = collection.Count; if (collectionSize == 0) { GUILayout.BeginHorizontal(); GUI.contentColor = Color.yellow; GUILayout.Label("Collection is empty!"); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } var collectionItemType = collection.GetType().GetElementType(); var flagsField = collectionItemType?.GetField("m_flags"); var flagIsEnum = flagsField?.FieldType.IsEnum == true && Type.GetTypeCode(flagsField.FieldType) == TypeCode.Int32; GUICollectionNavigation.SetUpCollectionNavigation("Collection", state, refChain, oldRefChain, collectionSize, out var arrayStart, out var arrayEnd); uint count = 0; foreach (var value in collection) { if (count < arrayStart) { count++; continue; } refChain = oldRefChain.Add(count); GUILayout.BeginHorizontal(GUIWindow.HighlightStyle); SceneExplorerCommon.InsertIndent(refChain.Indentation); var isNullOrEmpty = value == null || flagIsEnum && Convert.ToInt32(flagsField.GetValue(value)) == 0; var type = value?.GetType() ?? collectionItemType; if (type != null) { if (!isNullOrEmpty) { GUIExpander.ExpanderControls(state, refChain, type); } GUI.contentColor = MainWindow.Instance.Config.TypeColor; GUILayout.Label(type.ToString() + " "); } GUI.contentColor = MainWindow.Instance.Config.NameColor; GUILayout.Label($"{oldRefChain.LastItemName}.[{count}]"); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = MainWindow.Instance.Config.ValueColor; GUILayout.Label(value == null ? "null" : isNullOrEmpty ? "empty" : value.ToString()); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); if (!isNullOrEmpty) { GUIButtons.SetupCommonButtons(refChain, value, count, elementSmartType); } if (value != null) { GUIButtons.SetupJumpButton(value, refChain); } GUILayout.EndHorizontal(); if (!isNullOrEmpty && !TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(refChain.UniqueId)) { GUIReflect.OnSceneTreeReflect(state, refChain, value, false); } count++; if (count > arrayEnd) { break; } } }
public static void OnSceneTreeReflectProperty(SceneExplorerState state, ReferenceChain refChain, object obj, PropertyInfo property, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined, int nameHighlightFrom = -1, int nameHighlightLength = 0) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (obj == null || property == null) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "null"); return; } GUILayout.BeginHorizontal(GUIWindow.HighlightStyle); SceneExplorerCommon.InsertIndent(refChain.Indentation); object value = null; Exception exceptionOnGetting = null; if (property.CanRead && MainWindow.Instance.Config.EvaluateProperties || state.EvaluatedProperties.Contains(refChain.UniqueId)) { try { value = property.GetValue(obj, null); } catch (Exception e) { exceptionOnGetting = e; } if (value != null && exceptionOnGetting == null) { GUIExpander.ExpanderControls(state, refChain, property.PropertyType, obj); } } GUI.contentColor = Color.white; if (!property.CanWrite) { GUI.enabled = false; } if (MainWindow.Instance.Config.ShowModifiers) { GUI.contentColor = MainWindow.Instance.Config.MemberTypeColor; GUILayout.Label("property "); if (!property.CanWrite) { GUI.contentColor = MainWindow.Instance.Config.KeywordColor; GUILayout.Label("const "); } } GUI.contentColor = MainWindow.Instance.Config.TypeColor; GUILayout.Label(property.PropertyType.ToString() + " "); GUI.contentColor = MainWindow.Instance.Config.NameColor; GUIMemberName.MemberName(property, nameHighlightFrom, nameHighlightLength); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = MainWindow.Instance.Config.ValueColor; if (exceptionOnGetting != null) { GUI.contentColor = Color.red; GUILayout.Label("Exception happened when getting property value"); GUI.contentColor = Color.white; GUI.enabled = true; if (exceptionOnGetting.InnerException != null) { GUIStackTrace.StackTraceButton(new StackTrace(exceptionOnGetting.InnerException, true), exceptionOnGetting.InnerException.Message); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return; } if (!MainWindow.Instance.Config.EvaluateProperties && !state.EvaluatedProperties.Contains(refChain.UniqueId)) { GUI.enabled = true; if (GUILayout.Button("Evaluate")) { state.EvaluatedProperties.Add(refChain.UniqueId); } } else if (value == null || !TypeUtil.IsSpecialType(property.PropertyType)) { if (property.CanRead) { GUILayout.Label(value == null ? "null" : value.ToString()); } else { GUILayout.Label("(no get method)"); } GUI.contentColor = Color.white; } else { try { var newValue = GUIControls.EditorValueField(refChain.UniqueId, property.PropertyType, value); if (newValue != value) { property.SetValue(obj, newValue, null); } } catch (Exception) { if (property.CanRead) { GUILayout.Label(value == null ? "null" : value.ToString()); } else { GUILayout.Label("(no get method)"); } GUI.contentColor = Color.white; } } GUI.enabled = true; GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupCommonButtons(refChain, value, valueIndex: 0, smartType); object paste = null; var doPaste = property.CanWrite; if (doPaste) { doPaste = GUIButtons.SetupPasteButon(property.PropertyType, value, out paste); } if (value != null) { GUIButtons.SetupJumpButton(value, refChain); } GUILayout.EndHorizontal(); if (value != null && state.ExpandedObjects.Contains(refChain.UniqueId)) { GUIReflect.OnSceneTreeReflect(state, refChain, value, false); } if (doPaste) { try { property.SetValue(obj, paste, null); } catch (Exception e) { Logger.Warning(e.Message); } } }
public static void OnSceneTreeReflect(SceneExplorerState state, ReferenceChain refChain, object obj, bool rawReflection, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined, string filter = "") { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (obj == null) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "null"); return; } var type = obj.GetType(); if (!rawReflection) { if (!type.IsValueType && state.PreventCircularReferences.Contains(obj)) { try { GUI.contentColor = Color.yellow; SceneExplorerCommon.OnSceneTreeMessage(refChain, "Circular reference detected"); } finally { GUI.contentColor = Color.white; } return; } state.PreventCircularReferences.Add(obj); if (type == typeof(Transform)) { GUITransform.OnSceneTreeReflectUnityEngineTransform(refChain, (Transform)obj); return; } if (TypeUtil.IsList(obj)) { GUIList.OnSceneTreeReflectIList(state, refChain, obj, smartType); return; } if (TypeUtil.IsCollection(obj)) { GUICollection.OnSceneTreeReflectICollection(state, refChain, obj, smartType); return; } if (TypeUtil.IsEnumerable(obj)) { GUIEnumerable.OnSceneTreeReflectIEnumerable(state, refChain, obj, smartType); return; } if (type == typeof(Material)) { GUIMaterial.OnSceneReflectUnityEngineMaterial(state, refChain, (Material)obj); return; } if (type == typeof(Mesh) && !((Mesh)obj).isReadable) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "Mesh is not readable"); return; } } var members = TypeUtil.GetAllMembers(type, MainWindow.Instance.Config.ShowInheritedMembers); if (MainWindow.Instance.Config.SortItemsAlphabetically) { Array.Sort(members, (x, y) => string.CompareOrdinal(x.ReflectionInfo.Name, y.ReflectionInfo.Name)); } var matchingMembers = 0; foreach (var member in members) { var filterMatchFrom = -1; if (!filter.IsNullOrEmpty() && (filterMatchFrom = member.ReflectionInfo.Name.IndexOf(filter, StringComparison.OrdinalIgnoreCase)) < 0) { continue; } matchingMembers++; switch (member.ReflectionInfo.MemberType) { case MemberTypes.Field when MainWindow.Instance.Config.ShowFields: { var field = (FieldInfo)member.ReflectionInfo; if (field.IsLiteral && !field.IsInitOnly && !MainWindow.Instance.Config.ShowConsts) { continue; } try { GUIField.OnSceneTreeReflectField(state, refChain.Add(field), obj, field, TypeUtil.OverrideSmartType(member.DetectedType, field.Name, obj), filterMatchFrom, filter.Length); } catch (Exception ex) { SceneExplorerCommon.OnSceneTreeMessage(refChain, $"Exception when fetching field \"{field.Name}\" - {ex.Message}\n{ex.StackTrace}"); } break; } case MemberTypes.Property when MainWindow.Instance.Config.ShowProperties: { var property = (PropertyInfo)member.ReflectionInfo; if (property.GetIndexParameters().Length > 0) { continue; // TODO: add support for indexers } try { GUIProperty.OnSceneTreeReflectProperty(state, refChain.Add(property), obj, property, TypeUtil.OverrideSmartType(member.DetectedType, property.Name, obj), filterMatchFrom, filter.Length); } catch (Exception ex) { SceneExplorerCommon.OnSceneTreeMessage(refChain, $"Exception when fetching property \"{property.Name}\" - {ex.Message}\n{ex.StackTrace}"); } break; } case MemberTypes.Method when MainWindow.Instance.Config.ShowMethods: { var method = (MethodInfo)member.ReflectionInfo; try { GUIMethod.OnSceneTreeReflectMethod(refChain.Add(method), obj, method, filterMatchFrom, filter.Length); } catch (Exception ex) { SceneExplorerCommon.OnSceneTreeMessage(refChain, $"Exception when fetching method \"{method.Name}\" - {ex.Message}"); } break; } } } if (filter.IsNullOrEmpty() || members.Length <= 0 || matchingMembers != 0) { return; } GUI.contentColor = Color.yellow; SceneExplorerCommon.OnSceneTreeMessage(refChain, "No members matching the search term found!"); GUI.contentColor = Color.white; }
public static void OnSceneTreeReflectField(SceneExplorerState state, ReferenceChain refChain, object obj, FieldInfo field, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined, int nameHighlightFrom = -1, int nameHighlightLength = 0) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (obj == null || field == null) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "null"); return; } GUILayout.BeginHorizontal(GUIWindow.HighlightStyle); SceneExplorerCommon.InsertIndent(refChain.Indentation); GUI.contentColor = Color.white; object value = null; try { value = field.GetValue(obj); } catch (Exception e) { Debug.LogException(e); } if (value != null) { GUIExpander.ExpanderControls(state, refChain, field.FieldType); } if (field.IsInitOnly) { GUI.enabled = false; } if (MainWindow.Instance.Config.ShowModifiers) { GUI.contentColor = MainWindow.Instance.Config.ModifierColor; if (field.IsPublic) { GUILayout.Label("public "); } else if (field.IsPrivate) { GUILayout.Label("private "); } GUI.contentColor = MainWindow.Instance.Config.MemberTypeColor; GUILayout.Label("field "); if (field.IsStatic) { GUI.contentColor = MainWindow.Instance.Config.KeywordColor; GUILayout.Label("static "); } if (field.IsInitOnly) { GUI.contentColor = MainWindow.Instance.Config.KeywordColor; GUILayout.Label("const "); } } GUI.contentColor = MainWindow.Instance.Config.TypeColor; GUILayout.Label(field.FieldType + " "); GUIMemberName.MemberName(field, nameHighlightFrom, nameHighlightLength); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = MainWindow.Instance.Config.ValueColor; if (value == null || !TypeUtil.IsSpecialType(field.FieldType)) { GUILayout.Label(value?.ToString() ?? "null"); } else { try { var newValue = GUIControls.EditorValueField(refChain.UniqueId, field.FieldType, value); if (!newValue.Equals(value)) { field.SetValue(obj, newValue); } } catch (Exception) { GUILayout.Label(value.ToString()); } } GUI.enabled = true; GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUIButtons.SetupCommonButtons(refChain, value, valueIndex: 0, smartType); object paste = null; var doPaste = !field.IsLiteral && !field.IsInitOnly; if (doPaste) { doPaste = GUIButtons.SetupPasteButon(field.FieldType, value, out paste); } if (value != null) { GUIButtons.SetupJumpButton(value, refChain); } GUILayout.EndHorizontal(); if (value != null && !TypeUtil.IsSpecialType(field.FieldType) && state.ExpandedObjects.Contains(refChain.UniqueId)) { GUIReflect.OnSceneTreeReflect(state, refChain, value, false, smartType); } if (doPaste) { try { field.SetValue(obj, paste); } catch (Exception e) { Logger.Warning(e.Message); } } }
public static void SetupSmartShowButtons(object value, TypeUtil.SmartType smartType) { if (smartType == TypeUtil.SmartType.Undefined || value == null || value.GetType().IsArray) { return; } try { switch (smartType) { case TypeUtil.SmartType.Sprite: { if (!(value is string stringValue) || !UIView.GetAView().defaultAtlas.spriteNames.Contains(stringValue)) { return; } if (GUILayout.Button("Show sprite")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForSprite(stringValue)); } break; } case TypeUtil.SmartType.ParkedVehicle: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show parked vehicle")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForParkedVehicle(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.Vehicle: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show vehicle")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForVehicle(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.Building: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show building")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForBuilding(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.CitizenUnit: { if (Convert.ToUInt32(value) < 1) { return; } if (GUILayout.Button("Show citizen unit")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForCitizenUnit(Convert.ToUInt32(value))); } break; } case TypeUtil.SmartType.Citizen: { if (Convert.ToUInt32(value) < 1) { return; } if (GUILayout.Button("Show citizen")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForCitizen(Convert.ToUInt32(value))); } break; } case TypeUtil.SmartType.TransportLine: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show transport line")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForTransportLine(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.PathUnit: { if (Convert.ToUInt32(value) < 1) { return; } if (GUILayout.Button("Show path unit")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForPathUnit(Convert.ToUInt32(value))); } break; } case TypeUtil.SmartType.NetNode: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show network node")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForNode(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.NetSegment: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show network segment")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForSegment(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.NetLane: { if (Convert.ToUInt32(value) < 1) { return; } if (GUILayout.Button("Show network lane")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForLane(Convert.ToUInt32(value))); } break; } case TypeUtil.SmartType.ParkDistrict: { if (Convert.ToByte(value) < 1) { return; } if (GUILayout.Button("Show park district")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForPark(Convert.ToByte(value))); } break; } case TypeUtil.SmartType.District: { if (Convert.ToByte(value) < 1) { return; } if (GUILayout.Button("Show district")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForDistrict(Convert.ToByte(value))); } break; } case TypeUtil.SmartType.Tree: { if (Convert.ToUInt32(value) < 1) { return; } if (GUILayout.Button("Show tree")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForTree(Convert.ToUInt32(value))); } break; } case TypeUtil.SmartType.Prop: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show prop")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForProp(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.CitizenInstance: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show citizen instance")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForCitizenInstance(Convert.ToUInt16(value))); } break; } case TypeUtil.SmartType.ZoneBlock: { if (Convert.ToUInt16(value) < 1) { return; } if (GUILayout.Button("Show zone block")) { var sceneExplorer = Object.FindObjectOfType <SceneExplorer>(); sceneExplorer.Show(ReferenceChainBuilder.ForZoneBlock(Convert.ToUInt16(value))); } break; } default: return; } } catch { // suppress } }
public static void SetupCommonButtons(ReferenceChain refChain, object value, uint valueIndex, TypeUtil.SmartType smartType = TypeUtil.SmartType.Undefined) { switch (value) { case null: if (GUILayout.Button("Watch")) { MainWindow.Instance.Watches.AddWatch(refChain); } return; case PrefabInfo prefabInfo: SetupButtonsForPrefab(prefabInfo); break; case MilestoneInfo milestoneInfo: if (GUILayout.Button("Unlock")) { var wrapper = new MilestonesWrapper(UnlockManager.instance); wrapper.UnlockMilestone(milestoneInfo.name); } break; case NetInfo.Segment segmentInfo: SetupSegmentButtons(refChain, segmentInfo); break; case NetInfo.Node nodeInfo: SetupNodeButtons(refChain, nodeInfo); break; case BuildingInfo.MeshInfo buildingSumMeshInfo: SetupMeshPreviewButtons( name: null, buildingSumMeshInfo.m_subInfo?.m_mesh, buildingSumMeshInfo.m_subInfo?.m_material, buildingSumMeshInfo.m_subInfo?.m_lodMesh, buildingSumMeshInfo.m_subInfo?.m_lodMaterial); break; case VehicleInfo.MeshInfo vehicleSumMeshInfo: SetupMeshPreviewButtons( name: null, vehicleSumMeshInfo.m_subInfo?.m_mesh, vehicleSumMeshInfo.m_subInfo?.m_material, vehicleSumMeshInfo.m_subInfo?.m_lodMesh, vehicleSumMeshInfo.m_subInfo?.m_lodMaterial); break; case CitizenInstance instance when valueIndex > 0 && (instance.m_flags & (CitizenInstance.Flags.Created | CitizenInstance.Flags.Deleted)) == CitizenInstance.Flags.Created: InstanceID citizenInstanceInst = default; citizenInstanceInst.CitizenInstance = (ushort)valueIndex; SetupGotoButton(citizenInstanceInst, instance.GetLastFramePosition()); break; case Citizen citizen when citizen.m_instance > 0: ref var citizenInstance = ref CitizenManager.instance.m_instances.m_buffer[citizen.m_instance]; if ((citizenInstance.m_flags & (CitizenInstance.Flags.Created | CitizenInstance.Flags.Deleted)) == CitizenInstance.Flags.Created) { InstanceID citizenInstanceInst2 = default; citizenInstanceInst2.CitizenInstance = citizen.m_instance; SetupGotoButton(citizenInstanceInst2, citizenInstance.GetLastFramePosition()); } break; case Vehicle vehicle when valueIndex > 0 && (vehicle.m_flags & (Vehicle.Flags.Created | Vehicle.Flags.Deleted)) == Vehicle.Flags.Created: InstanceID vehicleInst = default; vehicleInst.Vehicle = (ushort)valueIndex; SetupGotoButton(vehicleInst, vehicle.GetLastFramePosition()); break; case VehicleParked parkedVehicle when valueIndex > 0 && (parkedVehicle.m_flags & 3) == 1: InstanceID parkedVehicleInst = default; parkedVehicleInst.ParkedVehicle = (ushort)valueIndex; SetupGotoButton(parkedVehicleInst, parkedVehicle.m_position); break; case Building building when valueIndex > 0 && (building.m_flags & (Building.Flags.Created | Building.Flags.Deleted)) == Building.Flags.Created: InstanceID buildingInst = default; buildingInst.Building = (ushort)valueIndex; SetupGotoButton(buildingInst, building.m_position); break; case PropInstance prop when valueIndex > 0 && ((PropInstance.Flags)prop.m_flags & (PropInstance.Flags.Created | PropInstance.Flags.Deleted)) == PropInstance.Flags.Created: InstanceID propInst = default; propInst.Prop = (ushort)valueIndex; SetupGotoButton(propInst, prop.Position); break; case TreeInstance tree when valueIndex > 0 && ((TreeInstance.Flags)tree.m_flags & (TreeInstance.Flags.Created | TreeInstance.Flags.Deleted)) == TreeInstance.Flags.Created: InstanceID treeInst = default; treeInst.Tree = valueIndex; SetupGotoButton(treeInst, tree.Position); break; case NetSegment segment when valueIndex > 0 && (segment.m_flags & (NetSegment.Flags.Created | NetSegment.Flags.Deleted)) == NetSegment.Flags.Created: InstanceID segmentInst = default; segmentInst.NetSegment = (ushort)valueIndex; SetupGotoButton(segmentInst, segment.m_middlePosition); break; case NetNode node when valueIndex > 0 && (node.m_flags & (NetNode.Flags.Created | NetNode.Flags.Deleted)) == NetNode.Flags.Created: InstanceID nodeInst = default; nodeInst.NetNode = (ushort)valueIndex; SetupGotoButton(nodeInst, node.m_position); break; case NetLane lane when valueIndex > 0 && ((NetLane.Flags)lane.m_flags & (NetLane.Flags.Created | NetLane.Flags.Deleted)) == NetLane.Flags.Created: InstanceID segmentInst1 = default; segmentInst1.NetSegment = lane.m_segment; var segment1 = NetManager.instance.m_segments.m_buffer[lane.m_segment]; SetupGotoButton(segmentInst1, segment1.m_middlePosition); break; case Texture texture: SetupTextureButtons(texture); break; case UITextureAtlas.SpriteInfo spriteInfo: SetupTextureButtons(spriteInfo.texture); break; case UITextureSprite textureSprite: SetupTextureButtons(textureSprite.texture); break; case Mesh mesh: SetupMeshButtons(refChain, mesh); break; } SetupSmartShowButtons(value, smartType); if (GUILayout.Button("Watch")) { MainWindow.Instance.Watches.AddWatch(refChain); } if (GUILayout.Button("Copy")) { buffer = value; } }
public static void OnSceneTreeReflectIEnumerable(SceneExplorerState state, ReferenceChain refChain, object myProperty, TypeUtil.SmartType elementSmartType = TypeUtil.SmartType.Undefined) { if (!SceneExplorerCommon.SceneTreeCheckDepth(refChain)) { return; } if (!(myProperty is IEnumerable enumerable)) { return; } uint count = 0; var oldRefChain = refChain; foreach (var value in enumerable) { refChain = oldRefChain.Add(count); GUILayout.BeginHorizontal(GUIWindow.HighlightStyle); SceneExplorerCommon.InsertIndent(refChain.Indentation); var type = value?.GetType(); if (type != null) { GUIExpander.ExpanderControls(state, refChain, type); GUI.contentColor = MainWindow.Instance.Config.TypeColor; GUILayout.Label(type.ToString() + " "); } GUI.contentColor = MainWindow.Instance.Config.NameColor; GUILayout.Label($"{oldRefChain.LastItemName}.[{count}]"); GUI.contentColor = Color.white; GUILayout.Label(" = "); GUI.contentColor = MainWindow.Instance.Config.ValueColor; GUILayout.Label(value == null ? "null" : value.ToString()); GUI.contentColor = Color.white; GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); if (type != null && !TypeUtil.IsSpecialType(type) && state.ExpandedObjects.Contains(refChain.UniqueId)) { GUIReflect.OnSceneTreeReflect(state, refChain, value, false, elementSmartType, string.Empty); } count++; if (count >= 128) { SceneExplorerCommon.OnSceneTreeMessage(refChain, "Enumerable too large to display"); break; } } }