質問編集履歴
1
質問を変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
unity の
|
1
|
+
unity のAnimationStateでモーションの現在時間を読み取れない
|
body
CHANGED
@@ -1,28 +1,18 @@
|
|
1
|
+
### 前提・実現したいこと
|
1
|
-
|
2
|
+
https://docs.unity3d.com/ja/current/ScriptReference/AnimationState.html
|
2
|
-
|
3
|
+
ここによると、AnimationStateでtimeは現在のアニメーション時間ということで利用したい。
|
3
|
-
```c#
|
4
4
|
|
5
|
-
public class TestAnimation : MonoBehaviour
|
6
|
-
{
|
7
|
-
|
5
|
+
### 発生している問題・エラーメッセージ
|
8
6
|
|
9
|
-
|
7
|
+
以下のコードで実行すると
|
10
|
-
{
|
11
|
-
m_animator = GetComponent< Animator >();
|
12
|
-
}
|
13
8
|
|
14
|
-
|
15
|
-
{
|
16
|
-
var clipInfoList = m_animator.GetCurrentAnimatorClipInfo( 0 );
|
17
|
-
var clip = clipInfoList[ 0 ].clip;
|
9
|
+
'Animation' does not contain a definition for 'speed' and no accessible extension method 'speed' accepting a first argument of type 'Animation' could be found (are you missing a using directive or an assembly reference?)
|
18
10
|
|
19
|
-
|
11
|
+
とエラーが出てしまう。(多分定義されていないといわれている?)
|
20
12
|
|
13
|
+
### 該当のソースコード
|
14
|
+
定義は省きます。また、modelはインスペクターにアニメーションを設定したゲームオブジェクトです。
|
15
|
+
```C#
|
21
|
-
|
16
|
+
animation = model.GetComponentInChildren<Animation>();
|
22
|
-
var animationHash = stateInfo.shortNameHash;
|
23
|
-
|
24
|
-
|
17
|
+
Debug.Log(animation.time);
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
18
|
```
|