/// <summary> /// The Common Call Function expanded for multiple functions. /// </summary> public void Call(List <string> functionNames, params object[] args) { bool ranLUAArgs = false; DynValue[] luaArgs = null; for (int i = 0; i < functionNames.Count; i++) { if (functionNames[i] == null) { UnityDebugger.Debugger.LogError(ModFunctionsLogChannel, "'" + functionNames[i] + "' is not a LUA nor CSharp function!"); continue; } IFunctions functions = GetFunctions(functionNames[i]); if (functions is LuaFunctions) { if (ranLUAArgs == false) { luaArgs = new DynValue[args.Length]; for (int j = 0; j < args.Length; j++) { luaArgs[j] = functions.CreateInstance(args[j]); } } Call(functionNames[i], false, luaArgs); } else { Call(functionNames[i], false, args); } } }
public T CreateInstance <T>(string className, bool throwError, params object[] args) { string fullClassName = className + (args.Length > 0 ? string.Join(",", args.Select(x => x.GetType().Name).ToArray()) : string.Empty); IFunctions functions = GetFunctions(fullClassName, true); if (functions != null) { return(functions.CreateInstance <T>(fullClassName, args)); } else { UnityDebugger.Debugger.Log(ModFunctionsLogChannel, "'" + className + "' is not a LUA function nor is it a CSharp constructor!"); if (throwError) { throw new Exception("'" + className + "' is not a LUA function nor is it a CSharp constructor!"); } return(default(T)); } }