unityでゲーム作りたい(Help!) (416レス)
前次1-
抽出解除 レス栞

リロード規制です。10分ほどで解除するので、他のブラウザへ避難してください。
350
(1): くまじょ [sage] 2020/05/14(木) 20:21:02.68 ID:6hw1sJEU(4/12) AAS
>>349
349(3): くまじょ [sage] 2020/05/14(木) 20:17:51.51 ID:6hw1sJEU(3/12) AAS
GameObject[] goPais;

goPais = GameObject.FindGameObjectsWithTag("Pai");
if(goPais.Length != 0)
{
Debug.Log("★-1- おかしな現象が起きてるぞ goPais.Length=" + goPais.Length);
}

ScriptPai pai = MakePai(0, 0, 0);

goPais = GameObject.FindGameObjectsWithTag("Pai");
if (goPais.Length != 1)
{
Debug.Log("★-2- おかしな現象が起きてるぞ goPais.Length=" + goPais.Length);
}

//pai.tag = "Player"; // このあとDestroyしてるのにGameObject.FindGameObjectsWithTag("Pai");で見つけてしまう

Destroy(pai.gameObject);

goPais = GameObject.FindGameObjectsWithTag("Pai");
if (goPais.Length != 0)
{
Debug.Log("★-3- おかしな現象が起きてるぞ goPais.Length="+ goPais.Length);
}
★-3- おかしな現象が起きてるぞ
が表示された

つまり
Destroyしたのに
GameObject.FindGameObjectsWithTagが見つけてしまう

このあと、
goPais = GameObject.FindGameObjectsWithTag("Pai");
goPais[0]になにかすると
すでにdestroyされているのでエラーになる
354
(1): くまじょ [sage] 2020/05/14(木) 20:51:02.09 ID:6hw1sJEU(7/12) AAS
>>350
訂正

Destroy() した直後は生きているから
m_goPais = GameObject.FindGameObjectsWithTagが見つけてしまう

直後ではなくて後で
m_goPais[0]に何かするとすでにdestroyされているのでエラーになる
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.014s