IEnumerator LoadDropEffect(string path, Vector3 dropPosition) { SGameEngine.PrefabResource prefab = new SGameEngine.PrefabResource(); yield return(SGameEngine.ResourceLoader.Instance.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab(path, prefab))); if (prefab != null && prefab.obj_ != null) { GameObject dropEffectGameObject = prefab.obj_; Actor localPlayer = Game.GetInstance().GetLocalPlayer(); if (localPlayer != null) { dropEffectGameObject.transform.parent = null; dropEffectGameObject.transform.localScale = Vector3.one; dropEffectGameObject.transform.localPosition = dropPosition; dropEffectGameObject.transform.localRotation = Quaternion.identity; TrackAnimationComponent com = dropEffectGameObject.AddComponent <TrackAnimationComponent>(); com.TargetTran = localPlayer.ActorTrans; com.TargetOffset = new Vector3(0f, 0.5f * localPlayer.Height, 0f); } else { GameObject.DestroyImmediate(dropEffectGameObject); } } }
/// <summary> /// 加载资源并进行实例化 /// </summary> /// <returns></returns> IEnumerator InitLoad() { // 加载UICommonTips的资源 SGameEngine.PrefabResource pr = new SGameEngine.PrefabResource(); yield return(ui.ugui.UIManager.Instance.MainCtrl.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab("Assets/Res/UI/Widget/Preset/UICommonTips.prefab", pr, false))); GameObject go = pr.obj_ as GameObject; GameObject.DontDestroyOnLoad(go); // 设置父节点 go.transform.SetParent(UIMainCtrl.MainCam.transform); var canvas = go.GetComponent <Canvas>(); if (canvas != null) { canvas.worldCamera = UIMainCtrl.MainCam; canvas.planeDistance = 0; canvas.sortingOrder = 10000 - 1; } // 实例化多个Tips的gameobject Transform tips_trans = go.transform.Find("TipsParent"); Transform tips_parent_trans = tips_trans.parent; GameObject tips_game_object = tips_trans.gameObject; tips_game_object.SetActive(false); for (int i = 0; i < mTipsObjCount; i++) { GameObject parentObj = GameObject.Instantiate(tips_game_object) as GameObject; GameObject obj = parentObj.transform.Find("Tips").gameObject; GameObject.DontDestroyOnLoad(parentObj); parentObj.name = "TipsParent"; obj.name = "Tips"; parentObj.transform.SetParent(tips_parent_trans); parentObj.transform.localPosition = Vector3.one; parentObj.transform.localScale = Vector3.one; Transform localTrans = obj.transform; RectTransform rect = localTrans.GetComponent <RectTransform>(); rect.sizeDelta = new Vector2(60, mTipsHeight); rect.anchoredPosition = Vector3.zero; UICommonTips commonTips = localTrans.gameObject.AddComponent <UICommonTips>(); InitCallBack(commonTips); commonTips.Check(); obj.SetActive(false); mDisplayTips.Add(commonTips); } mIsLoad = true; }
static int _m_load_prefab(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); SGameEngine.ResourceLoader __cl_gen_to_be_invoked = (SGameEngine.ResourceLoader)translator.FastGetCSObj(L, 1); int __gen_param_count = LuaAPI.lua_gettop(L); try { if (__gen_param_count == 6 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <SGameEngine.PrefabResource>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5) && translator.Assignable <UnityEngine.Transform>(L, 6)) { string _asset_path = LuaAPI.lua_tostring(L, 2); SGameEngine.PrefabResource _result = (SGameEngine.PrefabResource)translator.GetObject(L, 3, typeof(SGameEngine.PrefabResource)); bool _dont_destroy_on_load = LuaAPI.lua_toboolean(L, 4); bool _cache_global_bundle = LuaAPI.lua_toboolean(L, 5); UnityEngine.Transform parent = (UnityEngine.Transform)translator.GetObject(L, 6, typeof(UnityEngine.Transform)); System.Collections.IEnumerator __cl_gen_ret = __cl_gen_to_be_invoked.load_prefab(_asset_path, _result, _dont_destroy_on_load, _cache_global_bundle, parent); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 5 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <SGameEngine.PrefabResource>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 5)) { string _asset_path = LuaAPI.lua_tostring(L, 2); SGameEngine.PrefabResource _result = (SGameEngine.PrefabResource)translator.GetObject(L, 3, typeof(SGameEngine.PrefabResource)); bool _dont_destroy_on_load = LuaAPI.lua_toboolean(L, 4); bool _cache_global_bundle = LuaAPI.lua_toboolean(L, 5); System.Collections.IEnumerator __cl_gen_ret = __cl_gen_to_be_invoked.load_prefab(_asset_path, _result, _dont_destroy_on_load, _cache_global_bundle); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <SGameEngine.PrefabResource>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4)) { string _asset_path = LuaAPI.lua_tostring(L, 2); SGameEngine.PrefabResource _result = (SGameEngine.PrefabResource)translator.GetObject(L, 3, typeof(SGameEngine.PrefabResource)); bool _dont_destroy_on_load = LuaAPI.lua_toboolean(L, 4); System.Collections.IEnumerator __cl_gen_ret = __cl_gen_to_be_invoked.load_prefab(_asset_path, _result, _dont_destroy_on_load); translator.Push(L, __cl_gen_ret); return(1); } if (__gen_param_count == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable <SGameEngine.PrefabResource>(L, 3)) { string _asset_path = LuaAPI.lua_tostring(L, 2); SGameEngine.PrefabResource _result = (SGameEngine.PrefabResource)translator.GetObject(L, 3, typeof(SGameEngine.PrefabResource)); System.Collections.IEnumerator __cl_gen_ret = __cl_gen_to_be_invoked.load_prefab(_asset_path, _result); translator.Push(L, __cl_gen_ret); return(1); } } catch (System.Exception __gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e)); } return(LuaAPI.luaL_error(L, "invalid arguments to SGameEngine.ResourceLoader.load_prefab!")); }