예제 #1
0
 public static void Recycle(GameObject go)
 {
     if (go)
     {
         go.Disable();
         GOInfo info = GetGOInfo(go.name);
         goTable[info].Enqueue(go);
     }
 }
예제 #2
0
        public static GameObject Allocate(string name)
        {
            GOInfo             info  = GetGOInfo(name);
            Queue <GameObject> queue = goTable[info];

            if (queue.Count > 0)
            {
                return(queue.Dequeue().Enable());
            }
            else
            {
                return(info.prefab.Instantiate().Name(info.prefab.name));
            }
        }
예제 #3
0
파일: VGTUpdater.cs 프로젝트: wave255/VGT
    void PublishObjects()
    {
        foreach(string tag in Tags)
        {
            //Debug.Log("Tag$ "+tag);
            GameObject[] gameObjects = GameObject.FindGameObjectsWithTag(tag);
            //Debug.Log("Game objects found");

            foreach(GameObject go in gameObjects)
            {
                try{
                    //Debug.Log("GameObject$ "+go.name);

                    //create a new game object info for each object found in group named tag
                    if(!GOMap.ContainsKey(tag+":"+go.name))
                    {
                        _currentGO = new GOInfo(tag+":"+go.name);
                        _currentGO.Group = tag;
                        _currentGO.Name = go.name;
                        _currentGO.Vars = new Dictionary<string, string>();
                        GOMap[_currentGO.Id] = _currentGO;
                    }else _currentGO = GOMap[tag+":"+go.name];
                    //populate the current game object's variables
                    GetComponents(go.GetComponentsInChildren<Component>(),"");

                    string pathVarPairs = "";
                    int countOfVarsForObj = 0;
                    foreach(KeyValuePair<string,string> Var in _currentGO.Vars)
                        if(Var.Key != "" && Var.Value != "")
                        {
                            pathVarPairs += Var.Key + "," + Var.Value + "$";
                            countOfVarsForObj++;
                        }

                    //if there are variables to update then add them to the msg being sent out
                    if(countOfVarsForObj > 0)
                        OutMsg+= "@"+_currentGO.Id + "|" + pathVarPairs.Remove(pathVarPairs.Length-1); //remove trailing $
                }catch(Exception e)
                { Debug.Log(e.ToString()); }
            }
        }

        Application.ExternalCall("UpdateGraph", OutMsg);
    }
예제 #4
0
        private static GOInfo GetGOInfo(string name)
        {
            var iter = goTable.GetEnumerator();

            while (iter.MoveNext())
            {
                GOInfo info = iter.Current.Key;
                if (info.name == name)
                {
                    return(info);
                }
            }

            // 没有就创建
            GOInfo goInfo = new GOInfo()
            {
                name = name, prefab = ResourceUtil.Load <GameObject>(name)
            };
            Queue <GameObject> queue = new Queue <GameObject>();

            goTable.Add(goInfo, queue);
            return(goInfo);
        }