예제 #1
0
    static public List <Entry> GetMethods(GameObject target)
    {
        MonoBehaviour[] comps = target.GetComponents <MonoBehaviour>();

        List <Entry> list = new List <Entry>();

        for (int i = 0, imax = comps.Length; i < imax; ++i)
        {
            MonoBehaviour mb = comps[i];
            if (mb == null)
            {
                continue;
            }

            MethodInfo[] methods = mb.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static);

            for (int b = 0; b < methods.Length; ++b)
            {
                MethodInfo mi = methods[b];
                if (mi.ReturnType == typeof(void))
                {
                    ParameterInfo[] infos = mi.GetParameters();
                    string          param = "";
                    for (int j = 0; j < infos.Length; j++)
                    {
                        param += infos[j].ParameterType.ToString();
                        if (j == (infos.Length - 1))
                        {
                            break;
                        }
                        param += ";";
                    }
                    param = string.Format("({0})", param);
                    string name = mi.Name;
                    if (name == "Invoke")
                    {
                        continue;
                    }
                    if (name == "InvokeRepeating")
                    {
                        continue;
                    }
                    if (name == "CancelInvoke")
                    {
                        continue;
                    }
                    if (name == "StopCoroutine")
                    {
                        continue;
                    }
                    if (name == "StopAllCoroutines")
                    {
                        continue;
                    }
                    if (name == "BroadcastMessage")
                    {
                        continue;
                    }
                    if (name.StartsWith("SendMessage"))
                    {
                        continue;
                    }
                    if (name.StartsWith("set_"))
                    {
                        continue;
                    }
                    Entry ent = new Entry();
                    ent.target     = mb;
                    ent.name       = mi.Name;
                    ent.extendName = mi.Name + param;
                    ent.paramTypes = EditorTool.GetFuncParamType(param);
                    list.Add(ent);
                }
            }
        }
        return(list);
    }