開發(fā)公司可以注冊(cè)一造嗎seo關(guān)鍵詞工具
unity出了自己的對(duì)象池 這里記錄一下用法
-
命名空間就是這個(gè)
-
一般有兩種用法,第一種是在using里面獲取,脫離這個(gè)域就釋放。第二種是在Get和Release配合使用
// This version will only be returned to the pool if we call Release on it.//只有使用Release才會(huì)釋放var simplifiedPoints = ListPool<Vector2>.Get();
//這種只要脫離了Scope就會(huì)自動(dòng)釋放// Copy the points into a temp list so we can pass them into the Simplify method// When the pooled object leaves the scope it will be Disposed and returned to the pool automatically.// This version is ideal for working with temporary lists.using (var pooledObject = ListPool<Vector2>.Get(out List<Vector2> tempList)){for (int i = 0; i < points.Length; ++i){tempList.Add(points[i]);}LineUtility.Simplify(tempList, 1.5f, simplifiedPoints);}return simplifiedPoints;
- 一般比較常用的就幾個(gè)集合類和下面這個(gè),可以對(duì)自己的類進(jìn)行一個(gè)池子回收。
using UnityEngine.Pool;public class GenericPoolExample
{class MyClass{public int someValue;public string someString;}void GetPooled(){// Get an instancevar instance = GenericPool<MyClass>.Get();// Return the instanceGenericPool<MyClass>.Release(instance);}
}
- 對(duì)于一些unity中的GameObject對(duì)象可以使用ObjectPool