コード例 #1
0
    private static void DumpRigidBodies(string targetFolder)
    {
        Rigidbody[]   source        = UnityEngine.Object.FindObjectsOfType <Rigidbody>();
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.AppendLine("RigidBody");
        stringBuilder.AppendLine();
        StringBuilder stringBuilder2 = new StringBuilder();

        stringBuilder2.AppendLine("RigidBody");
        stringBuilder2.AppendLine();
        foreach (IGrouping <string, Rigidbody> item in from x in source
                 group x by TransformEx.GetRecursiveName(x.transform) into x
                 orderby x.Count() descending
                 select x)
        {
            stringBuilder.AppendFormat("{1:N0}\t{0} ({2:N0} awake) ({3:N0} kinematic) ({4:N0} non-discrete)", item.Key, item.Count(), item.Count((Rigidbody x) => !x.IsSleeping()), item.Count((Rigidbody x) => x.isKinematic), item.Count((Rigidbody x) => x.collisionDetectionMode != CollisionDetectionMode.Discrete));
            stringBuilder.AppendLine();
            foreach (Rigidbody item2 in item)
            {
                stringBuilder2.AppendFormat("{0} -{1}{2}{3}", item.Key, item2.isKinematic ? " KIN" : "", item2.IsSleeping() ? " SLEEP" : "", item2.useGravity ? " GRAVITY" : "");
                stringBuilder2.AppendLine();
                stringBuilder2.AppendFormat("Mass: {0}\tVelocity: {1}\tsleepThreshold: {2}", item2.mass, item2.velocity, item2.sleepThreshold);
                stringBuilder2.AppendLine();
                stringBuilder2.AppendLine();
            }
        }
        WriteTextToFile(targetFolder + "Physics.RigidBody.Objects.txt", stringBuilder.ToString());
        WriteTextToFile(targetFolder + "Physics.RigidBody.All.txt", stringBuilder2.ToString());
    }
コード例 #2
0
    private IEnumerator Start()
    {
        Debug.LogWarning("WARNING: CHILDRENFROMSCENE(" + SceneName + ") - WE SHOULDN'T BE USING THIS SHITTY COMPONENT NOW WE HAVE AWESOME PREFABS", base.gameObject);
        if (!SceneManager.GetSceneByName(SceneName).isLoaded)
        {
            yield return(SceneManager.LoadSceneAsync(SceneName, LoadSceneMode.Additive));
        }
        Scene sceneByName = SceneManager.GetSceneByName(SceneName);

        GameObject[] rootGameObjects = sceneByName.GetRootGameObjects();
        foreach (GameObject gameObject in rootGameObjects)
        {
            gameObject.transform.SetParent(base.transform, false);
            TransformEx.Identity(gameObject);
            RectTransform rectTransform = gameObject.transform as RectTransform;
            if ((bool)rectTransform)
            {
                rectTransform.pivot            = Vector2.zero;
                rectTransform.anchoredPosition = Vector2.zero;
                rectTransform.anchorMin        = Vector2.zero;
                rectTransform.anchorMax        = Vector2.one;
                rectTransform.sizeDelta        = Vector2.one;
            }
            SingletonComponent[] componentsInChildren = gameObject.GetComponentsInChildren <SingletonComponent>(true);
            for (int j = 0; j < componentsInChildren.Length; j++)
            {
                componentsInChildren[j].SingletonSetup();
            }
            if (StartChildrenDisabled)
            {
                gameObject.SetActive(false);
            }
        }
        SceneManager.UnloadSceneAsync(sceneByName);
    }
コード例 #3
0
 public virtual void SetOwnerPlayer(BasePlayer player)
 {
     Assert.IsTrue(base.isServer, "Should be server!");
     Assert.IsTrue(player.isServer, "Player should be serverside!");
     TransformEx.Identity(base.gameObject);
     SetParent(player, handBone);
     SetHeld(false);
 }
