XLua学习笔记:fish.lua修改Unity内的Treasour.cs脚本

 unity调用外部的fish.lua文件

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using XLua;
public class HotFixScripts : MonoBehaviour
{
    private LuaEnv luaEnv;
	void Start () {
		luaEnv=new LuaEnv();
        luaEnv.AddLoader(MyLoadder);
	    luaEnv.DoString("require'fish'");
	}
	void Update () {
		
	}

    private byte[] MyLoadder(ref string Filepath)
    {
        string absPath = @"F:\MyWork\Project\XluaProjects\PlayerGamePackage\" + Filepath+".lua.txt";
        return System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(absPath));
    }

    void OnDisable()
    {
        luaEnv.DoString("require'fishDispose'");
    }

    void OnDestroy()
    {
        luaEnv.Dispose();
    }
}

 fish.lua 修改Unity内的Treasour.cs内的CreatePrize方法

--1.1
local UnityEn

你可能感兴趣的:(Lua)