Esempio n. 1
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     luacache = new Dictionary <string, TextAsset>();
     lua      = new Lua();
     LoadScript();
 }
Esempio n. 2
0
 void OnDestroy()
 {
     if (onDestroyFn != null)
     {
         onDestroyFn.call();
     }
     updateFn = null;
     if (lua != null)
     {
         lua.luaState.Close();
     }
     lua       = null;
     _instance = null;
     if (net != null)
     {
         net.Dispose();
     }
     net = null;
     if (ChatNet != null)
     {
         ChatNet.Dispose();
     }
     ChatNet = null;
     luacache.Clear();
 }
Esempio n. 3
0
	void Start()
	{
		l = new LuaSvr();
		l.init(null, () =>{
			LuaTests t = new LuaTests();
			t.lua = l.luaState;
			t.lua.doString ("TestClass=NLuaTest.Mock.TestClass");

			MethodInfo[] methods = t.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);

			int pass = 0;
			int failed = 0;

			int i = 0;
			foreach(MethodInfo m in methods)
			{
				++i;
				try{
					Debug.Log("start test: " + m.Name);
					m.Invoke(t, null);
					++pass;
				}catch(Exception e)
				{
					++failed;
					Debug.LogError("[" + i + "] test failed: " + m.Name + ", e: "  + e);
				}
			}
			Debug.Log("test done. pass: "******", failed: " + failed);
		});
	}
Esempio n. 4
0
	// Use this for initialization
	void Start () {
        l = new LuaSvr();
		l.init(null, () =>
		{
			l.start("valuetype");
		});
	}
Esempio n. 5
0
	// Use this for initialization
	void Start()
	{
		l = new LuaSvr();
		l.init(null,()=>{
			l.start("delegate");
		});
	}
Esempio n. 6
0
        public LuaSvr()
        {
            LuaState luaState = new LuaState();

            this.luaState = luaState;
            main          = this;
        }
Esempio n. 7
0
    void Start()
    {
        lua = new LuaSvr();
        self = (LuaTable)lua.start("LuaFiles/building_txt");
        //self = (LuaTable)lua.luaState.getObject("data");
        //object o = lua.luaState.getFunction("GetData").call();
        Debug.Log("table " + ((LuaTable)self[1])["name"]);

        LuaFunction dataFunction = ((LuaFunction)self["GetData"]);
        LuaTable dataTable = (LuaTable)dataFunction.call();
        LuaFunction callFunction = (LuaFunction)self["CallBack"];
        callFunction.call(222);
        //lua.luaState.getFunction("CallBack").call();
        lua.luaState.getFunction("Call").call(2);
        Debug.Log("table " + ((LuaTable)dataTable[1])["use_money"] + "   is Null " + (callFunction == null));

        LuaTable d = (LuaTable)((LuaFunction)self["GetData1"]).call();
        Debug.Log("---------------- : " + ((LuaTable)d[1])["use_money"]);
        LuaTable table2 = (LuaTable)lua.start("LuaFiles/building_txt1");

        test2 = (LuaFunction)self["test"];
        object o = test2.call(self,9,1);
        Debug.Log("add function :"+o);

        SetTransform = (LuaFunction)self["SetTransform"];
        SetTransform.call(self, tr);
        //tr.localPosition = new Vector3(2, 2, 2);
    }
Esempio n. 8
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     luacache  = new Dictionary <string, byte[]>();
     lua       = new Lua();
     _instance = this;
     LoadScript();
 }
Esempio n. 9
0
 void Awake()
 {
     _instance = this;
     svr = new LuaSvr();
     self = (LuaTable)svr.start("LuaFiles/LuaCallCsAPI");
     self["event"] = DataEventSource.Instance;
     self["name"] = "API";
 }
Esempio n. 10
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     luacache = new Dictionary<string, TextAsset>();
     lua = new Lua();
     _instance = this;
     LoadScript();
 }