コード例 #4
0
        public UniqueObject(Object obj)
        {
            scene                    = new AmsSceneReference();
            fullPath                 = string.Empty;
            componentName            = string.Empty;
            version                  = CurrentSerializedVersion;
            componentIndex           = 0;
            editorLocalId            = 0;
            editorPrefabRelativePath = string.Empty;

            if (!obj)
            {
                return;
            }

            GameObject gameObject = GameObjectEx.EditorGetGameObjectFromComponent(obj);

            if (gameObject)
            {
                scene    = new AmsSceneReference(gameObject.scene);
                fullPath = gameObject.GetFullName();

                Component comp = obj as Component;
                if (comp)
                {
                    componentName = obj.GetType().AssemblyQualifiedName;
                    gameObject.GetComponents(obj.GetType(), _reusableComponentsList);
                    componentIndex = _reusableComponentsList.IndexOf(comp);
                }
            }

#if UNITY_2018_3_OR_NEWER
            // Get the nearest root (which will have an editor id)
            var prefabObj = PrefabUtility.GetPrefabInstanceHandle(obj);
            if (prefabObj)
            {
                editorLocalId = GetEditorId(prefabObj);

                var prefabRoot = PrefabUtility.GetOutermostPrefabInstanceRoot(obj);
                editorPrefabRelativePath = TransformEx.GetPathRelativeTo(gameObject.transform, prefabRoot.transform);
            }
#else
            // Get the prefab object
            var prefabObj = PrefabUtility.GetPrefabObject(obj);
            if (prefabObj)
            {
                GameObject prefabRoot = PrefabUtility.FindPrefabRoot(gameObject);
                editorLocalId            = prefabRoot ? GetEditorId(prefabRoot) : GetEditorId(obj);
                editorPrefabRelativePath = TransformEx.GetPathRelativeTo(gameObject.transform, prefabRoot.transform);
            }
#endif

            if (editorLocalId == 0)
            {
                editorLocalId = GetEditorId(obj);
            }
        }
コード例 #5
0
    static void FindGameObjectRecur(GameObject go, string name, List <GameObject> buffer)
    {
        GameObject temp = TransformEx.GetChildGameObject(go, name);

        if (temp)
        {
            buffer.Add(temp);
        }
    }
コード例 #6
0
ファイル: GizmosUtil.cs プロジェクト: Ailtop/RustDocuments
    public static void DrawBounds(Transform transform)
    {
        Bounds     bounds     = TransformEx.GetBounds(transform, true, false);
        Vector3    lossyScale = transform.lossyScale;
        Quaternion rotation   = transform.rotation;
        Vector3    pos        = transform.position + rotation * Vector3.Scale(lossyScale, bounds.center);
        Vector3    size       = Vector3.Scale(lossyScale, bounds.size);

        DrawCube(pos, size, rotation);
        DrawWireCube(pos, size, rotation);
    }
コード例 #7
0
            void FixedUpdate()
            {
                if (input.IsDown(BUTTON.CHAT))
                {
                    enabled = false;
                }
                else
                {
                    if (!player.IsSpectating())
                    {
                        player.SetPlayerFlag(BasePlayer.PlayerFlags.Spectating, true);
                        TransformEx.SetLayerRecursive(gameObject, "Invisible");
                        CancelInvoke("MetabolismUpdate");
                        CancelInvoke("InventoryUpdate");
                    }

                    direction = Vector3.zero;
                    if (input.IsDown(BUTTON.FORWARD))
                    {
                        direction.z++;
                    }
                    if (input.IsDown(BUTTON.RIGHT))
                    {
                        direction.x++;
                    }
                    if (input.IsDown(BUTTON.LEFT))
                    {
                        direction.x--;
                    }
                    if (input.IsDown(BUTTON.BACKWARD))
                    {
                        direction.z--;
                    }

                    if (input.IsDown(BUTTON.FIRE_PRIMARY))
                    {
                        if (input.IsDown(BUTTON.PREVIOUS))
                        {
                            speed++;
                        }
                        else if (input.IsDown(BUTTON.NEXT))
                        {
                            speed--;
                        }
                    }

                    if (direction != Vector3.zero)
                    {
                        CheckParent();
                        Move(transform.position + Quaternion.Euler(input.current.aimAngles) * direction * Time.deltaTime * speed);
                    }
                }
            }
