ソースコード
C#
1using UnityEngine; 2using UnityEngine.EventSystems; 3using TMPro; 4using DG.Tweening; 5 6 7public class DropArea : MonoBehaviour,IDropHandler 8{ 9 static int handMax = 5; 10 [SerializeField] private TextMeshProUGUI bulletText; 11 [SerializeField] private GameObject hand; 12 Transform[] handChildren = new Transform[handMax]; 13 14 15 public void OnDrop(PointerEventData eventData){ 16 Debug.Log(gameObject.name + "に" + eventData.pointerDrag.name + "がドロップされました。"); 17 bulletText.text = eventData.pointerDrag.name; 18 Destroy(eventData.pointerDrag.gameObject); 19 20 21 for(int i = 0; i < handMax; i++){ 22 handChildren[i] = hand.transform.GetChild(i); 23 handChildren[i].transform.DOLocalMove(new Vector3(200f*(handMax-i), 50, 0), 1f).SetLink(handChildren[i].gameObject); 24 25 Debug.Log(handChildren[i]); 26 } 27 } 28 29}
意図している挙動
例としては
hand(GameObject)
└card1
└card2
└card3
└card4
└card5
からcard3をDestroyし、Destroyされた後のChild群(card1,2,4,5)を取得して並べたい
起きている挙動
Destroyしたが、getChildによって取得されたものにDestroyしたものが含まれている
(DebugでDestroyしたはずのオブジェクトが出力される)
Unity内の表示では該当オブジェクト(例の場合だとcard3)は削除されている
getChildまたはDestroyについて何か誤解をしているかもしれません
必要な情報がありましたら補足します

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。