public void CreateObjectAsync(string resName, CreateObjectCallback callback) { PackageItem pi; if (!_itemsByName.TryGetValue(resName, out pi)) { Debug.LogError("FairyGUI: resource not found - " + resName + " in " + this.name); return; } AsyncCreationHelper.CreateObject(pi, callback); }
public static void CreateObjectFromURL(string url, CreateObjectCallback callback) { PackageItem pi = GetItemByURL(url); if (pi != null) { AsyncCreationHelper.CreateObject(pi, callback); } else { Debug.LogError("FairyGUI: resource not found - " + url); } }
public static void CreateObjectAsync(string pkgName, string resName, CreateObjectCallback callback) { UIPackage pkg = GetByName(pkgName); if (pkg != null) { pkg.CreateObjectAsync(resName, callback); } else { Debug.LogError("FairyGUI: package not found - " + pkgName); } }
// 异步创建物体,实际上只是异步加载,实例化还是同步的 public void createObjectAsync(string fileWithPath, CreateObjectCallback callback, string objectTag, object userData) { // 物体如果已经有相同的,则直接返回 ObjectInfo objInfo = getUnusedObject(fileWithPath); if (objInfo != null) { objInfo.setUsing(true); onObjectLoaded(objInfo.mObject, callback, userData); } else { object[] tempUserData = new object[] { callback, objectTag, userData }; // 预设未加载,异步加载预设 mResourceManager.loadResourceAsync <GameObject>(fileWithPath, onPrefabLoaded, tempUserData, true); } }
// 异步创建物体,实际上只是异步加载,实例化还是同步的 public void createObjectAsync(string fileWithPath, CreateObjectCallback callback, int objectTag, object userData = null) { // 物体如果已经有相同的,则直接返回 ObjectInfo objInfo = getUnusedObject(fileWithPath); if (objInfo != null) { objInfo.setUsing(true); objectLoaded(objInfo.mObject, callback, userData); } else { CLASS(out PrefabLoadParam param); param.mCallback = callback; param.mTag = objectTag; param.mUserData = userData; // 预设未加载,异步加载预设 mResourceManager.loadResourceAsync <GameObject>(fileWithPath, mPrefabCallback, param); } }
private long CreateObject(string obj_type, Dictionary<string, string> properties, bool isAsync, CreateObjectCallback callback, Object state) { var parameterList = new Dictionary<string, string> { { "method", "facebook.data.createObject" } }; Utilities.AddRequiredParameter(parameterList, "obj_type", obj_type); Utilities.AddJSONAssociativeArray(parameterList, "properties", properties); if (isAsync) { SendRequestAsync<data_createObject_response, long>(parameterList, new FacebookCallCompleted<long>(callback), state); return 0; } var response = SendRequest<data_createObject_response>(parameterList); return response == null ? 0 : response.TypedValue; }
/// <summary> /// Create a new object. /// </summary> /// <example> /// <code> /// /// </code> /// </example> /// <param name="obj_type">Specifies which type of new object to create. </param> /// <param name="properties">Optional - Name-value pairs of properties this new object has. The parameters must be JSON encoded with double quoted property and value, i.e. {"name":"value"} </param> /// <param name="callback">The AsyncCallback delegate</param> /// <param name="state">An object containing state information for this asynchronous request</param> /// <returns>Numeric identifier (fbid) of newly created object. </returns> public long CreateObjectAsync(string obj_type, Dictionary<string, string> properties, CreateObjectCallback callback, Object state) { return CreateObject(obj_type, properties, true, callback, state); }
IEnumerator _CreateObjectAsync(PackageItem item, CreateObjectCallback callback) { Stats.LatestObjectCreation = 0; Stats.LatestGraphicsCreation = 0; float frameTime = UIConfig.frameTimeForAsyncUIConstruction; List<DisplayListItem> itemList = new List<DisplayListItem>(); CollectComponentChildren(item, itemList); itemList.Add(new DisplayListItem(item, null)); int cnt = itemList.Count; List<GObject> objectPool = new List<GObject>(cnt); GObject obj; DisplayListItem di; float t = Time.realtimeSinceStartup; for (int i = 0; i < cnt; i++) { di = itemList[i]; if (di.packageItem != null) { obj = UIObjectFactory.NewObject(di.packageItem); obj.packageItem = di.packageItem; objectPool.Add(obj); _constructing++; if (di.packageItem.type == PackageItemType.Component) { int poolStart = objectPool.Count - di.packageItem.displayList.Length - 1; ((GComponent)obj).ConstructFromResource(objectPool, poolStart); objectPool.RemoveRange(poolStart, di.packageItem.displayList.Length); } else { GetItemAsset(di.packageItem); obj.ConstructFromResource(); } _constructing--; } else { obj = UIObjectFactory.NewObject(di.type); objectPool.Add(obj); if (di.type == "list" && di.listItemCount > 0) { int poolStart = objectPool.Count - di.listItemCount - 1; for (int k = 0; k < di.listItemCount; k++) //把他们都放到pool里,这样GList在创建时就不需要创建对象了 ((GList)obj).itemPool.ReturnObject(objectPool[k + poolStart]); objectPool.RemoveRange(poolStart, di.listItemCount); } } if ((i % 5 == 0) && Time.realtimeSinceStartup - t >= frameTime) { yield return null; t = Time.realtimeSinceStartup; } } callback(objectPool[0]); }
void CreateObjectAsync(PackageItem item, CreateObjectCallback callback) { Timers.inst.StartCoroutine(_CreateObjectAsync(item, callback)); }
public void CreateObjectAsync(string resName, CreateObjectCallback callback) { PackageItem pi; if (!_itemsByName.TryGetValue(resName, out pi)) { Debug.LogError("FairyGUI: resource not found - " + resName + " in " + this.name); return; } CreateObjectAsync(pi, callback); }
public static void CreateObjectFromURL(string url, CreateObjectCallback callback) { PackageItem pi = GetItemByURL(url); if (pi != null) pi.owner.CreateObjectAsync(pi, callback); else Debug.LogError("FairyGUI: resource not found - " + url); }
public static void CreateObjectAsync(string pkgName, string resName, CreateObjectCallback callback) { UIPackage pkg = GetByName(pkgName); if (pkg != null) pkg.CreateObjectAsync(resName, callback); else Debug.LogError("FairyGUI: package not found - " + pkgName); }
public Character() { mAnimationLenghtList = new Dictionary <string, float>(); mModelLoadCallback = onModelLoaded; }