Beispiel #1
0
        /// <summary>
        /// 初始化上下文
        /// </summary>
        public LuaContext()
        {
            _regTypes           = new HashSet <Type> ();
            _methodHandlers     = new Dictionary <string, LuaMethodHandler> ();
            _exportsTypeManager = new LuaExportsTypeManager(this);
            _nativeObjectId     = NativeUtils.createLuaContext();
            _contexts.Add(_nativeObjectId, new WeakReference(this));

            //初始化异常消息捕获
            IntPtr fp = Marshal.GetFunctionPointerForDelegate(new LuaExceptionHandleDelegate(luaException));

            NativeUtils.setExceptionHandler(_nativeObjectId, fp);

                        #if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaObject luaCacheDir = getLuaCacheDir();
            if (!luaCacheDir.Call <bool> ("exists", new object[0]))
            {
                luaCacheDir.Call <bool> ("mkdirs", new object[0]);
            }

            addSearchPath(luaCacheDir.Call <string> ("toString", new object[0]));
                        #else
            //增加搜索路径
            addSearchPath(Application.streamingAssetsPath);
                        #endif
        }
Beispiel #2
0
        /// <summary>
        /// 创建LuaContext
        /// </summary>
        public LuaContext()
        {
            _methodHandlers = new Dictionary <string, LuaMethodHandler> ();
            _nativeObjectId = NativeUtils.createLuaContext();
            _contexts.Add(_nativeObjectId, new WeakReference(this));

                        #if UNITY_ANDROID && !UNITY_EDITOR
            AndroidJavaObject luaCacheDir = getLuaCacheDir();
            if (!luaCacheDir.Call <bool> ("exists", new object[0]))
            {
                luaCacheDir.Call <bool> ("mkdirs", new object[0]);
            }

            addSearchPath(luaCacheDir.Call <string> ("toString", new object[0]));
                        #else
            //增加搜索路径
            addSearchPath(Application.streamingAssetsPath);
                        #endif
        }