Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.78 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Tags in list c#
  2. using UnityEngine;
  3. using System.Linq;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6.  
  7.  
  8. public class productManager : MonoBehaviour {
  9.  
  10.     public string ownerName = "";
  11.     public List<Transform> ingredients = new List<Transform>();
  12.     //public int count = (from Object in List<Transform> ingredients where Object.Tags.Contains("clean") select Object).Count<Transform>();
  13.  
  14.     void Start(){
  15.         ownerName = transform.name;
  16.         name = ownerName + "'s ingredients";
  17.     }
  18.  
  19.     void Update(){
  20.         int count = (from Object in List<Transform> where Object.Tags.Contains("clean") select Object).Count<Transform>();
  21.     }
  22. }
  23.        
  24. var itemsWithCleanTag = myList.Where(item => item.Tag == "clean");
  25.  
  26. foreach(var item in itemsWithCleanTag)
  27. {
  28.     item.Raise(5);
  29. }