Esempio n. 11
0
 private LuaModule()
 {
     #if UNITY_EDITOR
     UnityEngine.Debug.Log("Consturct LuaModule...");
     #endif
     _luaSvr = new LuaSvr();
     _luaSvr.init(progress => { }, () => { });
 }
Esempio n. 12
0
	// Use this for initialization
	void Start()
	{
		l = new LuaSvr();
		l.init(null, () =>
		{
			l.start("varobj");
		});
	}
Esempio n. 13
0
 void OnDestroy()
 {
     if (onDestroyFn != null) onDestroyFn.call();
     updateFn = null;
     lua = null;
     _instance = null;
     luacache.Clear();
 }
Esempio n. 14
0
 public static void DestoryLua()
 {
     if (lua != null && lua.luaState != null)
     {
         lua.luaState.Close();
     }
     lua = null;
 }
Esempio n. 15
0
	void Start () {
		svr = new LuaSvr();
		svr.init(null, () =>
		{
			self = (LuaTable)svr.start("circle/circle");
			update = (LuaFunction)self["update"];
		});
	}
Esempio n. 16
0
 public static LuaSvr getInstance()
 {
     if (_inst == null)
     {
         _inst = new LuaSvr();
         _inst.init(null, () => { });
     }
     return(_inst);
 }
Esempio n. 17
0
	void Start()
	{
		c = this;
		l = new LuaSvr();
		l.init(null, () =>
		{
			l.start("custom");
		});
	}
Esempio n. 18
0
 void Start()
 {
     #if UNITY_5
     Application.logMessageReceived += this.log;
     #else
     Application.RegisterLogCallback(this.log);
     #endif
     _l = new LuaSvr();
     _l.init(tick, complete, LuaSvrFlag.LSF_BASIC);
 }
Esempio n. 19
0
        public void bindUnity()
        {
            if (!openedSluaLib)
            {
                openSluaLib();
            }

            LuaSvr.doBind(L);
            LuaValueType.reg(L);
        }
Esempio n. 20
0
 public void Close()
 {
     if (!inited)
     {
         return;
     }
     inited = false;
     main   = null;
     luaState.Close();
     luaState = null;
 }
Esempio n. 21
0
        public IEnumerator bindUnity(Action <int> _tick, Action complete)
        {
            if (!openedSluaLib)
            {
                openSluaLib();
            }

            yield return(LuaSvr.doBind(L, _tick, complete));

            LuaValueType.reg(L);
        }
Esempio n. 22
0
	// Use this for initialization
	void Start()
	{
#if UNITY_5
		Application.logMessageReceived += this.log;
#else
		Application.RegisterLogCallback(this.log);
#endif

		l = new LuaSvr();
		l.init(tick,complete,true);
	}
Esempio n. 23
0
 void OnDestroy()
 {
     if (onDestroyFn != null)
     {
         onDestroyFn.call();
     }
     updateFn  = null;
     lua       = null;
     _instance = null;
     luacache.Clear();
 }
Esempio n. 24
0
        /// <summary>
        /// Pre Init Lua.
        /// </summary>
        /// <param name="sconds">Sconds.</param>
        public void PreInitLua () {
#if !HUGULA_RELEASE
            Debug.LogFormat ("ManagedThreadId = {0},frame={1}", System.Threading.Thread.CurrentThread.ManagedThreadId, Time.frameCount);
#endif
            if (lua == null) lua = new Lua ();
            Debug.LogFormat ("PreInitLua {0}", lua);
            CUtils.DebugCastTime ("");
            lua.init (null, () => {
                CUtils.DebugCastTime ("Slua binded");
                isLuaInitFinished = true;
            }, LuaSvrFlag.LSF_3RDDLL);
        }
Esempio n. 25
0
    private void doInit()
    {
        luacache = new Dictionary <string, byte[]>();
        lua      = new Lua();
        Lua.mainState.loaderDelegate = Loader;

        lua.init(this.progress, () =>
        {
            LoadBundle();
            this.m_tick = null;
        }, LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB | LuaSvrFlag.LSF_3RDDLL);
    }
