使用EasySpritesAnimation一键生成动画预制

本文介绍了一款名为EasySpritesAnimation的插件,通过提供链接和详细步骤,展示如何在Unity中批量将多个动画文件夹转换为预制件,简化动画管理流程。
摘要由CSDN通过智能技术生成

本文所用到的插件下载地址:
http://www.manew.com/forum.php?mod=viewthread&tid=100227&page=1#pid1322573

使用此脚本即可在unity中选中多个动画文件夹右键自动生成为预制
文件夹层级如下图:
这里写图片描述


public class AnimPrefabCreatorNew
{

    private static string ProjectPath = "D:/Project/Desinty/Engineer/Desinty/Desinty";
    private static string AnimationPath = "Animation";
    private static string AnimationControllerPath = "Animation";
    private static string PrefabPath = "Assets/Resources/RolePrefabs";

    private static string towerAmmoName = "飞行物";
    private static string spellRenderLayer = "mapSpell";    // 1
    private static string roleRenderLayer = "mapRole";      // 2
    private static string towerRenderLayer = "mapTower";    // 3
                                                            // 法术 >人 >塔

    private static string animationAssetPath = "";

    private static void Create(DirectoryInfo dictorys, string renderLayer, string prefabName = "")
    {
        string rp = dictorys.FullName;
        rp = rp.Replace("\\", "/");
        rp = rp.Replace(Application.dataPath, "Assets");
        List<AnimationClip> clips = new List<AnimationClip>();
        EditorUtility.DisplayProgressBar("create units...", dictorys.Name, 0.5f);

        SpriteAnimationAsset prefabAsset = null;
        BuildAnimationAsset(rp, dictorys, animationAsset =>
        {
            foreach (DirectoryInfo directoryInfo in dictorys.GetDirectories())
            {
                // 若文件夹名字是飞行物(单位的子弹) 跳过 子弹预制需要单独生成
                if (directoryInfo.Name.Equals(towerAmmoName) || directoryInfo.Name.Equals(AnimationPath))
                {
                    continue;
                }
                var sprites = GetAllSprites(directoryInfo);
                var animationProperty = BuildAnimationProperty(animationAsset.animations, directoryInfo.Name.StrToPinyin());
                BuildAnimation(animationProperty, sprites);
            }
            //BuildAnimationProperty(animationAsset.animations, "Normal");
            prefabAsset = animationAsset;

            EditorUtility.DisplayProgressBar("create Animation...", dictorys.Name, 0.8f);
        });

        BuildPrefab(dictorys, prefabAsset, renderLay
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值