Lua_ uLua_オブジェクトの作成_017


反射モードはんしゃもーど
using UnityEngine;
using System.Collections;
using LuaInterface;

/// 
///              ,     ,      wrap      ,
///               ,        ,        ,
///                C#     Lua ,              ,
///              wrap  ,    ,       ,      wrap,
///                ,     ,1%    ,        。
/// 
public class CreateGameObject01 : MonoBehaviour {

    private string script = @"
            luanet.load_assembly('UnityEngine')
            GameObject = luanet.import_type('UnityEngine.GameObject')        
            ParticleSystem = luanet.import_type('UnityEngine.ParticleSystem')         

            local newGameObj = GameObject('NewObj')
            newGameObj:AddComponent(luanet.ctype(ParticleSystem))
        ";

    //    
    void Start () {
        LuaState lua = new LuaState();
        lua.DoString(script);
    }

    // Update is called once per frame
    void Update () {

    }
}


非反射模式调用

using UnityEngine;
using System.Collections;
using LuaInterface;

public class CreateGameObject02 : MonoBehaviour {

    private string script = @"
            luanet.load_assembly('UnityEngine')
            GameObject = UnityEngine.GameObject
            ParticleSystem = UnityEngine.ParticleSystem
            local newGameObj = GameObject('NewObj')
            newGameObj:AddComponent(ParticleSystem.GetClassType())
        ";

    //     
    void Start () {
        LuaScriptMgr lua = new LuaScriptMgr();
        lua.Start();
        lua.DoString(script);
    }

    // Update is called once per frame
    void Update () {

    }
}

     Gen Lua Wrap Files,