コード例 #8
0
            public static RendererInstance From(Renderer renderer)
            {
                RendererInstance result = default(RendererInstance);

                result.IsVisible      = renderer.isVisible;
                result.CastShadows    = renderer.shadowCastingMode != ShadowCastingMode.Off;
                result.RecieveShadows = renderer.receiveShadows;
                result.Enabled        = renderer.enabled && renderer.gameObject.activeInHierarchy;
                result.Size           = renderer.bounds.size.magnitude;
                result.Distance       = Vector3.Distance(renderer.bounds.center, Camera.main.transform.position);
                result.MaterialCount  = renderer.sharedMaterials.Length;
                result.RenderType     = renderer.GetType().Name;
                BaseEntity baseEntity = GameObjectEx.ToBaseEntity(renderer.gameObject);

                if ((bool)baseEntity)
                {
                    result.EntityName = baseEntity.PrefabName;
                    if (baseEntity.net != null)
                    {
                        result.EntityId = baseEntity.net.ID;
                    }
                }
                else
                {
                    result.ObjectName = TransformEx.GetRecursiveName(renderer.transform);
                }
                if (renderer is MeshRenderer)
                {
                    result.BoneCount = 0;
                    MeshFilter component = renderer.GetComponent <MeshFilter>();
                    if ((bool)component)
                    {
                        result.ReadMesh(component.sharedMesh);
                    }
                }
                if (renderer is SkinnedMeshRenderer)
                {
                    SkinnedMeshRenderer skinnedMeshRenderer = renderer as SkinnedMeshRenderer;
                    result.ReadMesh(skinnedMeshRenderer.sharedMesh);
                    result.UpdateWhenOffscreen = skinnedMeshRenderer.updateWhenOffscreen;
                }
                if (renderer is ParticleSystemRenderer)
                {
                    ParticleSystem component2 = renderer.GetComponent <ParticleSystem>();
                    if ((bool)component2)
                    {
                        result.MeshName      = component2.name;
                        result.ParticleCount = component2.particleCount;
                    }
                }
                return(result);
            }
コード例 #9
0
 private void PutAnimatorToSleep()
 {
     if (!model || !model.animator)
     {
         Debug.LogWarning(TransformEx.GetRecursiveName(base.transform) + " has missing model/animator", base.gameObject);
         return;
     }
     model.animator.enabled = false;
     if (base.isServer)
     {
         SetFlag(Flags.Busy, false);
     }
     OnAnimatorDisabled();
 }
コード例 #10
0
ファイル: Hierarchy.cs プロジェクト: Ailtop/RustDocuments
        public static void ls(Arg args)
        {
            string text   = "";
            string filter = args.GetString(0);

            text = ((!currentDir) ? (text + "Listing .\n\n") : (text + "Listing " + TransformEx.GetRecursiveName(currentDir.transform) + "\n\n"));
            foreach (Transform item in (from x in GetCurrent()
                                        where string.IsNullOrEmpty(filter) || x.name.Contains(filter)
                                        select x).Take(40))
            {
                text += $"   {item.name} [{item.childCount}]\n";
            }
            text += "\n";
            args.ReplyWith(text);
        }
コード例 #11
0
    void TestGetFullPath()
    {
        var g0 = new GameObject("一");
        var g1 = new GameObject("二"); g1.transform.SetParent(g0.transform);
        var g2 = new GameObject("三"); g2.transform.SetParent(g1.transform);
        var g3 = new GameObject("四"); g3.transform.SetParent(g2.transform);
        var g4 = new GameObject("五"); g4.transform.SetParent(g3.transform);

        Debug.Log(TransformEx.GetFullPath(null));
        Debug.Log(g0.transform.GetFullPath());
        Debug.Log(g1.transform.GetFullPath());
        Debug.Log(g2.transform.GetFullPath());
        Debug.Log(g3.transform.GetFullPath());
        Debug.Log(g4.transform.GetFullPath());
    }
コード例 #12
0
            void OnDisable()
            {
                CheckParent();
                RaycastHit hit;

                if (Physics.Raycast(new Ray(transform.position, Vector3.down), out hit, 25000) || Physics.Raycast(new Ray(transform.position, Vector3.up), out hit, 25000))
                {
                    Move(hit.point);
                }
                player.metabolism.Reset();
                InvokeRepeating("InventoryUpdate", 1f, 0.1f * UnityEngine.Random.Range(0.99f, 1.01f));
                player.SetPlayerFlag(BasePlayer.PlayerFlags.Spectating, false);
                TransformEx.SetLayerRecursive(gameObject, "Player (Server)");
                player.ChatMessage("Fly deactivated!");
            }
