タイトル通りです。
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using System.Linq; 5 6public class linQ : MonoBehaviour { 7 8 private float time; 9 10 public GameObject[] tile; 11 public GameObject[] mario; 12 13 void Update () { 14 time -= Time.deltaTime; 15//updateだとうまく動作しないのでArrangeにワープさせています 16 if(time <= 0){ 17 time = 2f; 18 Arrange (); 19 } 20 }
c#
1 private void Arrange (){ 2 3 tile = GameObject.FindGameObjectsWithTag("Finish"); 4 Debug.Log(tile.Length); //400 5 6 mario = GameObject.FindGameObjectsWithTag ("Respawn"); 7 Debug.Log(mario.Length); //150 8 9 IEnumerable<GameObject> aa = mario.Except(tile);//150 10 foreach (GameObject go in aa) { 11 12 Debug.Log (go.transform.position); //marioのtransform.positionが150個出力される 13 } 14 } 15}
おそらく、Arrange内のIEnumable<GameObject>のところでtransform.positionの差集合ではなく、GameObjectの差集合が作られているのでforeachでmarioしか出力されていないのだと思うのですが、どうすればtransform.positionの差集合が求められるでしょうか。
ちなみにmarioの150個のオブジェクトは全てtileの上にあるので、transform.positionの差集合は250になるはずです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/22 03:54