コード例 #1
0
ファイル: Utility.cs プロジェクト: klj35/TextureProcessor
 public static void ResizeToMultipleOf4All()
 {
     if (EditorUtility.DisplayDialog("Prompt", "Are you sure you want to resize to multiple of 4 at all texture2d? this is maybe time consuming!", "Yes", "No"))
     {
         List <TextrueResizeFeedback> feedbacks = null;
         TimeSpan timeSpan = ExecutionInTimeMonitor(() =>
         {
             TextureResizer resizer = new TextureResizer();
             feedbacks = resizer.ResizeToMultipleOf4();
             resizer.Dispose();
         });
         TextrueResizeFeedbackWindow.OpenWindow(feedbacks, timeSpan);
     }
 }
コード例 #2
0
        /// <summary>
        /// 所有纹理代理GUI
        /// </summary>
        private void OnAgentsGUI()
        {
            if (_textureResizer != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("All Texture In: " + _folderPath);
                GUILayout.FlexibleSpace();
                string nameFilter = EditorGUILayout.TextField("", _nameFilter, "SearchTextField", GUILayout.Width(180));
                if (nameFilter != _nameFilter)
                {
                    _nameFilter = nameFilter;
                    ResetDisplayAgents();
                }
                if (GUILayout.Button("", _nameFilter != "" ? "SearchCancelButton" : "SearchCancelButtonEmpty", GUILayout.Width(20)))
                {
                    if (_nameFilter != "")
                    {
                        _nameFilter = "";
                        ResetDisplayAgents();
                        GUI.FocusControl(null);
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Total: [" + _agents.Count + "]");
                GUILayout.Space(20);
                GUILayout.Label("Current Page Raw: [" + _rawNumber + "]");
                GUILayout.FlexibleSpace();
                _isResizePng = GUILayout.Toggle(_isResizePng, "png");
                _isResizeJpg = GUILayout.Toggle(_isResizeJpg, "jpg");
                _isResizeTga = GUILayout.Toggle(_isResizeTga, "tga");
                if (GUILayout.Button("Resize To Multiple Of 4", EditorStyles.miniButton))
                {
                    if (EditorUtility.DisplayDialog("Prompt", "Are you sure you want to resize to multiple of 4 at all raw texture2d? this is maybe time consuming!", "Yes", "No"))
                    {
                        List <TextrueResizeFeedback> feedbacks = null;
                        TimeSpan timeSpan = Utility.ExecutionInTimeMonitor(() =>
                        {
                            feedbacks = _textureResizer.ResizeToMultipleOf4(_isResizePng, _isResizeJpg, _isResizeTga);
                        });
                        TextrueResizeFeedbackWindow.OpenWindow(feedbacks, timeSpan);
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginVertical("HelpBox");
                _scroll    = GUILayout.BeginScrollView(_scroll);
                _rawNumber = 0;
                for (int i = 0; i < _textureCount; i += 6)
                {
                    GUILayout.BeginHorizontal();
                    for (int j = 0; j < 6; j++)
                    {
                        int index = _currentPage * _textureCount + i + j;
                        if (index < _agents.Count)
                        {
                            TextureResizeAgent agent = _agents[index];
                            if (agent.Value == null)
                            {
                                RemoveAgent(agent);
                                j--;
                                continue;
                            }
                            bool isStandard = agent.IsMultipleOf4;
                            if (!isStandard)
                            {
                                _rawNumber += 1;
                            }
                            OnTextureGUI(agent, isStandard);
                        }
                    }
                    GUILayout.EndHorizontal();
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Prev Page", EditorStyles.miniButton))
                {
                    PrevPage();
                }
                GUILayout.Label((_currentPage + 1) + "/" + _totalPage);
                if (GUILayout.Button("Next Page", EditorStyles.miniButton))
                {
                    NextPage();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                KeyboardEvent();
            }
            else
            {
                EditorGUILayout.HelpBox("Please select a target folder, and click 'Search' button to process all texture in target folder!", MessageType.Info);
            }
        }