Esempio n. 26
0
        public LuaSvr()
        {
            if (Instance != null)
            {
                throw new Exception("LuaSvr had created");
            }

            LuaState luaState = new LuaState();

            this.luaState = luaState;
            Instance      = this;
        }
Esempio n. 27
0
 /// <summary>
 /// Pre Init Lua.
 /// </summary>
 /// <param name="sconds">Sconds.</param>
 public static void PreInitLua()
 {
     if (lua == null)
     {
         lua = new Lua();
     }
     CUtils.DebugCastTime("");
     lua.init(null, () =>
     {
         CUtils.DebugCastTime("Slua binded");
         isLuaInitFinished = true;
     }, LuaSvrFlag.LSF_3RDDLL);
 }
Esempio n. 28
0
 void OnDestroy()
 {
     RemoveAllEvents();
     if (onDestroyFn != null)
     {
         onDestroyFn.call();
     }
     updateFn = null;
     lua      = null;
     if (_instance == this)
     {
         _instance = null;
     }
 }
Esempio n. 29
0
    // Use this for initialization
    void Start()
    {
        #if UNITY_5
        Application.logMessageReceived += this.log;
        #else
        Application.RegisterLogCallback(this.log);
        #endif
        l = new LuaSvr();

        l.start("main");
        object o = l.luaState.getFunction("foo").call(1, 2, 3);
        object[] array = (object[])o;
        for (int n = 0; n < array.Length; n++)
            Debug.Log(array[n]);

        string s = (string)l.luaState.getFunction("str").call(new object[0]);
        Debug.Log(s);
    }
Esempio n. 30
0
	// Use this for initialization
	void Start()
	{
		var startMem = System.GC.GetTotalMemory (true);

		var start = Time.realtimeSinceStartup;
		l = new LuaSvr();
		l.init(null, () =>
		{
			Debug.Log ("start cost: " + (Time.realtimeSinceStartup - start));

			var endMem = System.GC.GetTotalMemory (true);
			Debug.Log ("startMem: " + startMem + ", endMem: " + endMem + ", " + "cost mem: " + (endMem - startMem));
			l.start("perf");
		});

#if UNITY_5
		Application.logMessageReceived += this.log;
#else
		Application.RegisterLogCallback(this.log);
#endif
	}
Esempio n. 31
0
	public override IEnumerator SetupAsync ()
	{
		Debug.Log ("~~~ setup Lua Service");

		yield return base.SetupAsync ();

		l = new LuaSvr();
		bool _isLoaded = false;

		LuaState.loaderDelegate = LoadLuaFile;

		l.init (null, () => {
			_isLoaded = true;	
		});

		while (!_isLoaded)
			yield return null;

		//TODO:在这里调用lua环境初始化脚本有一点问题,线上的版本assetbundle可能存在于两个地方:StreammingAssets or PersistentDataPath
		//在UpdateService执行完更新逻辑之前,任何调用可热更资源都可能造成读脏数据

		//Init lua libs
		RunString("require \"core/Init\"");

		//net msg callback
		var luaNetMgr = (LuaTable)RunString("return NetMgr");
		var func = luaNetMgr["OnReceiveMessage"] as LuaFunction;
		OnEvent<Packet>().ObserveOnMainThread().Subscribe((packet) => {
			//Debug.Log("call lua networkService:OnReceivePacket");
			func.call(luaNetMgr, packet);
		});


		Debug.Log ("Lua Service setup completed.");

	}
Esempio n. 32
0
 public static void DestoryLua()
 {
     //if (lua != null && lua.MainState != null) nulllua.MainState.d;
     lua = null;
 }
Esempio n. 33
0
 // Use this for initialization
 void Start()
 {
     SLua.LuaState.loaderDelegate = Loader;
     lua = new SLua.LuaSvr();
     lua.init(tick,complete,true);
 }
Esempio n. 34
0
 public StaticDataLua()
 {
     lua = new LuaSvr();
 }
