Пример #1
0
        void OnGUI()
        {
            _scroll_pos = EditorGUILayout.BeginScrollView(_scroll_pos);
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button(_refresh_button, EditorStyles.toolbarButton))
            {
                FindIcons();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Found " + _icons.Count + " icons");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Double-click name to copy", TarfmagougouHelperUII.GetMiniGreyLabelStyle());

            EditorGUILayout.Space();

            EditorGUIUtility.labelWidth = 100;
            for (int i = 0; i < _icons.Count; ++i)
            {
                EditorGUILayout.LabelField(_icons[i].icon, _icons[i].name);

                if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.clickCount > 1)
                {
                    string clipText = "(Texture2D)EditorGUIUtility.IconContent(\"" + _icons[i].name.text + "\").image";
                    EditorGUIUtility.systemCopyBuffer = clipText;
                }
            }

            EditorGUILayout.EndScrollView();
        }
        void OnGUI()
        {
            _scroll_pos = EditorGUILayout.BeginScrollView(_scroll_pos);
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button(_refresh_button, EditorStyles.toolbarButton))
            {
                FindIcons();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Found " + _icons.Count + " icons");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Double-click name to copy", TarfmagougouHelperUII.GetMiniGreyLabelStyle());

            EditorGUILayout.Space();

            EditorGUIUtility.labelWidth = 100;

            var k   = 0;
            var con = 6;
            var raw = Mathf.CeilToInt(_icons.Count / con);

            for (int j = 0; j < raw; j++)
            {
                using (var hor = new EditorGUILayout.HorizontalScope())
                {
                    for (int i = 0; i < con; ++i)
                    {
                        if (_icons[k].icon.image == null)
                        {
                            continue;
                        }
                        var btn = GUILayout.Button(_icons[k].icon /*, _icons[i].name*/);
                        if (btn)
                        {
                            EditorGUIUtility.systemCopyBuffer = _icons[k].name.text;
                            Debug.Log(_icons[k].name.text + " copied to clipboard.");
                        }
                        k++;
                        if (k == _icons.Count)
                        {
                            break;
                        }
                    }
                }
            }


            EditorGUILayout.EndScrollView();
        }
Пример #3
0
        void OnGUI()
        {
            _search = EditorGUILayout.TextField(_search);
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            if (GUILayout.Button(_refresh_button, EditorStyles.toolbarButton))
            {
                FindIcons();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Found " + _icons.Count + " icons");
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField("Double-click name to copy", TarfmagougouHelperUII.GetMiniGreyLabelStyle());

            _scroll_pos = EditorGUILayout.BeginScrollView(_scroll_pos);
            EditorGUILayout.Space();

            var filteredIcons = string.IsNullOrEmpty(_search)
                ? _icons
                : _icons.Where(x => x.name.text.Contains(_search)).ToList();


            EditorGUIUtility.labelWidth = 100;
            for (int i = 0; i < filteredIcons.Count; ++i)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(new GUIContent(EditorGUIUtility.FindTexture("SceneLoadIn")), (GUIStyle)"RL FooterButton", GUILayout.Width(24)))
                {
                    var savePath = EditorUtility.SaveFilePanel("Save Icon", Application.dataPath, filteredIcons[i].name.text, "png");
                    if (!string.IsNullOrEmpty(savePath))
                    {
                        SaveTexture(savePath, (Texture2D)filteredIcons[i].icon.image);
                    }
                }
                EditorGUILayout.LabelField(filteredIcons[i].icon, filteredIcons[i].name);
                GUILayout.EndHorizontal();

                if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown && Event.current.clickCount > 1)
                {
                    EditorGUIUtility.systemCopyBuffer = filteredIcons[i].name.text;
                    Debug.Log(filteredIcons[i].name.text + " copied to clipboard.");
                }
            }

            EditorGUILayout.EndScrollView();
        }