Beispiel #1
0
        private void DrawScript(Type t)
        {
            var att = t.RTGetAttribute <QuickExecuteAttribute>(false);

            if (att == null)
            {
                return;
            }
            GL.BeginVertical("OL box");
            GL.Label(t.Name, EditorStyles.boldLabel);
            var methods = t.GetMethods().Where((i) => { return(i.RTGetAttribute <ExecuteMethodAttribute>(false) != null); });

            if (methods.Count() < 1)
            {
                EGL.HelpBox("没有可以被执行的方法(请检查是否添加了[ExecuteMethodAttribute])", MessageType.Warning);
            }
            else
            {
                foreach (var m in methods)
                {
                    GL.Space(2);
                    GL.BeginHorizontal();
                    var methodName = m.Name + ":(";
                    var param      = m.GetParameters();
                    for (int i = 0; i < param.Length; i++)
                    {
                        var p = param[i];
                        if (i != param.Length - 1)
                        {
                            methodName += string.Format("<b>{0}</b> , ", p.ToString());
                        }
                        else
                        {
                            methodName += string.Format("<b>{0}</b>", p.ToString());
                        }
                    }
                    methodName += ")";
                    GL.Label(methodName);
                    if (GL.Button("Execute", GUILayout.Width(100)))
                    {
                        var o = ReflectionTools.CreateObject(t);
                        //TODO 扩展编辑参数
                        if (param.Length == 0)
                        {
                            m.Invoke(o, null);
                        }
                        Log.I(string.Format("<color=#FFA80B>Execute {0}</color>", methodName));
                    }
                    GL.EndHorizontal();
                    GL.Space(2);
                }
            }
            GL.EndVertical();
        }