public GameObject SpawnFromPoolSingle(Vector3 position, Quaternion rotation) { // if(!poolDictionary.ContainsKey(tag)){ // Debug.LogWarning("Pool with tag " + tag + " doesn't exist."); // return null; // } // PoolQueue<GameObject> poolQueue = poolDictionary[tag]; GameObject objectToSpawn; if (poolQueue.Count > 0) { objectToSpawn = (GameObject)poolQueue.Dequeue(); } else //return null; { objectToSpawn = CreateObjectBlankSingle(); } IPooledObject ObjectInterface = objectToSpawn.GetComponent <IPooledObject>(); //Get rid of GetComponent call. if (ObjectInterface != null) { ObjectInterface.OnObjectSpawn(); } objectToSpawn.transform.position = position; objectToSpawn.transform.rotation = rotation; objectToSpawn.SetActive(true); return(objectToSpawn); }
public VerifyResult ExecuteVerify(string url, string fileName, Image alarmImg) { maxAccepted.WaitOne(); //获取信号量 VerifyProcess tmpHandler = evtHandlers.Dequeue(); VerifyResult result = null; if (tmpHandler != null) { if (string.IsNullOrWhiteSpace(fileName)) { fileName = Guid.NewGuid().ToString(); } result = tmpHandler.VerifyImage(url, fileName, alarmImg); } evtHandlers.Enqueue(tmpHandler); maxAccepted.Release(); return(result); }
public GameObject SpawnFromPool(string tag, Vector3 position, Quaternion rotation) { if(!poolDictionary.ContainsKey(tag)){ Debug.LogWarning("Pool with tag " + tag + " doesn't exist."); return null; } PoolQueue<GameObject> poolQueue = poolDictionary[tag]; GameObject objectToSpawn; if(poolQueue.Count>0) objectToSpawn = (GameObject) poolQueue.Dequeue(); else //return null; objectToSpawn = CreateObjectBlank(poolQueue.poolParent); IPooledObject ObjectInterface = objectToSpawn.GetComponent<IPooledObject>(); //Get rid of GetComponent call. if(ObjectInterface != null) ObjectInterface.OnObjectSpawn(); objectToSpawn.transform.position = position; objectToSpawn.transform.rotation = rotation; objectToSpawn.SetActive(true); return objectToSpawn; }