0
1

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.

Addressableを使っているときにGameObjectを削除する方法

Last updated at Posted at 2023-06-09

ポイントは
シーンに配置したGameObjectを削除するときはDestroy()で良い
InstantiateAsync()で生成したGameObjectを削除するときはReleaseInstance()で削除する

例えば、敵キャラクターが死んだときは以下のように書く
このように書くと両方の場合に対応できる

    public void Die()
    {
        var released = Addressables.ReleaseInstance(gameObject);
        if (!released)
        {
            Destroy(gameObject);
        }
    }
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?