public void LoadFunction(object target) { #if UNITY_EDITOR if (target == null) { return; } System.Type tp = target.GetType(); HashSet <RTSPluginAttribute> sets = new HashSet <RTSPluginAttribute>(); mFunctions[tp] = sets; MethodInfo[] methods = tp.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); //bool first = true; for (int i = 0; i < methods.Length; i++) { try { object[] cmds = methods[i].GetCustomAttributes(typeof(RTSPluginAttribute), true); if (cmds.Length > 0) { RTSPluginAttribute cmd = cmds[0] as RTSPluginAttribute; if (!RTSUtil.isGoodName(cmd.Name)) { continue; } RTSPluginDelegate func = (RTSPluginDelegate)System.Delegate.CreateDelegate(typeof(RTSPluginDelegate), target, methods[i].Name); RTSPluginFunc f = new RTSPluginFunc(null, func, cmd.ArgCount); if (cmd.IsCmd) { AddCommand(cmd.Name, f); } else { AddFunction(cmd.Name, f); } //Debug.LogFormat("Load Function: {0}" , desc(cmd)); if (!string.IsNullOrEmpty(cmd.Doc)) { sets.Add(cmd); } } } catch (System.Exception e) { PutLog(Level.error, e.ToString()); Debug.LogException(e); } } #endif }
public RTSPluginFunc(IRTSType retType, RTSPluginDelegate dele, int argC) { mReturnType = retType; mTarget = dele; mArgC = argC; }