Beispiel #1
0
        private EditorMember(MemberInfo memberInfo, Type memberType, string memberName,
                             object rawTarget, UnityObject unityTarget, int targetId, Attribute[] attributes)
        {
            Info         = memberInfo;
            Type         = memberType;
            RawTarget    = rawTarget;
            Name         = memberName;
            TypeNiceName = memberType.GetNiceName();
            UnityTarget  = unityTarget;
            Attributes   = attributes ?? Empty;

            string displayFormat = null;

            var formatAttr = Attributes.GetAttribute <DisplayAttribute>();

            if (formatAttr != null && !string.IsNullOrEmpty(formatAttr.FormatLabel))
            {
                displayFormat = formatAttr.FormatLabel;
            }

            var settings = VFWSettings.GetInstance();

            if (displayFormat == null)
            {
                if (Type.IsImplementerOfRawGeneric(typeof(IDictionary <,>)))
                {
                    displayFormat = settings.DefaultDictionaryFormat;
                }
                else if (Type.IsImplementerOfRawGeneric(typeof(IList <>)))
                {
                    displayFormat = settings.DefaultSequenceFormat;
                }
                else
                {
                    displayFormat = settings.DefaultMemberFormat;
                }
            }

            var iter = Formatters.GetEnumerator();

            while (iter.MoveNext())
            {
                var pair    = iter.Current;
                var pattern = pair.Key;
                var result  = pair.Value(this);
                displayFormat = Regex.Replace(displayFormat, pattern, result, RegexOptions.IgnoreCase);
            }

            DisplayText = displayFormat;

            Id = RuntimeHelper.CombineHashCodes(targetId, TypeNiceName, DisplayText);
        }
Beispiel #2
0
 public static void SelectSettings()
 {
     Selection.activeObject = VFWSettings.GetInstance();
 }
Beispiel #3
0
        private EditorMember(MemberInfo memberInfo, Type memberType, string memberName,
                             object rawTarget, UnityObject unityTarget, int targetId, Attribute[] attributes)
        {
            if (attributes == null)
            {
                attributes = Empty;
            }
            else
            {
                ResolveUsing(ref attributes);
            }

            Info         = memberInfo;
            Type         = memberType;
            RawTarget    = rawTarget;
            TypeNiceName = memberType.GetNiceName();
            Name         = memberName;
            NiceName     = Formatters[@"\$nicename"].Invoke(this);
            UnityTarget  = unityTarget;
            Attributes   = attributes;

            string displayFormat = null;

            var displayAttr = attributes.GetAttribute <DisplayAttribute>();

            if (displayAttr != null && MemberDrawersHandler.IsApplicableAttribute(memberType, displayAttr, attributes))
            {
                displayFormat = displayAttr.FormatLabel;
            }

            var settings = VFWSettings.GetInstance();

            if (displayFormat == null)
            {
                if (Type.IsImplementerOfRawGeneric(typeof(IDictionary <,>)))
                {
                    displayFormat = settings.DictionaryFormat;
                }
                else if (Type.IsImplementerOfRawGeneric(typeof(IList <>)))
                {
                    displayFormat = settings.SequenceFormat;
                }
                else
                {
                    displayFormat = settings.MemberFormat;
                }
            }

            var iter = Formatters.GetEnumerator();

            while (iter.MoveNext())
            {
                var pair    = iter.Current;
                var pattern = pair.Key;
                var result  = pair.Value(this);
                displayFormat = Regex.Replace(displayFormat, pattern, result, RegexOptions.IgnoreCase);
            }

            DisplayText = displayFormat;

            Id = RuntimeHelper.CombineHashCodes(targetId, TypeNiceName, DisplayText);
        }