本文整理汇总了C#中SLua.LuaFunction类的典型用法代码示例。如果您正苦于以下问题:C# LuaFunction类的具体用法?C# LuaFunction怎么用?C# LuaFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaFunction类属于SLua命名空间,在下文中一共展示了LuaFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
lua = new LuaSvr();
self = (LuaTable)lua.start("LuaFiles/building_txt");
//self = (LuaTable)lua.luaState.getObject("data");
//object o = lua.luaState.getFunction("GetData").call();
Debug.Log("table " + ((LuaTable)self[1])["name"]);
LuaFunction dataFunction = ((LuaFunction)self["GetData"]);
LuaTable dataTable = (LuaTable)dataFunction.call();
LuaFunction callFunction = (LuaFunction)self["CallBack"];
callFunction.call(222);
//lua.luaState.getFunction("CallBack").call();
lua.luaState.getFunction("Call").call(2);
Debug.Log("table " + ((LuaTable)dataTable[1])["use_money"] + " is Null " + (callFunction == null));
LuaTable d = (LuaTable)((LuaFunction)self["GetData1"]).call();
Debug.Log("---------------- : " + ((LuaTable)d[1])["use_money"]);
LuaTable table2 = (LuaTable)lua.start("LuaFiles/building_txt1");
test2 = (LuaFunction)self["test"];
object o = test2.call(self,9,1);
Debug.Log("add function :"+o);
SetTransform = (LuaFunction)self["SetTransform"];
SetTransform.call(self, tr);
//tr.localPosition = new Vector3(2, 2, 2);
}
示例2: Init
public void Init(string ip, int port, LuaFunction recvCallback)
{
_ip = ip;
_port = port;
_recvCallback = recvCallback;
_socket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
}
示例3: Start
void Start () {
svr = new LuaSvr();
svr.init(null, () =>
{
self = (LuaTable)svr.start("circle/circle");
update = (LuaFunction)self["update"];
});
}
示例4: ForeachChild
/// <summary>
///
/// </summary>
/// <param name="parent"></param>
/// <param name="eachFn"></param>
public static void ForeachChild(GameObject parent, LuaFunction eachFn)
{
Transform pr=parent.transform;
int count = pr.childCount;
Transform child = null;
for (int i = 0; i < count; i++)
{
child = pr.GetChild(i);
eachFn.call(i, child.gameObject);
}
}
示例5: LoadLuaTable
/// <summary>
/// 加载luatable里面的request
/// </summary>
/// <param name="reqs"></param>
public void LoadLuaTable(LuaTable reqs, LuaFunction groupCompleteFn)
{
pushGroup = true;
foreach (var pair in reqs)
{
AddReqToQueue((CRequest)pair.value);
}
this.groupCompleteFn = groupCompleteFn;
pushGroup = false;
BeginQueue();
}
示例6: Load
public void Load(LuaFunction func)
{
_callBack = func;
if (_prefab != null)
{
LoadFinished();
}
if (_isAssetBundle)
{
StartLoadResource();
}
else
{
ResourceManager.Instance.StartCoroutine(StartLoadAssetBundle());
}
}
示例7: CallMethod
/**
* Call a lua method.
*
* @param ref LuaFunction cFunc - The out function. If it is not null, will call it instead of look up from table by strFunc.
* @param string strFunc - The function name.
* @param object cParam1 - The first param.
* @param object cParam2 - The second param.
* @param object cParam3 - The third param.
* @return object - The number of result.
*/
public object CallMethod(ref LuaFunction cFunc, string strFunc, object cParam1, object cParam2, object cParam3)
{
if (null == m_cLuaTableOpt)
{
return null;
}
return m_cLuaTableOpt.CallMethod(ref cFunc, strFunc, cParam1, cParam2, cParam3);
}
示例8: DeltaConditionNode
/// <summary>
/// 按一定时间执行的条件节点
/// </summary>
/// <param name="fn">luafunction</param>
public DeltaConditionNode(float delta,LuaFunction fn)
: base(fn)
{
this.delta = delta;
}
示例9: ConditionWaitNode
public ConditionWaitNode(LuaFunction fn,string name)
: base(fn,name)
{
}
示例10: ConditionNode
/// <summary>
/// 条件节点
/// </summary>
/// <param name="fn">条件委托 luafunction(input,output)</param>
public ConditionNode(LuaFunction fn)
: base()
{
this._fn = fn;
_condition = null;
}
示例11: loadLuaBundle
/// <summary>
/// 加载lua bundle
/// </summary>
/// <returns></returns>
private IEnumerator loadLuaBundle(bool domain,LuaFunction onLoadedFn)
{
string keyName = "";
string luaP = CUtils.GetAssetFullPath("font.u3d");
//Debug.Log("load lua bundle" + luaP);
WWW luaLoader = new WWW(luaP);
yield return luaLoader;
if (luaLoader.error == null)
{
byte[] byts=CryptographHelper.Decrypt(luaLoader.bytes,DESHelper.instance.Key,DESHelper.instance.IV);
AssetBundle item = AssetBundle.CreateFromMemoryImmediate(byts);
// item = luaLoader.assetBundle;
#if UNITY_5
TextAsset[] all = item.LoadAllAssets<TextAsset>();
foreach (var ass in all)
{
keyName = Regex.Replace(ass.name,@"\.","");
//Debug.Log("cache : " + keyName);
luacache[keyName] = ass;
}
#else
UnityEngine.Object[] all = item.LoadAll(typeof(TextAsset));
foreach (var ass in all)
{
keyName = Regex.Replace(ass.name,@"\.","");
Debug.Log(keyName + " complete");
luacache[keyName] = ass as TextAsset;
}
#endif
//Debug.Log("loaded lua bundle complete" + luaP);
// luaLoader.assetBundle.Unload(false);
item.Unload(false);
luaLoader.Dispose();
}
DoUnity3dLua();
if (domain)
DoMain();
if (onLoadedFn != null) onLoadedFn.call();
}
示例12: LoadBundle
/// <summary>
/// 加载lua 打包文件
/// </summary>
public void LoadBundle(LuaFunction onLoadedFn)
{
//Debug.Log(" refresh LoadBundle ");
StopCoroutine(loadLuaBundle(false, onLoadedFn));
StartCoroutine(loadLuaBundle(false, onLoadedFn));
}
示例13: OnDestroy
void OnDestroy()
{
if (onDestroyFn != null) onDestroyFn.call();
updateFn = null;
lua = null;
_instance = null;
luacache.Clear();
}
示例14: RemoveAllEvents
public void RemoveAllEvents()
{
onAllCompleteFn = null;
onProgressFn = null;
onSharedCompleteFn = null;
onCacheFn = null;
onSharedErrFn = null;
onAssetBundleCompleteFn = null;
onAssetBundleErrFn = null;
}
示例15: ClearPrefab
public void ClearPrefab()
{
_prefab = null;
_callBack = null;
if (_dependenciesPath != null)
{
_dependenciesPath.Clear();
_dependenciesPath = null;
}
}