コード例 #1
0
    private void OnEnable()
    {
        playerPrefGroup = target as PlayerPrefGroup;

        filterList = new OnionReorderableList(new SerializedObject(playerPrefGroup).FindProperty("regexFilter"))
        {
            title     = "Regex Filters",
            titleIcon = OnionDataEditor.GetIconTexture("Filter"),
        };

        customGUIList = new OnionReorderableList(new SerializedObject(playerPrefGroup).FindProperty("customGUI"))
        {
            title     = "Custom GUI Type",
            titleIcon = OnionDataEditor.GetIconTexture("Filter"),
            customGUI = CustomItemGUI,
        };


        void CustomItemGUI(Rect r, SerializedProperty sp, int index)
        {
            var rs = r.HorizontalSplit(2, 4);

            EditorGUI.PropertyField(rs[0], sp.FindPropertyRelative("regexFilter"), GUIContent.none);
            EditorGUI.PropertyField(rs[1], sp.FindPropertyRelative("guiType"), GUIContent.none);
        }
    }
コード例 #2
0
    private void OnEnable()
    {
        assetFilterGroup = target as AssetFilterGroup;

        filterList = new OnionReorderableList(new SerializedObject(assetFilterGroup).FindProperty("filters"))
        {
            title         = "Filters",
            emptyListHint = "No filter",
            customGUI     = itemGUI,
            titleIcon     = OnionDataEditor.GetIconTexture("Filter"),
        };

        searchFolderList = new OnionReorderableList(new SerializedObject(assetFilterGroup).FindProperty("searchFolders"))
        {
            title         = "Search Folders",
            emptyListHint = "Search all folders",
            titleIcon     = OnionDataEditor.GetIconTexture("Folder"),
        };


        void itemGUI(Rect r, SerializedProperty sp, int inx)
        {
            if (string.IsNullOrEmpty(assetFilterGroup.filters[inx].value))
            {
                //IS NULL
                GUI.color = new Color(1F, 0.8F, 0.8F);
            }

            const float objWidth   = 150;
            const float spaceWidth = 10;

            Rect objRect = r;

            objRect.width = objWidth;

            Rect pathRect = r;

            pathRect.x     += objWidth + spaceWidth;
            pathRect.width -= objWidth + spaceWidth;

            using (var ch = new EditorGUI.ChangeCheckScope())
            {
                var o = EditorGUI.EnumPopup(objRect, assetFilterGroup.filters[inx].type);
                if (ch.changed)
                {
                    assetFilterGroup.filters[inx].type = (AssetFilterGroup.FilterType)o;
                }
            }

            using (var ch = new EditorGUI.ChangeCheckScope())
            {
                var p = GUI.TextField(pathRect, assetFilterGroup.filters[inx].value);
                if (ch.changed)
                {
                    assetFilterGroup.filters[inx].value = p;
                }
            }


            GUI.color = Color.white;
        }
    }