本文整理汇总了C#中LuaInterface.LuaFunction类的典型用法代码示例。如果您正苦于以下问题:C# LuaFunction类的具体用法?C# LuaFunction怎么用?C# LuaFunction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LuaFunction类属于LuaInterface命名空间,在下文中一共展示了LuaFunction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDelegate
public static Delegate CreateDelegate(Type t, LuaFunction func, LuaTable self)
{
DelegateValue Create = null;
if (!dict.TryGetValue(t, out Create))
{
throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
}
if (func != null)
{
LuaState state = func.GetLuaState();
LuaDelegate target = state.GetLuaDelegate(func, self);
if (target != null)
{
return Delegate.CreateDelegate(t, target, target.method);
}
else
{
Delegate d = Create(func, self, true);
target = d.Target as LuaDelegate;
state.AddLuaDelegate(target, func, self);
return d;
}
}
return Create(func, self, true);
}
示例2: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(GameObject go, LuaFunction luafunc) {
if (go == null) return;
UIEventListener.Get(go).onClick = delegate(GameObject o) {
luafunc.Call(go);
buttons.Add(luafunc);
};
}
示例3: Button
public int Button(
int formHandle,
string caption,
LuaFunction clickEvent,
int? x = null,
int? y = null,
int? width = null,
int? height = null)
{
var form = GetForm(formHandle);
if (form == null)
{
return 0;
}
var button = new LuaButton();
SetText(button, caption);
form.Controls.Add(button);
form.ControlEvents.Add(new LuaWinform.LuaEvent(button.Handle, clickEvent));
if (x.HasValue && y.HasValue)
{
SetLocation(button, x.Value, y.Value);
}
if (width.HasValue && height.HasValue)
{
SetSize(button, width.Value, height.Value);
}
return (int)button.Handle;
}
示例4: OnCreatePanel
IEnumerator OnCreatePanel(string name, LuaFunction func = null)
{
yield return StartCoroutine(Initialize());
string assetName = name + "Panel";
// Load asset from assetBundle.
string abName = name.ToLower() + AppConst.ExtName;
AssetBundleAssetOperation request = ResourceManager.LoadAssetAsync(abName, assetName, typeof(GameObject));
if (request == null) yield break;
yield return StartCoroutine(request);
// Get the asset.
GameObject prefab = request.GetAsset<GameObject>();
if (Parent.FindChild(name) != null || prefab == null) {
yield break;
}
GameObject go = Instantiate(prefab) as GameObject;
go.name = assetName;
go.layer = LayerMask.NameToLayer("Default");
go.transform.SetParent(Parent);
go.transform.localScale = Vector3.one;
go.transform.localPosition = Vector3.zero;
go.AddComponent<LuaBehaviour>();
if (func != null) func.Call(go);
Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
}
示例5: callFunction
/*
* Calls the provided function with the provided parameters
*/
public static object callFunction(LuaFunction function,object[] args,Type[] returnTypes,object[] inArgs,int[] outArgs)
{
// args is the return array of arguments, inArgs is the actual array
// of arguments passed to the function (with in parameters only), outArgs
// has the positions of out parameters
object returnValue;
int iRefArgs;
object[] returnValues=function.call(inArgs,returnTypes);
if(returnTypes[0] == typeof(void))
{
returnValue=null;
iRefArgs=0;
}
else
{
returnValue=returnValues[0];
iRefArgs=1;
}
for(int i=0;i<outArgs.Length;i++)
{
args[outArgs[i]]=returnValues[iRefArgs];
iRefArgs++;
}
return returnValue;
}
示例6: Add
public Delegate Add(LuaFunction function)
{
Delegate handler = CodeGeneration.Instance.GetDelegate(this.eventInfo.EventHandlerType, function);
this.eventInfo.AddEventHandler(this.target, handler);
this.pendingEvents.Add(handler, this);
return handler;
}
示例7: CreatePanel
/// <summary>
/// ������壬������Դ������
/// </summary>
/// <param name="type"></param>
public void CreatePanel(string name, LuaFunction func = null)
{
string assetName = name + "Panel";
string abName = name.ToLower() + AppConst.ExtName;
ResManager.LoadPrefab(abName, assetName, delegate(UnityEngine.Object[] objs) {
if (objs.Length == 0) return;
// Get the asset.
GameObject prefab = objs[0] as GameObject;
if (Parent.FindChild(name) != null || prefab == null) {
return;
}
GameObject go = Instantiate(prefab) as GameObject;
go.name = assetName;
go.layer = LayerMask.NameToLayer("Default");
go.transform.SetParent(Parent);
go.transform.localScale = Vector3.one;
go.transform.localPosition = Vector3.zero;
go.AddComponent<LuaBehaviour>();
if (func != null) func.Call(go);
Debug.LogWarning("CreatePanel::>> " + name + " " + prefab);
});
}
示例8: Action
public static Delegate Action(LuaFunction func)
{
Action d = () =>
{
func.Call();
};
return d;
}
示例9: SafeRelease
private void SafeRelease(ref LuaFunction func)
{
if (func != null)
{
func.Dispose();
func = null;
}
}
示例10: UnityEngine_Events_UnityAction
public static Delegate UnityEngine_Events_UnityAction(LuaFunction func)
{
UnityEngine.Events.UnityAction d = () =>
{
func.Call();
};
return d;
}
示例11: CreateTimer
public static STimer CreateTimer(int end, LuaFunction funct)
{
STimer newTimer = new STimer();
newTimer.currentTime = 0;
newTimer.endTime = end;
newTimer.funct = funct;
return newTimer;
}
示例12: add
public static void add(string name, string uni, LuaFunction funct)
{
if (!table.ContainsKey(name))
{
table.Add(name, new Dictionary<string, LuaFunction>());
}
table[name].Add(uni, funct);
}
示例13: AddClick
/// <summary>
/// 添加单击事件
/// </summary>
public void AddClick(string button, LuaFunction luafunc) {
Transform to = trans.Find(button);
if (to == null) return;
GameObject go = to.gameObject;
UIEventListener.Get(go).onClick = delegate(GameObject o) {
luafunc.Call(go);
buttons.Add(luafunc);
};
}
示例14: InitLua
public void InitLua()
{
LuaScriptMgr.Instance.DoFile(PathMod.LuaUI + this.gameObject.name);
m_AwakeFunc = GetLuaFunction("Awake");
m_UpdateFunc = GetLuaFunction("Update");
m_LateUpdateFunc = GetLuaFunction("LateUpdate");
m_FixedUpdateFunc = GetLuaFunction("FixedUpdate");
m_LevelLoaded = GetLuaFunction("OnLevelLoaded");
}
示例15: Dispose
public void Dispose(bool disposeManagedResources)
{
if (!beDisposed)
{
beDisposed = true;
//if (_call != null)
//{
// _call.Dispose(disposeManagedResources);
// _call = null;
//}
if (_add != null)
{
_add.Dispose(disposeManagedResources);
_add = null;
}
if (_remove != null)
{
_remove.Dispose(disposeManagedResources);
_remove = null;
}
if (self != null)
{
self.Dispose(disposeManagedResources);
}
Clear();
}
}