Esempio n. 1
0
 static int Destroy(IntPtr L)
 {
     try
     {
         UnityEngine.Object self = LuaExtend.GetObject(L, 1) as UnityEngine.Object;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         System.Double param1 = default(System.Double);
         param1 = (System.Double)LuaDLL.lua_tonumber(L, 2);
         if (self != null)
         {
             UnityEngine.Object.Destroy(
                 (UnityEngine.Object)self,
                 (System.Single)param1
                 );
         }
         IntPtr idptr = LuaDLL.lua_touserdata(L, 1);
         LuaExtend.RemoveObject(L, idptr);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 2
0
 static int AddComponent(IntPtr L)
 {
     try
     {
         UnityEngine.GameObject self = LuaExtend.GetObject(L, 1) as UnityEngine.GameObject;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         string component             = LuaDLL.lua_tostring(L, 2);
         ComponentMethodDelegate func = null;
         if (typesAdd.TryGetValue(component, out func))
         {
             UnityEngine.Component com = func(self);
             LuaExtend.AddObject2Lua(L, com, null);
         }
         else
         {
             throw new LuaException(L, "Component is not registed:" + component);
         }
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 3
0
        public static int removeObjectFromCache(IntPtr L)
        {
            IntPtr idptr = LuaDLL.lua_touserdata(L, 1);

            LuaExtend.RemoveObject(L, idptr);
            return(0);
        }
Esempio n. 4
0
        public static void Init()
        {
            luaState = new LuaState(LuaNameSpace);
            L        = luaState.L;
            LuaStateCacheMan.AddLuaStateCache(L);

            printFunction = new LuaCSFunction(LuaFuncs.print);
            LuaDLL.wlua_pushcfunction(L, printFunction);
            LuaDLL.wlua_setglobal(L, "print");

            Lua_Register.Register(L, LuaNameSpace);
            LuaExtend.SetSearcher(L, loader);
        }
Esempio n. 5
0
 static int CreatePrimitive(IntPtr L)
 {
     try
     {
         PrimitiveType type = (PrimitiveType)LuaDLL.lua_tointeger(L, 1);
         GameObject    go   = UnityEngine.GameObject.CreatePrimitive(type);
         LuaExtend.AddObject2Lua(L, go, null);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 6
0
 static int set_enabled(IntPtr L)
 {
     try
     {
         UnityEngine.Collider self = LuaExtend.GetObject(L, 1) as UnityEngine.Collider;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         self.enabled = LuaDLL.lua_toboolean(L, 2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 7
0
 static int set_tag(IntPtr L)
 {
     try
     {
         UnityEngine.GameObject self = LuaExtend.GetObject(L, 1) as UnityEngine.GameObject;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         self.tag = LuaDLL.lua_tostring(L, 2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 8
0
 static int get_activeSelf(IntPtr L)
 {
     try
     {
         UnityEngine.GameObject self = LuaExtend.GetObject(L, 1) as UnityEngine.GameObject;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         LuaDLL.lua_pushboolean(L, self.activeSelf);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 9
0
 static int GameObject(IntPtr L)
 {
     try
     {
         System.String param0 = default(System.String);
         param0 = LuaDLL.lua_tostring(L, 1);
         UnityEngine.GameObject ret = new UnityEngine.GameObject(
             param0
             );
         LuaExtend.AddObject2Lua(L, ret, null);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 10
0
 static int set_receiveShadows(IntPtr L)
 {
     try
     {
         UnityEngine.Renderer self = LuaExtend.GetObject(L, 1) as UnityEngine.Renderer;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         self.receiveShadows = LuaDLL.lua_toboolean(L, 2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 11
0
 static int get_name(IntPtr L)
 {
     try
     {
         UnityEngine.Object self = LuaExtend.GetObject(L, 1) as UnityEngine.Object;
         if (self == null)
         {
             throw new LuaException(L, "Object is null");
         }
         LuaDLL.lua_pushstring(L, self.name);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.wluaL_error(L, e));
     }
 }
Esempio n. 12
0
        public static int loader(IntPtr L)
        {
            try
            {
                int    top      = LuaDLL.lua_gettop(L);
                string fileName = String.Empty;
                fileName  = LuaDLL.lua_tostring(L, 1);
                fileName  = fileName.Replace('.', '/');
                fileName += ".lua";

                string fullPath = Path.Combine(luaPath, fileName);
                if (File.Exists(fullPath))
                {
                    byte[] fileData = StreamingAssetsHelper.ReadAllBytes(fullPath);
                    if (LuaDLL.luaL_loadbuffer(L, fileData, fileData.Length, "@" + fileName) != LuaDLL.LUA_OK)
                    {
                        UnityEngine.Debug.LogWarning("lua2:" + LuaDLL.lua_tostring(L, -1));
                        throw new LuaException(L, LuaDLL.lua_tostring(L, -1));
                    }

                    LuaDLL.lua_pushvalue(L, 1);
                    if (!LuaExtend.PCall(L, 1, LuaDLL.LUA_MULTRET))
                    {
                        throw new LuaException(L, "require failed:" + fileName);                         //avoid redundancy error msg log, because PCall has log error msg
                    }
                    return(LuaDLL.lua_gettop(L) - top);
                }
                else
                {
                    throw new LuaException(L, "file is not found:" + fileName);
                }
            }
            catch (Exception e)
            {
                return(LuaDLL.wluaL_error(L, e));
            }
        }