Exemple #1
0
        public static void RemoveInvisibleSprites()
        {
            var objects = (GameObject[])Resources.FindObjectsOfTypeAll(typeof(GameObject));
            int removed = 0;

            ProxyEditor.RecordObjects(objects, "Remove Invisible Sprites");
            foreach (GameObject gameObject in objects)
            {
                PrefabType type = ProxyEditor.GetPrefabType(gameObject);
                if (type == PrefabType.Prefab || type == PrefabType.ModelPrefab || gameObject == null)
                {
                    continue;
                }
                Vector3 position   = gameObject.transform.localPosition;
                bool    isRoot     = gameObject.transform.parent == null;
                string  pureName   = gameObject.name.Contains("@") ? gameObject.name.Split('@')[0] : gameObject.name;
                string  parentName = !isRoot ? gameObject.transform.parent.name : "";
                bool    nested     = !isRoot && gameObject.transform.parent.parent == null;
                nested = nested || (parentName.Contains(pureName) && !parentName.Contains("SpriteGroup"));
                if (IsSprite(gameObject) && (isRoot || !nested) && position.x == 0 && position.z == 0)
                {
                    Log.Show("[HelperMenu]" + gameObject.name + " has been removed.");
                    GameObject.DestroyImmediate(gameObject);
                    ++removed;
                }
            }
            Log.Show("[HelperMenu]" + removed + " null game objects removed.");
        }
        private static void Bake()
        {
            BakeVertexData.complete = false;
            if (EditorApplication.update != BakeVertexData.Step && Selection.gameObjects.Length > 0)
            {
                BakeVertexData.index        = 0;
                BakeVertexData.target       = Selection.gameObjects[0].transform;
                BakeVertexData.baked        = File.GetAsset <Material>("Baked.mat");
                BakeVertexData.bakedOutline = File.GetAsset <Material>("BakedOutline.mat");
                BakeVertexData.bakedShaded  = File.GetAsset <Material>("BakedShaded.mat");
                BakeVertexData.renderers    = BakeVertexData.target.GetComponentsInChildren <MeshRenderer>();
                BakeVertexData.time         = Time.Get();
                ProxyEditor.RecordObjects(BakeVertexData.renderers, "Undo Bake Vertex Colors");
            }
            int passesPerStep = 1000;

            while (passesPerStep > 0)
            {
                EditorApplication.update += BakeVertexData.Step;
                passesPerStep            -= 1;
            }
        }