Esempio n. 35
0
 void OnDestroy()
 {
     if (onDestroyFn != null) onDestroyFn.call();
     updateFn = null;
     if (lua != null) lua.luaState.Close();
     lua = null;
     _instance = null;
     if(net!=null)net.Dispose();
     net = null;
     if(ChatNet!=null)ChatNet.Dispose();
     ChatNet = null;
     luacache.Clear();
 }
Esempio n. 36
0
 void Start()
 {
     svr = new LuaSvr();
     self=(LuaTable)svr.start("circle/circle");
     //update = (LuaFunction)self["update"];
 }
Esempio n. 37
0
        public IEnumerator BindUnity(Action <int> tickAction, Action onComplete)
        {
            yield return(LuaSvr.DoBind(StatePointer, tickAction, onComplete));

            LuaValueType.Register(StatePointer);
        }
Esempio n. 38
0
 public void BindUnity()
 {
     LuaSvr.DoBind(StatePointer);
     LuaValueType.Register(StatePointer);
 }
Esempio n. 39
0
 void Start()
 {
     svr = new LuaSvr();
     self=(LuaTable)svr.start("test/test");
     //update = (LuaFunction)self["update"];
 }
Esempio n. 40
0
    void Awake()
    {
        if (null != sInstance)
            return;

        sInstance = this;

        // keep alive on change scene
        DontDestroyOnLoad(this.gameObject);

        // if exist gameobject called "UIRoot". Destory it.
        // this maybe we add to desing ui temply
        GameObject gameObjectUIRoot = GameObject.Find("UIRoot");
        if (null != gameObjectUIRoot)
            GameObject.Destroy (gameObjectUIRoot);

        GameObject uiPageMain = GameObject.Find("UIPageMain");
        if (null != uiPageMain)
            GameObject.Destroy (uiPageMain);

        mAssetsMgr = AssetsManager.GetInstance ();

        mUIMgr = UIManager.GetInstance ();

        // asset manager update path
        string updatePath = Application.persistentDataPath + "Update";
        if (!Directory.Exists(updatePath)) Directory.CreateDirectory(updatePath);
        mAssetsMgr.AddUpdatePath (updatePath);

        // ui manager
        _Load(0, () => {
            // lua
            LuaState.loaderDelegate = LuaLoadFunction;
            luaSvr_GM = new LuaSvr();
            luaSelf_GM =(LuaTable)luaSvr_GM.start("Lua/GameManager");
            luaUpdate_GM = (LuaFunction)luaSelf_GM["update"];
        });
    }
Esempio n. 41
0
 public void bindUnity()
 {
     LuaSvr.doBind(L);
     LuaValueType.reg(L);
 }
Esempio n. 42
0
	void Start()
	{
		l = new LuaSvr();
		l.init(null,()=>{l.start("lua_socket_test");});
	}
Esempio n. 43
0
 void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     lua = new Lua();
     LoadScript();
 }
Esempio n. 44
0
	void Start()
	{
		l = new LuaSvr();
		l.init(null,()=>{l.start("sqliteTest");});
	}
Esempio n. 45
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.start("delegate");
 }
Esempio n. 46
0
 void Start()
 {
     l = new LuaSvr();
     l.start("protoTest");
 }
Esempio n. 47
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.start("valuetype");
 }
Esempio n. 48
0
        public IEnumerator bindUnity(Action <int> _tick, Action complete)
        {
            yield return(LuaSvr.doBind(L, _tick, complete));

            LuaValueType.reg(L);
        }
Esempio n. 49
0
    private IEnumerator _Setup()
    {
        LuaState.loaderDelegate = LoadFile;
        _svr = new LuaSvr();
        _svr.init(delegate(int obj) {

        },delegate() {
            _isInited = true;
        },LuaSvrFlag.LSF_3RDDLL);
        while(!isInited){
            yield return null;
        }
    }
Esempio n. 50
0
 void Start()
 {
     c = this;
     l = new LuaSvr();
     l.start("custom");
 }
Esempio n. 51
0
	void Start()
	{
		l = new LuaSvr();
		l.init(null,()=>{l.start("sproto_test");});
	}