1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

unityでアニメーションを設定する。 クリックされたらアニメーションが再生するように設定する。

Last updated at Posted at 2020-10-29

単純にクリックされたらアニメーションが再生されるようにしたかったがいろんな方法がいろんなところに書かれていてよくわからなかった。最終的には
https://freesworder.net/unity-animation-play/
の方法が簡単だったように思う。

以下のようなアニメーションを作った

ezgif-2-8d13b8b525b8.gif

まず、ガチャ本体のイラストと、動かしたいハンドルの部分のイラストを用意し、Assetsにいれる。

スクリーンショット 2020-10-29 15.29.28.png

画像二つを画面の方にドロップ
スクリーンショット 2020-10-29 15.30.54.png

ハンドルが回るアニメーションを作る
スクリーンショット 2020-10-29 15.32.03.png

ウインドウ > アニメーション > アニメーション

を押すとアニメーションウインドウが表示されるようになる
スクリーンショット 2020-10-29 15.33.13.png

ここでアニメーションを設定。

スクリーンショット 2020-10-29 15.34.16.png

handleAnimationというのがAssetsにできる

スクリーンショット 2020-10-29 17.12.48.png

handleを選択して コンポーネント追加でanimationを追加する

その項目の中に、作成したhandleAnimationを選んでおく

クリックしたときにこのアニメーションを再生するようにスクリプトを作成する
スクリーンショット 2020-10-29 17.16.56.png

これをhandleにくっつける

スクリーンショット 2020-10-29 17.17.41.png

これで完成。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?