예제 #1
0
        private void GeneratePrefab(AnimationBaker.BakedData bakedData)
        {
            string path  = AssetDatabase.GetAssetPath(this);
            int    start = path.LastIndexOf('/');

            path  = path.Remove(start, path.Length - start);
            path += "/" + name + ".prefab";

            // Get info.
            NamingConventionUtils.PositionMapInfo info = bakedData.GetPositionMap.name.GetTextureInfo();

            // Generate Material
            if (!AssetDatabaseUtils.HasChildAsset(this, material))
            {
                material = AnimationMaterial.Create(name, materialShader, positionMap, useNormalA, useInterpolation, info.maxFrames);
                AssetDatabase.AddObjectToAsset(material, this);
            }
            else
            {
                material.Update(name, materialShader, positionMap, useNormalA, useInterpolation, info.maxFrames);
            }

            // Generate Prefab
            prefab = AnimationPrefab.Create(path, name, meshes, material, lodSettings.GetTransitionSettings());
        }
예제 #2
0
        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);
            }
        }