コード例 #1
0
ファイル: NodeBrowser.cs プロジェクト: hagusen/AI-Testing
        public static string GetRichMemberName(MemberInfo member)
        {
            if (uNodePreference.GetPreference().coloredItem)
            {
                Type type = member as Type;
                if (type != null)
                {
                    if (type.IsEnum)
                    {
                        return(uNodeUtility.WrapTextWithColor(type.PrettyName(), uNodePreference.GetPreference().itemEnumColor, false));
                    }
                    else if (type.IsInterface)
                    {
                        return(uNodeUtility.WrapTextWithColor(type.PrettyName(), uNodePreference.GetPreference().itemInterfaceColor, false));
                    }
                    return(uNodeUtility.WrapTextWithColor(type.PrettyName(), uNodePreference.GetPreference().itemTypeColor, false));
                }
                switch (member.MemberType)
                {
                case MemberTypes.Method:
                    return(GetRichMethodName(member as MethodInfo, false));

                case MemberTypes.Constructor:
                    return(GetRichConstructorNames(member as ConstructorInfo));
                }
            }
            switch (member.MemberType)
            {
            case MemberTypes.Method:
                return(EditorReflectionUtility.GetOverloadingMethodNames(member as MethodInfo, false));

            case MemberTypes.Constructor:
                return(EditorReflectionUtility.GetOverloadingConstructorNames(member as ConstructorInfo));

            case MemberTypes.TypeInfo:
            case MemberTypes.NestedType:
                return((member as Type).PrettyName());
            }
            return(member.Name);
        }
コード例 #2
0
        private void ResolveMethodTooltip(MethodBase methodBase, int numOfOverload, List <GUIContent> contents)
        {
            if (methodBase is MethodInfo)
            {
                contents.Add(new GUIContent(
                                 EditorReflectionUtility.GetOverloadingMethodNames(methodBase as MethodInfo),
                                 uNodeEditorUtility.GetIcon(methodBase)));
            }
            else if (methodBase is ConstructorInfo)
            {
                contents.Add(new GUIContent(
                                 EditorReflectionUtility.GetOverloadingConstructorNames(methodBase as ConstructorInfo),
                                 uNodeEditorUtility.GetIcon(methodBase)));
            }
            var mType = ReflectionUtils.GetMemberType(methodBase);

            #region Docs
            if (uNodePreference.GetPreference().showDocumentation&& XmlDoc.hasLoadDoc)
            {
                XmlElement documentation = XmlDoc.XMLFromMember(methodBase);
                if (documentation != null)
                {
                    contents.Add(new GUIContent("Documentation ▼ " + documentation["summary"].InnerText.Trim().AddLineInFirst()));
                }
                var parameters = methodBase.GetParameters();
                if (parameters.Length > 0)
                {
                    for (int x = 0; x < parameters.Length; x++)
                    {
                        Type PType = parameters[x].ParameterType;
                        if (PType != null)
                        {
                            contents.Add(new GUIContent(parameters[x].Name + " : " +
                                                        uNodeUtility.GetDisplayName(PType),
                                                        uNodeEditorUtility.GetTypeIcon(PType)));
                            if (documentation != null && documentation["param"] != null)
                            {
                                XmlNode paramDoc = null;
                                XmlNode doc      = documentation["param"];
                                while (doc.NextSibling != null)
                                {
                                    if (doc.Attributes["name"] != null && doc.Attributes["name"].Value.Equals(parameters[x].Name))
                                    {
                                        paramDoc = doc;
                                        break;
                                    }
                                    doc = doc.NextSibling;
                                }
                                if (paramDoc != null && !string.IsNullOrEmpty(paramDoc.InnerText))
                                {
                                    contents.Add(new GUIContent(paramDoc.InnerText.Trim()));
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            //contents.Add(new GUIContent("Return	: " + mType.PrettyName(true), uNodeEditorUtility.GetTypeIcon(mType)));
            if (numOfOverload > 0)
            {
                contents.Add(new GUIContent("▲ " + (overrideIndex + 1).ToString() + " of " + numOfOverload + " ▼"));
            }
        }