public void DeleteSavedAssets() { // Remove assets. var assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(this)); foreach (var a in assets) { if (a != this) { AssetDatabase.RemoveObjectFromAsset(a); } } // Delete prefab. string path = AssetDatabase.GetAssetPath(prefab); AssetDatabase.DeleteAsset(path); // Clear variables. prefab = null; positionMap = null; material = null; meshes = null; book = null; animations = new List <VA_Animation>(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
private void GenerateBook(AnimationBaker.BakedData bakedData) { // Create book. if (!book) { book = CreateInstance <VA_AnimationBook>(); } book.name = string.Format("{0}_Book", name); book.positionMap = positionMap; book.animations = new List <VA_Animation>(); book.TryAddMaterial(material); // Save book. if (!AssetDatabaseUtils.HasChildAsset(this, book)) { AssetDatabase.AddObjectToAsset(book, this); } // Get animation info. List <NamingConventionUtils.PositionMapInfo> info = new List <NamingConventionUtils.PositionMapInfo>(); foreach (var t in bakedData.positionMaps) { info.Add(t.name.GetTextureInfo()); } // Create animations. for (int i = 0; i < info.Count; i++) { string animationName = string.Format("{0}_{1}", name, info[i].name); VA_AnimationData newData = new VA_AnimationData(animationName, info[i].frames, info[i].maxFrames, info[i].fps, i, -1); // Either update existing animation or create a new one. if (TryGetAnimationWithName(animationName, out VA_Animation animation)) { animation.SetData(newData); } else { animation = CreateInstance <VA_Animation>(); animation.name = animationName; animation.SetData(newData); animations.Add(animation); } book.TryAddAnimation(animation); } // Save animation objects. foreach (var a in animations) { AssetDatabaseUtils.TryAddChildAsset(book, a); } }
void OnEnable() { animationBook = target as VA_AnimationBook; }