IEnumerator UF_IAsyncLoadObjectImage(string name, DelegateObject callback) { Object target = null; int timestamp = GTime.EnvTick; yield return(null); #if __EDITOR_MODE__ target = UF_LoadObjectImageFromDatabase(name); #else AssetBundleData abd = UF_LoadAssetBundleData(name, LoadAssetBundleOptions.UNLOAD_IN_NO_REF); if (abd != null) { AssetBundleRequest request = abd.UF_LoadAssetAsync <Object> (name); yield return(request); target = request.asset; } #endif if (callback != null) { callback(target); } Debugger.UF_TrackRes(name, Mathf.Abs(GTime.EnvTick - timestamp)); }
public int UF_LoadTextureAsync(string textureName, DelegateTexture callback) { var tex = RefObjectManager.UF_GetInstance().UF_GetRefObject <Texture2D>(textureName, false) as Texture2D; if (tex != null) { if (callback != null) { callback(tex); } } else { DelegateObject _loadfinish = delegate(UnityEngine.Object image) { Texture2D texture = image as Texture2D; if (texture != null) { RefObjectManager.UF_GetInstance().UF_RetainRef(texture); } if (callback != null) { callback(texture); } }; return(AssetSystem.UF_GetInstance().UF_AsyncLoadObjectImage(textureName, _loadfinish)); } return(0); }
/// <summary> /// 异步创建实体 /// </summary> public int UF_AsyncCreate(string name, DelegateObject callback) { IEntityHnadle val = m_PoolEntitys.UF_Pop(name); if (val != null) { UF_ActiveEntity(val); if (callback != null) { callback(val as Object); } return(0); } //异步加载 return(AssetSystem.UF_GetInstance().UF_AsyncLoadObject(name, (param) => { if (param == null) { Debugger.UF_Error(string.Format("Create Entity[{0}] Failed,Entity Asset Not Exist!", name)); if (callback != null) { callback(null); } return; } GameObject entityGo = param as GameObject; if (entityGo == null) { Debugger.UF_Error(string.Format("Create Entity[{0}] Failed,Asset Entity Is Not GameObject Type!", name)); if (callback != null) { callback(null); } return; } IEntityHnadle entity = entityGo.GetComponent <IEntityHnadle>(); if (entity == null) { Debugger.UF_Error(string.Format("Create Entity[{0}] Failed,GameObject Count Not Find IEntityHnadle Component!", name)); if (callback != null) { callback(null); } return; } if (entity is IOnAwake) { (entity as IOnAwake).UF_OnAwake(); } UF_ActiveEntity(entity); if (callback != null) { callback(entity as Object); } } )); }
public static void UF_SafeCallDelegate(DelegateObject method, UnityEngine.Object param) { try{ if (method != null) { method(param); } } catch (System.Exception e) { Debugger.UF_Exception(e); } }
public void multiDelegateRegisterTest() { DelegateObject obj = new DelegateObject(); int i = 0; obj.func += onFunc; obj.func += onFunc; bool onFunc() { i++; Debug.Log(i); return(true); } obj.invoke(); Assert.AreEqual(1, i); }
public int UF_AsyncLoadObject(string name, DelegateObject callback) { DelegateObject finished = delegate(Object image) { Object ret = null; if (image != null) { ret = Object.Instantiate(image); UF_RetainRef(name); ret.name = image.name; } if (callback != null) { callback(ret); } }; return(UF_AsyncLoadObjectImage(name, finished)); }
/// <summary> /// 异步显示界面,加入到指定Canvas中 /// </summary> public int UF_ShowView(string canvas, string viewName, DelegateObject callback) { UIView value = UF_GetView(viewName); if (value != null) { UF_AddView(canvas, value); return(0); } else { if (m_MarkViewInLoad.Contains(viewName)) { Debugger.UF_Error(string.Format("View[{0}] is in Loading,can not load twince!", viewName)); return(0); } else { m_MarkViewInLoad.Add(viewName); } return(CEntitySystem.UF_GetInstance().UF_AsyncCreate(viewName, (e) => { m_MarkViewInLoad.Remove(viewName); UIView view = e as UIView; if (view != null) { UF_AddView(canvas, view); } else { Debugger.UF_Error(string.Format("ASync Show View {0}] Failed !", viewName)); } if (callback != null) { callback(view); } } )); } }
public void funcDelegateTest() { DelegateObject obj = new DelegateObject(); obj.func += () => { Debug.Log("1=>true"); return(true); }; obj.func += () => { Debug.Log("2=>false"); return(false); }; //obj.func += () => //{ // Debug.Log("3=>true"); // return true; //}; Assert.False(obj.invoke()); }
private void UF_AsyncShow(string contentName, DelegateObject callback) { if (m_IsLoadProcess) { Debugger.UF_Error(string.Format("UIContent AsyncShow Failed! Content[{0}] is in loading!", contentName)); return; } m_IsLoadProcess = true; try { CEntitySystem.UF_GetInstance().UF_AsyncCreate(contentName, (entity) => { m_IsLoadProcess = false; if (entity != null) { if (m_IsClosed) { (entity as IEntityHnadle).isReleased = true; return; } else { UF_AddToContent(entity as UIView); GHelper.UF_SafeCallDelegate(callback, this); MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_UI_SHOW, this); } } } ); } catch (System.Exception e) { Debugger.UF_Error("UIContent AstncShow Exception:"); Debugger.UF_Exception(e); } }
public void UF_Show(string contentName, DelegateObject callback) { if (string.IsNullOrEmpty(contentName)) { Debugger.UF_Warn(string.Format("UIContent AsyncShow Failed! contentName is Null")); return; } if (m_Content != null && m_Content.name == contentName) { m_IsClosed = false; m_Content.UF_SetActive(true); GHelper.UF_SafeCallDelegate(callback, m_Content); MessageSystem.UF_GetInstance().UF_Send(DefineEvent.E_UI_SHOW, m_Content); return; } if (m_Content != null && m_Content.name != contentName) { this.UF_Close(); } UF_AsyncShow(contentName, callback); }
private extern static void Register(DelegateClass d_class, DelegateNew d_new, DelegateBang d_bang, DelegateFloat d_float, DelegateSymbol d_symbol, DelegatePointer d_pointer, DelegateList d_list, DelegateAnything d_anything, DelegateObject d_object);
public int UF_AsyncLoadObjectImage(string name, DelegateObject callback) { return(FrameHandle.UF_AddCoroutine(UF_IAsyncLoadObjectImage(name, callback))); }