public AnimBlock(string _clipName, AnimMachine _origin) { clipName = _clipName; pictureIndex = 0; origin = _origin; lastSpriteChangeTime = 0; sprites = SpritesData.LoadSpritesAtPath("Import/Art/Sprites/" + origin.name + "-" + clipName + "/"); }
public static void BuildSpritesData(string folderPath) { SpritesData data = null; string folderName = PathHelper.FullAssetPath2Name(folderPath); string spriteDataPath = folderPath + "/" + folderName + "SpritesData.asset"; data = AssetDatabase.LoadAssetAtPath <SpritesData>(spriteDataPath); if (data == null) { data = ScriptableObject.CreateInstance <SpritesData>(); data.atlasName = folderPath; AssetDatabase.CreateAsset(data, spriteDataPath); } data.ClearAllSprites(); string workPath = EditorUtils.AssetsPath2ABSPath(folderPath); var filePaths = Directory.GetFiles(workPath); string spritePackingTag = folderPath.ToLower(); for (int i = 0; i < filePaths.Length; ++i) { string relPath = EditorUtils.ABSPath2AssetsPath(filePaths[i]); UnityEngine.Object[] objs = AssetDatabase.LoadAllAssetsAtPath(relPath); if (objs != null) { for (int j = 0; j < objs.Length; ++j) { if (objs[j] is Sprite) { data.AddSprite(objs[j] as Sprite); } else if (objs[j] is Texture2D) { ProcessSpriteTextureImport(relPath, spritePackingTag); } } } } EditorUtility.SetDirty(data); AssetDatabase.SaveAssets(); Log.i("Success Process SpriteImport:" + folderPath); }