コード例 #13
0
ファイル: GameManager.cs プロジェクト: Ailtop/RustDocuments
    public GameObject CreatePrefab(string strPrefab, Transform parent, bool active = true)
    {
        GameObject gameObject = Instantiate(strPrefab, parent.position, parent.rotation);

        if ((bool)gameObject)
        {
            gameObject.transform.SetParent(parent, false);
            TransformEx.Identity(gameObject);
            if (active)
            {
                PoolableEx.AwakeFromInstantiate(gameObject);
            }
        }
        return(gameObject);
    }
コード例 #14
0
ファイル: DroppedItem.cs プロジェクト: Ailtop/RustDocuments
    public override void PostInitShared()
    {
        base.PostInitShared();
        GameObject gameObject = null;

        gameObject = ((item == null || !item.info.worldModelPrefab.isValid) ? Object.Instantiate(itemModel) : item.info.worldModelPrefab.Instantiate());
        gameObject.transform.SetParent(base.transform, false);
        gameObject.transform.localPosition = Vector3.zero;
        gameObject.transform.localRotation = Quaternion.identity;
        TransformEx.SetLayerRecursive(gameObject, base.gameObject.layer);
        childCollider = gameObject.GetComponent <Collider>();
        if ((bool)childCollider)
        {
            childCollider.enabled = false;
            childCollider.enabled = true;
        }
        if (base.isServer)
        {
            WorldModel component   = gameObject.GetComponent <WorldModel>();
            float      mass        = (component ? component.mass : 1f);
            float      drag        = 0.1f;
            float      angularDrag = 0.1f;
            Rigidbody  rigidbody   = base.gameObject.AddComponent <Rigidbody>();
            rigidbody.mass          = mass;
            rigidbody.drag          = drag;
            rigidbody.angularDrag   = angularDrag;
            rigidbody.interpolation = RigidbodyInterpolation.None;
            ConVar.Physics.ApplyDropped(rigidbody);
            Renderer[] componentsInChildren = gameObject.GetComponentsInChildren <Renderer>(true);
            for (int i = 0; i < componentsInChildren.Length; i++)
            {
                componentsInChildren[i].enabled = false;
            }
        }
        if (item != null)
        {
            PhysicsEffects component2 = base.gameObject.GetComponent <PhysicsEffects>();
            if (component2 != null)
            {
                component2.entity = this;
                if (item.info.physImpactSoundDef != null)
                {
                    component2.physImpactSoundDef = item.info.physImpactSoundDef;
                }
            }
        }
        gameObject.SetActive(true);
    }
コード例 #15
0
    private static void DumpColliders(string targetFolder)
    {
        Collider[]    source        = UnityEngine.Object.FindObjectsOfType <Collider>();
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.AppendLine("Physics Colliders");
        stringBuilder.AppendLine();
        foreach (IGrouping <string, Collider> item in from x in source
                 group x by TransformEx.GetRecursiveName(x.transform) into x
                 orderby x.Count() descending
                 select x)
        {
            stringBuilder.AppendFormat("{1:N0}\t{0} ({2:N0} triggers) ({3:N0} enabled)", item.Key, item.Count(), item.Count((Collider x) => x.isTrigger), item.Count((Collider x) => x.enabled));
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "Physics.Colliders.Objects.txt", stringBuilder.ToString());
    }
コード例 #16
0
    private static void DumpLODGroupTotals(string targetFolder)
    {
        LODGroup[]    source        = UnityEngine.Object.FindObjectsOfType <LODGroup>();
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.AppendLine("LODGroups");
        stringBuilder.AppendLine();
        foreach (IGrouping <string, LODGroup> item in from x in source
                 group x by TransformEx.GetRecursiveName(x.transform) into x
                 orderby x.Count() descending
                 select x)
        {
            stringBuilder.AppendFormat("{1:N0}\t{0}", item.Key, item.Count());
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "LODGroups.Objects.txt", stringBuilder.ToString());
    }
