44 lines
1.1 KiB
Markdown
44 lines
1.1 KiB
Markdown
![]() |
#unity/日常积累
|
|||
|
|
|||
|
unity的动画片段,如果单独使用的话,一般挂载到Animation上,是需要修改 legacy 格式才可以正常挂载和播放的
|
|||
|
|
|||
|
![[Pasted image 20230310142806.png]]
|
|||
|
|
|||
|
|
|||
|
``` cs
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Sirenix.OdinInspector.Editor;
|
|||
|
using UnityEditor;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class test : OdinEditorWindow
|
|||
|
{
|
|||
|
[MenuItem("GameObject/3DMax同步")]
|
|||
|
public static void ShowWindow()
|
|||
|
{
|
|||
|
GameObject CanAnimObject = new GameObject("CamAnim");
|
|||
|
string AnimPath = "Assets/Anim/ani&lobThief_06@Idle.anim";
|
|||
|
|
|||
|
CanAnimObject.AddComponent<Animation>();
|
|||
|
Animation anim = CanAnimObject.GetComponent<Animation>();
|
|||
|
|
|||
|
AnimationClip src = AssetDatabase.LoadAssetAtPath<AnimationClip>(AnimPath);
|
|||
|
src.legacy = true;
|
|||
|
|
|||
|
anim.clip = src;
|
|||
|
anim.AddClip(src, src.name);
|
|||
|
}
|
|||
|
}
|
|||
|
```
|
|||
|
|
|||
|
如果这一行注释:
|
|||
|
|
|||
|
![[Pasted image 20230310142909.png]]
|
|||
|
|
|||
|
|
|||
|
挂载上去的时候,是不会放到Animations列表里,运行游戏也不会自动播放
|
|||
|
|
|||
|
![[Pasted image 20230310142934.png]]
|
|||
|
|