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 5 years have passed since last update.

UI.Button をスクリプトで複製したら、コールバックイベントはとにかくリセットしたい。

Last updated at Posted at 2019-03-23

スクリプトで複製したボタン
このボタンのコールバックを削除したい。リセットしたい。全消ししたい。
ときに、イベントも複製されるんだっけ...されないんだっけ...

環境

  • バージョン 2018.3.8f1

1. スクリプトで、AddListener() した場合。(非永続的)

onClick イベントは引き継がれない

ので、特に何もしない。

2. インスペクタ上から登録した場合。(永続的)

onClick イベントも引き継がれる

ので、オフにする。

int persistentEventCount = btn.onClick.GetPersistentEventCount();
for (int i = 0; i < persistentEventCount; i++)
    btn.onClick.SetPersistentListenerState(i, UnityEventCallState.Off);
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?