/// <summary> /// 将指定值装入ValueObject /// </summary> /// <typeparam name="T">值类型</typeparam> /// <param name="value">要装入的值</param> /// <returns></returns> static public ValueObject Get <T>(T value) { #if UNITY_EDITOR if (!typeof(T).IsValueType) { throw new InvalidOperationException( string.Format("Only value type supported! type = <{0}>", typeof(T))); } #endif // 装箱 TypeObj <T> typeObj = ObjPool <TypeObj <T> > .Get(); typeObj.value = value; ValueObject betterObj = null; lock (mValueObjPool) { #if UNITY_EDITOR detecter.IncreseInstance(); #endif betterObj = mValueObjPool.Count > 0 ? mValueObjPool.Dequeue() : new ValueObject(); } betterObj.mObjType = typeof(T); betterObj.mTypeObj = typeObj; betterObj.mTypeObjHolder = ObjPool <TypeObj <T> > .instance; return(betterObj); }
static public BetterLinkedListNode <T> Get() { BetterLinkedListNode <T> node = ObjPool <BetterLinkedListNode <T> > .Get(); if (node != null) { node.List = default(BetterLinkedList <T>); node.Value = default(T); } return(node); }