Esempio n. 1
0
            static private CachedSelectionList GetList(EightCCSelectorAttribute inSelector)
            {
                CachedSelectionList list;
                Type cachingType = inSelector.GetCachingType();

                if (cachingType != null)
                {
                    if (!s_CachedLists.TryGetValue(cachingType, out list))
                    {
                        list = new CachedSelectionList(inSelector);
                        s_CachedLists.Add(cachingType, list);
                    }
                    return(list);
                }
                else
                {
                    return(new CachedSelectionList(inSelector));
                }
            }
Esempio n. 2
0
            public CachedSelectionList(EightCCSelectorAttribute inSelector)
            {
                List <Registry> registries = new List <Registry>();

                foreach (var type in inSelector.Types)
                {
                    Registry r = GetRegistry(type, false, true);
                    if (r != null)
                    {
                        registries.Add(r);
                    }
                }

                if (registries.Count == 0)
                {
                    m_Options = new EightCC[] { EightCC.Zero };
                    m_Content = new GUIContent[] { new GUIContent("[empty]") };
                }
                else
                {
                    List <RegistryEntry> entries = new List <RegistryEntry>();
                    foreach (var registry in registries)
                    {
                        registry.CopyEntries(entries);
                    }
                    entries.Sort();

                    m_Options = new EightCC[entries.Count + 1];
                    m_Content = new GUIContent[entries.Count + 1];

                    m_Options[0] = EightCC.Zero;
                    m_Content[0] = new GUIContent("[empty]");

                    for (int i = 0; i < entries.Count; ++i)
                    {
                        m_Options[i + 1] = entries[i].Value;
                        m_Content[i + 1] = new GUIContent(entries[i].Display, entries[i].Tooltip);
                    }
                }
            }
Esempio n. 3
0
            public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
            {
                CachedSelectionList list = null;

                EightCCSelectorAttribute selector = this.attribute as EightCCSelectorAttribute;
                bool bShowDebug = true;

                if (selector != null)
                {
                    list       = GetList(selector);
                    bShowDebug = selector.ShowDebug;
                }

                SerializedProperty valueProp = property.FindPropertyRelative("m_Value");

                Rect labelRect    = position;
                Rect indentedRect = EditorGUI.IndentedRect(labelRect);

                label = EditorGUI.BeginProperty(labelRect, label, property);

                if (!string.IsNullOrEmpty(label.text))
                {
                    labelRect.width    = EditorGUIUtility.labelWidth;
                    indentedRect.x     = labelRect.xMax;
                    indentedRect.width = position.xMax - indentedRect.xMin;
                    EditorGUI.LabelField(labelRect, label);
                }

                int prevIndent = EditorGUI.indentLevel;

                {
                    EditorGUI.indentLevel = 0;

                    Rect fieldRect = indentedRect;

                    if (bShowDebug)
                    {
                        fieldRect.width -= VALUE_WIDTH;
                    }

                    if (list != null)
                    {
                        DropdownInput(fieldRect, list, valueProp);
                    }
                    else
                    {
                        StringInput(fieldRect, valueProp);
                    }

                    if (bShowDebug)
                    {
                        Rect valueRect = indentedRect;
                        valueRect.x    += valueRect.width - VALUE_WIDTH;
                        valueRect.width = VALUE_WIDTH;

                        ValueDisplay(valueRect, valueProp);
                    }
                }
                EditorGUI.indentLevel = prevIndent;

                EditorGUI.EndProperty();
            }