-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimationEditorStuff
More file actions
36 lines (31 loc) · 888 Bytes
/
AnimationEditorStuff
File metadata and controls
36 lines (31 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
[ExecuteInEditMode]
public class AnimTest : MonoBehaviour {
[Range(0,2)]
public float animTime = 0;
public AnimationClip animState;
public bool AutoPlay;
private float mLastTime = 0;
private float mDeltaTime = 0;
// Update is called once per frame
void Update () {
mDeltaTime = (float)EditorApplication.timeSinceStartup - mLastTime;
mLastTime = (float)EditorApplication.timeSinceStartup;
if (animState)
{
if (AutoPlay)
{
animTime += mDeltaTime;
if (animTime > animState.length)
{
animTime = 0;
}
}
//AnimationClip 指定目标GameObject取样
animState.SampleAnimation(gameObject, animTime);
}
}
}