add
This commit is contained in:
537
Assets/CoolapeFrame/Scripts/Lua/CLBaseLua.cs
Normal file
537
Assets/CoolapeFrame/Scripts/Lua/CLBaseLua.cs
Normal file
@@ -0,0 +1,537 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
*Copyright(C),coolae.net
|
||||
*Author: chenbin
|
||||
*Version: 2.0
|
||||
*Date: 2017-01-09
|
||||
*Description: 把mobobehaviour的处理都转到lua层
|
||||
*Others:
|
||||
*History:
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using XLua;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLBaseLua : MonoBehaviour
|
||||
{
|
||||
public bool isPause = false;
|
||||
public string luaPath;
|
||||
|
||||
protected static LuaEnv _mainLua = null;
|
||||
// 防止报错
|
||||
public static LuaEnv mainLua
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_mainLua == null)
|
||||
_mainLua = new LuaEnv();
|
||||
return _mainLua;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMainLua()
|
||||
{
|
||||
_mainLua = new LuaEnv();
|
||||
}
|
||||
|
||||
public LuaEnv lua;
|
||||
|
||||
public virtual void setLua()
|
||||
{
|
||||
if (luaTable != null)
|
||||
return;
|
||||
doSetLua(false);
|
||||
}
|
||||
|
||||
LuaTable _luaTable;
|
||||
|
||||
public LuaTable luaTable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_luaTable == null)
|
||||
{
|
||||
}
|
||||
return _luaTable;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_luaTable != value && _luaTable != null)
|
||||
{
|
||||
destoryLua();
|
||||
}
|
||||
_luaTable = value;
|
||||
}
|
||||
}
|
||||
|
||||
string luaClassname = null;
|
||||
public bool isClassLua
|
||||
{
|
||||
get
|
||||
{
|
||||
if (luaClassname == null)
|
||||
{
|
||||
if (luaTable != null)
|
||||
{
|
||||
luaClassname = luaTable.GetInPath<string>("__cname");
|
||||
}
|
||||
luaClassname = luaClassname == null ? "" : luaClassname;
|
||||
}
|
||||
return !string.IsNullOrEmpty(luaClassname);
|
||||
}
|
||||
}
|
||||
|
||||
public object[] doSetLua(bool Independent)
|
||||
{
|
||||
object[] ret = null;
|
||||
try
|
||||
{
|
||||
destoryLua();
|
||||
if (Independent)
|
||||
{
|
||||
lua = new LuaEnv();
|
||||
}
|
||||
else
|
||||
{
|
||||
lua = mainLua;
|
||||
}
|
||||
CLUtlLua.addLuaLoader(lua);
|
||||
if (!string.IsNullOrEmpty(luaPath))
|
||||
{
|
||||
ret = CLUtlLua.doLua(lua, luaPath);
|
||||
if (ret != null && ret.Length > 0)
|
||||
{
|
||||
luaTable = (LuaTable)(ret[0]);
|
||||
if(isClassLua)
|
||||
{
|
||||
LuaFunction newFunc= luaTable.GetInPath<LuaFunction>("new");
|
||||
if (newFunc != null)
|
||||
{
|
||||
ret = newFunc.Call();
|
||||
if (ret != null && ret.Length > 0)
|
||||
{
|
||||
luaTable = (LuaTable)(ret[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Is class lua, but no new function ==" + luaPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("SetLua no luatable returned !! ==" + luaPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("[" + gameObject.name + "]" + e);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Transform _tr;
|
||||
//缓存transform
|
||||
public Transform transform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_tr == null)
|
||||
{
|
||||
_tr = gameObject.transform;
|
||||
}
|
||||
return _tr;
|
||||
}
|
||||
}
|
||||
|
||||
public object[] call(LuaFunction func, params object[] _params)
|
||||
{
|
||||
if (func == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (isClassLua)
|
||||
{
|
||||
NewList list = ObjPool.listPool.borrowObject();
|
||||
list.Clear();
|
||||
list.Add(luaTable);
|
||||
list.AddRange(_params);
|
||||
object[] ret = func.Call(list.ToArray(), null);
|
||||
ObjPool.listPool.returnObject(list);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
return func.Call(_params);
|
||||
}
|
||||
}
|
||||
|
||||
public void onNotifyLua(GameObject gameObj, string funcName, object paras)
|
||||
{
|
||||
LuaFunction lfunc = null;
|
||||
if (!string.IsNullOrEmpty(funcName))
|
||||
{
|
||||
lfunc = getLuaFunction(funcName);
|
||||
}
|
||||
else
|
||||
{
|
||||
lfunc = getLuaFunction("onNotifyLua");
|
||||
}
|
||||
if (lfunc != null)
|
||||
{
|
||||
call(lfunc, gameObj, paras);
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<string, LuaFunction> luaFuncMap = new Dictionary<string, LuaFunction>();
|
||||
|
||||
public virtual LuaFunction getLuaFunction(string funcName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(funcName))
|
||||
return null;
|
||||
LuaFunction ret = null;
|
||||
if (luaFuncMap.ContainsKey(funcName))
|
||||
{
|
||||
ret = luaFuncMap[funcName];
|
||||
}
|
||||
if (ret == null && luaTable != null)
|
||||
{
|
||||
ret = luaTable.GetInPath<LuaFunction>(funcName);
|
||||
//ret = (LuaFunction)(luaTable [funcName]);
|
||||
if (ret != null)
|
||||
{
|
||||
luaFuncMap[funcName] = ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public object getLuaVar(string name)
|
||||
{
|
||||
if (luaTable == null)
|
||||
return null;
|
||||
return luaTable.GetInPath<object>(name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoke4s the lua.回调lua函数, 等待时间
|
||||
/// </summary>
|
||||
/// <param name='callbakFunc'>
|
||||
/// Callbak func.
|
||||
/// </param>
|
||||
/// <param name='sec'>
|
||||
/// Sec.
|
||||
/// </param>
|
||||
Hashtable coroutineMap = Hashtable.Synchronized(new Hashtable());
|
||||
Hashtable coroutineIndex = Hashtable.Synchronized(new Hashtable());
|
||||
|
||||
public UnityEngine.Coroutine invoke4Lua(object callbakFunc, float sec)
|
||||
{
|
||||
return invoke4Lua(callbakFunc, "", sec);
|
||||
}
|
||||
|
||||
public UnityEngine.Coroutine invoke4Lua(object callbakFunc, object orgs, float sec)
|
||||
{
|
||||
return invoke4Lua(callbakFunc, orgs, sec, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoke4s the lua.
|
||||
/// </summary>
|
||||
/// <param name="callbakFunc">Callbak func.lua函数</param>
|
||||
/// <param name="orgs">Orgs.参数</param>
|
||||
/// <param name="sec">Sec.等待时间</param>
|
||||
public UnityEngine.Coroutine invoke4Lua(object callbakFunc, object orgs, float sec, bool onlyOneCoroutine)
|
||||
{
|
||||
if (!gameObject.activeInHierarchy)
|
||||
{
|
||||
Debug.LogWarning("invoke4Lua error, then gameObject is hidden.name=" + gameObject.name);
|
||||
return null;
|
||||
}
|
||||
if (callbakFunc == null)
|
||||
{
|
||||
Debug.LogError("callbakFunc is null ......");
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
UnityEngine.Coroutine ct = null;
|
||||
if (onlyOneCoroutine)
|
||||
{
|
||||
cleanCoroutines(callbakFunc);
|
||||
}
|
||||
int index = getCoroutineIndex(callbakFunc);
|
||||
ct = StartCoroutine(doInvoke4Lua(callbakFunc, sec, orgs, index));
|
||||
setCoroutine(callbakFunc, ct, index);
|
||||
return ct;
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("[" + gameObject.name + "]" + callbakFunc + ":" + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCoroutineIndex(object callbakFunc)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineIndex);
|
||||
int ret = MapEx.getInt(coroutineIndex, key);
|
||||
coroutineIndex[key] = ret + 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setCoroutineIndex(object callbakFunc, int val)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineIndex);
|
||||
coroutineIndex[key] = val;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the key4 invoke map.当直接传luafunction时,不能直接用,用Equals查找一下key
|
||||
/// </summary>
|
||||
/// <returns>The key4 invoke map.</returns>
|
||||
/// <param name="callbakFunc">Callbak func.</param>
|
||||
/// <param name="map">Map.</param>
|
||||
public object getKey4InvokeMap(object callbakFunc, Hashtable map)
|
||||
{
|
||||
if (callbakFunc == null || map == null)
|
||||
return callbakFunc;
|
||||
object key = callbakFunc;
|
||||
if (callbakFunc != null)
|
||||
{
|
||||
NewList keys = ObjPool.listPool.borrowObject();
|
||||
keys.AddRange(map.Keys);
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
if ((callbakFunc).Equals((keys[i])))
|
||||
{
|
||||
key = keys[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
ObjPool.listPool.returnObject(keys);
|
||||
keys = null;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public Hashtable getCoroutines(object callbakFunc)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineMap);
|
||||
if (coroutineMap[key] == null)
|
||||
{
|
||||
coroutineMap[key] = new Hashtable();
|
||||
}
|
||||
return (coroutineMap[key]) as Hashtable;
|
||||
}
|
||||
|
||||
public void setCoroutine(object callbakFunc, UnityEngine.Coroutine ct, int index)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineMap);
|
||||
Hashtable map = getCoroutines(callbakFunc);
|
||||
map[index] = ct;
|
||||
coroutineMap[key] = map;
|
||||
}
|
||||
|
||||
public void cleanCoroutines(object callbakFunc)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineMap);
|
||||
Hashtable list = getCoroutines(callbakFunc);
|
||||
foreach (DictionaryEntry cell in list)
|
||||
{
|
||||
StopCoroutine((UnityEngine.Coroutine)(cell.Value));
|
||||
}
|
||||
list.Clear();
|
||||
setCoroutineIndex(callbakFunc, 0);
|
||||
coroutineMap.Remove(key);
|
||||
}
|
||||
|
||||
public void rmCoroutine(object callbakFunc, int index)
|
||||
{
|
||||
object key = getKey4InvokeMap(callbakFunc, coroutineMap);
|
||||
Hashtable list = getCoroutines(callbakFunc);
|
||||
list.Remove(index);
|
||||
coroutineMap[key] = list;
|
||||
}
|
||||
|
||||
public void cancelInvoke4Lua()
|
||||
{
|
||||
cancelInvoke4Lua(null);
|
||||
}
|
||||
|
||||
public void cancelInvoke4Lua(object callbakFunc)
|
||||
{
|
||||
if (callbakFunc == null)
|
||||
{
|
||||
Hashtable list = null;
|
||||
NewList keys = ObjPool.listPool.borrowObject();
|
||||
keys.AddRange(coroutineMap.Keys);
|
||||
object key = null;
|
||||
for (int i = 0; i < keys.Count; i++)
|
||||
{
|
||||
key = keys[i];
|
||||
if (key != null)
|
||||
{
|
||||
list = getCoroutines(key);
|
||||
foreach (DictionaryEntry cell in list)
|
||||
{
|
||||
StopCoroutine((UnityEngine.Coroutine)(cell.Value));
|
||||
}
|
||||
list.Clear();
|
||||
}
|
||||
}
|
||||
coroutineMap.Clear();
|
||||
coroutineIndex.Clear();
|
||||
ObjPool.listPool.returnObject(keys);
|
||||
}
|
||||
else
|
||||
{
|
||||
cleanCoroutines(callbakFunc);
|
||||
}
|
||||
}
|
||||
|
||||
Queue invokeFuncs = new Queue();
|
||||
|
||||
IEnumerator doInvoke4Lua(object callbakFunc, float sec, object orgs, int index)
|
||||
{
|
||||
yield return new WaitForSeconds(sec);
|
||||
try
|
||||
{
|
||||
rmCoroutine(callbakFunc, index);
|
||||
object func = null;
|
||||
if (callbakFunc is string)
|
||||
{
|
||||
func = getLuaFunction(callbakFunc.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
func = callbakFunc;
|
||||
}
|
||||
if (func != null)
|
||||
{
|
||||
if (!isPause)
|
||||
{
|
||||
if (isClassLua && func is LuaFunction)
|
||||
{
|
||||
if (orgs == null)
|
||||
{
|
||||
Utl.doCallback(func, luaTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utl.doCallback(func, luaTable, orgs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (orgs == null)
|
||||
{
|
||||
Utl.doCallback(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utl.doCallback(func, orgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ArrayList list = new ArrayList ();
|
||||
NewList list = ObjPool.listPool.borrowObject();
|
||||
list.Add(func);
|
||||
list.Add(orgs);
|
||||
list.Add(index);
|
||||
invokeFuncs.Enqueue(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
string msg = "[" + gameObject.name + "] call err:doInvoke4Lua" + ",callbakFunc=[" + callbakFunc + "]";
|
||||
// CLAlert.add (msg, Color.red, -1);
|
||||
Debug.LogError(msg);
|
||||
Debug.LogError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void pause()
|
||||
{
|
||||
isPause = true;
|
||||
}
|
||||
|
||||
public virtual void regain()
|
||||
{
|
||||
isPause = false;
|
||||
object func = null;
|
||||
object orgs = null;
|
||||
NewList invokeList = null;
|
||||
try
|
||||
{
|
||||
while (invokeFuncs.Count > 0)
|
||||
{
|
||||
invokeList = (NewList)(invokeFuncs.Dequeue());
|
||||
func = invokeList[0];
|
||||
orgs = invokeList[1];
|
||||
if (isClassLua && func is LuaFunction)
|
||||
{
|
||||
if (orgs == null)
|
||||
{
|
||||
Utl.doCallback(func, luaTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utl.doCallback(func, luaTable, orgs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (orgs == null)
|
||||
{
|
||||
Utl.doCallback(func);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utl.doCallback(func, orgs);
|
||||
}
|
||||
}
|
||||
ObjPool.listPool.returnObject(invokeList);
|
||||
invokeList = null;
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError("[" + gameObject.name + "]" + func != null ? func.ToString() : "" + "==" + e);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnDestroy()
|
||||
{
|
||||
destoryLua();
|
||||
}
|
||||
|
||||
public void destoryLua()
|
||||
{
|
||||
foreach (var cell in luaFuncMap)
|
||||
{
|
||||
if (cell.Value != null)
|
||||
{
|
||||
cell.Value.Dispose();
|
||||
}
|
||||
}
|
||||
luaFuncMap.Clear();
|
||||
if (_luaTable != null)
|
||||
{
|
||||
_luaTable.Dispose();
|
||||
_luaTable = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CoolapeFrame/Scripts/Lua/CLBaseLua.cs.meta
Normal file
12
Assets/CoolapeFrame/Scripts/Lua/CLBaseLua.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1df20d8783b8149d189311ee36483a66
|
||||
timeCreated: 1483978167
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
288
Assets/CoolapeFrame/Scripts/Lua/CLBehaviour4Lua.cs
Normal file
288
Assets/CoolapeFrame/Scripts/Lua/CLBehaviour4Lua.cs
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
*Copyright(C),coolae.net
|
||||
*Author: chenbin
|
||||
*Version: 2.0
|
||||
*Date: 2017-01-09
|
||||
*Description: 把mobobehaviour的处理都转到lua层
|
||||
*Others:
|
||||
*History:
|
||||
*********************************************************************************
|
||||
*/
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using XLua;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLBehaviour4Lua : CLBaseLua
|
||||
{
|
||||
public override void setLua ()
|
||||
{
|
||||
base.setLua ();
|
||||
initGetLuaFunc ();
|
||||
}
|
||||
|
||||
// 把lua方法存在起来
|
||||
public virtual void initGetLuaFunc ()
|
||||
{
|
||||
if (luaTable != null) {
|
||||
flStart = getLuaFunction ("Start");
|
||||
flAwake = getLuaFunction ("Awake");
|
||||
// flReset = getLuaFunction ("Reset");
|
||||
flOnTriggerEnter = getLuaFunction ("OnTriggerEnter");
|
||||
flOnTriggerExit = getLuaFunction ("OnTriggerExit");
|
||||
flOnTriggerStay = getLuaFunction ("OnTriggerStay");
|
||||
flOnCollisionEnter = getLuaFunction ("OnCollisionEnter");
|
||||
flOnCollisionExit = getLuaFunction ("OnCollisionExit");
|
||||
flOnApplicationPause = getLuaFunction ("OnApplicationPause");
|
||||
flOnApplicationFocus = getLuaFunction ("OnApplicationFocus");
|
||||
flOnBecameInvisible = getLuaFunction ("OnBecameInvisible");
|
||||
flOnBecameVisible = getLuaFunction ("OnBecameVisible");
|
||||
flOnControllerColliderHit = getLuaFunction ("OnControllerColliderHit");
|
||||
flOnDestroy = getLuaFunction ("OnDestroy");
|
||||
flOnDisable = getLuaFunction ("OnDisable");
|
||||
flOnEnable = getLuaFunction ("OnEnable");
|
||||
flOnWillRenderObject = getLuaFunction ("OnWillRenderObject");
|
||||
flOnPreRender = getLuaFunction ("OnPreRender");
|
||||
flOnPostRender = getLuaFunction ("OnPostRender");
|
||||
flOnClick = getLuaFunction ("OnClick");
|
||||
flOnPress = getLuaFunction ("OnPress");
|
||||
flOnDrag = getLuaFunction ("OnDrag");
|
||||
flUIEventDelegate = getLuaFunction ("uiEventDelegate");
|
||||
flclean = getLuaFunction ("clean");
|
||||
flApplicationQuit = getLuaFunction ("OnApplicationQuit");
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flclean = null;
|
||||
public LuaFunction flApplicationQuit = null;
|
||||
|
||||
bool isQuit = false;
|
||||
public virtual void OnApplicationQuit (){
|
||||
isQuit = true;
|
||||
if (flApplicationQuit != null) {
|
||||
call(flApplicationQuit);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void clean ()
|
||||
{
|
||||
if (flclean != null) {
|
||||
call(flclean);
|
||||
}
|
||||
if (isQuit)
|
||||
return;
|
||||
|
||||
cancelInvoke4Lua (null);
|
||||
CancelInvoke ();
|
||||
StopAllCoroutines ();
|
||||
}
|
||||
|
||||
public LuaFunction flStart = null;
|
||||
public LuaFunction flAwake = null;
|
||||
// Use this for initialization
|
||||
public virtual void Start ()
|
||||
{
|
||||
if (flStart != null) {
|
||||
call(flStart, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Awake ()
|
||||
{
|
||||
if (flAwake != null) {
|
||||
call(flAwake, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnTriggerEnter = null;
|
||||
|
||||
public virtual void OnTriggerEnter (Collider other)
|
||||
{
|
||||
if (flOnTriggerEnter != null) {
|
||||
call(flOnTriggerEnter, other);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnTriggerExit = null;
|
||||
|
||||
public virtual void OnTriggerExit (Collider other)
|
||||
{
|
||||
if (flOnTriggerExit != null) {
|
||||
call(flOnTriggerExit, other);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnTriggerStay = null;
|
||||
|
||||
public virtual void OnTriggerStay (Collider other)
|
||||
{
|
||||
if (flOnTriggerStay != null) {
|
||||
call(flOnTriggerStay, other);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnCollisionEnter = null;
|
||||
|
||||
public virtual void OnCollisionEnter (Collision collision)
|
||||
{
|
||||
if (flOnCollisionEnter != null) {
|
||||
call(flOnCollisionEnter, collision);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnCollisionExit = null;
|
||||
|
||||
public virtual void OnCollisionExit (Collision collisionInfo)
|
||||
{
|
||||
if (flOnCollisionExit != null) {
|
||||
call(flOnCollisionExit, collisionInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnApplicationPause = null;
|
||||
|
||||
public virtual void OnApplicationPause (bool pauseStatus)
|
||||
{
|
||||
if (flOnApplicationPause != null) {
|
||||
call(flOnApplicationPause, pauseStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnApplicationFocus = null;
|
||||
|
||||
public virtual void OnApplicationFocus (bool focusStatus)
|
||||
{
|
||||
if (flOnApplicationFocus != null) {
|
||||
call(flOnApplicationFocus, focusStatus);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnBecameInvisible = null;
|
||||
|
||||
public virtual void OnBecameInvisible ()
|
||||
{
|
||||
if (isQuit)
|
||||
return;
|
||||
if (flOnBecameInvisible != null) {
|
||||
call(flOnBecameInvisible, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnBecameVisible = null;
|
||||
|
||||
public virtual void OnBecameVisible ()
|
||||
{
|
||||
if (flOnBecameVisible != null) {
|
||||
call(flOnBecameVisible, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnControllerColliderHit = null;
|
||||
|
||||
public virtual void OnControllerColliderHit (ControllerColliderHit hit)
|
||||
{
|
||||
if (flOnControllerColliderHit != null) {
|
||||
call(flOnControllerColliderHit, hit);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnDestroy = null;
|
||||
|
||||
public override void OnDestroy ()
|
||||
{
|
||||
if (flOnDestroy != null) {
|
||||
call(flOnDestroy, gameObject);
|
||||
}
|
||||
base.OnDestroy ();
|
||||
}
|
||||
|
||||
public LuaFunction flOnDisable = null;
|
||||
|
||||
public virtual void OnDisable ()
|
||||
{
|
||||
if (flOnDisable != null) {
|
||||
call(flOnDisable, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnEnable = null;
|
||||
|
||||
public virtual void OnEnable ()
|
||||
{
|
||||
if (flOnEnable != null) {
|
||||
call(flOnEnable, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnWillRenderObject = null;
|
||||
|
||||
public virtual void OnWillRenderObject ()
|
||||
{
|
||||
if (flOnWillRenderObject != null) {
|
||||
call(flOnWillRenderObject, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnPreRender = null;
|
||||
|
||||
public virtual void OnPreRender ()
|
||||
{
|
||||
if (flOnPreRender != null) {
|
||||
call(flOnPreRender, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnPostRender = null;
|
||||
|
||||
public virtual void OnPostRender ()
|
||||
{
|
||||
if (flOnPostRender != null) {
|
||||
call(flOnPostRender, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnClick = null;
|
||||
|
||||
public virtual void OnClick ()
|
||||
{
|
||||
if (flOnClick != null) {
|
||||
call(flOnClick, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnPress = null;
|
||||
|
||||
public virtual void OnPress (bool isPressed)
|
||||
{
|
||||
if (flOnPress != null) {
|
||||
call(flOnPress, gameObject, isPressed);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flOnDrag = null;
|
||||
|
||||
public virtual void OnDrag (Vector2 delta)
|
||||
{
|
||||
if (flOnDrag != null) {
|
||||
call(flOnDrag, gameObject, delta);
|
||||
}
|
||||
}
|
||||
|
||||
public LuaFunction flUIEventDelegate = null;
|
||||
|
||||
/// <summary>
|
||||
/// User interfaces the event delegate.
|
||||
/// </summary>
|
||||
/// <param name="go">Go.</param>
|
||||
public virtual void uiEventDelegate (GameObject go)
|
||||
{
|
||||
if (flUIEventDelegate != null) {
|
||||
call(flUIEventDelegate, go);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CoolapeFrame/Scripts/Lua/CLBehaviour4Lua.cs.meta
Normal file
12
Assets/CoolapeFrame/Scripts/Lua/CLBehaviour4Lua.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a09d9c7f40fa24f0ea7f6c22fe11ac48
|
||||
timeCreated: 1483978167
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
277
Assets/CoolapeFrame/Scripts/Lua/CLBehaviourWithUpdate4Lua.cs
Normal file
277
Assets/CoolapeFrame/Scripts/Lua/CLBehaviourWithUpdate4Lua.cs
Normal file
@@ -0,0 +1,277 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using XLua;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLBehaviourWithUpdate4Lua : CLBehaviour4Lua
|
||||
{
|
||||
public bool canUpdateInvoke = false;
|
||||
|
||||
public LuaFunction flUpdate = null;
|
||||
public LuaFunction flLateUpdate = null;
|
||||
public LuaFunction flFixedUpdate = null;
|
||||
public override void initGetLuaFunc ()
|
||||
{
|
||||
base.initGetLuaFunc ();
|
||||
flUpdate = getLuaFunction ("Update");
|
||||
flLateUpdate = getLuaFunction ("LateUpdate");
|
||||
flFixedUpdate = getLuaFunction ("FixedUpdate");
|
||||
}
|
||||
|
||||
public override void clean ()
|
||||
{
|
||||
canFixedInvoke = false;
|
||||
cancelFixedInvoke4Lua (null);
|
||||
}
|
||||
|
||||
public virtual void LateUpdate ()
|
||||
{
|
||||
if (flLateUpdate != null) {
|
||||
call(flLateUpdate, gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
//================================================
|
||||
// Fixed invoke 4 lua
|
||||
//================================================
|
||||
bool _doFixedUpdate = false;
|
||||
|
||||
public bool canFixedInvoke {
|
||||
get {
|
||||
return _doFixedUpdate;
|
||||
}
|
||||
set {
|
||||
_doFixedUpdate = value;
|
||||
if (value) {
|
||||
if (fixedInvokeMap == null) {
|
||||
fixedInvokeMap = Hashtable.Synchronized (_fixedInvokeMap);
|
||||
}
|
||||
}
|
||||
if (!_doFixedUpdate) {
|
||||
frameCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// public Dictionary<long, List<LuaFunction>> fixedInvokeMap = new Dictionary<long, List<LuaFunction>> ();
|
||||
Hashtable _fixedInvokeMap = new Hashtable ();
|
||||
public Hashtable fixedInvokeMap = null;
|
||||
|
||||
public void fixedInvoke4Lua (object luaFunc, float waitSec)
|
||||
{
|
||||
fixedInvoke (luaFunc, null, waitSec);
|
||||
}
|
||||
|
||||
public void fixedInvoke4Lua (object luaFunc, object paras, float waitSec)
|
||||
{
|
||||
fixedInvoke (luaFunc, paras, waitSec);
|
||||
}
|
||||
|
||||
public void fixedInvoke (object callback, object paras, float waitSec)
|
||||
{
|
||||
if (fixedInvokeMap == null) {
|
||||
fixedInvokeMap = Hashtable.Synchronized (_fixedInvokeMap);
|
||||
}
|
||||
int waiteFrame = Mathf.CeilToInt (waitSec / Time.fixedDeltaTime);
|
||||
waiteFrame = waiteFrame <= 0 ? 1 : waiteFrame; //至少有帧
|
||||
long key = frameCounter + waiteFrame;
|
||||
object[] content = new object[2];
|
||||
// print (waiteFrame + "===" + key +"====" + luaFunc);
|
||||
List<object[]> funcList = (List<object[]>)(fixedInvokeMap [key]);
|
||||
if (funcList == null) {
|
||||
funcList = new List<object[]> ();
|
||||
}
|
||||
content [0] = callback;
|
||||
content [1] = paras;
|
||||
funcList.Add (content);
|
||||
fixedInvokeMap [key] = funcList;
|
||||
canFixedInvoke = true;
|
||||
}
|
||||
|
||||
public void cancelFixedInvoke4Lua ()
|
||||
{
|
||||
cancelFixedInvoke4Lua (null);
|
||||
}
|
||||
|
||||
public void cancelFixedInvoke4Lua (object func)
|
||||
{
|
||||
if (func == null) {
|
||||
if (fixedInvokeMap != null) {
|
||||
fixedInvokeMap.Clear ();
|
||||
}
|
||||
return;
|
||||
}
|
||||
List<object[]> list = null;
|
||||
int count = 0;
|
||||
object[] content = null;
|
||||
foreach (DictionaryEntry item in fixedInvokeMap) {
|
||||
list = (List<object[]>)(item.Value);
|
||||
count = list.Count;
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
content = list [i];
|
||||
if (func.Equals (content [0])) {
|
||||
list.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
if(list.Count == 0) {
|
||||
fixedInvokeMap.Remove (item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void doFixedInvoke (long key)
|
||||
{
|
||||
if (fixedInvokeMap == null && fixedInvokeMap.Count <= 0)
|
||||
return;
|
||||
object[] content = null;
|
||||
List<object[]> funcList = (List<object[]>)(fixedInvokeMap [key]);
|
||||
object callback = null;
|
||||
if (funcList != null) {
|
||||
for (int i = 0; i < funcList.Count; i++) {
|
||||
content = funcList [i];
|
||||
callback = content [0];
|
||||
if (callback is string) {
|
||||
callback = getLuaFunction (callback.ToString ());
|
||||
}
|
||||
Utl.doCallback(callback, content[1]);
|
||||
}
|
||||
funcList.Clear ();
|
||||
funcList = null;
|
||||
fixedInvokeMap.Remove (key);
|
||||
}
|
||||
}
|
||||
|
||||
//================================================
|
||||
// FixedUpdate
|
||||
//================================================
|
||||
public long frameCounter = 0;
|
||||
//帧统计
|
||||
public virtual void FixedUpdate ()
|
||||
{
|
||||
if (flFixedUpdate != null) {
|
||||
call(flFixedUpdate, gameObject);
|
||||
}
|
||||
if (canFixedInvoke) {
|
||||
frameCounter++;
|
||||
if (fixedInvokeMap.Count > 0) {
|
||||
doFixedInvoke (frameCounter);
|
||||
} else {
|
||||
canFixedInvoke = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//================================================
|
||||
// Update
|
||||
//================================================
|
||||
ArrayList _invokeByUpdateList = null;
|
||||
|
||||
ArrayList invokeByUpdateList {
|
||||
get {
|
||||
if (_invokeByUpdateList == null) {
|
||||
_invokeByUpdateList = ArrayList.Synchronized (new ArrayList ());
|
||||
}
|
||||
return _invokeByUpdateList;
|
||||
}
|
||||
}
|
||||
|
||||
public void invokeByUpdate (object callbakFunc, float sec)
|
||||
{
|
||||
invokeByUpdate (callbakFunc, null, sec);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoke4s the lua.
|
||||
/// </summary>
|
||||
/// <param name="callbakFunc">Callbak func.lua函数</param>
|
||||
/// <param name="orgs">Orgs.参数</param>
|
||||
/// <param name="sec">Sec.等待时间</param>
|
||||
public void invokeByUpdate (object callbakFunc, object orgs, float sec)
|
||||
{
|
||||
if (callbakFunc == null)
|
||||
return;
|
||||
NewList list = ObjPool.listPool.borrowObject ();
|
||||
list.Add (callbakFunc);
|
||||
list.Add (orgs);
|
||||
list.Add (Time.unscaledTime + sec);
|
||||
invokeByUpdateList.Add (list);
|
||||
canUpdateInvoke = true;
|
||||
}
|
||||
|
||||
public void cancelInvokeByUpdate ()
|
||||
{
|
||||
cancelInvokeByUpdate (null);
|
||||
}
|
||||
|
||||
public void cancelInvokeByUpdate (object callbakFunc)
|
||||
{
|
||||
NewList list = null;
|
||||
int count = invokeByUpdateList.Count;
|
||||
if (callbakFunc == null) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
list = (NewList)(invokeByUpdateList [i]);
|
||||
ObjPool.listPool.returnObject (list);
|
||||
}
|
||||
list = null;
|
||||
invokeByUpdateList.Clear ();
|
||||
return;
|
||||
}
|
||||
for (int i = count - 1; i >= 0; i--) {
|
||||
list = (NewList)(invokeByUpdateList [i]);
|
||||
if (callbakFunc.Equals (list [0])) {
|
||||
invokeByUpdateList.RemoveAt (i);
|
||||
ObjPool.listPool.returnObject (list);
|
||||
}
|
||||
}
|
||||
list = null;
|
||||
}
|
||||
|
||||
void doInvokeByUpdate ()
|
||||
{
|
||||
int count = invokeByUpdateList.Count;
|
||||
NewList list = null;
|
||||
object callbakFunc;
|
||||
object orgs;
|
||||
float sec;
|
||||
int index = 0;
|
||||
object func = null;
|
||||
while (index < invokeByUpdateList.Count) {
|
||||
list = (invokeByUpdateList [index]) as NewList;
|
||||
if (list == null)
|
||||
continue;
|
||||
callbakFunc = list [0];
|
||||
orgs = list [1];
|
||||
sec = (float)(list [2]);
|
||||
if (sec <= Time.unscaledTime) {
|
||||
if (callbakFunc is string) {
|
||||
func = getLuaFunction (callbakFunc.ToString ());
|
||||
} else {
|
||||
func = callbakFunc;
|
||||
}
|
||||
|
||||
Utl.doCallback(callbakFunc, orgs);
|
||||
invokeByUpdateList.RemoveAt (index);
|
||||
ObjPool.listPool.returnObject (list);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
list = null;
|
||||
}
|
||||
|
||||
public virtual void Update ()
|
||||
{
|
||||
if (flUpdate != null) {
|
||||
call(flUpdate, gameObject);
|
||||
}
|
||||
if (canUpdateInvoke) {
|
||||
if (invokeByUpdateList.Count > 0) {
|
||||
doInvokeByUpdate ();
|
||||
} else {
|
||||
canUpdateInvoke = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 80dc18c009d1e4303ab5f48275766a5d
|
||||
timeCreated: 1506673478
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
245
Assets/CoolapeFrame/Scripts/Lua/CLUtlLua.cs
Normal file
245
Assets/CoolapeFrame/Scripts/Lua/CLUtlLua.cs
Normal file
@@ -0,0 +1,245 @@
|
||||
/*
|
||||
********************************************************************************
|
||||
*Copyright(C),coolae.net
|
||||
*Author: chenbin
|
||||
*Version: 2.0
|
||||
*Date: 2017-01-09
|
||||
*Description: lua相关处理工具类
|
||||
*Others:
|
||||
*History:
|
||||
*********************************************************************************
|
||||
*/
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using XLua;
|
||||
using System.IO;
|
||||
|
||||
namespace Coolape
|
||||
{
|
||||
public class CLUtlLua
|
||||
{
|
||||
//public static bool isFinishAddLoader = false;
|
||||
public static Hashtable FileBytesCacheMap = new Hashtable();
|
||||
|
||||
/// <summary>
|
||||
/// Adds the lua loader.
|
||||
/// </summary>
|
||||
/// <param name="lua">Lua.</param>
|
||||
public static void addLuaLoader(LuaEnv lua)
|
||||
{
|
||||
LuaEnv.CustomLoader loader = (LuaEnv.CustomLoader)(myLuaLoader);
|
||||
if (!lua.customLoaders.Contains(loader))
|
||||
{
|
||||
lua.AddLoader(loader);
|
||||
}
|
||||
//isFinishAddLoader = true;
|
||||
}
|
||||
|
||||
public static void cleanFileBytesCacheMap()
|
||||
{
|
||||
FileBytesCacheMap.Clear();
|
||||
}
|
||||
|
||||
public static byte[] myLuaLoader(ref string filepath)
|
||||
{
|
||||
byte[] bytes = null;
|
||||
string luaPath = "";
|
||||
string strs = "";
|
||||
try
|
||||
{
|
||||
if (!filepath.StartsWith(CLPathCfg.self.basePath))
|
||||
{
|
||||
//说明是通过require进来的
|
||||
filepath = filepath.Replace(".", "/");
|
||||
filepath = PStr.b().a(CLPathCfg.self.basePath).a("/upgradeRes/priority/lua/").a(filepath).a(".lua").e();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (CLCfgBase.self.isEditMode)
|
||||
{
|
||||
filepath = filepath.Replace("/upgradeRes/", "/upgradeRes4Dev/");
|
||||
luaPath = PStr.b().a(Application.dataPath).a("/").a(filepath).e();
|
||||
bytes = MapEx.getBytes(FileBytesCacheMap, luaPath);
|
||||
if (bytes != null)
|
||||
{
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
if (File.Exists(luaPath))
|
||||
{
|
||||
strs = FileEx.getTextFromCache(luaPath);
|
||||
bytes = System.Text.Encoding.UTF8.GetBytes(strs);
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if UNITY_WEBGL
|
||||
bytes = MapEx.getBytes(FileBytesCacheMap, filepath);
|
||||
if (bytes != null)
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes = FileEx.readNewAllBytes(filepath);
|
||||
bytes = deCodeLua(bytes);
|
||||
FileBytesCacheMap[filepath] = bytes;
|
||||
return bytes;
|
||||
}
|
||||
#else
|
||||
//=======================================================
|
||||
//1.first load from CLPathCfg.persistentDataPath;
|
||||
luaPath = PStr.b ().a (CLPathCfg.persistentDataPath).a ("/").a (filepath).e ();
|
||||
bytes = MapEx.getBytes (FileBytesCacheMap, luaPath);
|
||||
if (bytes != null) {
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
if (File.Exists (luaPath)) {
|
||||
bytes = FileEx.getBytesFromCache (luaPath);
|
||||
if (bytes != null) {
|
||||
// bytes = System.Text.Encoding.UTF8.GetBytes(strs);
|
||||
bytes = deCodeLua (bytes);
|
||||
FileBytesCacheMap [luaPath] = bytes;
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
//=======================================================
|
||||
//2.second load from Application.streamingAssetsPath;
|
||||
luaPath = PStr.b ().a (Application.streamingAssetsPath).a ("/").a (filepath).e ();
|
||||
bytes = MapEx.getBytes (FileBytesCacheMap, luaPath);
|
||||
if (bytes != null) {
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
bytes = FileEx.getBytesFromCache (luaPath);
|
||||
if (bytes != null) {
|
||||
// bytes = System.Text.Encoding.UTF8.GetBytes(strs);
|
||||
bytes = deCodeLua (bytes);
|
||||
FileBytesCacheMap [luaPath] = bytes;
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
//=======================================================
|
||||
//3.third load from Resources.Load ();
|
||||
luaPath = filepath;
|
||||
bytes = MapEx.getBytes(FileBytesCacheMap, luaPath);
|
||||
if (bytes != null)
|
||||
{
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
TextAsset text = Resources.Load<TextAsset>(filepath);
|
||||
if (text != null)
|
||||
{
|
||||
bytes = text.bytes;// System.Text.Encoding.UTF8.GetBytes(text.text);
|
||||
if (bytes != null)
|
||||
{
|
||||
bytes = deCodeLua(bytes);
|
||||
FileBytesCacheMap[luaPath] = bytes;
|
||||
filepath = luaPath;
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
//==========================
|
||||
return bytes;
|
||||
#endif
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(luaPath + ":" + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// lua文件解密
|
||||
public static byte[] deCodeLua(byte[] buff)
|
||||
{
|
||||
if (buff == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (CLCfgBase.self.isEncodeLua)
|
||||
{
|
||||
return XXTEA.Decrypt(buff, XXTEA.defaultKey);
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
|
||||
public static string getLua(string fn)
|
||||
{
|
||||
string path = fn;
|
||||
string str = "";
|
||||
byte[] buff = myLuaLoader(ref path);
|
||||
if (buff != null)
|
||||
{
|
||||
str = System.Text.Encoding.UTF8.GetString(buff);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static object[] doLua(LuaEnv lua, string _path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = _path.Replace("\\", "/");
|
||||
string filebase = Path.GetFileName(path);
|
||||
path = path.Replace("/upgradeRes4Publish/", "/upgradeRes/");
|
||||
string luaContent = "";
|
||||
#if UNITY_EDITOR
|
||||
if (CLCfgBase.self.isEditMode)
|
||||
{
|
||||
string tmpPath = path.Replace("/upgradeRes/", "/upgradeRes4Dev/");
|
||||
luaContent = getLua(tmpPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
luaContent = getLua(path);
|
||||
}
|
||||
#else
|
||||
luaContent = getLua (path);
|
||||
#endif
|
||||
if (string.IsNullOrEmpty(luaContent))
|
||||
{
|
||||
Debug.LogError(_path + " get content is null!");
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return lua.DoString(luaContent, filebase);
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(_path + "," + e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList luaTableKeys2List(LuaTable table)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
foreach (object key in table.GetKeys<object>())
|
||||
{
|
||||
list.Add(key);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static ArrayList luaTableVals2List(LuaTable table)
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
foreach (object key in table.GetKeys<object>())
|
||||
{
|
||||
list.Add(table.Get<object>(key));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/CoolapeFrame/Scripts/Lua/CLUtlLua.cs.meta
Normal file
12
Assets/CoolapeFrame/Scripts/Lua/CLUtlLua.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d29bed7257e9d4a6fa5caf398ad544bd
|
||||
timeCreated: 1483970403
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user