コード例 #17
0
    public void CreateScreenshots()
    {
        RenderTexture renderTexture = new RenderTexture(width, height, 0);
        GameObject    gameObject    = new GameObject();
        Camera        camera        = gameObject.AddComponent <Camera>();

        camera.targetTexture   = renderTexture;
        camera.orthographic    = false;
        camera.fieldOfView     = fieldOfView;
        camera.nearClipPlane   = 0.1f;
        camera.farClipPlane    = 2000f;
        camera.cullingMask     = LayerMask.GetMask("TransparentFX");
        camera.clearFlags      = CameraClearFlags.Color;
        camera.backgroundColor = new Color(0f, 0f, 0f, 0f);
        camera.renderingPath   = RenderingPath.DeferredShading;
        Texture2D texture2D = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.ARGB32, false);

        foreach (Transform item in base.transform.Cast <Transform>())
        {
            PositionCamera(camera, item.gameObject);
            int layer = item.gameObject.layer;
            TransformEx.SetLayerRecursive(item.gameObject, 1);
            camera.Render();
            TransformEx.SetLayerRecursive(item.gameObject, layer);
            string recursiveName = TransformEx.GetRecursiveName(item);
            recursiveName        = recursiveName.Replace('/', '.');
            RenderTexture.active = renderTexture;
            texture2D.ReadPixels(new Rect(0f, 0f, renderTexture.width, renderTexture.height), 0, 0, false);
            RenderTexture.active = null;
            byte[] bytes         = texture2D.EncodeToPNG();
            string path          = string.Format(folder, recursiveName, item.name);
            string directoryName = Path.GetDirectoryName(path);
            if (!Directory.Exists(directoryName))
            {
                Directory.CreateDirectory(directoryName);
            }
            File.WriteAllBytes(path, bytes);
        }
        UnityEngine.Object.DestroyImmediate(texture2D, true);
        UnityEngine.Object.DestroyImmediate(renderTexture, true);
        UnityEngine.Object.DestroyImmediate(gameObject, true);
    }
コード例 #18
0
    private static void DumpAnimators(string targetFolder)
    {
        Animator[]    array         = UnityEngine.Object.FindObjectsOfType <Animator>();
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.AppendLine("All animators");
        stringBuilder.AppendLine();
        Animator[] array2 = array;
        foreach (Animator animator in array2)
        {
            stringBuilder.AppendFormat("{1}\t{0}", TransformEx.GetRecursiveName(animator.transform), animator.enabled);
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "UnityEngine.Animators.List.txt", stringBuilder.ToString());
        StringBuilder stringBuilder2 = new StringBuilder();

        stringBuilder2.AppendLine("All animators - grouped by object name");
        stringBuilder2.AppendLine();
        foreach (IGrouping <string, Animator> item in from x in array
                 group x by TransformEx.GetRecursiveName(x.transform) into x
                 orderby x.Count() descending
                 select x)
        {
            stringBuilder2.AppendFormat("{1:N0}\t{0}", TransformEx.GetRecursiveName(item.First().transform), item.Count());
            stringBuilder2.AppendLine();
        }
        WriteTextToFile(targetFolder + "UnityEngine.Animators.Counts.txt", stringBuilder2.ToString());
        StringBuilder stringBuilder3 = new StringBuilder();

        stringBuilder3.AppendLine("All animators - grouped by enabled/disabled");
        stringBuilder3.AppendLine();
        foreach (IGrouping <string, Animator> item2 in from x in array
                 group x by TransformEx.GetRecursiveName(x.transform, x.enabled ? "" : " (DISABLED)") into x
                 orderby x.Count() descending
                 select x)
        {
            stringBuilder3.AppendFormat("{1:N0}\t{0}", TransformEx.GetRecursiveName(item2.First().transform, item2.First().enabled ? "" : " (DISABLED)"), item2.Count());
            stringBuilder3.AppendLine();
        }
        WriteTextToFile(targetFolder + "UnityEngine.Animators.Counts.Enabled.txt", stringBuilder3.ToString());
    }
コード例 #19
0
        public UniqueObject(Object obj)
        {
            scene                    = new AmsSceneReference();
            fullPath                 = string.Empty;
            componentName            = string.Empty;
            version                  = CurrentSerializedVersion;
            componentIndex           = 0;
            editorLocalId            = 0;
            editorPrefabRelativePath = string.Empty;

            if (!obj)
            {
                return;
            }

            GameObject gameObject = GameObjectEx.EditorGetGameObjectFromComponent(obj);

            if (gameObject)
            {
                scene    = new AmsSceneReference(gameObject.scene);
                fullPath = gameObject.GetFullName();

                Component comp = obj as Component;
                if (comp)
                {
                    componentName = obj.GetType().AssemblyQualifiedName;
                    gameObject.GetComponents(obj.GetType(), _reusableComponentsList);
                    componentIndex = _reusableComponentsList.IndexOf(comp);
                }
            }

            // Get the prefab object
            var prefabObj = PrefabUtility.GetPrefabObject(obj);

            if (prefabObj)
            {
                GameObject prefabRoot = PrefabUtility.FindPrefabRoot(gameObject);
                editorLocalId            = prefabObj ? GetEditorId(prefabObj) : GetEditorId(obj);
                editorPrefabRelativePath = TransformEx.GetPathRelativeTo(gameObject.transform, prefabRoot.transform);
            }
        }
