示例#1
0
        public static void ReimportTextures(TextureImportData data)
        {
            if (data == null)
            {
                return;
            }
            string[] guids = AssetDatabase.FindAssets("t:Texture", new string[] { data.AssetPath });
            for (int i = 0; i < guids.Length; i++)
            {
                string path = AssetDatabase.GUIDToAssetPath(guids[i]);

                if (string.IsNullOrEmpty(path))
                {
                    continue;
                }

                if (!data.IsRecursive)
                {
                    string dir = path.Remove(path.LastIndexOf('/'));
                    if (!dir.Equals(data.AssetPath))
                    {
                        continue;
                    }
                }

                string name = path.Substring(path.LastIndexOf('/') + 1);
                if (data.IsMatch(name))
                {
                    AssetImporter ai = AssetImporter.GetAtPath(path);
                    if (null != ai)
                    {
                        ApplyRulesToTexture(ai, data);
                    }
                }
            }
        }