Exemplo n.º 1
0
        public static string GetPath(this GameObject current)
        {
            if (current.IsNull() || current.transform.IsNull())
            {
                return("");
            }
            string path = current.transform.name;

            if (Proxy.IsEditor())
            {
                var type = ProxyEditor.GetPrefabType(current);
                if (type.ContainsAny("Prefab", "ModelPrefab"))
                {
                    path = "Prefab/" + path;
                }
            }
            Transform parent = current.transform.parent;

            while (!parent.IsNull())
            {
                path   = parent.name + "/" + path;
                parent = parent.parent;
            }
            return("/" + path + "/");
        }
Exemplo n.º 2
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.");
        }
Exemplo n.º 3
0
 public static bool IsPrefab(this GameObject current)
 {
     if (current.IsNull())
     {
         return(false);
     }
     if (Proxy.IsEditor())
     {
         return(!ProxyEditor.GetPrefabType(current.transform.root.gameObject).IsNull());
     }
     return(false);
 }