DoFile() public method

public DoFile ( string fileName ) : object[]
fileName string
return object[]
Exemplo n.º 1
0
    // UniLua.ILuaState uniLua = LuaAPI.NewState();
    // NLua.Lua nlua = new NLua.Lua();

    // Use this for initialization
    void Start()
    {
        // GameObject labelas = GameObject.Find ("Label1");
        GameObject label1 = this.transform.FindChild("Label1").gameObject;

        label1.AddComponent <TestClick>();

        UIEventListener com = this.transform.FindChild("Label4").GetComponent <UIEventListener> ();

        com.onClick = OnClick;

        uLua.RegisterLuaDelegateType(typeof(UIEventListener.VoidDelegate), typeof(LuaEventArgsHandler));


        object[] aa = uLua.DoFile("TestLua");

        LuaInterface.LuaFunction fun = uLua.GetFunction("TB.TB1.Start");
        uLua.callFunction(fun, new object[] { this.gameObject });

        // uniLua.L_OpenLibs();

        // var status = uniLua.L_DoFile("TestUniLua.lua");
        // if( status != ThreadStatus.LUA_OK )
        // {
        //  Debug.Log(uniLua.ToString(-1));
        // }


        // TextAsset file = Resources.Load<TextAsset>("TestNLua");
        // object[] aa1 = nlua.DoString(file.text, "TestNLua");
        // NLua.LuaFunction fun1 = nlua.GetFunction ("TB.TB1.Start");
        // nlua.CallFunction (fun1, new object[]{this.gameObject});
    }
Exemplo n.º 2
0
		//初始化
		private void init()
		{
//			if (mLuaState != null) {
//				mLuaState.Dispose ();
//			}
			#if UNITY_EDITOR
				LuaFileUtils.Instance.beZip = UseAssetBundleLuaInEditor;
			#else
				LuaFileUtils.Instance.beZip = true;
			#endif
			mLuaState = new LuaState();
			mLuaState.LogGC = false;
			mLuaState.Start();
			LuaBinder.Bind(mLuaState);
			mLuaState.DoFile(LuaFileUtils.Instance.beZip?LuaEnterFile:LuaEnterDebugFile);

			//协程
			luaCoroutine = GameObject.Find ("LuaCoroutine");
			if (luaCoroutine == null) {
				luaCoroutine = new GameObject ();
				luaCoroutine.gameObject.name = "LuaCoroutine";
				luaCoroutine.AddComponent<LuaCoroutineComponent> ();
				UnityEngine.Object.DontDestroyOnLoad(luaCoroutine);
			}
			LuaCoroutine.Register(mLuaState, luaCoroutine.GetComponent<LuaCoroutineComponent>());

			addFunc(FuncName.createLuaFile);

		}
Exemplo n.º 3
0
 // Use this for initialization
 void Start()
 {
     //只是展示如何加载文件。不是推荐这么做
     LuaState l = new LuaState();
     string path = Application.dataPath + "/uLua/Example/04_ScriptsFromFile/ScriptsFromFile02.lua";        
     l.DoFile(path);
 }
Exemplo n.º 4
0
	void Start () 
    {        
        Application.RegisterLogCallback(ShowTips);           
        new LuaResLoader();          
        state = new LuaState();
        state.Start();
        LuaBinder.Bind(state);                       
        state.DoFile("Test.lua");        
        state.LuaGC(LuaGCOptions.LUA_GCCOLLECT);      
	}
Exemplo n.º 5
0
	void Start () 
    {        
        LuaState lua = new LuaState();
        lua.Start();        
        
        string fullPath = Application.dataPath + "/ToLua/Examples/02_ScriptsFromFile";
        lua.AddSearchPath(fullPath);         
        lua.DoFile("ScriptsFromFile.lua");        
        //lua.DoString("require 'ScriptsFromFile'");                             
        //lua.Require("ScriptsFromFile");                

        lua.Dispose();
	}
Exemplo n.º 6
0
	void Start () 
    {        
        Application.RegisterLogCallback(Logger);
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();

        state.DoFile("TestLoader.lua");

        LuaFunction func = state.GetFunction("Test");        
        func.Call();
        Application.RegisterLogCallback(null);
        func.Dispose();
        state.Dispose();
	}
Exemplo n.º 7
0
	void Start () 
    {        
#if UNITY_5		
		Application.logMessageReceived += ShowTips;
#else
        Application.RegisterLogCallback(ShowTips);
#endif         
        new LuaResLoader();          
        state = new LuaState();
        state.Start();
        LuaBinder.Bind(state);                       
        state.DoFile("Test.lua");        
        state.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
        state.LogGC = true;        
	}
Exemplo n.º 8
0
    public static void Init(string mainScript)
    {
        if (string.IsNullOrEmpty(mainScript))
            throw new System.NullReferenceException("Can't found the main script.");

        State = new LuaState();

        // 增加搜索路径
        for (int i = 0; i < globalSearchPaths.Count; ++i)
            State.AddSearchPath(globalSearchPaths[i]);

        State.OpenLibs(LuaDLL.luaopen_pb);
        LuaBinder.Bind(State);
        State.Start();
        State.DoFile(mainScript);
    }
Exemplo n.º 9
0
	void Start () 
    {
        if (IntPtr.Size == 8) Debugger.Log("64 go");
        Application.RegisterLogCallback(ShowTips);           
        new LuaResLoader();          
        state = new LuaState();
        state.Start();
        LuaBinder.Bind(state);                       
        state.DoFile("Test.lua");        
        state.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
        state.LogGC = true;        

        state.LuaRawGlobal("xxoo");
        string error = null;
        int n = state.CheckInteger(-1, out error);
        Debugger.Log("xxoo {0}", n);
	}
Exemplo n.º 10
0
	void Start () 
    {
#if UNITY_5
        Application.logMessageReceived += Logger;
#else
        Application.RegisterLogCallback(Logger);
#endif    
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();

        state.DoFile("TestLoader.lua");

        LuaFunction func = state.GetFunction("Test");        
        func.Call();        
        func.Dispose();
        state.Dispose();
#if UNITY_5
        Application.logMessageReceived -= Logger;
#else
        Application.RegisterLogCallback(null);
#endif    
	}
Exemplo n.º 11
0
 void OnBundleLoad()
 {
     LuaState state = new LuaState();
     state.Start();
     state.DoString("print('hello tolua#:'..tostring(Vector3.zero))");
     state.DoFile("Main.lua");
     LuaFunction func = state.GetFunction("Main");
     func.Call();
     func.Dispose();
     state.Dispose();
     state = null;
 }
Exemplo n.º 12
0
    void Start()
    {
        #if UNITY_5
        Application.logMessageReceived += ShowTips;
        #else
        Application.RegisterLogCallback(ShowTips);
        #endif
        new LuaResLoader();
        state = new LuaState();
        state.Start();
        LuaBinder.Bind(state);
        state.DoFile("TestPerf.lua");
        state.LuaGC(LuaGCOptions.LUA_GCCOLLECT);
        state.LogGC = false;

        Debug.Log(typeof(List<int>).BaseType);
    }