コード例 #20
0
ファイル: Hierarchy.cs プロジェクト: Ailtop/RustDocuments
        public static void cd(Arg args)
        {
            if (args.FullString == ".")
            {
                currentDir = null;
                args.ReplyWith("Changed to .");
                return;
            }
            if (args.FullString == "..")
            {
                if ((bool)currentDir)
                {
                    currentDir = (currentDir.transform.parent ? currentDir.transform.parent.gameObject : null);
                }
                currentDir = null;
                if ((bool)currentDir)
                {
                    args.ReplyWith("Changed to " + TransformEx.GetRecursiveName(currentDir.transform));
                }
                else
                {
                    args.ReplyWith("Changed to .");
                }
                return;
            }
            Transform transform = GetCurrent().FirstOrDefault((Transform x) => x.name.ToLower() == args.FullString.ToLower());

            if (transform == null)
            {
                transform = GetCurrent().FirstOrDefault((Transform x) => x.name.StartsWith(args.FullString, StringComparison.CurrentCultureIgnoreCase));
            }
            if ((bool)transform)
            {
                currentDir = transform.gameObject;
                args.ReplyWith("Changed to " + TransformEx.GetRecursiveName(currentDir.transform));
            }
            else
            {
                args.ReplyWith("Couldn't find \"" + args.FullString + "\"");
            }
        }
コード例 #21
0
 protected void Start()
 {
     TransformEx.SetHierarchyGroup(base.transform, "Dungeon");
 }
コード例 #22
0
    public static Transform FindTransform(GameObject go, string name)
    {
        var findGO = TransformEx.GetChildGameObject(go, name);

        return(findGO ? findGO.transform : null);
    }
コード例 #23
0
 public static GameObject FindGameObject(GameObject go, string name)
 {
     return(TransformEx.GetChildGameObject(go, name));
 }
コード例 #24
0
    private static void DumpGameObjects(string targetFolder)
    {
        Transform[]   rootObjects   = TransformUtil.GetRootObjects();
        StringBuilder stringBuilder = new StringBuilder();

        stringBuilder.AppendLine("All active game objects");
        stringBuilder.AppendLine();
        Transform[] array = rootObjects;
        foreach (Transform tx in array)
        {
            DumpGameObjectRecursive(stringBuilder, tx, 0);
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "GameObject.Hierarchy.txt", stringBuilder.ToString());
        stringBuilder = new StringBuilder();
        stringBuilder.AppendLine("All active game objects including components");
        stringBuilder.AppendLine();
        array = rootObjects;
        foreach (Transform tx2 in array)
        {
            DumpGameObjectRecursive(stringBuilder, tx2, 0, true);
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "GameObject.Hierarchy.Components.txt", stringBuilder.ToString());
        stringBuilder = new StringBuilder();
        stringBuilder.AppendLine("Root gameobjects, grouped by name, ordered by the total number of objects excluding children");
        stringBuilder.AppendLine();
        foreach (IGrouping <string, Transform> item in from x in rootObjects
                 group x by x.name into x
                 orderby x.Count() descending
                 select x)
        {
            Transform transform = item.First();
            stringBuilder.AppendFormat("{1:N0}\t{0}", transform.name, item.Count());
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "GameObject.Count.txt", stringBuilder.ToString());
        stringBuilder = new StringBuilder();
        stringBuilder.AppendLine("Root gameobjects, grouped by name, ordered by the total number of objects including children");
        stringBuilder.AppendLine();
        foreach (KeyValuePair <Transform, int> item2 in from x in rootObjects
                 group x by x.name into x
                 select new KeyValuePair <Transform, int>(x.First(), x.Sum((Transform y) => TransformEx.GetAllChildren(y).Count)) into x
                 orderby x.Value descending
                 select x)
        {
            stringBuilder.AppendFormat("{1:N0}\t{0}", item2.Key.name, item2.Value);
            stringBuilder.AppendLine();
        }
        WriteTextToFile(targetFolder + "GameObject.Count.Children.txt", stringBuilder.ToString());
    }