我想檢查列表中的對象是否有標籤。對於每個匹配「clean」的標籤,都需要提出一個整數。這可能嗎?如果是這樣,我該如何做到這一點?列表c中的標籤#
在此先感謝!
P.S .:這是我現在擁有的。
using UnityEngine;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class productManager : MonoBehaviour {
public string ownerName = "";
public List<Transform> ingredients = new List<Transform>();
//public int count = (from Object in List<Transform> ingredients where Object.Tags.Contains("clean") select Object).Count<Transform>();
void Start(){
ownerName = transform.name;
name = ownerName + "'s ingredients";
}
void Update(){
int count = (from Object in List<Transform> where Object.Tags.Contains("clean") select Object).Count<Transform>();
}
}
完全可能的,也是非常容易的。建議在網上進行搜索,看看你能想出什麼,然後問一個具體的問題。你會更好地學習這種方式。 – CSharpened 2012-02-13 10:08:32
我已經嘗試過,但在這個問題上找到一個簡單的答案並不那麼容易。至少對我來說:S。 – Amacoder 2012-02-13 10:15:31