SLua-在Lua中实现Unity中的生命周期

Unity中Lua脚本与C#交互

Enumerable.Cast(IEnumerable) Method :
Casts the elements of an IEnumerable to the specified type.
将一个IEnumerable的元素转换为一个具体的类型。

实现Unity中的Unity生命周期
1.获取Lua的表
2.获取表中的Update方法
3.使用强制类型转换将LuaFunction转换成一个委托方法,此委托方法可以传入LuaTable自身
4.在C#中调用转换成委托的方法并传入LuaTable

using System.Collections;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Net;

using UnityEngine;
using SLua;
using System.IO;
using System;

public class OpenLuaFile : MonoBehaviour {

    private LuaSvr lua_svr;
    private LuaTable self;
    private LuaFunction update;

    [CustomLuaClass]
    public delegate void UpdateDelegate(object self);

    UpdateDelegate ud;

    void Start () {
        lua_svr = new LuaSvr();
        lua_svr.init(null, InitCo
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值