回覆列表
  • 1 # CoreCode

    之前在網上看到有人在找unity使用ulua開發只需要例項化一個LuaState嗎。看到以後我也很好奇,所以也搜了一下,想要知道這個答案,首先先看一下ulua的一些案例,我們就知道答案了。

    1、HelloWorldusing LuaInterface;public class HelloWorld : MonoBehaviour {void Start () {LuaState l = new LuaState();// 在C#下使用Lual.DoString("print("hello world 世界")");}}

    2、CreateGameObject using LuaInterface;public class CreateGameObject : MonoBehaviour {//Lua指令碼 Lua下使用c#private string script = @"luanet.load_assembly("UnityEngine") //首先需要載入一個assembly包含指定型別GameObject = luanet.import_type("UnityEngine.GameObject")//來獲得指定型別引用//使用引用local newGameObj = GameObject("NewObj")newGameObj:AddComponent("ParticleSystem")";// 在C#下使用Luavoid Start () {LuaState l = new LuaState();l.DoString(script); //執行Lua指令碼}}

  • 中秋節和大豐收的關聯?
  • 上句:一曲秋風醉,下句怎麼對?