如何将unity3d动画嵌入html,Unity中将Animation Clip嵌入Animator Controller的方法

最近再研究Unity的UI动效果,过程中发现一个小细节:在使用UGUI的Button时,如果设置Transition过渡方式为Animation0e3163dbb02611d5ca546b51b06f7097.png

和其他FBX7cd31a13667ca4de0d0325ef40539ab1.png

看着明显不如Button自动生成的那种要整洁!

后来在Unity论坛上发现了一篇讨论这个问题的帖子:https://forum.unity.com/threads/embedding-motion-clips-in-the-controller-asset.379885/,其中提供了一个Editor脚本实现了此功能,我测试了一下发现有个小bug(不能在已有内嵌Clip的Controller中

// ==================================================================================================================

// NestAnimClips.cs - Nesting AnimationClips inside an AnimationContoller.

// ZombieGorilla for Unity Forums, Modified by K-Res.

// 1.0

// 2016-02-14

// ==================================================================================================================

using UnityEngine;

using UnityEditor;

public class NestAnimClips : MonoBehaviour

{

[MenuItem("Assets/Nest AnimClips in Controller")]

static public void nestAnimClips()

{

UnityEditor.Animations.AnimatorController anim_controller = null;

AnimationClip[] clips = null;

if (Selection.activeObject.GetType() == typeof(UnityEditor.Animations.AnimatorController))

{

anim_controller = (UnityEditor.Animations.AnimatorController)Selection.activeObject;

clips = anim_controller.animationClips;

if (anim_controller != null && clips.Length > 0)

{

foreach (AnimationClip ac in clips)

{

var acAssetPath = AssetDatabase.GetAssetPath(ac);

// Check if this ac is not in the controller

if (acAssetPath.EndsWith(".anim"))

{

var new_ac = Object.Instantiate(ac) as AnimationClip;

new_ac.name = ac.name;

AssetDatabase.AddObjectToAsset(new_ac, anim_controller);

AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(new_ac));

AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(ac));

}

}

Debug.Log("Added " + clips.Length.ToString() + " clips to controller: " + anim_controller.name + "");

}

else

{

Debug.Log("Nothing done. Select a controller that has anim clips to nest.");

}

}

}

}

使用方法很简单,选中Animator Controller资源,然后右键菜单中选”Nest AnimClips in Controller”,即可将此Controller中所有外部Clip都

文字加密小工具v3

请输入要加密的内容

博主友情提示:

如您在评论中需要提及如QQ号、电子邮件地址或其他隐私敏感信息,欢迎使用

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值