Example #1
0
 /// <summary>
 /// 执行L#对应的方法
 /// </summary>
 /// <param name="funName">方法</param>
 /// <param name="paramTypes">参数类型列表</param>
 /// <param name="param">参数列表</param>
 protected void doFun(GMBEventMethod method, MethodParamList paramTypes = null, object[] param = null)
 {
     if (funDic == null)
     {
         init();
     }
     if (!funDic.ContainsKey(method))
     {
         funDic.Add(method, GMBManager.instance.getGMBEventMethod(clrInst.type, method, paramTypes));
     }
     if (funDic[method] != null)
     {
         funDic[method].Invoke(CLRSharpManager.instance.context, clrInst, param);
     }
 }
Example #2
0
        //============================================================
        /// <summary>
        /// 获取GMonoBehaviour事件的方法
        /// </summary>
        /// <param name="clrType"></param>
        /// <param name="method"></param>
        /// <param name="paramTypes"></param>
        /// <returns></returns>
        public IMethod getGMBEventMethod(ICLRType clrType, GMBEventMethod method, MethodParamList paramTypes = null)
        {
            if (paramTypes == null)
            {
                paramTypes = MethodParamList.constEmpty();
            }

            if (clrType == null || clrType.FullName == "Freamwork.GMB")
            {
                return null;
            }

            Dictionary<string, IMethod> methodDic;
            if (!dic.ContainsKey(clrType.FullName))
            {
                methodDic = new Dictionary<string, IMethod>();
                dic.Add(clrType.FullName, methodDic);
            }
            else
            {
                methodDic = dic[clrType.FullName];
            }

            string methodName = totalMethodNameList[(int)method];
            if (methodDic.ContainsKey(methodName))
            {
                return methodDic[methodName];
            }

            IMethod eventMethod = clrType.GetMethod(methodName, paramTypes);
            if (eventMethod == null)
            {
                Type_Common_CLRSharp type = clrType as Type_Common_CLRSharp;
                if (type != null)
                {
                    eventMethod = getGMBEventMethod(type.BaseType, method, paramTypes);
                }
            }
            methodDic[methodName] = eventMethod;
            return eventMethod;
        }