1
0

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 1 year has passed since last update.

Unity: AnimationコンポーネントのPlay AutomaticallyはSetActiveでも動くから便利

Last updated at Posted at 2022-05-09

AnimationコンポーネントのPlay Automaticallyにインスペクタからtrueにしていると、EditorからPlayした時に勝手にアニメーションがPlayされる。
しかしSetActive(true)でオブジェクトをActiveにした場合でもアニメーションがPlayされるため、あらかじめロード用のアニメーションを用意していれば
image.png

loadingAnim
 [SerializeField]
    private GameObject loadingIconImage;
//何かしらの非同期メソッドを実行して、さらにその間に読み込み中アニメーションを起動する
  public async UniTask<string> Request_Installation()
    {
        loadingUI.SetActive(true);

        var response_text = await Installation();
               
        loadingUI.SetActive(false);

        return response_text;
    }

こんな感じで読み込み画面とリクエストの処理をシンプルに記述することが出来る。
foreachでAnim.Play()とかしなくて済む。

1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?