最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

【Unity技巧2】簡(jiǎn)單的動(dòng)畫預(yù)覽工具

2022-08-06 16:13 作者:機(jī)智的小草yns  | 我要投稿

前言:當(dāng)有比較多動(dòng)畫片段需要預(yù)覽時(shí),需要找到原本的動(dòng)畫文件預(yù)覽比較麻煩。為了方便預(yù)覽較多的動(dòng)畫,就做了這個(gè)工具。

使用展示


打開位置:頂部菜單欄的Tools/EditorAnimDisplayWindow

使用:把角色模型拽上去,就會(huì)自動(dòng)顯示動(dòng)畫機(jī)內(nèi)的所有動(dòng)畫。

其次是下面的輸入框可以做搜索篩選

源碼:

using UnityEditor;
using UnityEngine;

namespace Assets.Editor
{
??? public class EditorAnimDisplay : EditorWindow
??? {
??????? #region init
??????? private static EditorAnimDisplay instance;
??????? [MenuItem("Tools/EditorAnimDisplayWindow")]
??????? static void PrefabWrapTool()
??????? {
??????????? //獲取當(dāng)前窗口實(shí)例
??????????? instance = EditorWindow.GetWindow<EditorAnimDisplay>();
??????????? instance.Show();
??????????? //ShowUtility() 實(shí)體窗口樣式
??????? }
??????? #endregion

??????? public AnimationClip[] clips;
??????? public GameObject player;
??????? public string Fitter = "";

??????? private AnimationClip curAnimClip;
??????? private float Timer = 0;
??????? private int playCount = 0;
??????? private Vector2 pos = Vector2.zero;


??????? void OnGUI()
??????? {
??????????? player = EditorGUILayout.ObjectField("player", player, typeof(GameObject), true) as GameObject;
??????????? Fitter= EditorGUILayout.TextField("NameFitter",Fitter );
??????????? if (player)
??????????? {
??????????????? clips = player.GetComponent<Animator>().runtimeAnimatorController.animationClips;
??????????????? pos = GUILayout.BeginScrollView(pos, false, false);
??????????????? foreach (var item in clips)
??????????????? {

??????????????????? if (IsShow(item.name)&&GUILayout.Button(item.name))
??????????????????? {
??????????????????????? PlayAnim(item);
??????????????????? }
??????????????? }
??????????????? GUILayout.EndScrollView();
??????????? }
??????? }

??????? private bool IsShow(string clipName)
??????? {
??????????? if (Fitter=="")
??????????????? return true;
??????????? else
??????????? {
??????????????? return clipName.ToLower().Contains(Fitter.ToLower());
??????????? }??????? ?
??????? }

??????? private void PlayAnim(AnimationClip clip)
??????? {
??????????? Timer = 0;
??????????? playCount = 0;
??????????? curAnimClip = clip;
??????????? Selection.activeObject = clip;
??????????? //DragAndDrop.objectReferences[0] = clip;
??????????? //Debug.Log("yns? play");
??????? }

??????? private void Update()
??????? {
??????????????? UpdateAnim(Time.deltaTime);
??????? }

??????? private void UpdateAnim(float delta)
??????? {
??????????? if (curAnimClip != null)
??????????? {
??????????????? Timer += delta;
??????????????? if (Timer > curAnimClip.length && playCount <2)
??????????????? {
??????????????????? playCount++;
??????????????????? Timer = 0;
??????????????? }
??????????????? else
??????????????? {

??????????????????? //動(dòng)畫執(zhí)行方法

??????????????????? curAnimClip.SampleAnimation(player, Timer);
??????????????? }
??????????? }
??????? }
??? }
}



【Unity技巧2】簡(jiǎn)單的動(dòng)畫預(yù)覽工具的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
娄底市| 江川县| 榕江县| 竹溪县| 深泽县| 且末县| 正宁县| 元谋县| 舒城县| 二手房| 都兰县| 桃园市| 华容县| 昆山市| 图片| 乐亭县| 大安市| 搜索| 大埔县| 青神县| 舟山市| 镇沅| 辉县市| 临沭县| 花垣县| 垫江县| 榕江县| 灌阳县| 叙永县| 泾阳县| 临桂县| 南华县| 长白| 临沭县| 潞城市| 南安市| 孝感市| 巴塘县| 惠水县| 安平县| 浮山县|