Created
January 8, 2019 15:35
-
-
Save DMagic1/887fa3dd150e800b2a547b7424b4eede to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void DumpGameObjectChilds(GameObject go, string pre, StringBuilder sb) | |
{ | |
bool first = pre == ""; | |
List<GameObject> neededChilds = new List<GameObject>(); | |
int count = go.transform.childCount; | |
for (int i = 0; i < count; i++) | |
{ | |
GameObject child = go.transform.GetChild(i).gameObject; | |
if (!child.GetComponent<Part>() && child.name != "main camera pivot") | |
neededChilds.Add(child); | |
} | |
count = neededChilds.Count; | |
sb.Append(pre); | |
if (!first) | |
{ | |
sb.Append(count > 0 ? "--+" : "---"); | |
} | |
else | |
{ | |
sb.Append("+"); | |
} | |
sb.AppendFormat("{0} T:{1} L:{2} ({3})\n", go.name, go.tag, go.layer, LayerMask.LayerToName(go.layer)); | |
string front = first ? "" : " "; | |
string preComp = pre + front + (count > 0 ? "| " : " "); | |
Component[] comp = go.GetComponents<Component>(); | |
for (int i = 0; i < comp.Length; i++) | |
{ | |
if (comp[i] == null) | |
continue; | |
if (comp[i] is RectTransform) | |
{ | |
RectTransform rect = (RectTransform)comp[i]; | |
sb.AppendFormat("{0} {1} - {2}\n{0} Anchor Min {3:F0} - Max {4:F0} - Pivot {5}\n{0} Position {6:F0} - Rotation {8:F5} - Size {7:F0}\n" | |
, preComp, comp[i].GetType().Name, go.transform.name, rect.anchorMin, rect.anchorMax, rect.pivot, rect.anchoredPosition3D, rect.sizeDelta, rect.localRotation.eulerAngles); | |
} | |
//else if (comp[i] is Canvas) | |
//{ | |
// Debug.Log("4-3"); | |
// Canvas c = (Canvas)comp[i]; | |
// sb.AppendFormat("{0} {1} - {2}\n{0} Mode {3} - PP {4} - Camera {5} - Sort {6} - Layer {7} - LayerName {8}\n" | |
// , preComp, comp[i].GetType().Name, go.transform.name, c.renderMode, c.pixelPerfect, c.worldCamera.name, c.sortingOrder, c.sortingLayerID, c.sortingLayerName); | |
//} | |
else if (comp[i] is CanvasScaler) | |
{ | |
CanvasScaler cs = (CanvasScaler)comp[i]; | |
sb.AppendFormat("{0} {1} - {2}\n {0} Mode {3} - Scale {4:N1} - PPU {5:N1}\n", preComp, comp[i].GetType().Name, go.transform.name, cs.uiScaleMode, cs.scaleFactor, cs.referencePixelsPerUnit); | |
} | |
else if (comp[i] is Transform) | |
{ | |
sb.AppendFormat("{0} {1} - {2}\n", preComp, comp[i].GetType().Name, go.transform.name); | |
} | |
else if (comp[i] is Text) | |
{ | |
Text t = (Text) comp[i]; | |
sb.AppendFormat("{0} {1} - {2} - {3} - {4} - {5} - {6}\n", preComp, comp[i].GetType().Name, t.text, t.alignByGeometry, t.pixelsPerUnit, t.font.dynamic, t.fontSize); | |
} | |
else if (comp[i] is TextMeshProUGUI) | |
{ | |
TextMeshProUGUI tmp = (TextMeshProUGUI)comp[i]; | |
sb.AppendFormat("{0} {1} - {2}\n {0} {3} - {4} - {5} - {6}\n", preComp, comp[i].GetType().Name, tmp.text, tmp.fontSize, tmp.fontStyle, tmp.alignment, tmp.color); | |
} | |
else if (comp[i] is Light) | |
{ | |
Light l = (Light)comp[i]; | |
sb.AppendFormat("{16} {17} - {18}\n{16} Range: {0} - Spot Angle: {1} - CookieSize: {2} - CullingMask: {3}\n{16} ShadowNearPlane: {4} - ShadowNormalBias: {5} - ShadowCustomResolution: {6} - ShadowBias: {7}\n{16} Color: {8} - ColorTemp: {9} - Intensity: {10} - Type: {11}\n{16} Shadows: {12} - ShadowStrength: {13} - ShadowResolution: {14} - BounceIntensity: {15}\n" | |
, l.range, l.spotAngle, l.cookieSize, l.cullingMask, l.shadowNearPlane, l.shadowNormalBias, l.shadowCustomResolution | |
, l.shadowBias, l.color, l.colorTemperature, l.intensity, l.type | |
, l.shadows, l.shadowStrength, l.shadowResolution, l.bounceIntensity | |
, preComp, comp[i].GetType().Name, go.transform.name); | |
} | |
else if (comp[i] is BoxCollider) | |
{ | |
BoxCollider bc = (BoxCollider)comp[i]; | |
sb.AppendFormat("{2} {3} - {4}\n{2} Center: {0} - Size: {1}\n", bc.center, bc.size, preComp, comp[i].GetType().Name, go.transform.name); | |
} | |
else if (comp[i] is SphereCollider) | |
{ | |
SphereCollider sc = (SphereCollider)comp[i]; | |
sb.AppendFormat("{2} {3} - {4}\n{2} Center: {0} - Radius: {1}\n", sc.center, sc.radius, preComp, comp[i].GetType().Name, go.transform.name); | |
} | |
else if (comp[i] is CapsuleCollider) | |
{ | |
CapsuleCollider cc = (CapsuleCollider)comp[i]; | |
sb.AppendFormat("{4} {5} - {6}\n{4} Center: {0} - Radius: {1} - Height: {2} - Direction: {3}\n", cc.center, cc.radius, cc.height, cc.direction | |
, preComp, comp[i].GetType().Name, go.transform.name); | |
} | |
else | |
{ | |
sb.AppendFormat("{0} {1} - {2}\n", preComp, comp[i].GetType().Name, comp[i].name); | |
} | |
} | |
sb.AppendLine(preComp); | |
for (int i = 0; i < count; i++) | |
{ | |
DumpGameObjectChilds(neededChilds[i], i == count - 1 ? pre + front + " " : pre + front + "|", sb); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment