private static void PrintDetails() { if (!HasSelection()) { Debug.Log("Current selection is empty."); return; } GameObject gameObject = CurrentGameObject(); if (gameObject != null) { Debug.Log(DumpUtils.FormatGameObject(gameObject.name, gameObject)); return; } System.Collections.IEnumerable enumerable = CurrentSelection() as System.Collections.IEnumerable; if (enumerable != null) { foreach (object value in enumerable) { Debug.Log(DumpUtils.FormatValue(null, value)); } return; } Debug.Log("Cannot print details of " + CurrentSelection()); }
private static void DumpAll() { string name = uConsole.GetString(); System.Type type = System.Type.GetType(name + ",Assembly-CSharp", false, true); if (type == null) { type = System.Type.GetType(name + ",UnityEngine", false, true); } if (type == null) { Debug.LogError("Unknown type '" + name + "'."); return; } foreach (Object eachObject in Resources.FindObjectsOfTypeAll(type)) { if (eachObject is Component) { GameObject gameObject = ((Component)eachObject).gameObject; Debug.Log(DumpUtils.FormatGameObject(null, gameObject)); } else { Debug.Log(DumpUtils.FormatValue(null, eachObject)); } } }
internal static string FormatSerializable(string name, object serializable, int indent = 0, List <object> visitedObjects = null) { if (visitedObjects != null) { if (visitedObjects.Contains(serializable)) { return(FormatString(name, serializable.ToString() + " [RECURSION]", indent)); } visitedObjects.Add(serializable); } StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(serializable.ToString()); FieldInfo[] fieldInfos = serializable.GetType().GetFields(); foreach (FieldInfo eachFieldInfo in fieldInfos) { if (skip(serializable, eachFieldInfo.Name)) { continue; } object value = eachFieldInfo.GetValue(serializable); writer.WriteLine(DumpUtils.FormatValue(eachFieldInfo.Name, value, indent + 1, visitedObjects)); } PropertyInfo[] propertyInfos = serializable.GetType().GetProperties(); foreach (PropertyInfo eachPropertyInfo in propertyInfos) { if (eachPropertyInfo.GetCustomAttributes(false).OfType <ObsoleteAttribute>().Count() > 0) { continue; } if (skip(serializable, eachPropertyInfo.Name)) { continue; } if (eachPropertyInfo.CanRead) { MethodInfo methodInfo = eachPropertyInfo.GetGetMethod(); if (methodInfo.GetParameters().Length > 0) { Debug.Log(methodInfo); continue; } object value = GetMethodResult(serializable, methodInfo); writer.WriteLine(DumpUtils.FormatValue(eachPropertyInfo.Name, value, indent + 1, visitedObjects)); } } return(writer.ToString()); }
internal static string FormatLODGroup(string name, LODGroup lodGroup, int indent, List <object> visitedObjects = null) { StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(lodGroup.ToString()); writer.WriteLine(DumpUtils.FormatValue("animateCrossFading", lodGroup.animateCrossFading, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("fadeMode", lodGroup.fadeMode, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("localReferencePoint", lodGroup.localReferencePoint, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("LODs", lodGroup.GetLODs(), indent + 1, visitedObjects)); return(writer.ToString()); }
private static void UniStorm() { UniStormWeatherSystem uniStormWeatherSystem = GameManager.GetUniStorm(); GameObject starSphere = uniStormWeatherSystem.m_StarSphere; Debug.Log(DumpUtils.FormatGameObject("starSphere", starSphere)); ObjExporter.DoExport(starSphere, true); Renderer starSphereRenderer = starSphere.GetComponent <Renderer>(); Material material = starSphereRenderer.material; Debug.Log(DumpUtils.FormatValue("material", material)); Debug.Log(DumpUtils.FormatValue("mainTexture", material.mainTexture)); }
internal static string FormatTransform(string name, Transform transform, int indent, List <System.Object> visitedObjects = null) { StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(transform.ToString()); writer.WriteLine(DumpUtils.FormatValue("instanceID", transform.gameObject.GetInstanceID(), indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("localPosition", transform.localPosition, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("localRotation", transform.localRotation, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("localScale", transform.localScale, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("position", transform.position, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("rotation", transform.rotation, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("lossyScale", transform.lossyScale, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("parent", transform.parent, indent + 1, visitedObjects)); return(writer.ToString()); }
internal static string FormatRenderer(string name, Renderer renderer, int indent, List <object> visitedObjects = null) { StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(renderer.ToString()); if (renderer != null) { writer.WriteLine(DumpUtils.FormatValue("isPartOfStaticBatch", renderer.isPartOfStaticBatch, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("bounds", renderer.bounds.ToString("F3"), indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("enabled", renderer.enabled, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("isVisible", renderer.isVisible, indent + 1, visitedObjects)); writer.WriteLine(DumpUtils.FormatValue("materials", renderer.materials, indent + 1, visitedObjects)); } return(writer.ToString()); }
internal static string FormatPlayerStateTransitions(string name, PlayerStateTransitions playerStateTransitions, int indent = 0) { StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(); FieldInfo fieldInfo = playerStateTransitions.GetType().GetField("m_ValidTransitions", BindingFlags.NonPublic | BindingFlags.Instance); object value = fieldInfo.GetValue(playerStateTransitions); writer.WriteLine(DumpUtils.FormatValue(fieldInfo.Name, value, indent + 1)); fieldInfo = playerStateTransitions.GetType().GetField("m_InvalidTransitions", BindingFlags.NonPublic | BindingFlags.Instance); value = fieldInfo.GetValue(playerStateTransitions); writer.WriteLine(DumpUtils.FormatValue(fieldInfo.Name, value, indent + 1)); return(writer.ToString()); }
private static void LoadResource() { if (uConsole.GetNumParameters() != 1) { Debug.Log(" Resource name required"); return; } string name = uConsole.GetString(); Debug.Log(" Loading " + name); Object resource = Resources.Load(name); if (resource == null) { Debug.Log(" Not found"); return; } Debug.Log(DumpUtils.FormatValue(name, resource)); }
private static string FormatComponent(string name, Component component, int indent = 0, List <object> visitedObjects = null) { if (component is Transform) { return(FormatTransform(name, component as Transform, indent, visitedObjects)); } if (component is Renderer) { return(FormatRenderer(name, component as Renderer, indent, visitedObjects)); } if (component is LODGroup) { return(FormatLODGroup(name, component as LODGroup, indent, visitedObjects)); } if (visitedObjects != null) { if (visitedObjects.Contains(component)) { return(FormatString(name, component.ToString() + " [RECURSION]", indent)); } visitedObjects.Add(component); } StringWriter writer = new StringWriter(); writer.Write(GetIndentation(indent)); WriteName(name, writer); writer.WriteLine(component.ToString()); FieldInfo[] fieldInfos = component.GetType().GetFields(); foreach (FieldInfo eachFieldInfo in fieldInfos) { if (skip(component, eachFieldInfo.Name)) { continue; } object value = eachFieldInfo.GetValue(component); writer.WriteLine(DumpUtils.FormatValue(eachFieldInfo.Name, value, indent + 1, visitedObjects)); } PropertyInfo[] propertyInfos = component.GetType().GetProperties(); foreach (PropertyInfo eachPropertyInfo in propertyInfos) { if (eachPropertyInfo.GetCustomAttributes(false).OfType <ObsoleteAttribute>().Count() > 0) { continue; } if (skip(component, eachPropertyInfo.Name)) { continue; } if (eachPropertyInfo.CanRead) { MethodInfo methodInfo = eachPropertyInfo.GetGetMethod(); if (methodInfo.GetParameters().Length > 0) { Debug.Log(methodInfo); continue; } object value = GetMethodResult(component, methodInfo); writer.WriteLine(DumpUtils.FormatValue(eachPropertyInfo.Name, value, indent + 1, visitedObjects)); } } return(writer.ToString()); }