回答編集履歴

1

コメント

2018/12/26 00:13

投稿

negitama
negitama

スコア943

test CHANGED
@@ -13,3 +13,59 @@
13
13
  Destroy (anim);
14
14
 
15
15
  ```
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+ 【追記】
24
+
25
+ こちらで検証に使用したスクリプトを載せておきます。
26
+
27
+ コード内のコメント箇所を確認してみてください。
28
+
29
+ ```
30
+
31
+ using UnityEngine;
32
+
33
+
34
+
35
+ // 子のゲームオブジェクトにアタッチする
36
+
37
+ public class StopAnimator : MonoBehaviour
38
+
39
+ {
40
+
41
+ void Update ()
42
+
43
+ {
44
+
45
+ // マウスの左クリック
46
+
47
+ if ( Input.GetMouseButton ( 0 ) )
48
+
49
+ {
50
+
51
+ // 親のオブジェクトにアタッチされたAnimatorコンポーネントを取得して変数animに格納
52
+
53
+ var anim = GetComponentInParent<Animator> ();
54
+
55
+
56
+
57
+ // 変数animに格納されたAnimatorコンポーネントを消去
58
+
59
+ Destroy ( anim );
60
+
61
+ }
62
+
63
+ }
64
+
65
+ }
66
+
67
+ ```
68
+
69
+ GIFはこちら。
70
+
71
+ ![イメージ説明](accbf760a1c4c102ae8d9e1ae0871da5.gif)