SIGN IN SIGN UP
Tencent / xLua UNCLAIMED

xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.

2017-01-10 11:35:25 +08:00
using XLua;
#if !XLUA_GENERAL
2017-01-10 11:35:25 +08:00
using UnityEngine;
#endif
2017-01-10 11:35:25 +08:00
using System.Collections.Generic;
using System;
public class LuaEnvSingleton {
static private LuaEnv instance = null;
static public LuaEnv Instance
{
get
{
if(instance == null)
{
instance = new LuaEnv();
#if XLUA_GENERAL
instance.DoString("package.path = package.path..';../Test/UnitTest/xLuaTest/CSharpCallLua/Resources/?.lua.txt;../Test/UnitTest/StreamingAssets/?.lua'");
#endif
}
return instance;
2017-01-10 11:35:25 +08:00
}
}
}
[LuaCallCSharp]
public class LuaTestCommon
{
#if UNITY_IOS || UNITY_IPHONE
public static string resultPath = Application.persistentDataPath + "/";
public static string xxxtdrfilepath = Application.dataPath + "/Raw" + "/testxxx.tdr";
public static string xxxtdr2filepath = Application.dataPath + "/Raw" + "/testxxx2.tdr";
public static bool android_platform = false;
#elif UNITY_ANDROID
public static string resultPath = "/sdcard/luatest/";
public static string xxxtdrfilepath = Application.streamingAssetsPath + "/testxxx.tdr";
public static string xxxtdr2filepath = Application.streamingAssetsPath + "/testxxx2.tdr";
public static bool android_platform = true;
2017-03-21 17:52:12 +08:00
#elif UNITY_EDITOR || UNITY_WSA
2017-01-10 11:35:25 +08:00
public static string resultPath = Application.dataPath + "/xLuaTest/";
public static string xxxtdrfilepath = Application.dataPath + "/StreamingAssets" + "/testxxx.tdr";
public static string xxxtdr2filepath = Application.dataPath + "/StreamingAssets" + "/testxxx2.tdr";
public static bool android_platform = false;
#elif XLUA_GENERAL
public static string resultPath = ".";
public static bool android_platform = false;
public static string xxxtdrfilepath = "../Test/UnitTest/StreamingAssets" + "/testxxx.tdr";
#endif
public static bool IsXLuaGeneral()
{
#if XLUA_GENERAL
return true;
2017-01-10 11:35:25 +08:00
#else
return false;
2017-01-10 11:35:25 +08:00
#endif
}
public static bool IsMacPlatform()
2017-01-10 11:35:25 +08:00
{
#if UNITY_EDITOR
string os = System.Environment.OSVersion.ToString();
if (os.Contains("Unix"))
{
return true;
}
else
{
return false;
}
#else
return false;
#endif
}
public static bool IsIOSPlatform()
{
#if UNITY_IOS || UNITY_IPHONE
return true;
#else
return false;
#endif
}
public static void Log(string str)
{
#if XLUA_GENERAL
System.Console.WriteLine(str);
#else
UnityEngine.Debug.Log(str);
#endif
}
2017-01-10 11:35:25 +08:00
}
#if !XLUA_GENERAL
2017-01-04 19:25:57 +08:00
//注意:用户自己代码不建议在这里配置,建议通过标签来声明!!
2017-07-20 20:27:42 +08:00
public class TestCaseGenConfig
2017-01-10 11:35:25 +08:00
{
//lua中要使用到C#库的配置比如C#标准库或者Unity API第三方库等。
2017-07-20 20:27:42 +08:00
[LuaCallCSharp]
2017-01-10 11:35:25 +08:00
public List<Type> LuaCallCSharp
{
get
{
return new List<Type>()
{
typeof(UnityEngine.TextAsset),
};
}
}
}
#endif