300 lines
9.0 KiB
C#
300 lines
9.0 KiB
C#
#if USE_UNI_LUA
|
|
using LuaAPI = UniLua.Lua;
|
|
using RealStatePtr = UniLua.ILuaState;
|
|
using LuaCSFunction = UniLua.CSharpFunctionDelegate;
|
|
#else
|
|
using LuaAPI = XLua.LuaDLL.Lua;
|
|
using RealStatePtr = System.IntPtr;
|
|
using LuaCSFunction = XLua.LuaDLL.lua_CSFunction;
|
|
#endif
|
|
|
|
using XLua;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
namespace XLua.CSObjectWrap
|
|
{
|
|
using Utils = XLua.Utils;
|
|
public class BFAssetObjectWrap
|
|
{
|
|
public static void __Register(RealStatePtr L)
|
|
{
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
System.Type type = typeof(BF.AssetObject);
|
|
Utils.BeginObjectRegister(type, L, translator, 0, 7, 0, 0);
|
|
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadComplete", _m_LoadComplete);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadAsync", _m_LoadAsync);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "LoadSync", _m_LoadSync);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "Unload", _m_Unload);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "UnloadAsset", _m_UnloadAsset);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "StartLoadAsset", _m_StartLoadAsset);
|
|
Utils.RegisterFunc(L, Utils.METHOD_IDX, "AssetDataBaseLoadEnd", _m_AssetDataBaseLoadEnd);
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndObjectRegister(type, L, translator, null, null,
|
|
null, null, null);
|
|
|
|
Utils.BeginClassRegister(type, L, __CreateInstance, 1, 0, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Utils.EndClassRegister(type, L, translator);
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int __CreateInstance(RealStatePtr L)
|
|
{
|
|
|
|
try {
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
if(LuaAPI.lua_gettop(L) == 4 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable<System.Type>(L, 3) && LuaTypes.LUA_TBOOLEAN == LuaAPI.lua_type(L, 4))
|
|
{
|
|
string _assetPath = LuaAPI.lua_tostring(L, 2);
|
|
System.Type _type = (System.Type)translator.GetObject(L, 3, typeof(System.Type));
|
|
bool _needSync = LuaAPI.lua_toboolean(L, 4);
|
|
|
|
var gen_ret = new BF.AssetObject(_assetPath, _type, _needSync);
|
|
translator.Push(L, gen_ret);
|
|
|
|
return 1;
|
|
}
|
|
if(LuaAPI.lua_gettop(L) == 3 && (LuaAPI.lua_isnil(L, 2) || LuaAPI.lua_type(L, 2) == LuaTypes.LUA_TSTRING) && translator.Assignable<System.Type>(L, 3))
|
|
{
|
|
string _assetPath = LuaAPI.lua_tostring(L, 2);
|
|
System.Type _type = (System.Type)translator.GetObject(L, 3, typeof(System.Type));
|
|
|
|
var gen_ret = new BF.AssetObject(_assetPath, _type);
|
|
translator.Push(L, 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 BF.AssetObject constructor!");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_LoadComplete(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
UnityEngine.Object _asset = (UnityEngine.Object)translator.GetObject(L, 2, typeof(UnityEngine.Object));
|
|
|
|
gen_to_be_invoked.LoadComplete( _asset );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_LoadAsync(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
System.Action<string, UnityEngine.Object> _callback = translator.GetDelegate<System.Action<string, UnityEngine.Object>>(L, 2);
|
|
|
|
gen_to_be_invoked.LoadAsync( _callback );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_LoadSync(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.LoadSync( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_Unload(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
bool _immediately = LuaAPI.lua_toboolean(L, 2);
|
|
|
|
var gen_ret = gen_to_be_invoked.Unload( _immediately );
|
|
LuaAPI.lua_pushboolean(L, gen_ret);
|
|
|
|
|
|
|
|
return 1;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_UnloadAsset(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
|
|
gen_to_be_invoked.UnloadAsset( );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_StartLoadAsset(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
UnityEngine.AssetBundle _ab = (UnityEngine.AssetBundle)translator.GetObject(L, 2, typeof(UnityEngine.AssetBundle));
|
|
|
|
gen_to_be_invoked.StartLoadAsset( _ab );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
[MonoPInvokeCallbackAttribute(typeof(LuaCSFunction))]
|
|
static int _m_AssetDataBaseLoadEnd(RealStatePtr L)
|
|
{
|
|
try {
|
|
|
|
ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);
|
|
|
|
|
|
BF.AssetObject gen_to_be_invoked = (BF.AssetObject)translator.FastGetCSObj(L, 1);
|
|
|
|
|
|
|
|
{
|
|
UnityEngine.Object _obj = (UnityEngine.Object)translator.GetObject(L, 2, typeof(UnityEngine.Object));
|
|
|
|
gen_to_be_invoked.AssetDataBaseLoadEnd( _obj );
|
|
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
} catch(System.Exception gen_e) {
|
|
return LuaAPI.luaL_error(L, "c# exception:" + gen_e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|