public void LoadAsyncInstance(string name, GameObject parent, Action <UnityEngine.Object> load, Action <float> progress, int type = ResourceType.RES_UI, bool unloadObject = false, bool isPermanent = false) { LoadResourceAsync(name, (_obj) => { if (_obj == null) { Debug.LogError("resource load prefab object is null! name:" + name); return; } GameObject ret = MonoExtendUtil.CreateChild(parent, _obj as GameObject); if (ret == null) { Debug.LogError("Instantiate object is null!"); load(null); return; } UnloadResource(name, unloadObject); if (load != null) { load(ret); } } , progress, type, isPermanent); }
/// <summary> /// 同步加载核心接口方法 /// </summary> /// <param name="name"></param> /// <param name="parent"></param> /// <param name="type"></param> /// <returns></returns> public UnityEngine.Object LoadInstance(string name, GameObject parent, int type = ResourceType.RES_UI, bool unloadObject = false, bool isPermanent = false) { UnityEngine.Object prefabObj = LoadResource(name, type, isPermanent); GameObject ret = MonoExtendUtil.CreateChild(parent, prefabObj as GameObject); StartCoroutine(UnloadResourceCoroutine(name, unloadObject)); return(ret); }
static int CreateChild(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject)); UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.CheckObject(L, 2, typeof(UnityEngine.GameObject)); UnityEngine.GameObject o = MonoExtendUtil.CreateChild(arg0, arg1); ToLua.PushSealed(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }