Ejemplo n.º 1
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자 + Overall Menu가 아니라면..
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait || _editor.Select.SelectionType != apSelection.SELECTION_TYPE.Overall)
            {
                Debug.LogError("Exit - Editor / Portrait Missmatch");
                CloseDialog();
                return;
            }

            //여기서 체크 및 실행하자
            //Request => Process => Process 처리
            if (_exportProcessType == EXPORT_TYPE.None && _exportRequestType != EXPORT_TYPE.None)
            {
                _iProcess = 0;
                switch (_exportRequestType)
                {
                case EXPORT_TYPE.None:
                    break;

                case EXPORT_TYPE.Thumbnail:
                    _exportProcessType = EXPORT_TYPE.Thumbnail;
                    break;

                case EXPORT_TYPE.PNG:
                    _exportProcessType = EXPORT_TYPE.PNG;
                    break;

                case EXPORT_TYPE.GIFAnimation:
                    _exportProcessType = EXPORT_TYPE.GIFAnimation;
                    break;
                }

                _exportRequestType = EXPORT_TYPE.None;
            }
            switch (_exportProcessType)
            {
            case EXPORT_TYPE.None:
                break;

            case EXPORT_TYPE.Thumbnail:
                Process_MakeThumbnail();
                break;

            case EXPORT_TYPE.PNG:
                Process_PNGScreenShot();
                break;

            case EXPORT_TYPE.GIFAnimation:
                Process_MakeGIF();
                break;
            }

            _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(height));
            width  -= 24;
            EditorGUILayout.BeginVertical(GUILayout.Width(width));

            int settingWidth       = ((width - 10) / 3) - 4;
            int settingWidth_Label = 50;
            int settingWidth_Value = settingWidth - (50 + 8);
            int settingHeight      = 70;

            EditorGUILayout.LabelField("Setting");
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(settingHeight));
            GUILayout.Space(5);

            //Position
            //------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));


            EditorGUILayout.LabelField("Position", GUILayout.Width(settingWidth));
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("X", GUILayout.Width(settingWidth_Label));
            int posX = EditorGUILayout.DelayedIntField(_editor._captureFrame_PosX, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Y", GUILayout.Width(settingWidth_Label));
            int posY = EditorGUILayout.DelayedIntField(_editor._captureFrame_PosY, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
            //------------------------


            //Capture Size
            //------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));

            EditorGUILayout.LabelField("Capture Size", GUILayout.Width(settingWidth));
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Width", GUILayout.Width(settingWidth_Label));
            int srcSizeWidth = EditorGUILayout.DelayedIntField(_editor._captureFrame_SrcWidth, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Height", GUILayout.Width(settingWidth_Label));
            int srcSizeHeight = EditorGUILayout.DelayedIntField(_editor._captureFrame_SrcHeight, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();


            if (srcSizeWidth < 8)
            {
                srcSizeWidth = 8;
            }
            if (srcSizeHeight < 8)
            {
                srcSizeHeight = 8;
            }

            EditorGUILayout.EndVertical();


            //------------------------

            //File Size
            //-------------------------------
            EditorGUILayout.BeginVertical(GUILayout.Width(settingWidth), GUILayout.Height(settingHeight));

            EditorGUILayout.LabelField("File Size", GUILayout.Width(settingWidth));

            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Width", GUILayout.Width(settingWidth_Label));
            int dstSizeWidth = EditorGUILayout.DelayedIntField(_editor._captureFrame_DstWidth, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(settingWidth));
            EditorGUILayout.LabelField("Height", GUILayout.Width(settingWidth_Label));
            int dstSizeHeight = EditorGUILayout.DelayedIntField(_editor._captureFrame_DstHeight, GUILayout.Width(settingWidth_Value));

            EditorGUILayout.EndHorizontal();

            if (dstSizeWidth < 8)
            {
                dstSizeWidth = 8;
            }
            if (dstSizeHeight < 8)
            {
                dstSizeHeight = 8;
            }



            EditorGUILayout.EndVertical();
            //-------------------------------

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            int setting2CompWidth = ((width - 10) / 2) - 8;

            //Color와 AspectRatio
            EditorGUILayout.LabelField("BG Color", GUILayout.Width(80));
            Color prevCaptureColor = _editor._captureFrame_Color;

            try
            {
                _editor._captureFrame_Color = EditorGUILayout.ColorField(_editor._captureFrame_Color, GUILayout.Width(setting2CompWidth - 86));
            }
            catch (Exception) { }


            GUILayout.Space(30);
            if (apEditorUtil.ToggledButton_2Side("Aspect Ratio Fixed", "Aspect Ratio Not Fixed", _editor._isCaptureAspectRatioFixed, true, setting2CompWidth - 20, 20))
            {
                _editor._isCaptureAspectRatioFixed = !_editor._isCaptureAspectRatioFixed;

                if (_editor._isCaptureAspectRatioFixed)
                {
                    //AspectRatio를 굳혔다.
                    //Dst계열 변수를 Src에 맞춘다.
                    //Height를 고정, Width를 맞춘다.
                    _editor._captureFrame_DstWidth = GetAspectRatio_Width(_editor._captureFrame_DstHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    dstSizeWidth = _editor._captureFrame_DstWidth;
                }

                _editor.SaveEditorPref();


                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();


            //AspectRatio를 맞추어보자
            if (_editor._isCaptureAspectRatioFixed)
            {
                if (srcSizeWidth != _editor._captureFrame_SrcWidth)
                {
                    //Width가 바뀌었다. => Height를 맞추자
                    srcSizeHeight = GetAspectRatio_Height(srcSizeWidth, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    //>> Dst도 바꾸자 => Width
                    dstSizeWidth = GetAspectRatio_Width(dstSizeHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                }
                else if (srcSizeHeight != _editor._captureFrame_SrcHeight)
                {
                    //Height가 바뀌었다. => Width를 맞추자
                    srcSizeWidth = GetAspectRatio_Width(srcSizeHeight, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                    //>> Dst도 바꾸자 => Height
                    dstSizeHeight = GetAspectRatio_Height(dstSizeWidth, _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight);
                }
                else if (dstSizeWidth != _editor._captureFrame_DstWidth)
                {
                    //Width가 바뀌었다. => Height를 맞추자
                    dstSizeHeight = GetAspectRatio_Height(dstSizeWidth, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                    //>> Src도 바꾸다 => Width
                    srcSizeWidth = GetAspectRatio_Width(srcSizeHeight, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                }
                else if (dstSizeHeight != _editor._captureFrame_DstHeight)
                {
                    //Height가 바뀌었다. => Width를 맞추자
                    dstSizeWidth = GetAspectRatio_Width(dstSizeHeight, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                    //>> Dst도 바꾸자 => Height
                    srcSizeHeight = GetAspectRatio_Height(srcSizeWidth, _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight);
                }
            }

            if (posX != _editor._captureFrame_PosX ||
                posY != _editor._captureFrame_PosY ||
                srcSizeWidth != _editor._captureFrame_SrcWidth ||
                srcSizeHeight != _editor._captureFrame_SrcHeight ||
                dstSizeWidth != _editor._captureFrame_DstWidth ||
                dstSizeHeight != _editor._captureFrame_DstHeight
                )
            {
                _editor._captureFrame_PosX      = posX;
                _editor._captureFrame_PosY      = posY;
                _editor._captureFrame_SrcWidth  = srcSizeWidth;
                _editor._captureFrame_SrcHeight = srcSizeHeight;
                _editor._captureFrame_DstWidth  = dstSizeWidth;
                _editor._captureFrame_DstHeight = dstSizeHeight;

                _editor.SaveEditorPref();
                apEditorUtil.ReleaseGUIFocus();
            }

            if (prevCaptureColor.r != _editor._captureFrame_Color.r ||
                prevCaptureColor.g != _editor._captureFrame_Color.g ||
                prevCaptureColor.b != _editor._captureFrame_Color.b)
            {
                _editor.SaveEditorPref();
                //색상은 GUIFocus를 null로 만들면 안되기에..
            }



            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);

            EditorGUILayout.LabelField("Thumbnail Capture");
            GUILayout.Space(5);

            EditorGUILayout.LabelField("File Path");
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
            GUILayout.Space(5);
            GUILayout.Box(_editor._portrait._thumbnailImage, GUI.skin.label, GUILayout.Width(50), GUILayout.Height(25));
            _editor._portrait._imageFilePath_Thumbnail = EditorGUILayout.TextField(_editor._portrait._imageFilePath_Thumbnail, GUILayout.Width(width - (130)));
            if (GUILayout.Button("Change", GUILayout.Width(60)))
            {
                string fileName = EditorUtility.SaveFilePanelInProject("Thumbnail File Path", _editor._portrait.name + "_Thumb.png", "png", "Please Enter a file name to save Thumbnail to");
                if (!string.IsNullOrEmpty(fileName))
                {
                    _editor._portrait._imageFilePath_Thumbnail = fileName;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Make Thumbnail", GUILayout.Width(width), GUILayout.Height(30)))
            {
                if (string.IsNullOrEmpty(_editor._portrait._imageFilePath_Thumbnail))
                {
                    //EditorUtility.DisplayDialog("Thumbnail Creating Failed", "File Name is Empty", "Close");
                    EditorUtility.DisplayDialog(_editor.GetText(apLocalization.TEXT.ThumbCreateFailed_Title),
                                                _editor.GetText(apLocalization.TEXT.ThumbCreateFailed_Body_NoFile),
                                                _editor.GetText(apLocalization.TEXT.Close)
                                                );
                }
                else
                {
                    RequestExport(EXPORT_TYPE.Thumbnail);
                    #region [비동기 스타일로 변경]
                    //int thumbnailWidth = 256;
                    //int thumbnailHeight = 128;

                    //float preferAspectRatio = (float)thumbnailWidth / (float)thumbnailHeight;

                    //float srcAspectRatio = (float)_editor._captureFrame_SrcWidth / (float)_editor._captureFrame_SrcHeight;
                    ////긴쪽으로 캡쳐 크기를 맞춘다.
                    //int srcThumbWidth = _editor._captureFrame_SrcWidth;
                    //int srcThumbHeight = _editor._captureFrame_SrcHeight;
                    ////AspectRatio = W / H
                    //if(srcAspectRatio < preferAspectRatio)
                    //{
                    //	//가로가 더 길군요.
                    //	//가로를 자릅시다.

                    //	//H = W / AspectRatio;
                    //	srcThumbHeight = (int)((srcThumbWidth / preferAspectRatio) + 0.5f);
                    //}
                    //else
                    //{
                    //	//세로가 더 길군요.
                    //	//세로를 자릅시다.
                    //	//W = AspectRatio * H
                    //	srcThumbWidth = (int)((srcThumbHeight * preferAspectRatio) + 0.5f);
                    //}


                    //Texture2D result = _editor.Exporter.RenderToTexture(_editor.Select.RootUnit._childMeshGroup,
                    //												(int)(_editor._captureFrame_PosX + apGL.WindowSizeHalf.x), (int)(_editor._captureFrame_PosY + apGL.WindowSizeHalf.y),
                    //												srcThumbWidth, srcThumbHeight,
                    //												thumbnailWidth, thumbnailHeight,
                    //												_editor._captureFrame_Color
                    //												);

                    //if (result != null)
                    //{
                    //	//이미지를 저장하자
                    //	//이건 Asset으로 자동 저장
                    //	string filePathWOExtension = _editor._portrait._imageFilePath_Thumbnail.Substring(0, _editor._portrait._imageFilePath_Thumbnail.Length - 4);
                    //	bool isSaveSuccess = _editor.Exporter.SaveTexture2DToPNG(result, filePathWOExtension, true);

                    //	if(isSaveSuccess)
                    //	{
                    //		AssetDatabase.Refresh();

                    //		_editor._portrait._thumbnailImage = AssetDatabase.LoadAssetAtPath<Texture2D>(_editor._portrait._imageFilePath_Thumbnail);
                    //	}
                    //}
                    #endregion
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);

            //Screenshot을 찍자
            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            EditorGUILayout.LabelField("Screenshot Capture");
            GUILayout.Space(5);
            if (GUILayout.Button("Take a Screenshot", GUILayout.Width(width), GUILayout.Height(30)))
            {
                RequestExport(EXPORT_TYPE.PNG);
            }

            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);


            //GIF Animation을 만들자
            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
            EditorGUILayout.LabelField("GIF Animation");
            GUILayout.Space(5);

            apRootUnit curRootUnit = _editor.Select.RootUnit;

            if (_curRootUnit != curRootUnit)
            {
                //AnimList 리셋
                _animClips.Clear();

                _curRootUnit = curRootUnit;
                if (_curRootUnit != null)
                {
                    for (int i = 0; i < _editor._portrait._animClips.Count; i++)
                    {
                        apAnimClip animClip = _editor._portrait._animClips[i];
                        if (animClip._targetMeshGroup == _curRootUnit._childMeshGroup)
                        {
                            _animClips.Add(animClip);
                        }
                    }
                }

                _selectedAnimClip = null;
            }
            if (curRootUnit == null)
            {
                _selectedAnimClip = null;
            }
            else
            {
                if (_selectedAnimClip != null && _animClips.Count > 0)
                {
                    if (!_animClips.Contains(_selectedAnimClip))
                    {
                        _selectedAnimClip = null;
                    }
                }
                else
                {
                    _selectedAnimClip = null;
                }
            }

            string animName    = "< Animation is not selected >";
            Color  animBGColor = new Color(1.0f, 0.7f, 0.7f, 1.0f);
            if (_selectedAnimClip != null)
            {
                animName    = _selectedAnimClip._name;
                animBGColor = new Color(0.7f, 1.0f, 0.7f, 1.0f);
            }

            Color    prevGUIColor = GUI.backgroundColor;
            GUIStyle guiStyleBox  = new GUIStyle(GUI.skin.box);
            guiStyleBox.alignment = TextAnchor.MiddleCenter;

            GUI.backgroundColor = animBGColor;

            GUILayout.Box(animName, guiStyleBox, GUILayout.Width(width), GUILayout.Height(30));

            GUI.backgroundColor = prevGUIColor;

            GUILayout.Space(5);
            int width_GIFSetting = (width - 32) / 2;

            int gifQuality = 256 - _editor._captureFrame_GIFSampleQuality;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            string strQuality = "";
            if (gifQuality > 200)
            {
                strQuality = "Quality [ High ]";
            }
            else if (gifQuality > 120)
            {
                strQuality = "Quality [ Medium ]";
            }
            else
            {
                strQuality = "Quality [ Low ]";
            }
            EditorGUILayout.LabelField(strQuality, GUILayout.Width(width_GIFSetting));
            GUILayout.Space(20);

            EditorGUILayout.LabelField("Loop Count", GUILayout.Width(width_GIFSetting));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            //10 ~ 256
            //246 ~ 0
            gifQuality = EditorGUILayout.IntSlider(gifQuality, 0, 246, GUILayout.Width(width_GIFSetting));

            gifQuality = 256 - gifQuality;
            if (_editor._captureFrame_GIFSampleQuality != gifQuality)
            {
                _editor._captureFrame_GIFSampleQuality = gifQuality;
                _editor.SaveEditorPref();
            }

            GUILayout.Space(20);

            int loopCount = EditorGUILayout.DelayedIntField(_editor._captureFrame_GIFSampleLoopCount, GUILayout.Width(width_GIFSetting));

            if (loopCount != _editor._captureFrame_GIFSampleLoopCount)
            {
                loopCount = Mathf.Clamp(loopCount, 1, 10);
                _editor._captureFrame_GIFSampleLoopCount = loopCount;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            //GUILayout.Space(10);

            //Rect lastRect_Progress = GUILayoutUtility.GetLastRect();

            //Rect barRect = new Rect(lastRect_Progress.x + 5, lastRect_Progress.y + 10, width - 5, 16);
            //float barRatio = 0.0f;
            //string strProcessName = "";
            //if(_exportProcessType == EXPORT_TYPE.GIFAnimation)
            //{
            //	barRatio = Mathf.Clamp01((float)_exportProcessX100 / 100.0f);
            //	strProcessName = "Exporting.. [ " + _exportProcessX100 + "% ]";
            //}

            ////EditorGUI.ProgressBar(barRect, barRatio, "Convert PSD Data To Editor..");

            //EditorGUI.ProgressBar(barRect, barRatio, strProcessName);
            //GUILayout.Space(20);


            if (apEditorUtil.ToggledButton_2Side("Take a GIF Animation", "Take a GIF Animation", false, (_selectedAnimClip != null), width, 30))
            {
                //RequestExport(EXPORT_TYPE.GIFAnimation);//리퀘스트 안할래..
                string defFileName  = "GIF_" + DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day + "_" + DateTime.Now.Hour + "" + DateTime.Now.Minute + "" + DateTime.Now.Second + ".gif";
                string saveFilePath = EditorUtility.SaveFilePanel("Save GIF Animation", _prevFilePath_Directory, defFileName, "gif");
                if (!string.IsNullOrEmpty(saveFilePath))
                {
                    bool result = _editor.Exporter.MakeGIFAnimation(saveFilePath,
                                                                    _editor.Select.RootUnit._childMeshGroup,
                                                                    _selectedAnimClip, _editor._captureFrame_GIFSampleLoopCount,
                                                                    (int)(_editor._captureFrame_PosX + apGL.WindowSizeHalf.x), (int)(_editor._captureFrame_PosY + apGL.WindowSizeHalf.y),
                                                                    _editor._captureFrame_SrcWidth, _editor._captureFrame_SrcHeight,
                                                                    _editor._captureFrame_DstWidth, _editor._captureFrame_DstHeight,
                                                                    _editor._captureFrame_Color,
                                                                    _editor._captureFrame_GIFSampleQuality
                                                                    );
                    if (result)
                    {
                        System.IO.FileInfo fi = new System.IO.FileInfo(saveFilePath);

                        Application.OpenURL("file://" + fi.Directory.FullName);
                        Application.OpenURL("file://" + saveFilePath);

                        _prevFilePath           = _editor.Exporter.GIF_FilePath;
                        _prevFilePath_Directory = fi.Directory.FullName;
                    }
                }
            }

            GUILayout.Space(10);

            GUIStyle guiStyle = new GUIStyle(GUIStyle.none);
            guiStyle.normal.textColor = GUI.skin.label.normal.textColor;

            GUILayout.Button("Animation Clips", guiStyle, GUILayout.Width(width), GUILayout.Height(20));            //투명 버튼


            //애니메이션 클립 리스트를 만들어야 한다.
            if (_animClips.Count > 0)
            {
                Texture2D iconImage = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation);

                apAnimClip nextSelectedAnimClip = null;
                for (int i = 0; i < _animClips.Count; i++)
                {
                    apAnimClip animClip = _animClips[i];

                    if (animClip == _selectedAnimClip)
                    {
                        Rect lastRect = GUILayoutUtility.GetLastRect();
                        prevCaptureColor = GUI.backgroundColor;

                        GUI.backgroundColor = new Color(0.4f, 0.8f, 1.0f, 1.0f);

                        GUI.Box(new Rect(lastRect.x, lastRect.y + 20, width, 20), "");
                        GUI.backgroundColor = prevGUIColor;
                    }

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                    GUILayout.Space(15);
                    if (GUILayout.Button(new GUIContent(" " + animClip._name, iconImage), guiStyle, GUILayout.Width(width - 35), GUILayout.Height(20)))
                    {
                        nextSelectedAnimClip = animClip;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (nextSelectedAnimClip != null)
                {
                    for (int i = 0; i < _editor._portrait._animClips.Count; i++)
                    {
                        _editor._portrait._animClips[i]._isSelectedInEditor = false;
                    }

                    nextSelectedAnimClip.LinkEditor(_editor._portrait);
                    nextSelectedAnimClip.RefreshTimelines();
                    nextSelectedAnimClip.SetFrame_Editor(nextSelectedAnimClip.StartFrame);
                    nextSelectedAnimClip.Pause_Editor();
                    nextSelectedAnimClip._isSelectedInEditor = true;
                    _selectedAnimClip = nextSelectedAnimClip;

                    _editor._portrait._animPlayManager.SetAnimClip_Editor(_selectedAnimClip);
                }
            }

            EditorGUILayout.EndVertical();
            GUILayout.Space(500);

            EditorGUILayout.EndScrollView();


            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
        }
Ejemplo n.º 2
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            width -= 10;
            //if (_editor == null)
            //{
            //	CloseDialog();
            //	return;
            //}

            ////만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            //if (_editor != apEditor.CurrentEditor)
            //{
            //	CloseDialog();
            //	return;
            //}


            //1. 로고
            //2. 버전
            //3. 데모 기능 제한 확인하기

            int   logoWidth  = _img_Logo.width;
            int   logoHeight = _img_Logo.height;
            int   boxHeight  = (int)((float)width * ((float)logoHeight / (float)logoWidth));
            Color prevColor  = GUI.backgroundColor;

            GUI.backgroundColor = Color.black;
            GUILayout.Box(_img_Logo, GUILayout.Width(width), GUILayout.Height(boxHeight));

            GUI.backgroundColor = prevColor;
            GUILayout.Space(5);

            if (_isFullVersion)
            {
                EditorGUILayout.LabelField(string.Format("Build : {0}", apVersion.I.APP_VERSION));
            }
            else
            {
                //"Demo Version : " + apVersion.I.APP_VERSION
                EditorGUILayout.LabelField(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_DemoVersion), apVersion.I.APP_VERSION));
            }
            GUILayout.Space(10);

            //풀 버전 : 로고 / 버전 / 홈페이지 /  닫기 / "다시 보이지 않음" (Toogle)
            //데모 버전 : 로고 / 버전 / 데모와 정품 차이 안내<- 이거 한글만 되어있다. / 닫기 / AssetStore 페이지
            if (_isFullVersion)
            {
                //홈페이지
                //데모 다운로드 안내
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_StartPage_Hompage), GUILayout.Width(width), GUILayout.Height(40)))                //"Check Limitations"
                {
                    //홈페이지로 갑시다.
                    Application.OpenURL("https://www.rainyrizzle.com");
                    CloseDialog();
                }
            }
            else
            {
                //데모 다운로드 안내
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_CheckLimitations), GUILayout.Width(width), GUILayout.Height(40)))                //"Check Limitations"
                {
                    //홈페이지로 갑시다.
                    if (_editor._language == apEditor.LANGUAGE.Korean)
                    {
                        Application.OpenURL("https://www.rainyrizzle.com/ap-demodownload-kor");
                    }
                    else
                    {
                        Application.OpenURL("https://www.rainyrizzle.com/ap-demodownload-eng");
                    }

                    CloseDialog();
                }
            }

            GUILayout.Space(5);

            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Width(width), GUILayout.Height(25)))           //"Close"
            {
                CloseDialog();
            }

            //왼쪽 : 에셋 스토어 또는 계속 시작

            GUILayout.Space(10);
            if (_isFullVersion)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_StartPage_AlawysOn), GUILayout.Width(width - (12 + 20)), GUILayout.Height(20));
                bool isShow = EditorGUILayout.Toggle(_editor._startScreenOption_IsShowStartup, GUILayout.Width(20), GUILayout.Height(20));
                if (_editor._startScreenOption_IsShowStartup != isShow)
                {
                    _editor._startScreenOption_IsShowStartup = isShow;
                    _editor.SaveEditorPref();
                }

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                if (GUILayout.Button("AssetStore", GUILayout.Width(width), GUILayout.Height(20)))
                {
                    //AssetStore 등록하면 여기에 넣자
                    Application.OpenURL("http://u3d.as/16c7");
                    CloseDialog();
                }
            }
        }
Ejemplo n.º 3
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                CloseDialog();
                return;
            }



            //Sorting Layer를 추가하자
            if (_sortingLayerNames == null || _sortingLayerIDs == null)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }
            else if (_sortingLayerNames.Length != SortingLayer.layers.Length ||
                     _sortingLayerIDs.Length != SortingLayer.layers.Length)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }

            for (int i = 0; i < SortingLayer.layers.Length; i++)
            {
                _sortingLayerNames[i] = SortingLayer.layers[i].name;
                _sortingLayerIDs[i]   = SortingLayer.layers[i].id;
            }


            int width_2Btn = (width - 14) / 2;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Bake), _tab == TAB.Bake, width_2Btn, 25))
            {
                _tab = TAB.Bake;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Setting), _tab == TAB.Options, width_2Btn, 25))
            {
                _tab = TAB.Options;
            }
            EditorGUILayout.EndHorizontal();


            if (_tab == TAB.Bake)
            {
                GUILayout.Space(5);

                // 1. Bake에 대한 UI
                //Bake 설정
                //EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_BakeSetting));//"Bake Setting"
                //GUILayout.Space(5);

                EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Portrait), _targetPortrait, typeof(apPortrait), true);                //"Portait"

                GUILayout.Space(5);

                //"Bake Scale"
                float prevBakeScale = _targetPortrait._bakeScale;
                _targetPortrait._bakeScale = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_BakeScale), _targetPortrait._bakeScale);

                //"Z Per Depth"
                float prevBakeZSize = _targetPortrait._bakeZSize;
                _targetPortrait._bakeZSize = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_ZPerDepth), _targetPortrait._bakeZSize);

                if (_targetPortrait._bakeZSize < 0.5f)
                {
                    _targetPortrait._bakeZSize = 0.5f;
                }

                if (prevBakeScale != _targetPortrait._bakeScale ||
                    prevBakeZSize != _targetPortrait._bakeZSize)
                {
                    apEditorUtil.SetEditorDirty();
                }


                //Bake 버튼
                GUILayout.Space(10);
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Bake), GUILayout.Height(45)))                //"Bake"
                {
                    GUI.FocusControl(null);

                    //CheckChangedProperties(nextRootScale, nextZScale);
                    apEditorUtil.SetEditorDirty();

                    //-------------------------------------
                    // Bake 함수를 실행한다. << 중요오오오오
                    //-------------------------------------

                    apBakeResult bakeResult = _editor.Controller.Bake();


                    _editor.Notification("[" + _targetPortrait.name + "] is Baked", false, false);

                    if (bakeResult.NumUnlinkedExternalObject > 0)
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                    _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                    _editor.GetText(TEXT.Okay));
                    }

                    //추가 3.29 : Bake 후에 Ambient를 체크하자
                    CheckAmbientAndCorrection();
                }

                GUILayout.Space(10);
                apEditorUtil.GUI_DelimeterBoxH(width - 10);
                GUILayout.Space(10);


                //최적화 Bake
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_OptimizedBaking));                //"Optimized Baking"

                //"Target"
                apPortrait nextOptPortrait = (apPortrait)EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Target), _targetPortrait._bakeTargetOptPortrait, typeof(apPortrait), true);

                if (nextOptPortrait != _targetPortrait._bakeTargetOptPortrait)
                {
                    //타겟을 바꾸었다.
                    bool isChanged = false;
                    if (nextOptPortrait != null)
                    {
                        //1. 다른 Portrait를 선택했다.
                        if (!nextOptPortrait._isOptimizedPortrait)
                        {
                            //1-1. 최적화된 객체가 아니다.
                            EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                        _editor.GetText(TEXT.OptBakeError_NotOptTarget_Body),
                                                        _editor.GetText(TEXT.Close));
                        }
                        else if (nextOptPortrait._bakeSrcEditablePortrait != _targetPortrait)
                        {
                            //1-2. 다른 대상으로부터 Bake된 Portrait같다. (물어보고 계속)
                            bool isResult = EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                                        _editor.GetText(TEXT.OptBakeError_SrcMatchError_Body),
                                                                        _editor.GetText(TEXT.Okay),
                                                                        _editor.GetText(TEXT.Cancel));

                            if (isResult)
                            {
                                //뭐 선택하겠다는데요 뭐..
                                isChanged = true;
                            }
                        }
                        else
                        {
                            //1-3. 오케이. 변경 가능
                            isChanged = true;
                        }
                    }
                    else
                    {
                        //2. 선택을 해제했다.
                        isChanged = true;
                    }

                    if (isChanged)
                    {
                        //Target을 변경한다.
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                        _targetPortrait._bakeTargetOptPortrait = nextOptPortrait;
                    }
                }

                string optBtnText = "";
                if (_targetPortrait._bakeTargetOptPortrait != null)
                {
                    //optBtnText = "Optimized Bake to\n[" + _targetPortrait._bakeTargetOptPortrait.gameObject.name + "]";
                    optBtnText = string.Format("{0}\n[{1}]", _editor.GetText(TEXT.DLG_OptimizedBakeTo), _targetPortrait._bakeTargetOptPortrait.gameObject.name);
                }
                else
                {
                    //optBtnText = "Optimized Bake\n(Make New GameObject)";
                    optBtnText = _editor.GetText(TEXT.DLG_OptimizedBakeMakeNew);
                }
                GUILayout.Space(10);

                if (GUILayout.Button(optBtnText, GUILayout.Height(45)))
                {
                    GUI.FocusControl(null);

                    //CheckChangedProperties(nextRootScale, nextZScale);


                    //Optimized Bake를 하자
                    apBakeResult bakeResult = _editor.Controller.OptimizedBake(_targetPortrait, _targetPortrait._bakeTargetOptPortrait);

                    if (bakeResult.NumUnlinkedExternalObject > 0)
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                    _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                    _editor.GetText(TEXT.Okay));
                    }

                    _editor.Notification("[" + _targetPortrait.name + "] is Baked (Optimized)", false, false);

                    //추가 3.29 : Bake 후에 Ambient를 체크하자
                    CheckAmbientAndCorrection();
                }
            }
            else
            {
                //Vector2 curScroll = (_tab == TAB.Bake) ? _scroll_Bake : _scroll_Options;

                _scroll_Options = EditorGUILayout.BeginScrollView(_scroll_Options, false, true, GUILayout.Width(width), GUILayout.Height(height - 30));

                EditorGUILayout.BeginVertical(GUILayout.Width(width - 24));
                GUILayout.Space(5);

                width -= 24;

                // 2. Option에 대한 UI
                //1. Gamma Space Space
                bool prevBakeGamma   = _editor._isBakeColorSpaceToGamma;
                int  iPrevColorSpace = prevBakeGamma ? 0 : 1;
                int  iNextColorSpace = EditorGUILayout.Popup(_editor.GetUIWord(UIWORD.ColorSpace), iPrevColorSpace, _colorSpaceNames);
                if (iNextColorSpace != iPrevColorSpace)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (iNextColorSpace == 0)
                    {
                        //Gamma
                        _editor._isBakeColorSpaceToGamma = true;
                    }
                    else
                    {
                        //Linear
                        _editor._isBakeColorSpaceToGamma = false;
                    }
                }

                GUILayout.Space(10);

                //2. Sorting Layer
                int prevSortingLayerID = _editor._portrait._sortingLayerID;
                int prevSortingOrder   = _editor._portrait._sortingOrder;
                apPortrait.SORTING_ORDER_OPTION prevSortingLayerOption = _editor._portrait._sortingOrderOption;

                int layerIndex = -1;
                for (int i = 0; i < SortingLayer.layers.Length; i++)
                {
                    if (SortingLayer.layers[i].id == _editor._portrait._sortingLayerID)
                    {
                        //찾았다.
                        layerIndex = i;
                        break;
                    }
                }
                if (layerIndex < 0)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);

                    //어라 레이어가 없는데용..
                    //초기화해야겠다.
                    _editor._portrait._sortingLayerID = -1;
                    if (SortingLayer.layers.Length > 0)
                    {
                        _editor._portrait._sortingLayerID = SortingLayer.layers[0].id;
                        layerIndex = 0;
                    }
                }
                int nextIndex = EditorGUILayout.Popup(_editor.GetText(TEXT.SortingLayer), layerIndex, _sortingLayerNames);                //"Sorting Layer"
                if (nextIndex != layerIndex)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    //레이어가 변경되었다.
                    if (nextIndex >= 0 && nextIndex < SortingLayer.layers.Length)
                    {
                        //LayerID 변경
                        _editor._portrait._sortingLayerID = SortingLayer.layers[nextIndex].id;
                    }
                }

                //추가 19.8.18 : Sorting Order를 지정하는 방식을 3가지 + 미적용 1가지로 더 세분화
                apPortrait.SORTING_ORDER_OPTION nextSortingLayerOption = (apPortrait.SORTING_ORDER_OPTION)EditorGUILayout.EnumPopup(_editor.GetText(TEXT.SortingOrderOption), _editor._portrait._sortingOrderOption);
                if (nextSortingLayerOption != _editor._portrait._sortingOrderOption)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _editor._portrait._sortingOrderOption = nextSortingLayerOption;
                }

                if (_editor._portrait._sortingOrderOption == apPortrait.SORTING_ORDER_OPTION.SetOrder)
                {
                    //Set Order인 경우에만 한정
                    int nextOrder = EditorGUILayout.IntField(_editor.GetText(TEXT.SortingOrder), _editor._portrait._sortingOrder);                    //"Sorting Order"
                    if (nextOrder != _editor._portrait._sortingOrder)
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                        _editor._portrait._sortingOrder = nextOrder;
                    }
                }

                GUILayout.Space(10);

                //3. 메카님 사용 여부

                //EditorGUILayout.LabelField("Animation Settings");
                bool   prevIsUsingMecanim = _targetPortrait._isUsingMecanim;
                string prevMecanimPath    = _targetPortrait._mecanimAnimClipResourcePath;
                _targetPortrait._isUsingMecanim = EditorGUILayout.Toggle(_editor.GetText(TEXT.IsMecanimAnimation), _targetPortrait._isUsingMecanim); //"Is Mecanim Animation"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.AnimationClipExportPath));                                                           //"Animation Clip Export Path"

                GUIStyle guiStyle_ChangeBtn = new GUIStyle(GUI.skin.button);
                guiStyle_ChangeBtn.margin = GUI.skin.textField.margin;
                guiStyle_ChangeBtn.border = GUI.skin.textField.border;

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(20));
                GUILayout.Space(5);
                EditorGUILayout.TextField(_targetPortrait._mecanimAnimClipResourcePath, GUILayout.Width(width - (70 + 15)));
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), guiStyle_ChangeBtn, GUILayout.Width(70), GUILayout.Height(18)))
                {
                    string nextPath = EditorUtility.SaveFolderPanel("Select to export animation clips", "", "");
                    if (!string.IsNullOrEmpty(nextPath))
                    {
                        if (apEditorUtil.IsInAssetsFolder(nextPath))
                        {
                            //유효한 폴더인 경우
                            //중요 : 경로가 절대 경로로 찍힌다.
                            //상대 경로로 바꾸자
                            apEditorUtil.PATH_INFO_TYPE pathInfoType = apEditorUtil.GetPathInfo(nextPath);
                            if (pathInfoType == apEditorUtil.PATH_INFO_TYPE.Absolute_InAssetFolder)
                            {
                                //절대 경로 + Asset 폴더 안쪽이라면
                                //Debug.LogError("절대 경로가 리턴 되었다. : " + nextPath);
                                nextPath = apEditorUtil.AbsolutePath2RelativePath(nextPath);
                                //Debug.LogError(">> 상대 경로로 변경 : " + nextPath);
                            }

                            apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_BakeOptionChanged, _editor, _targetPortrait, _targetPortrait, false);

                            _targetPortrait._mecanimAnimClipResourcePath = nextPath;
                        }
                        else
                        {
                            //유효한 폴더가 아닌 경우
                            //EditorUtility.DisplayDialog("Invalid Folder Path", "Invalid Clip Path", "Close");
                            EditorUtility.DisplayDialog(
                                _editor.GetText(TEXT.DLG_AnimClipSavePathValidationError_Title),
                                _editor.GetText(TEXT.DLG_AnimClipSavePathResetError_Body),
                                _editor.GetText(TEXT.Close));
                        }
                    }

                    GUI.FocusControl(null);
                }
                EditorGUILayout.EndHorizontal();



                GUILayout.Space(10);

                if (_guiContent_Setting_IsImportant == null)
                {
                    _guiContent_Setting_IsImportant = apGUIContentWrapper.Make(_editor.GetText(TEXT.DLG_Setting_IsImportant), false, "When this setting is on, it always updates and the physics effect works.");
                }
                if (_guiContent_Setting_FPS == null)
                {
                    _guiContent_Setting_FPS = apGUIContentWrapper.Make(_editor.GetText(TEXT.DLG_Setting_FPS), false, "This setting is used when <Important> is off");
                }



                //4. Important
                //"Is Important"
                bool nextImportant = EditorGUILayout.Toggle(_guiContent_Setting_IsImportant.Content, _targetPortrait._isImportant);
                if (nextImportant != _targetPortrait._isImportant)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._isImportant = nextImportant;
                }

                //"FPS (Important Off)"
                int nextFPS = EditorGUILayout.DelayedIntField(_guiContent_Setting_FPS.Content, _targetPortrait._FPS);
                if (_targetPortrait._FPS != nextFPS)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (nextFPS < 10)
                    {
                        nextFPS = 10;
                    }
                    _targetPortrait._FPS = nextFPS;
                }

                GUILayout.Space(10);

                //5. Billboard + Perspective

                apPortrait.BILLBOARD_TYPE nextBillboardType = (apPortrait.BILLBOARD_TYPE)EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Billboard), (int)_targetPortrait._billboardType, _billboardTypeNames);
                if (nextBillboardType != _targetPortrait._billboardType)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._billboardType = nextBillboardType;
                }

                //추가 19.9.24 : Billboard인 경우 카메라의 SortMode를 OrthoGraphic으로 강제할지 여부
                if (_targetPortrait._billboardType != apPortrait.BILLBOARD_TYPE.None)
                {
                    GUILayout.Space(2);
                    EditorGUILayout.BeginHorizontal(GUILayout.Width(width));

                    int      width_Value            = 30;
                    int      width_Label            = width - (width_Value + 10);
                    GUIStyle guiStyle_LabelWrapText = new GUIStyle(GUI.skin.label);
                    guiStyle_LabelWrapText.wordWrap = true;

                    GUILayout.Space(5);
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.SetSortMode2Orthographic), guiStyle_LabelWrapText, GUILayout.Width(width_Label));

                    bool nextForceSortModeToOrtho = EditorGUILayout.Toggle(_targetPortrait._isForceCamSortModeToOrthographic, GUILayout.Width(width_Value), GUILayout.Height(20));
                    if (nextForceSortModeToOrtho != _targetPortrait._isForceCamSortModeToOrthographic)
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                        _targetPortrait._isForceCamSortModeToOrthographic = nextForceSortModeToOrtho;
                    }

                    EditorGUILayout.EndHorizontal();
                }


                GUILayout.Space(10);

                //6. Shadow

                apPortrait.SHADOW_CASTING_MODE nextChastShadows = (apPortrait.SHADOW_CASTING_MODE)EditorGUILayout.EnumPopup(_editor.GetUIWord(UIWORD.CastShadows), _targetPortrait._meshShadowCastingMode);
                bool nextReceiveShaodw = EditorGUILayout.Toggle(_editor.GetUIWord(UIWORD.ReceiveShadows), _targetPortrait._meshReceiveShadow);
                if (nextChastShadows != _targetPortrait._meshShadowCastingMode ||
                    nextReceiveShaodw != _targetPortrait._meshReceiveShadow)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._meshShadowCastingMode = nextChastShadows;
                    _targetPortrait._meshReceiveShadow     = nextReceiveShaodw;
                }

                GUILayout.Space(10);

                //#if UNITY_2018_1_OR_NEWER
                //변경 19.6.22 : LWRP 기능은 삭제
                //Material Library를 열도록 하자
                //>> 다시 변경 19.8.5 : Clipped Mesh 땜시 다시 열자

                //7. LWRP
                //LWRP 쉐이더를 쓸지 여부와 다시 강제로 생성하기 버튼을 만들자. : 이건 2019부터 적용 (그 전에는 SRP용 처리가 안된다.)
#if UNITY_2019_1_OR_NEWER
                bool prevUseLWRP  = _editor._isUseSRP;
                int  iPrevUseLWRP = prevUseLWRP ? 1 : 0;
                int  iNextUseLWRP = EditorGUILayout.Popup(_editor.GetText(TEXT.RenderPipeline), iPrevUseLWRP, _renderPipelineNames);               //"Render Pipeline"
                if (iNextUseLWRP != iPrevUseLWRP)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (iNextUseLWRP == 0)
                    {
                        //사용 안함
                        _editor._isUseSRP = false;
                    }
                    else
                    {
                        //LWRP 사용함
                        _editor._isUseSRP = true;
                    }
                }
                GUILayout.Space(10);
#endif
                //if(GUILayout.Button("Generate Lightweight Shaders"))
                //{
                //	apShaderGenerator shaderGenerator = new apShaderGenerator();
                //	shaderGenerator.GenerateLWRPShaders();
                //}

                //GUILayout.Space(10);
                //#endif

                //8. VR Supported 19.9.24 추가
                //VR Supported
                int iNextVRSupported = EditorGUILayout.Popup(_editor.GetText(TEXT.VROption), (int)_targetPortrait._vrSupportMode, _vrSupportModeLabel);
                if (iNextVRSupported != (int)_targetPortrait._vrSupportMode)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._vrSupportMode = (apPortrait.VR_SUPPORT_MODE)iNextVRSupported;
                }

                if (_targetPortrait._vrSupportMode == apPortrait.VR_SUPPORT_MODE.SingleCamera)
                {
                    //Single Camera인 경우, Clipping Mask의 크기를 결정해야한다.
                    int iNextVRRTSize = EditorGUILayout.Popup(_editor.GetUIWord(UIWORD.MaskTextureSize), (int)_targetPortrait._vrRenderTextureSize, _vrRTSizeLabel);
                    if (iNextVRRTSize != (int)_targetPortrait._vrRenderTextureSize)
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                        _targetPortrait._vrRenderTextureSize = (apPortrait.VR_RT_SIZE)iNextVRRTSize;
                    }
                }

                GUILayout.Space(10);


                //11.7 추가 : Ambient Light를 검은색으로 만든다.

                if (GUILayout.Button(_editor.GetText(TEXT.DLG_AmbientToBlack), GUILayout.Height(20)))
                {
                    MakeAmbientLightToBlack();
                }

                //CheckChangedProperties(nextRootScale, nextZScale);
                if (prevSortingLayerID != _editor._portrait._sortingLayerID ||
                    prevSortingOrder != _editor._portrait._sortingOrder ||
                    prevSortingLayerOption != _editor._portrait._sortingOrderOption ||
                    prevIsUsingMecanim != _targetPortrait._isUsingMecanim ||
                    !string.Equals(prevMecanimPath, _targetPortrait._mecanimAnimClipResourcePath) ||
                    prevBakeGamma != _editor._isBakeColorSpaceToGamma
#if UNITY_2019_1_OR_NEWER
                    || prevUseLWRP != _editor._isUseSRP
#endif
                    )
                {
                    apEditorUtil.SetEditorDirty();
                    _editor.SaveEditorPref();
                }

                GUILayout.Space(height + 500);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndScrollView();
            }

            GUILayout.Space(5);
        }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            bool isChanged = false;

            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                //Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //int height_top = 30;
            //int height_bottom = 35 + 40;
            //int height_middle = height - (height_top + height_bottom);
            int height_middle = 370;

            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_ModLockSettings), GUILayout.Height(25));            //"Modifier Lock Settings"



            GUI.Box(new Rect(0, 30, width / 2, 300), "");
            GUI.Box(new Rect(width / 2 - 1, 30, width / 2 + 1, 300), "");


            Texture2D img_Lock   = _editor.ImageSet.Get(apImageSet.PRESET.Edit_ModLock);
            Texture2D img_Unlock = _editor.ImageSet.Get(apImageSet.PRESET.Edit_ModUnlock);

            GUIStyle guiStyle_Title = new GUIStyle(GUI.skin.label);

            guiStyle_Title.alignment = TextAnchor.MiddleCenter;

            GUIStyle guiStyle_Box = new GUIStyle(GUI.skin.box);

            guiStyle_Box.alignment = TextAnchor.MiddleCenter;

            int width_half = (width - 10) / 2;

            EditorGUILayout.BeginVertical(GUILayout.Width(width), GUILayout.Height(height_middle));

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(40));

            GUILayout.Space(5);
            //Lock Mode / Unlock Mode
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetText(TEXT.DLG_ModLockMode), img_Lock), guiStyle_Title, GUILayout.Width(width_half), GUILayout.Height(40));
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetText(TEXT.DLG_ModUnlockMode), img_Unlock), guiStyle_Title, GUILayout.Width(width_half), GUILayout.Height(40));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            Color prevColor = GUI.backgroundColor;

            //1. 설명

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(60));
            GUILayout.Space(5);
            GUI.backgroundColor = new Color(prevColor.r * 1.8f, prevColor.g * 0.7f, prevColor.b * 0.7f, 1.0f);
            //"Other than the selected Modifier\nwill not be executed."
            GUILayout.Box(_editor.GetText(TEXT.DLG_ModLockDescription), guiStyle_Box, GUILayout.Width(width_half - 5), GUILayout.Height(60));

            GUILayout.Space(5);

            GUI.backgroundColor = new Color(prevColor.r * 0.7f, prevColor.g * 1.8f, prevColor.b * 1.8f, 1.0f);
            //"Except Modifiers which are of the same type\nor can not be edited at the same time,\nothers are executed."
            GUILayout.Box(_editor.GetText(TEXT.DLG_ModUnlockDescription), guiStyle_Box, GUILayout.Width(width_half - 5), GUILayout.Height(60));

            GUI.backgroundColor = prevColor;

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);


            //2. 어떤 객체가 Modifier나 Timeline Layer에 등록 안된 경우, 배타적인 계산을 하지 않는다.
            //Lock On인 경우 없다.
            //"Calculating transformations\nof unregistered objects"
            string strOpt_CalculateIfNotAddedOther_On = _editor.GetText(TEXT.DLG_ModLockCalculateUnregisteredObj);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(40));
            GUILayout.Space(5 + width_half + 5);
            if (apEditorUtil.ToggledButton_2Side(strOpt_CalculateIfNotAddedOther_On,
                                                 strOpt_CalculateIfNotAddedOther_On,
                                                 _editor._modLockOption_CalculateIfNotAddedOther,
                                                 true,
                                                 width_half - 5, 40))
            {
                _editor._modLockOption_CalculateIfNotAddedOther = !_editor._modLockOption_CalculateIfNotAddedOther;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);


            //3. Color Preview
            //"Render Calculated Colors"
            string strOpt_ColorPreview = _editor.GetText(TEXT.DLG_ModLockRenderCalculatedColors);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton_2Side(strOpt_ColorPreview, strOpt_ColorPreview,
                                                 _editor._modLockOption_ColorPreview_Lock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_ColorPreview_Lock = !_editor._modLockOption_ColorPreview_Lock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            GUILayout.Space(5);

            if (apEditorUtil.ToggledButton_2Side(strOpt_ColorPreview, strOpt_ColorPreview,
                                                 _editor._modLockOption_ColorPreview_Unlock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_ColorPreview_Unlock = !_editor._modLockOption_ColorPreview_Unlock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            //4. Bone Preview
            //"Preview Calculated Bones"
            string strOpt_BonePreview = _editor.GetText(TEXT.DLG_ModLockPreviewCalculatedBones);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton_2Side(strOpt_BonePreview, strOpt_BonePreview,
                                                 _editor._modLockOption_BonePreview_Lock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_BonePreview_Lock = !_editor._modLockOption_BonePreview_Lock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            GUILayout.Space(5);

            if (apEditorUtil.ToggledButton_2Side(strOpt_BonePreview, strOpt_BonePreview,
                                                 _editor._modLockOption_BonePreview_Unlock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_BonePreview_Unlock = !_editor._modLockOption_BonePreview_Unlock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);


            //5. Mesh Preview
            //string strOpt_MeshPreview = "Preview Calculated Meshes";
            //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            //GUILayout.Space(5);
            //if(apEditorUtil.ToggledButton_2Side(strOpt_MeshPreview, strOpt_MeshPreview,
            //									_editor._modLockOption_MeshPreview_Lock,
            //									true,
            //									width_half - 5, 30))
            //{
            //	_editor._modLockOption_MeshPreview_Lock = !_editor._modLockOption_MeshPreview_Lock;
            //	isChanged = true;
            //	_editor.SaveEditorPref();
            //}

            //GUILayout.Space(5);

            //if(apEditorUtil.ToggledButton_2Side(strOpt_MeshPreview, strOpt_MeshPreview,
            //									_editor._modLockOption_MeshPreview_Unlock,
            //									true,
            //									width_half - 5, 30))
            //{
            //	_editor._modLockOption_MeshPreview_Unlock = !_editor._modLockOption_MeshPreview_Unlock;
            //	isChanged = true;
            //	_editor.SaveEditorPref();
            //}

            //EditorGUILayout.EndHorizontal();

            //GUILayout.Space(5);


            //6. Modifier List UI
            //"Show Modifier List"
            string strOpt_ModifierListUI = _editor.GetText(TEXT.DLG_ModLockShowModifierList);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton_2Side(strOpt_ModifierListUI, strOpt_ModifierListUI,
                                                 _editor._modLockOption_ModListUI_Lock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_ModListUI_Lock = !_editor._modLockOption_ModListUI_Lock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            GUILayout.Space(5);

            if (apEditorUtil.ToggledButton_2Side(strOpt_ModifierListUI, strOpt_ModifierListUI,
                                                 _editor._modLockOption_ModListUI_Unlock,
                                                 true,
                                                 width_half - 5, 30))
            {
                _editor._modLockOption_ModListUI_Unlock = !_editor._modLockOption_ModListUI_Unlock;
                isChanged = true;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(15);


            //7. Preview 색상
            //"Preview Color"
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_ModLockPreviewColor));
            //try
            //{
            //	Color nextColor = EditorGUILayout.ColorField("Mesh Preview Color", _editor._modLockOption_MeshPreviewColor);
            //	if(!IsSameColor(nextColor, _editor._modLockOption_MeshPreviewColor))
            //	{
            //		_editor._modLockOption_MeshPreviewColor = nextColor;
            //		isChanged = true;
            //		_editor.SaveEditorPref();
            //	}
            //}
            //catch(Exception) { }

            try
            {
                //"Bone Preview Color"
                _editor._modLockOption_BonePreviewColor = EditorGUILayout.ColorField(_editor.GetText(TEXT.DLG_ModLockBonePreviewColor), _editor._modLockOption_BonePreviewColor);
            }
            catch (Exception) { }

            EditorGUILayout.EndVertical();


            //"Restore Settings"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_ModLockRestoreSettings), GUILayout.Height(20)))
            {
                //TODO
                _editor._modLockOption_CalculateIfNotAddedOther = false;
                _editor._modLockOption_ColorPreview_Lock        = false;
                _editor._modLockOption_ColorPreview_Unlock      = true;              //<< True 기본값
                _editor._modLockOption_BonePreview_Lock         = false;
                _editor._modLockOption_BonePreview_Unlock       = true;              //<< True 기본값
                //_editor._modLockOption_MeshPreview_Lock =		false;
                //_editor._modLockOption_MeshPreview_Unlock =		false;
                _editor._modLockOption_ModListUI_Lock   = false;
                _editor._modLockOption_ModListUI_Unlock = false;

                //_editor._modLockOption_MeshPreviewColor = apEditor.DefauleColor_ModLockOpt_MeshPreview;
                _editor._modLockOption_BonePreviewColor = apEditor.DefauleColor_ModLockOpt_BonePreview;
                isChanged = true;
                _editor.SaveEditorPref();
            }


            if (isChanged)
            {
                if (_editor.Select != null)
                {
                    _editor.Select.RefreshModifierExclusiveEditing();
                    _editor.Select.RefreshAnimEditingLayerLock();
                }
            }

            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Height(35)))
            {
                _editor.SaveEditorPref();
                CloseDialog();
            }
        }
Ejemplo n.º 5
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                CloseDialog();
                return;
            }

            //_scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(height));
            //EditorGUILayout.BeginVertical(GUILayout.Width(width - 28));
            width -= 10;


            //Color toneColor = _editor._colorOption_OnionToneColor;
            //Color animPrevColor = _editor._colorOption_OnionAnimPrevColor;
            //Color animNextColor = _editor._colorOption_OnionAnimNextColor;

            bool  isOutlineRender      = _editor._onionOption_IsOutlineRender;
            float outlineThickness     = _editor._onionOption_OutlineThickness;
            bool  isRenderOnlySelected = _editor._onionOption_IsRenderOnlySelected;
            bool  isRenderBehind       = _editor._onionOption_IsRenderBehind;
            bool  isRenderAnimFrames   = _editor._onionOption_IsRenderAnimFrames;
            int   prevRange            = _editor._onionOption_PrevRange;
            int   nextRange            = _editor._onionOption_NextRange;
            int   renderPerFrame       = _editor._onionOption_RenderPerFrame;
            float posOffsetX           = _editor._onionOption_PosOffsetX;
            float posOffsetY           = _editor._onionOption_PosOffsetY;
            bool  IKCalculateForce     = _editor._onionOption_IKCalculateForce;

            bool isChanged = false;

            GUIStyle guiStyle_Box = new GUIStyle(GUI.skin.box);

            guiStyle_Box.alignment = TextAnchor.MiddleCenter;
            if (EditorGUIUtility.isProSkin)
            {
                guiStyle_Box.normal.textColor = Color.white;
            }

            Color prevColor = GUI.backgroundColor;

            GUILayout.Space(10);
            GUI.backgroundColor = new Color(0.7f, 1.0f, 0.6f, 1.0f);

            GUILayout.Box(_editor.GetText(TEXT.DLG_BasicSettings), guiStyle_Box, GUILayout.Width(width), GUILayout.Height(25));            //"Basic Settings"
            GUI.backgroundColor = prevColor;
            GUILayout.Space(5);
            //- 색상
            //- 렌더링 방식 < Outline / Solid (Enum)
            //- 두께
            //- 앞/뒤 < Enum
            //- 선택Only / 전체 < Enum
            int widthValue     = 130;
            int widthLabel     = width - (10 + widthValue + 5);
            int widthValueHalf = (widthValue / 2) - 2;

            //1. 색상들

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Colors), GUILayout.Width(widthLabel));            //"Colors"
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Mesh), GUILayout.Width(widthValueHalf));          //"Mesh"
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Bone), GUILayout.Width(widthValueHalf));          //"Bone"
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_SingleMarker), GUILayout.Width(widthLabel));            //"Single Marker"
            try
            {
                Color nextToneColor = EditorGUILayout.ColorField(_editor._colorOption_OnionToneColor, GUILayout.Width(widthValueHalf));
                if (!IsSameColor(_editor._colorOption_OnionToneColor, nextToneColor))
                {
                    _editor._colorOption_OnionToneColor = nextToneColor;
                    apGL.SetToneOption(_editor._colorOption_OnionToneColor, _editor._onionOption_OutlineThickness, _editor._onionOption_IsOutlineRender, _editor._onionOption_PosOffsetX, _editor._onionOption_PosOffsetY, _editor._colorOption_OnionBoneColor);
                }
            }
            catch (Exception) { }
            try
            {
                Color nextBoneColor = EditorGUILayout.ColorField(_editor._colorOption_OnionBoneColor, GUILayout.Width(widthValueHalf));
                if (!IsSameColor(nextBoneColor, _editor._colorOption_OnionBoneColor))
                {
                    _editor._colorOption_OnionBoneColor = nextBoneColor;
                    apGL.SetToneOption(_editor._colorOption_OnionToneColor, _editor._onionOption_OutlineThickness, _editor._onionOption_IsOutlineRender, _editor._onionOption_PosOffsetX, _editor._onionOption_PosOffsetY, _editor._colorOption_OnionBoneColor);
                }
            }
            catch (Exception) { }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PreviousFrames), GUILayout.Width(widthLabel));            //"Previous Frames"
            try { _editor._colorOption_OnionAnimPrevColor = EditorGUILayout.ColorField(_editor._colorOption_OnionAnimPrevColor, GUILayout.Width(widthValueHalf)); }
            catch (Exception) { }
            try { _editor._colorOption_OnionBonePrevColor = EditorGUILayout.ColorField(_editor._colorOption_OnionBonePrevColor, GUILayout.Width(widthValueHalf)); }
            catch (Exception) { }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_NextFrames), GUILayout.Width(widthLabel));            //"Next Frames"
            try { _editor._colorOption_OnionAnimNextColor = EditorGUILayout.ColorField(_editor._colorOption_OnionAnimNextColor, GUILayout.Width(widthValueHalf)); }
            catch (Exception) { }
            try { _editor._colorOption_OnionBoneNextColor = EditorGUILayout.ColorField(_editor._colorOption_OnionBoneNextColor, GUILayout.Width(widthValueHalf)); }
            catch (Exception) { }
            EditorGUILayout.EndHorizontal();


            if (GUILayout.Button(_editor.GetText(TEXT.DLG_RestoretoDefaultColors), GUILayout.Width(width), GUILayout.Height(20)))            //"Restore Default Colors"
            {
                _editor._colorOption_OnionToneColor     = apEditor.DefaultColor_OnionToneColor;
                _editor._colorOption_OnionAnimPrevColor = apEditor.DefaultColor_OnionAnimPrevColor;
                _editor._colorOption_OnionAnimNextColor = apEditor.DefaultColor_OnionAnimNextColor;
                _editor._colorOption_OnionBoneColor     = apEditor.DefaultColor_OnionBoneColor;
                _editor._colorOption_OnionBonePrevColor = apEditor.DefaultColor_OnionBonePrevColor;
                _editor._colorOption_OnionBoneNextColor = apEditor.DefaultColor_OnionBoneNextColor;
                _editor.SaveEditorPref();
            }
            GUILayout.Space(10);

            //렌더 모드
            int iEnumRenderMode = (isOutlineRender ? 0 : 1);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Shape), GUILayout.Width(widthLabel));            //"Shape"
            int nextEnumRenderMode = EditorGUILayout.Popup(iEnumRenderMode, _enumTitle_RenderMode, GUILayout.Width(widthValue));

            if (nextEnumRenderMode != iEnumRenderMode)
            {
                isOutlineRender = (nextEnumRenderMode == 0 ? true : false);
                isChanged       = true;
            }
            EditorGUILayout.EndHorizontal();

            //- 두께
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Thickness01), GUILayout.Width(widthLabel));            //"Thickness (0~1)"
            float nextOutlineThickness = EditorGUILayout.DelayedFloatField(outlineThickness, GUILayout.Width(widthValue));

            if (nextOutlineThickness != outlineThickness)
            {
                outlineThickness = nextOutlineThickness;
                isChanged        = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();

            //- 앞/뒤 < Enum
            int iEnumRenderOrder = (isRenderBehind ? 1 : 0);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Order), GUILayout.Width(widthLabel));            //"Order"
            int nextEnumRenderOrder = EditorGUILayout.Popup(iEnumRenderOrder, _enumTitle_RenderOrder, GUILayout.Width(widthValue));

            if (nextEnumRenderOrder != iEnumRenderOrder)
            {
                isRenderBehind = (nextEnumRenderOrder == 0 ? false : true);
                isChanged      = true;
            }
            EditorGUILayout.EndHorizontal();

            //- 선택Only / 전체 < Enum
            int iEnumSelected = (isRenderOnlySelected ? 1 : 0);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Target), GUILayout.Width(widthLabel));            //"Target"
            int nextEnumSelected = EditorGUILayout.Popup(iEnumSelected, _enumTitle_SelectedMode, GUILayout.Width(widthValue));

            if (nextEnumSelected != iEnumSelected)
            {
                isRenderOnlySelected = (nextEnumSelected == 0 ? false : true);
                isChanged            = true;
            }
            EditorGUILayout.EndHorizontal();

            //float posOffsetX = _editor._onionOption_PosOffsetX;
            //float posOffsetY = _editor._onionOption_PosOffsetY;
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PositionOffset), GUILayout.Width(widthLabel));            //"Position Offset"
            float nextPosOffsetX = EditorGUILayout.DelayedFloatField(posOffsetX, GUILayout.Width((widthValue / 2) - 2));
            float nextPosOffsetY = EditorGUILayout.DelayedFloatField(posOffsetY, GUILayout.Width((widthValue / 2) - 2));

            if (Mathf.Abs(nextPosOffsetX - posOffsetX) > 0.0001f)
            {
                posOffsetX = nextPosOffsetX;
                isChanged  = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            if (Mathf.Abs(nextPosOffsetY - posOffsetY) > 0.0001f)
            {
                posOffsetY = nextPosOffsetY;
                isChanged  = true;
                apEditorUtil.ReleaseGUIFocus();
            }

            EditorGUILayout.EndHorizontal();

            //IK 계산
            int iEnumIK = (IKCalculateForce ? 0 : 1);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_IKCalculation), GUILayout.Width(widthLabel));            //"IK calculation"
            int nextEnumIK = EditorGUILayout.Popup(iEnumIK, _enimTitle_IKCalculate, GUILayout.Width(widthValue));

            if (nextEnumIK != iEnumIK)
            {
                IKCalculateForce = (nextEnumIK == 0 ? true : false);
                isChanged        = true;
            }
            EditorGUILayout.EndHorizontal();



            GUILayout.Space(20);
            GUI.backgroundColor = new Color(0.3f, 0.9f, 1.0f, 1.0f);
            GUILayout.Box(_editor.GetText(TEXT.DLG_AnimationSettings), guiStyle_Box, GUILayout.Width(width), GUILayout.Height(25));            //"Animation Settings"
            GUI.backgroundColor = prevColor;
            GUILayout.Space(5);
            //- 단일 프레임 <-> 범위 프레임 비교 < 아이콘
            //- 이전/이후 프레임
            //- Render Per Frame

            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_AnimationFrameRendering), GUILayout.Width(width));            //"Animation Frame Rendering"
            Texture2D img_SingleFrame   = _editor.ImageSet.Get(apImageSet.PRESET.OnionSkin_SingleFrame);
            Texture2D img_MultipleFrame = _editor.ImageSet.Get(apImageSet.PRESET.OnionSkin_MultipleFrame);
            int       width_Half        = ((width - 10) / 2) - 2;


            string strBtn_SingleFrame    = " " + _editor.GetText(TEXT.DLG_SingleFrame);         //" Single Frame"
            string strBtn_MultipleFrames = " " + _editor.GetText(TEXT.DLG_MultipleFrames);      //" Multiple Frames"

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(30));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton_2Side(img_SingleFrame, strBtn_SingleFrame, strBtn_SingleFrame, !isRenderAnimFrames, true, width_Half, 30))
            {
                isRenderAnimFrames = false;
                isChanged          = true;
            }
            if (apEditorUtil.ToggledButton_2Side(img_MultipleFrame, strBtn_MultipleFrames, strBtn_MultipleFrames, isRenderAnimFrames, true, width_Half, 30))
            {
                isRenderAnimFrames = true;
                isChanged          = true;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Range), GUILayout.Width(width));            //"Range"
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PreviousRange), GUILayout.Width(widthLabel));            //"Previous"
            int changedPrevRange = EditorGUILayout.DelayedIntField(prevRange, GUILayout.Width(widthValue));

            if (changedPrevRange != prevRange)
            {
                prevRange = changedPrevRange;
                isChanged = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_NextRange), GUILayout.Width(widthLabel));            //"Next"
            int changedNextRange = EditorGUILayout.DelayedIntField(nextRange, GUILayout.Width(widthValue));

            if (changedNextRange != nextRange)
            {
                nextRange = changedNextRange;
                isChanged = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_FramePerRender), GUILayout.Width(widthLabel));            //"Render per Frame"
            int changedRenderPerFrame = EditorGUILayout.DelayedIntField(renderPerFrame, GUILayout.Width(widthValue));

            if (changedRenderPerFrame != renderPerFrame)
            {
                renderPerFrame = changedRenderPerFrame;
                isChanged      = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();

            if (isChanged)
            {
                _editor._onionOption_IsOutlineRender      = isOutlineRender;
                _editor._onionOption_OutlineThickness     = Mathf.Clamp01(outlineThickness);
                _editor._onionOption_IsRenderOnlySelected = isRenderOnlySelected;
                _editor._onionOption_IsRenderBehind       = isRenderBehind;
                _editor._onionOption_IsRenderAnimFrames   = isRenderAnimFrames;
                _editor._onionOption_PrevRange            = Mathf.Max(prevRange, 0);
                _editor._onionOption_NextRange            = Mathf.Max(nextRange, 0);
                _editor._onionOption_RenderPerFrame       = Mathf.Max(renderPerFrame, 1);
                _editor._onionOption_PosOffsetX           = posOffsetX;
                _editor._onionOption_PosOffsetY           = posOffsetY;
                _editor._onionOption_IKCalculateForce     = IKCalculateForce;

                _editor.SaveEditorPref();
            }



            GUILayout.Space(20);
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_RestoretoDefaultSettings), GUILayout.Width(width), GUILayout.Height(20)))           //"Restore to Default Settings"
            {
                //TODO
                _editor._onionOption_IsOutlineRender      = true;
                _editor._onionOption_OutlineThickness     = 0.5f;
                _editor._onionOption_IsRenderOnlySelected = false;
                _editor._onionOption_IsRenderBehind       = false;
                _editor._onionOption_IsRenderAnimFrames   = false;
                _editor._onionOption_PrevRange            = 1;
                _editor._onionOption_NextRange            = 1;
                _editor._onionOption_RenderPerFrame       = 1;
                _editor._onionOption_PosOffsetX           = 0.0f;
                _editor._onionOption_PosOffsetY           = 0.0f;
                _editor._onionOption_IKCalculateForce     = false;

                _editor.SaveEditorPref();
            }
            GUILayout.Space(5);

            if (GUILayout.Button(_editor.GetText(TEXT.Close), GUILayout.Width(width), GUILayout.Height(35)))
            {
                _editor.SaveEditorPref();
                CloseDialog();
            }

            //GUILayout.Height(height + 300);

            //EditorGUILayout.EndVertical();
            //EditorGUILayout.EndScrollView();
        }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            if (_editor == null)
            {
                CloseDialog();
                return;
            }

            int width  = (int)position.width;
            int height = (int)position.height;

            width -= 10;
            bool isClose = false;

            GUILayout.Space(5);
            GUIStyle guiStyle_Center = new GUIStyle(GUI.skin.label);

            guiStyle_Center.alignment = TextAnchor.MiddleCenter;
            guiStyle_Center.wordWrap  = true;

            if (_guiContent_ImgInfo == null)
            {
                _guiContent_ImgInfo = new apGUIContentWrapper();
                _guiContent_ImgInfo.SetImage(_img_Info);
            }


            //EditorGUILayout.LabelField(new GUIContent("", _img_Info), guiStyle_Center, GUILayout.Width(width), GUILayout.Height(256));
            EditorGUILayout.LabelField(_guiContent_ImgInfo.Content, guiStyle_Center, GUILayout.Width(width), GUILayout.Height(256));

            GUILayout.Space(10);
            //"Ambient Color가 검은색이 아니면 결과물이\n원본보다 밝게 보여질 수 있습니다."
            EditorGUILayout.LabelField(_str_Info, guiStyle_Center, GUILayout.Height(40));
            GUILayout.Space(5);

            //"Ambient Color를 검은색으로 변경하기"
            if (GUILayout.Button(_str_Convert, GUILayout.Height(30)))
            {
                MakeAmbientLightToBlack();
                isClose = true;
            }

            //"닫기"
            if (GUILayout.Button(_str_Close, GUILayout.Height(30)))
            {
                isClose = true;
            }
            GUILayout.Space(5);

            //"이 메시지 더이상 보지 않기"
            //이부분 버그
            bool doNotShowAmbientDialog = !_editor._isAmbientCorrectionOption;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
            GUILayout.Space(10);
            //bool isAmbientOption = EditorGUILayout.Toggle(_editor._isAmbientCorrectionOption, GUILayout.Width(30));
            bool nextDoNotShowAmbient = EditorGUILayout.Toggle(doNotShowAmbientDialog, GUILayout.Width(30));

            GUILayout.Space(5);
            //if(isAmbientOption != _editor._isAmbientCorrectionOption)
            if (nextDoNotShowAmbient != doNotShowAmbientDialog)
            {
                //_editor._isAmbientCorrectionOption = isAmbientOption;
                _editor._isAmbientCorrectionOption = !nextDoNotShowAmbient;
                _editor.SaveEditorPref();
            }

            EditorGUILayout.LabelField(_str_DoNotShow, GUILayout.Width(300));


            EditorGUILayout.EndHorizontal();

            if (isClose)
            {
                CloseDialog();
            }
        }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                //Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                //Debug.LogError("Exit - Editor / Portrait Missmatch");
                CloseDialog();
                return;
            }

            int tabBtnHeight = 25;
            int tabBtnWidth  = ((width - 10) / 3) - 4;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Portrait), _tab == TAB.PortriatSetting, tabBtnWidth, tabBtnHeight))            //"Portrait"
            {
                _tab = TAB.PortriatSetting;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Editor), _tab == TAB.EditorSetting, tabBtnWidth, tabBtnHeight))            //"Editor"
            {
                _tab = TAB.EditorSetting;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_About), _tab == TAB.About, tabBtnWidth, tabBtnHeight))            //"About"
            {
                _tab = TAB.About;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            int scrollHeight = height - 40;

            _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(scrollHeight));
            width  -= 25;
            GUILayout.BeginVertical(GUILayout.Width(width));

            switch (_tab)
            {
            case TAB.PortriatSetting:
            {
                //Portrait 설정
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PortraitSetting));                                    //"Portrait Settings"
                GUILayout.Space(10);
                string nextName = EditorGUILayout.DelayedTextField(_editor.GetText(TEXT.DLG_Name), _targetPortrait.name); //"Name"
                if (nextName != _targetPortrait.name)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait.name = nextName;
                }

                //"FPS (Important Off)"
                int nextFPS = EditorGUILayout.DelayedIntField(new GUIContent(_editor.GetText(TEXT.DLG_Setting_FPS), "This setting is used when <Important> is off"), _targetPortrait._FPS);
                if (_targetPortrait._FPS != nextFPS)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (nextFPS < 10)
                    {
                        nextFPS = 10;
                    }
                    _targetPortrait._FPS = nextFPS;
                }

                //"Is Important"
                bool nextImportant = EditorGUILayout.Toggle(new GUIContent(_editor.GetText(TEXT.DLG_Setting_IsImportant), "When this setting is on, it always updates and the physics effect works."), _targetPortrait._isImportant);
                if (nextImportant != _targetPortrait._isImportant)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._isImportant = nextImportant;
                }


                GUILayout.Space(10);
                //수동으로 백업하기
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Setting_ManualBackUp), GUILayout.Height(30)))                               //"Save Backup (Manual)"
                {
                    if (_editor.Backup.IsAutoSaveWorking())
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.BackupError_Title),
                                                    _editor.GetText(TEXT.BackupError_Body),
                                                    _editor.GetText(TEXT.Okay));
                    }
                    else
                    {
                        string defaultBackupFileName = _targetPortrait.name + "_backup_" + apBackup.GetCurrentTimeString();
                        string savePath = EditorUtility.SaveFilePanel("Backup File Path", "", defaultBackupFileName, "bck");
                        if (string.IsNullOrEmpty(savePath))
                        {
                            _editor.Notification("Backup Canceled", true, false);
                        }
                        else
                        {
                            _editor.Backup.SaveBackup(savePath, _targetPortrait);
                            _editor.Notification("Backup Saved [" + savePath + "]", false, true);
                        }

                        CloseDialog();
                    }
                }
            }
            break;

            case TAB.EditorSetting:
            {
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_EditorSetting));                                //"Editor Settings"
                GUILayout.Space(10);

                apEditor.LANGUAGE prevLanguage = _editor._language;
                int prevLangIndex = -1;
                for (int i = 0; i < _validLanguageIndex.Length; i++)
                {
                    if (_validLanguageIndex[i] == (int)prevLanguage)
                    {
                        prevLangIndex = i;
                    }
                }
                if (prevLangIndex < 0)
                {
                    prevLangIndex = 0;                                    //English 강제
                }

                bool prevGUIFPS        = _editor._guiOption_isFPSVisible;
                bool prevGUIStatistics = _editor._guiOption_isStatisticsVisible;

                Color prevColor_Background = _editor._colorOption_Background;
                Color prevColor_GridCenter = _editor._colorOption_GridCenter;
                Color prevColor_Grid       = _editor._colorOption_Grid;

                Color prevColor_MeshEdge        = _editor._colorOption_MeshEdge;
                Color prevColor_MeshHiddenEdge  = _editor._colorOption_MeshHiddenEdge;
                Color prevColor_Outline         = _editor._colorOption_Outline;
                Color prevColor_TFBorder        = _editor._colorOption_TransformBorder;
                Color prevColor_VertNotSelected = _editor._colorOption_VertColor_NotSelected;
                Color prevColor_VertSelected    = _editor._colorOption_VertColor_Selected;

                Color prevColor_GizmoFFDLine      = _editor._colorOption_GizmoFFDLine;
                Color prevColor_GizmoFFDInnerLine = _editor._colorOption_GizmoFFDInnerLine;

                Color prevColor_ToneColor = _editor._colorOption_OnionToneColor;

                bool   prevBackup_IsAutoSave = _editor._backupOption_IsAutoSave;
                string prevBackup_Path       = _editor._backupOption_BaseFolderName;
                int    prevBackup_Time       = _editor._backupOption_Minute;


                string prevBonePose_Path = _editor._bonePose_BaseFolderName;

                //"Language"
                //이전 방식은 Enum을 모두 조회
                //_editor._language = (apEditor.LANGUAGE)EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Setting_Language), (int)_editor._language, _strLanguageName);

                //사용 가능한 Language만 따로 조회
                int nextLangIndex = EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Setting_Language), prevLangIndex, _strLanguageName);
                _editor._language = (apEditor.LANGUAGE)_validLanguageIndex[nextLangIndex];

                GUILayout.Space(10);
                _editor._guiOption_isFPSVisible        = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_ShowFPS), _editor._guiOption_isFPSVisible);                         //"Show FPS"
                _editor._guiOption_isStatisticsVisible = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_ShowStatistics), _editor._guiOption_isStatisticsVisible);           // "Show Statistics"


                GUILayout.Space(10);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_AutoBackupSetting));                                                           //"Auto Backup Option"
                _editor._backupOption_IsAutoSave = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_AutoBackup), _editor._backupOption_IsAutoSave); //"Auto Backup"

                if (_editor._backupOption_IsAutoSave)
                {
                    //경로와 시간
                    //"Time (Min)"
                    _editor._backupOption_Minute = EditorGUILayout.IntField(_editor.GetText(TEXT.DLG_Setting_BackupTime), _editor._backupOption_Minute, GUILayout.Width(width));

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(18));
                    GUILayout.Space(5);
                    //"Save Path"
                    _editor._backupOption_BaseFolderName = EditorGUILayout.TextField(_editor.GetText(TEXT.DLG_Setting_BackupPath), _editor._backupOption_BaseFolderName, GUILayout.Width(width - 100), GUILayout.Height(18));
                    if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), GUILayout.Width(90), GUILayout.Height(18)))                                   //"Change"
                    {
                        string pathResult = EditorUtility.SaveFolderPanel("Set the Backup Folder", _editor._backupOption_BaseFolderName, "");
                        if (!string.IsNullOrEmpty(pathResult))
                        {
                            //Debug.Log("백업 폴더 경로 [" + pathResult + "] - " + Application.dataPath);
                            Uri targetUri = new Uri(pathResult);
                            Uri baseUri   = new Uri(Application.dataPath);

                            string relativePath = baseUri.MakeRelativeUri(targetUri).ToString();
                            _editor._backupOption_BaseFolderName = relativePath;
                            //Debug.Log("상대 경로 [" + relativePath + "]");
                            apEditorUtil.SetEditorDirty();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }

                GUILayout.Space(10);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_PoseSnapshotSetting));                                //"Pose Snapshot Option"
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(18));
                GUILayout.Space(5);
                //"Save Path"
                _editor._bonePose_BaseFolderName = EditorGUILayout.TextField(_editor.GetText(TEXT.DLG_Setting_BackupPath), _editor._bonePose_BaseFolderName, GUILayout.Width(width - 100), GUILayout.Height(18));

                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), GUILayout.Width(90), GUILayout.Height(18)))                                //"Change"
                {
                    string pathResult = EditorUtility.SaveFolderPanel("Set the Pose Folder", _editor._bonePose_BaseFolderName, "");
                    if (!string.IsNullOrEmpty(pathResult))
                    {
                        Uri targetUri = new Uri(pathResult);
                        Uri baseUri   = new Uri(Application.dataPath);

                        string relativePath = baseUri.MakeRelativeUri(targetUri).ToString();

                        _editor._bonePose_BaseFolderName = relativePath;

                        apEditorUtil.SetEditorDirty();
                    }
                }
                EditorGUILayout.EndHorizontal();



                GUILayout.Space(10);
                try
                {
                    //int width_Btn = 65;
                    //int width_Color = width - (width_Btn + 8);

                    //int height_Color = 18;
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_BackgroundColors));                                    //"Background Colors"

                    //"Background"
                    _editor._colorOption_Background = ColorUI(_editor.GetText(TEXT.DLG_Setting_Background), _editor._colorOption_Background, width, apEditor.DefaultColor_Background);

                    //"Grid Center"
                    _editor._colorOption_GridCenter = ColorUI(_editor.GetText(TEXT.DLG_Setting_GridCenter), _editor._colorOption_GridCenter, width, apEditor.DefaultColor_GridCenter);

                    //"Grid"
                    _editor._colorOption_Grid = ColorUI(_editor.GetText(TEXT.DLG_Setting_Grid), _editor._colorOption_Grid, width, apEditor.DefaultColor_Grid);

                    //"Atlas Border"
                    _editor._colorOption_AtlasBorder = ColorUI(_editor.GetText(TEXT.DLG_Setting_AtlasBorder), _editor._colorOption_AtlasBorder, width, apEditor.DefaultColor_AtlasBorder);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_MeshGUIColors));                                    //"Mesh GUI Colors"

                    //"Mesh Edge"
                    _editor._colorOption_MeshEdge = ColorUI(_editor.GetText(TEXT.DLG_Setting_MeshEdge), _editor._colorOption_MeshEdge, width, apEditor.DefaultColor_MeshEdge);

                    //"Mesh Hidden Edge"
                    _editor._colorOption_MeshHiddenEdge = ColorUI(_editor.GetText(TEXT.DLG_Setting_MeshHiddenEdge), _editor._colorOption_MeshHiddenEdge, width, apEditor.DefaultColor_MeshHiddenEdge);

                    //"Outline"
                    _editor._colorOption_Outline = ColorUI(_editor.GetText(TEXT.DLG_Setting_Outline), _editor._colorOption_Outline, width, apEditor.DefaultColor_Outline);

                    //"Transform Border"
                    _editor._colorOption_TransformBorder = ColorUI(_editor.GetText(TEXT.DLG_Setting_TransformBorder), _editor._colorOption_TransformBorder, width, apEditor.DefaultColor_TransformBorder);

                    //"Vertex"
                    _editor._colorOption_VertColor_NotSelected = ColorUI(_editor.GetText(TEXT.DLG_Setting_Vertex), _editor._colorOption_VertColor_NotSelected, width, apEditor.DefaultColor_VertNotSelected);

                    //"Selected Vertex"
                    _editor._colorOption_VertColor_Selected = ColorUI(_editor.GetText(TEXT.DLG_Setting_SelectedVertex), _editor._colorOption_VertColor_Selected, width, apEditor.DefaultColor_VertSelected);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_GizmoColors));                                    //"Gizmo Colors"

                    //"FFD Line"
                    _editor._colorOption_GizmoFFDLine = ColorUI(_editor.GetText(TEXT.DLG_Setting_FFDLine), _editor._colorOption_GizmoFFDLine, width, apEditor.DefaultColor_GizmoFFDLine);

                    //"FFD Inner Line"
                    _editor._colorOption_GizmoFFDInnerLine = ColorUI(_editor.GetText(TEXT.DLG_Setting_FFDInnerLine), _editor._colorOption_GizmoFFDInnerLine, width, apEditor.DefaultColor_GizmoFFDInnerLine);

                    GUILayout.Space(5);
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_OnionSkinColor));                                    //"Onion Skin Color"

                    //"Onion Skin (2x)"
                    _editor._colorOption_OnionToneColor = ColorUI(_editor.GetText(TEXT.DLG_Setting_OnionSkinColor2X), _editor._colorOption_OnionToneColor, width, apEditor.DefaultColor_OnionToneColor);
                }
                catch (Exception)
                {
                }

                GUILayout.Space(10);
                bool prevStartupScreen = _editor._startScreenOption_IsShowStartup;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_StartPage_AlawysOn), GUILayout.Width((width - (10 + 30))));
                _editor._startScreenOption_IsShowStartup = EditorGUILayout.Toggle(_editor._startScreenOption_IsShowStartup, GUILayout.Width(30));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(20);

                //"Restore Editor Default Setting"
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Setting_RestoreDefaultSetting), GUILayout.Height(20)))
                {
                    _editor.RestoreEditorPref();
                }


                if (prevLanguage != _editor._language ||
                    prevGUIFPS != _editor._guiOption_isFPSVisible ||
                    prevGUIStatistics != _editor._guiOption_isStatisticsVisible ||
                    prevColor_Background != _editor._colorOption_Background ||
                    prevColor_GridCenter != _editor._colorOption_GridCenter ||
                    prevColor_Grid != _editor._colorOption_Grid ||

                    prevColor_MeshEdge != _editor._colorOption_MeshEdge ||
                    prevColor_MeshHiddenEdge != _editor._colorOption_MeshHiddenEdge ||
                    prevColor_Outline != _editor._colorOption_Outline ||
                    prevColor_TFBorder != _editor._colorOption_TransformBorder ||
                    prevColor_VertNotSelected != _editor._colorOption_VertColor_NotSelected ||
                    prevColor_VertSelected != _editor._colorOption_VertColor_Selected ||

                    prevColor_GizmoFFDLine != _editor._colorOption_GizmoFFDLine ||
                    prevColor_GizmoFFDInnerLine != _editor._colorOption_GizmoFFDInnerLine ||
                    prevColor_ToneColor != _editor._colorOption_OnionToneColor ||
                    prevBackup_IsAutoSave != _editor._backupOption_IsAutoSave ||
                    !prevBackup_Path.Equals(_editor._backupOption_BaseFolderName) ||
                    prevBackup_Time != _editor._backupOption_Minute ||
                    !prevBonePose_Path.Equals(_editor._bonePose_BaseFolderName) ||

                    prevStartupScreen != _editor._startScreenOption_IsShowStartup
                    )
                {
                    bool isLanguageChanged = (prevLanguage != _editor._language);

                    _editor.SaveEditorPref();
                    apEditorUtil.SetEditorDirty();

                    apGL.SetToneColor(_editor._colorOption_OnionToneColor);

                    if (isLanguageChanged)
                    {
                        _editor.ResetHierarchyAll();
                        _editor.RefreshTimelineLayers(true);
                        _editor.RefreshControllerAndHierarchy();
                    }
                }
            }
            break;

            case TAB.About:
            {
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_About));                                //"About"

                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[AnyPortrait]");
                EditorGUILayout.LabelField("Build : " + apVersion.I.APP_VERSION_NUMBER_ONLY);



                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[Open Source Library License]");
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[PSD File Import Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Ntreev Photoshop Document Parser for .Net");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Released under the MIT License.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Copyright (c) 2015 Ntreev Soft co., Ltd.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Permission is hereby granted, free of charge,");
                EditorGUILayout.LabelField("to any person obtaining a copy of this software");
                EditorGUILayout.LabelField("and associated documentation files (the \"Software\"),");
                EditorGUILayout.LabelField("to deal in the Software without restriction,");
                EditorGUILayout.LabelField("including without limitation the rights ");
                EditorGUILayout.LabelField("to use, copy, modify, merge, publish, distribute,");
                EditorGUILayout.LabelField("sublicense, and/or sell copies of the Software, ");
                EditorGUILayout.LabelField("and to permit persons to whom the Software is furnished");
                EditorGUILayout.LabelField("to do so, subject to the following conditions:");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("The above copyright notice and ");
                EditorGUILayout.LabelField("this permission notice shall be included");
                EditorGUILayout.LabelField("in all copies or substantial portions of the Software.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT ");
                EditorGUILayout.LabelField("WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, ");
                EditorGUILayout.LabelField("INCLUDING BUT NOT LIMITED TO THE WARRANTIES ");
                EditorGUILayout.LabelField("OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ");
                EditorGUILayout.LabelField("PURPOSE AND NONINFRINGEMENT. ");
                EditorGUILayout.LabelField("IN NO EVENT SHALL THE AUTHORS OR ");
                EditorGUILayout.LabelField("COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES ");
                EditorGUILayout.LabelField("OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ");
                EditorGUILayout.LabelField("TORT OR OTHERWISE, ARISING FROM, OUT OF OR ");
                EditorGUILayout.LabelField("IN CONNECTION WITH THE SOFTWARE OR ");
                EditorGUILayout.LabelField("THE USE OR OTHER DEALINGS IN THE SOFTWARE.");

                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[GIF Export Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("NGif, Animated GIF Encoder for .NET");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Released under the CPOL 1.02.");
                GUILayout.Space(10);
            }
            break;
            }



            GUILayout.Space(height);
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                Debug.LogError("Exit - Editor / Portrait is Null");
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                Debug.LogError("Exit - Editor / Portrait Missmatch");
                CloseDialog();
                return;
            }

            int tabBtnHeight = 25;
            int tabBtnWidth  = ((width - 10) / 3) - 4;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton("Portrait", _tab == TAB.PortriatSetting, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.PortriatSetting;
            }
            if (apEditorUtil.ToggledButton("Editor", _tab == TAB.EditorSetting, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.EditorSetting;
            }
            if (apEditorUtil.ToggledButton("About", _tab == TAB.About, tabBtnWidth, tabBtnHeight))
            {
                _tab = TAB.About;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            int scrollHeight = height - 40;

            _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(scrollHeight));
            width  -= 25;
            GUILayout.BeginVertical(GUILayout.Width(width));

            switch (_tab)
            {
            case TAB.PortriatSetting:
            {
                //Portrait 설정
                EditorGUILayout.LabelField("Portrait Settings");
                GUILayout.Space(10);
                string nextName = EditorGUILayout.DelayedTextField("Name", _targetPortrait.name);
                if (nextName != _targetPortrait.name)
                {
                    _targetPortrait.name = nextName;
                }

                int nextFPS = EditorGUILayout.DelayedIntField("Update FPS", _targetPortrait._FPS);
                if (_targetPortrait._FPS != nextFPS)
                {
                    if (nextFPS < 10)
                    {
                        nextFPS = 10;
                    }
                    _targetPortrait._FPS = nextFPS;
                }

                bool nextGPUAcc = EditorGUILayout.Toggle("GPU Acceleration", _targetPortrait._isGPUAccel);
                if (nextGPUAcc != _targetPortrait._isGPUAccel)
                {
                    _targetPortrait._isGPUAccel = nextGPUAcc;
                }
            }
            break;

            case TAB.EditorSetting:
            {
                EditorGUILayout.LabelField("Editor Settings");
                GUILayout.Space(10);

                apEditor.LANGUAGE prevLanguage = _editor._language;
                bool prevGUIFPS = _editor._guiOption_isFPSVisible;

                Color prevColor_Background = _editor._colorOption_Background;
                Color prevColor_GridCenter = _editor._colorOption_GridCenter;
                Color prevColor_Grid       = _editor._colorOption_Grid;

                Color prevColor_MeshEdge        = _editor._colorOption_MeshEdge;
                Color prevColor_MeshHiddenEdge  = _editor._colorOption_MeshHiddenEdge;
                Color prevColor_Outline         = _editor._colorOption_Outline;
                Color prevColor_TFBorder        = _editor._colorOption_TransformBorder;
                Color prevColor_VertNotSelected = _editor._colorOption_VertColor_NotSelected;
                Color prevColor_VertSelected    = _editor._colorOption_VertColor_Selected;

                Color prevColor_GizmoFFDLine      = _editor._colorOption_GizmoFFDLine;
                Color prevColor_GizmoFFDInnerLine = _editor._colorOption_GizmoFFDInnerLine;

                _editor._language = (apEditor.LANGUAGE)EditorGUILayout.EnumPopup("Language", _editor._language);

                GUILayout.Space(10);
                _editor._guiOption_isFPSVisible = EditorGUILayout.Toggle("Show FPS", _editor._guiOption_isFPSVisible);


                GUILayout.Space(10);
                try
                {
                    int width_Btn   = 65;
                    int width_Color = width - (width_Btn + 8);

                    int height_Color = 18;
                    EditorGUILayout.LabelField("Background Colors");

                    //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(height_Color));
                    //GUILayout.Space(5);
                    //_editor._colorOption_Background = EditorGUILayout.ColorField("Background", _editor._colorOption_Background, GUILayout.Width(width_Color), GUILayout.Height(height_Color));
                    //if(GUILayout.Button("Default", GUILayout.Width(width_Btn), GUILayout.Height(height_Color)))
                    //{
                    //	_editor._colorOption_Background = apEditor.DefaultColor_Background;
                    //}
                    //EditorGUILayout.EndHorizontal();

                    //_editor._colorOption_GridCenter = EditorGUILayout.ColorField("Grid Center", _editor._colorOption_GridCenter);
                    //_editor._colorOption_Grid = EditorGUILayout.ColorField("Grid", _editor._colorOption_Grid);
                    //_editor._colorOption_AtlasBorder = EditorGUILayout.ColorField("Atlas Border", _editor._colorOption_AtlasBorder);

                    _editor._colorOption_Background  = ColorUI("Background", _editor._colorOption_Background, width, apEditor.DefaultColor_Background);
                    _editor._colorOption_GridCenter  = ColorUI("Grid Center", _editor._colorOption_GridCenter, width, apEditor.DefaultColor_GridCenter);
                    _editor._colorOption_Grid        = ColorUI("Grid", _editor._colorOption_Grid, width, apEditor.DefaultColor_Grid);
                    _editor._colorOption_AtlasBorder = ColorUI("Atlas Border", _editor._colorOption_AtlasBorder, width, apEditor.DefaultColor_AtlasBorder);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField("Mesh GUI Colors");
                    //_editor._colorOption_MeshEdge = EditorGUILayout.ColorField("Mesh Edge", _editor._colorOption_MeshEdge);
                    //_editor._colorOption_MeshHiddenEdge = EditorGUILayout.ColorField("Mesh Hidden Edge", _editor._colorOption_MeshHiddenEdge);
                    //_editor._colorOption_Outline = EditorGUILayout.ColorField("Outline", _editor._colorOption_Outline);
                    //_editor._colorOption_TransformBorder = EditorGUILayout.ColorField("Transform Border", _editor._colorOption_TransformBorder);
                    //_editor._colorOption_VertColor_NotSelected = EditorGUILayout.ColorField("Vertex", _editor._colorOption_VertColor_NotSelected);
                    //_editor._colorOption_VertColor_Selected = EditorGUILayout.ColorField("Selected Vertex", _editor._colorOption_VertColor_Selected);

                    _editor._colorOption_MeshEdge              = ColorUI("Mesh Edge", _editor._colorOption_MeshEdge, width, apEditor.DefaultColor_MeshEdge);
                    _editor._colorOption_MeshHiddenEdge        = ColorUI("Mesh Hidden Edge", _editor._colorOption_MeshHiddenEdge, width, apEditor.DefaultColor_MeshHiddenEdge);
                    _editor._colorOption_Outline               = ColorUI("Outline", _editor._colorOption_Outline, width, apEditor.DefaultColor_Outline);
                    _editor._colorOption_TransformBorder       = ColorUI("Transform Border", _editor._colorOption_TransformBorder, width, apEditor.DefaultColor_TransformBorder);
                    _editor._colorOption_VertColor_NotSelected = ColorUI("Vertex", _editor._colorOption_VertColor_NotSelected, width, apEditor.DefaultColor_VertNotSelected);
                    _editor._colorOption_VertColor_Selected    = ColorUI("Selected Vertex", _editor._colorOption_VertColor_Selected, width, apEditor.DefaultColor_VertSelected);


                    GUILayout.Space(5);
                    EditorGUILayout.LabelField("Gizmo Colors");
                    //_editor._colorOption_GizmoFFDLine = EditorGUILayout.ColorField("FFD Line", _editor._colorOption_GizmoFFDLine);
                    //_editor._colorOption_GizmoFFDInnerLine = EditorGUILayout.ColorField("FFD Inner Line", _editor._colorOption_GizmoFFDInnerLine);

                    _editor._colorOption_GizmoFFDLine      = ColorUI("FFD Line", _editor._colorOption_GizmoFFDLine, width, apEditor.DefaultColor_GizmoFFDLine);
                    _editor._colorOption_GizmoFFDInnerLine = ColorUI("FFD Inner Line", _editor._colorOption_GizmoFFDInnerLine, width, apEditor.DefaultColor_GizmoFFDInnerLine);
                }
                catch (Exception)
                {
                }

                GUILayout.Space(20);
                if (GUILayout.Button("Restore Editor Default Setting", GUILayout.Height(20)))
                {
                    _editor.RestoreEditorPref();
                }


                if (prevLanguage != _editor._language ||
                    prevGUIFPS != _editor._guiOption_isFPSVisible ||
                    prevColor_Background != _editor._colorOption_Background ||
                    prevColor_GridCenter != _editor._colorOption_GridCenter ||
                    prevColor_Grid != _editor._colorOption_Grid ||

                    prevColor_MeshEdge != _editor._colorOption_MeshEdge ||
                    prevColor_MeshHiddenEdge != _editor._colorOption_MeshHiddenEdge ||
                    prevColor_Outline != _editor._colorOption_Outline ||
                    prevColor_TFBorder != _editor._colorOption_TransformBorder ||
                    prevColor_VertNotSelected != _editor._colorOption_VertColor_NotSelected ||
                    prevColor_VertSelected != _editor._colorOption_VertColor_Selected ||

                    prevColor_GizmoFFDLine != _editor._colorOption_GizmoFFDLine ||
                    prevColor_GizmoFFDInnerLine != _editor._colorOption_GizmoFFDInnerLine)
                {
                    _editor.SaveEditorPref();
                }
            }
            break;

            case TAB.About:
            {
                EditorGUILayout.LabelField("About");

                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[AnyPortrait]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Copyright (c) 2017 RainyRizzle. All right reserved.");

                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[PSD File Import Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Ntreev Photoshop Document Parser for .Net");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Released under the MIT License.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Copyright (c) 2015 Ntreev Soft co., Ltd.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("Permission is hereby granted, free of charge,");
                EditorGUILayout.LabelField("to any person obtaining a copy of this software");
                EditorGUILayout.LabelField("and associated documentation files (the \"Software\"),");
                EditorGUILayout.LabelField("to deal in the Software without restriction,");
                EditorGUILayout.LabelField("including without limitation the rights ");
                EditorGUILayout.LabelField("to use, copy, modify, merge, publish, distribute,");
                EditorGUILayout.LabelField("sublicense, and/or sell copies of the Software, ");
                EditorGUILayout.LabelField("and to permit persons to whom the Software is furnished");
                EditorGUILayout.LabelField("to do so, subject to the following conditions:");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("The above copyright notice and ");
                EditorGUILayout.LabelField("this permission notice shall be included");
                EditorGUILayout.LabelField("in all copies or substantial portions of the Software.");
                GUILayout.Space(10);

                EditorGUILayout.LabelField("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT ");
                EditorGUILayout.LabelField("WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, ");
                EditorGUILayout.LabelField("INCLUDING BUT NOT LIMITED TO THE WARRANTIES ");
                EditorGUILayout.LabelField("OF MERCHANTABILITY, FITNESS FOR A PARTICULAR ");
                EditorGUILayout.LabelField("PURPOSE AND NONINFRINGEMENT. ");
                EditorGUILayout.LabelField("IN NO EVENT SHALL THE AUTHORS OR ");
                EditorGUILayout.LabelField("COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES ");
                EditorGUILayout.LabelField("OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, ");
                EditorGUILayout.LabelField("TORT OR OTHERWISE, ARISING FROM, OUT OF OR ");
                EditorGUILayout.LabelField("IN CONNECTION WITH THE SOFTWARE OR ");
                EditorGUILayout.LabelField("THE USE OR OTHER DEALINGS IN THE SOFTWARE.");

                GUILayout.Space(20);
                apEditorUtil.GUI_DelimeterBoxH(width);
                GUILayout.Space(20);

                EditorGUILayout.LabelField("[GIF Export Library]");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("NGif, Animated GIF Encoder for .NET");
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Released under the CPOL 1.02.");
                GUILayout.Space(10);
            }
            break;
            }



            GUILayout.Space(height);
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
        }
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                CloseDialog();
                return;
            }

            //Sorting Layer를 추가하자
            if (_sortingLayerNames == null || _sortingLayerIDs == null)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }
            else if (_sortingLayerNames.Length != SortingLayer.layers.Length ||
                     _sortingLayerIDs.Length != SortingLayer.layers.Length)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }

            for (int i = 0; i < SortingLayer.layers.Length; i++)
            {
                _sortingLayerNames[i] = SortingLayer.layers[i].name;
                _sortingLayerIDs[i]   = SortingLayer.layers[i].id;
            }


            //Bake 설정
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_BakeSetting));            //"Bake Setting"
            GUILayout.Space(5);

            EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Portrait), _targetPortrait, typeof(apPortrait), true);            //"Portait"

            GUILayout.Space(5);

            //"Bake Scale"
            float prevBakeScale = _targetPortrait._bakeScale;

            _targetPortrait._bakeScale = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_BakeScale), _targetPortrait._bakeScale);



            //"Z Per Depth"
            float prevBakeZSize = _targetPortrait._bakeZSize;

            _targetPortrait._bakeZSize = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_ZPerDepth), _targetPortrait._bakeZSize);


            if (_targetPortrait._bakeZSize < 0.5f)
            {
                _targetPortrait._bakeZSize = 0.5f;
            }

            GUILayout.Space(5);



            //Gamma Space Space
            bool prevBakeGamma   = _editor._isBakeColorSpaceToGamma;
            int  iPrevColorSpace = prevBakeGamma ? 0 : 1;
            int  iNextColorSpace = EditorGUILayout.Popup(_editor.GetUIWord(UIWORD.ColorSpace), iPrevColorSpace, _colorSpaceNames);

            if (iNextColorSpace != iPrevColorSpace)
            {
                if (iNextColorSpace == 0)
                {
                    //Gamma
                    _editor._isBakeColorSpaceToGamma = true;
                }
                else
                {
                    //Linear
                    _editor._isBakeColorSpaceToGamma = false;
                }
            }
            //_editor._isBakeColorSpaceToGamma = EditorGUILayout.Toggle("Gamma Color Space", _editor._isBakeColorSpaceToGamma);

            //GUILayout.Space(5);
            //float nextPhysicsScale = EditorGUILayout.DelayedFloatField("Physic Scale", _targetPortrait._physicBakeScale);

            GUILayout.Space(5);

            //Sorting Layer
            int prevSortingLayerID = _editor._portrait._sortingLayerID;
            int prevSortingOrder   = _editor._portrait._sortingOrder;

            int layerIndex = -1;

            for (int i = 0; i < SortingLayer.layers.Length; i++)
            {
                if (SortingLayer.layers[i].id == _editor._portrait._sortingLayerID)
                {
                    //찾았다.
                    layerIndex = i;
                    break;
                }
            }
            if (layerIndex < 0)
            {
                //어라 레이어가 없는데용..
                //초기화해야겠다.
                _editor._portrait._sortingLayerID = -1;
                if (SortingLayer.layers.Length > 0)
                {
                    _editor._portrait._sortingLayerID = SortingLayer.layers[0].id;
                    layerIndex = 0;
                }
            }
            int nextIndex = EditorGUILayout.Popup("Sorting Layer", layerIndex, _sortingLayerNames);

            if (nextIndex != layerIndex)
            {
                //레이어가 변경되었다.
                if (nextIndex >= 0 && nextIndex < SortingLayer.layers.Length)
                {
                    //LayerID 변경
                    _editor._portrait._sortingLayerID = SortingLayer.layers[nextIndex].id;
                }
            }
            _editor._portrait._sortingOrder = EditorGUILayout.IntField("Sorting Order", _editor._portrait._sortingOrder);



            //CheckChangedProperties(nextRootScale, nextZScale);
            if (prevBakeScale != _targetPortrait._bakeScale ||
                prevBakeZSize != _targetPortrait._bakeZSize ||
                prevSortingLayerID != _editor._portrait._sortingLayerID ||
                prevSortingOrder != _editor._portrait._sortingOrder)
            {
                apEditorUtil.SetEditorDirty();
            }

            if (prevBakeGamma != _editor._isBakeColorSpaceToGamma

                )
            {
                apEditorUtil.SetEditorDirty();
                _editor.SaveEditorPref();
            }

            GUILayout.Space(10);


            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Bake), GUILayout.Height(45)))            //"Bake"
            {
                GUI.FocusControl(null);

                //CheckChangedProperties(nextRootScale, nextZScale);
                apEditorUtil.SetEditorDirty();

                //-------------------------------------
                // Bake 함수를 실행한다. << 중요오오오오
                //-------------------------------------
                apBakeResult bakeResult = _editor.Controller.Bake();


                _editor.Notification("[" + _targetPortrait.name + "] is Baked", false, false);

                if (bakeResult.NumUnlinkedExternalObject > 0)
                {
                    EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                _editor.GetText(TEXT.Okay));
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width - 10);
            GUILayout.Space(10);

            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_OptimizedBaking));            //"Optimized Baking"

            //"Target"
            apPortrait nextOptPortrait = (apPortrait)EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Target), _targetPortrait._bakeTargetOptPortrait, typeof(apPortrait), true);

            if (nextOptPortrait != _targetPortrait._bakeTargetOptPortrait)
            {
                //타겟을 바꾸었다.
                bool isChanged = false;
                if (nextOptPortrait != null)
                {
                    //1. 다른 Portrait를 선택했다.
                    if (!nextOptPortrait._isOptimizedPortrait)
                    {
                        //1-1. 최적화된 객체가 아니다.
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                    _editor.GetText(TEXT.OptBakeError_NotOptTarget_Body),
                                                    _editor.GetText(TEXT.Close));
                    }
                    else if (nextOptPortrait._bakeSrcEditablePortrait != _targetPortrait)
                    {
                        //1-2. 다른 대상으로부터 Bake된 Portrait같다. (물어보고 계속)
                        bool isResult = EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                                    _editor.GetText(TEXT.OptBakeError_SrcMatchError_Body),
                                                                    _editor.GetText(TEXT.Okay),
                                                                    _editor.GetText(TEXT.Cancel));

                        if (isResult)
                        {
                            //뭐 선택하겠다는데요 뭐..
                            isChanged = true;
                        }
                    }
                    else
                    {
                        //1-3. 오케이. 변경 가능
                        isChanged = true;
                    }
                }
                else
                {
                    //2. 선택을 해제했다.
                    isChanged = true;
                }

                if (isChanged)
                {
                    //Target을 변경한다.
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._bakeTargetOptPortrait = nextOptPortrait;
                }
            }

            string optBtnText = "";

            if (_targetPortrait._bakeTargetOptPortrait != null)
            {
                //optBtnText = "Optimized Bake to\n[" + _targetPortrait._bakeTargetOptPortrait.gameObject.name + "]";
                optBtnText = string.Format("{0}\n[{1}]", _editor.GetText(TEXT.DLG_OptimizedBakeTo), _targetPortrait._bakeTargetOptPortrait.gameObject.name);
            }
            else
            {
                //optBtnText = "Optimized Bake\n(Make New GameObject)";
                optBtnText = _editor.GetText(TEXT.DLG_OptimizedBakeMakeNew);
            }
            GUILayout.Space(10);

            if (GUILayout.Button(optBtnText, GUILayout.Height(45)))
            {
                GUI.FocusControl(null);

                //CheckChangedProperties(nextRootScale, nextZScale);

                //Optimized Bake를 하자
                apBakeResult bakeResult = _editor.Controller.OptimizedBake(_targetPortrait, _targetPortrait._bakeTargetOptPortrait);

                if (bakeResult.NumUnlinkedExternalObject > 0)
                {
                    EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                _editor.GetText(TEXT.Okay));
                }

                _editor.Notification("[" + _targetPortrait.name + "] is Baked (Optimized)", false, false);
            }
        }
Ejemplo n.º 10
0
        // GUI
        //------------------------------------------------------------------
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetPortrait == null)
            {
                CloseDialog();
                return;
            }

            //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자
            if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait)
            {
                CloseDialog();
                return;
            }



            //Sorting Layer를 추가하자
            if (_sortingLayerNames == null || _sortingLayerIDs == null)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }
            else if (_sortingLayerNames.Length != SortingLayer.layers.Length ||
                     _sortingLayerIDs.Length != SortingLayer.layers.Length)
            {
                _sortingLayerNames = new string[SortingLayer.layers.Length];
                _sortingLayerIDs   = new int[SortingLayer.layers.Length];
            }

            for (int i = 0; i < SortingLayer.layers.Length; i++)
            {
                _sortingLayerNames[i] = SortingLayer.layers[i].name;
                _sortingLayerIDs[i]   = SortingLayer.layers[i].id;
            }


            int width_2Btn = (width - 14) / 2;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Bake), _tab == TAB.Bake, width_2Btn, 25))
            {
                _tab = TAB.Bake;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Setting), _tab == TAB.Options, width_2Btn, 25))
            {
                _tab = TAB.Options;
            }
            EditorGUILayout.EndHorizontal();


            if (_tab == TAB.Bake)
            {
                GUILayout.Space(5);

                // 1. Bake에 대한 UI
                //Bake 설정
                //EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_BakeSetting));//"Bake Setting"
                //GUILayout.Space(5);

                EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Portrait), _targetPortrait, typeof(apPortrait), true);                //"Portait"

                GUILayout.Space(5);

                //"Bake Scale"
                float prevBakeScale = _targetPortrait._bakeScale;
                _targetPortrait._bakeScale = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_BakeScale), _targetPortrait._bakeScale);

                //"Z Per Depth"
                float prevBakeZSize = _targetPortrait._bakeZSize;
                _targetPortrait._bakeZSize = EditorGUILayout.FloatField(_editor.GetText(TEXT.DLG_ZPerDepth), _targetPortrait._bakeZSize);

                if (_targetPortrait._bakeZSize < 0.5f)
                {
                    _targetPortrait._bakeZSize = 0.5f;
                }

                if (prevBakeScale != _targetPortrait._bakeScale ||
                    prevBakeZSize != _targetPortrait._bakeZSize)
                {
                    apEditorUtil.SetEditorDirty();
                }


                //Bake 버튼
                GUILayout.Space(10);
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Bake), GUILayout.Height(45)))                //"Bake"
                {
                    GUI.FocusControl(null);

                    //CheckChangedProperties(nextRootScale, nextZScale);
                    apEditorUtil.SetEditorDirty();

                    //-------------------------------------
                    // Bake 함수를 실행한다. << 중요오오오오
                    //-------------------------------------
                    apBakeResult bakeResult = _editor.Controller.Bake();


                    _editor.Notification("[" + _targetPortrait.name + "] is Baked", false, false);

                    if (bakeResult.NumUnlinkedExternalObject > 0)
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                    _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                    _editor.GetText(TEXT.Okay));
                    }
                }

                GUILayout.Space(10);
                apEditorUtil.GUI_DelimeterBoxH(width - 10);
                GUILayout.Space(10);


                //최적화 Bake
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_OptimizedBaking));                //"Optimized Baking"

                //"Target"
                apPortrait nextOptPortrait = (apPortrait)EditorGUILayout.ObjectField(_editor.GetText(TEXT.DLG_Target), _targetPortrait._bakeTargetOptPortrait, typeof(apPortrait), true);

                if (nextOptPortrait != _targetPortrait._bakeTargetOptPortrait)
                {
                    //타겟을 바꾸었다.
                    bool isChanged = false;
                    if (nextOptPortrait != null)
                    {
                        //1. 다른 Portrait를 선택했다.
                        if (!nextOptPortrait._isOptimizedPortrait)
                        {
                            //1-1. 최적화된 객체가 아니다.
                            EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                        _editor.GetText(TEXT.OptBakeError_NotOptTarget_Body),
                                                        _editor.GetText(TEXT.Close));
                        }
                        else if (nextOptPortrait._bakeSrcEditablePortrait != _targetPortrait)
                        {
                            //1-2. 다른 대상으로부터 Bake된 Portrait같다. (물어보고 계속)
                            bool isResult = EditorUtility.DisplayDialog(_editor.GetText(TEXT.OptBakeError_Title),
                                                                        _editor.GetText(TEXT.OptBakeError_SrcMatchError_Body),
                                                                        _editor.GetText(TEXT.Okay),
                                                                        _editor.GetText(TEXT.Cancel));

                            if (isResult)
                            {
                                //뭐 선택하겠다는데요 뭐..
                                isChanged = true;
                            }
                        }
                        else
                        {
                            //1-3. 오케이. 변경 가능
                            isChanged = true;
                        }
                    }
                    else
                    {
                        //2. 선택을 해제했다.
                        isChanged = true;
                    }

                    if (isChanged)
                    {
                        //Target을 변경한다.
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                        _targetPortrait._bakeTargetOptPortrait = nextOptPortrait;
                    }
                }

                string optBtnText = "";
                if (_targetPortrait._bakeTargetOptPortrait != null)
                {
                    //optBtnText = "Optimized Bake to\n[" + _targetPortrait._bakeTargetOptPortrait.gameObject.name + "]";
                    optBtnText = string.Format("{0}\n[{1}]", _editor.GetText(TEXT.DLG_OptimizedBakeTo), _targetPortrait._bakeTargetOptPortrait.gameObject.name);
                }
                else
                {
                    //optBtnText = "Optimized Bake\n(Make New GameObject)";
                    optBtnText = _editor.GetText(TEXT.DLG_OptimizedBakeMakeNew);
                }
                GUILayout.Space(10);

                if (GUILayout.Button(optBtnText, GUILayout.Height(45)))
                {
                    GUI.FocusControl(null);

                    //CheckChangedProperties(nextRootScale, nextZScale);

                    //Optimized Bake를 하자
                    apBakeResult bakeResult = _editor.Controller.OptimizedBake(_targetPortrait, _targetPortrait._bakeTargetOptPortrait);

                    if (bakeResult.NumUnlinkedExternalObject > 0)
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.BakeWarning_Title),
                                                    _editor.GetTextFormat(TEXT.BakeWarning_Body, bakeResult.NumUnlinkedExternalObject),
                                                    _editor.GetText(TEXT.Okay));
                    }

                    _editor.Notification("[" + _targetPortrait.name + "] is Baked (Optimized)", false, false);
                }
            }
            else
            {
                //Vector2 curScroll = (_tab == TAB.Bake) ? _scroll_Bake : _scroll_Options;

                _scroll_Options = EditorGUILayout.BeginScrollView(_scroll_Options, false, true, GUILayout.Width(width), GUILayout.Height(height - 30));

                EditorGUILayout.BeginVertical(GUILayout.Width(width - 24));
                GUILayout.Space(5);

                width -= 24;

                // 2. Option에 대한 UI
                //1. Gamma Space Space
                bool prevBakeGamma   = _editor._isBakeColorSpaceToGamma;
                int  iPrevColorSpace = prevBakeGamma ? 0 : 1;
                int  iNextColorSpace = EditorGUILayout.Popup(_editor.GetUIWord(UIWORD.ColorSpace), iPrevColorSpace, _colorSpaceNames);
                if (iNextColorSpace != iPrevColorSpace)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (iNextColorSpace == 0)
                    {
                        //Gamma
                        _editor._isBakeColorSpaceToGamma = true;
                    }
                    else
                    {
                        //Linear
                        _editor._isBakeColorSpaceToGamma = false;
                    }
                }

                GUILayout.Space(10);

                //2. Sorting Layer
                int prevSortingLayerID = _editor._portrait._sortingLayerID;
                int prevSortingOrder   = _editor._portrait._sortingOrder;

                int layerIndex = -1;
                for (int i = 0; i < SortingLayer.layers.Length; i++)
                {
                    if (SortingLayer.layers[i].id == _editor._portrait._sortingLayerID)
                    {
                        //찾았다.
                        layerIndex = i;
                        break;
                    }
                }
                if (layerIndex < 0)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);

                    //어라 레이어가 없는데용..
                    //초기화해야겠다.
                    _editor._portrait._sortingLayerID = -1;
                    if (SortingLayer.layers.Length > 0)
                    {
                        _editor._portrait._sortingLayerID = SortingLayer.layers[0].id;
                        layerIndex = 0;
                    }
                }
                int nextIndex = EditorGUILayout.Popup(_editor.GetText(TEXT.SortingLayer), layerIndex, _sortingLayerNames);                //"Sorting Layer"
                if (nextIndex != layerIndex)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    //레이어가 변경되었다.
                    if (nextIndex >= 0 && nextIndex < SortingLayer.layers.Length)
                    {
                        //LayerID 변경
                        _editor._portrait._sortingLayerID = SortingLayer.layers[nextIndex].id;
                    }
                }
                _editor._portrait._sortingOrder = EditorGUILayout.IntField(_editor.GetText(TEXT.SortingOrder), _editor._portrait._sortingOrder);                //"Sorting Order"

                GUILayout.Space(10);

                //3. 메카님 사용 여부

                //EditorGUILayout.LabelField("Animation Settings");
                bool   prevIsUsingMecanim = _targetPortrait._isUsingMecanim;
                string prevMecanimPath    = _targetPortrait._mecanimAnimClipResourcePath;
                _targetPortrait._isUsingMecanim = EditorGUILayout.Toggle(_editor.GetText(TEXT.IsMecanimAnimation), _targetPortrait._isUsingMecanim); //"Is Mecanim Animation"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.AnimationClipExportPath));                                                           //"Animation Clip Export Path"

                GUIStyle guiStyle_ChangeBtn = new GUIStyle(GUI.skin.button);
                guiStyle_ChangeBtn.margin = GUI.skin.textField.margin;
                guiStyle_ChangeBtn.border = GUI.skin.textField.border;

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(20));
                GUILayout.Space(5);
                EditorGUILayout.TextField(_targetPortrait._mecanimAnimClipResourcePath, GUILayout.Width(width - (70 + 15)));
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), guiStyle_ChangeBtn, GUILayout.Width(70), GUILayout.Height(18)))
                {
                    string defaultPath = _targetPortrait._mecanimAnimClipResourcePath;
                    if (string.IsNullOrEmpty(defaultPath))
                    {
                        defaultPath = Application.dataPath;
                    }
                    string nextPath = EditorUtility.SaveFolderPanel("Select to export animation clips", defaultPath, "");
                    if (!string.IsNullOrEmpty(nextPath))
                    {
                        if (apEditorUtil.IsInAssetsFolder(nextPath))
                        {
                            //유효한 폴더인 경우
                            _targetPortrait._mecanimAnimClipResourcePath = nextPath;
                        }
                        else
                        {
                            //유효한 폴더가 아닌 경우
                            EditorUtility.DisplayDialog("Invalid Folder Path", "Invalid Clip Path", "Close");
                        }
                    }

                    GUI.FocusControl(null);
                }
                EditorGUILayout.EndHorizontal();



                GUILayout.Space(10);

                //4. Important
                //"Is Important"
                bool nextImportant = EditorGUILayout.Toggle(new GUIContent(_editor.GetText(TEXT.DLG_Setting_IsImportant), "When this setting is on, it always updates and the physics effect works."), _targetPortrait._isImportant);
                if (nextImportant != _targetPortrait._isImportant)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._isImportant = nextImportant;
                }

                //"FPS (Important Off)"
                int nextFPS = EditorGUILayout.DelayedIntField(new GUIContent(_editor.GetText(TEXT.DLG_Setting_FPS), "This setting is used when <Important> is off"), _targetPortrait._FPS);
                if (_targetPortrait._FPS != nextFPS)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (nextFPS < 10)
                    {
                        nextFPS = 10;
                    }
                    _targetPortrait._FPS = nextFPS;
                }

                GUILayout.Space(10);

                //5. Billboard + Perspective

                apPortrait.BILLBOARD_TYPE nextBillboardType = (apPortrait.BILLBOARD_TYPE)EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Billboard), (int)_targetPortrait._billboardType, _billboardTypeNames);
                if (nextBillboardType != _targetPortrait._billboardType)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._billboardType = nextBillboardType;
                }

                GUILayout.Space(10);

                //6. Shadow

                apPortrait.SHADOW_CASTING_MODE nextChastShadows = (apPortrait.SHADOW_CASTING_MODE)EditorGUILayout.EnumPopup(_editor.GetUIWord(UIWORD.CastShadows), _targetPortrait._meshShadowCastingMode);
                bool nextReceiveShaodw = EditorGUILayout.Toggle(_editor.GetUIWord(UIWORD.ReceiveShadows), _targetPortrait._meshReceiveShadow);
                if (nextChastShadows != _targetPortrait._meshShadowCastingMode ||
                    nextReceiveShaodw != _targetPortrait._meshReceiveShadow)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    _targetPortrait._meshShadowCastingMode = nextChastShadows;
                    _targetPortrait._meshReceiveShadow     = nextReceiveShaodw;
                }

                GUILayout.Space(10);

#if UNITY_2018_2_OR_NEWER
                //7. LWRP
                //LWRP 쉐이더를 쓸지 여부와 다시 강제로 생성하기 버튼을 만들자.
                bool prevUseLWRP  = _editor._isUseLWRPShader;
                int  iPrevUseLWRP = prevUseLWRP ? 1 : 0;
                int  iNextUseLWRP = EditorGUILayout.Popup("Render Pipeline", iPrevUseLWRP, _renderPipelineNames);
                if (iNextUseLWRP != iPrevUseLWRP)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false);
                    if (iNextUseLWRP == 0)
                    {
                        //사용 안함
                        _editor._isUseLWRPShader = false;
                    }
                    else
                    {
                        //LWRP 사용함
                        _editor._isUseLWRPShader = true;
                    }
                }
                if (GUILayout.Button("Generate Lightweight Shaders"))
                {
                    apShaderGenerator shaderGenerator = new apShaderGenerator();
                    shaderGenerator.GenerateLWRPShaders();
                }

                GUILayout.Space(10);
#endif

                //11.7 추가 : Ambient Light를 검은색으로 만든다.
                GUILayout.Space(10);
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_AmbientToBlack), GUILayout.Height(20)))
                {
                    MakeAmbientLightToBlack();
                }

                //CheckChangedProperties(nextRootScale, nextZScale);
                if (prevSortingLayerID != _editor._portrait._sortingLayerID ||
                    prevSortingOrder != _editor._portrait._sortingOrder ||
                    prevIsUsingMecanim != _targetPortrait._isUsingMecanim ||
                    !string.Equals(prevMecanimPath, _targetPortrait._mecanimAnimClipResourcePath) ||
                    prevBakeGamma != _editor._isBakeColorSpaceToGamma
#if UNITY_2018_2_OR_NEWER
                    || prevUseLWRP != _editor._isUseLWRPShader
#endif
                    )
                {
                    apEditorUtil.SetEditorDirty();
                    _editor.SaveEditorPref();
                }

                GUILayout.Space(height + 500);
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndScrollView();
            }

            GUILayout.Space(5);
        }
        void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            if (_editor == null || _targetMeshGroup == null)
            {
                CloseDialog();
                return;
            }

            try
            {
                Color prevColor = GUI.backgroundColor;

                //레이아웃 구조
                // 타이틀
                // Pose 리스트 경로 + 변경 + 갱신
                // Pose 보기 종류 : 동일 MeshGroup만, 동일 Portrait만, 모든 Scene에서의 Pose 기록 (Import 안될 수도 있음)
                // Pose 리스트
                // 선택한 Pose 정보
                // Pose 이름, 설명
                // 저장된 Bone 이름들 (최대 4개 보여주기)
                // Import / Close

                width -= 10;

                //1. 다이얼로그 타이틀
                GUIStyle guiStyleBox = new GUIStyle(GUI.skin.box);
                guiStyleBox.alignment        = TextAnchor.MiddleCenter;
                guiStyleBox.normal.textColor = apEditorUtil.BoxTextColor;

                GUIStyle guiStyleBox_Left = new GUIStyle(GUI.skin.textField);
                guiStyleBox_Left.alignment = TextAnchor.MiddleLeft;

                //"  Import Pose"
                GUILayout.Box(new GUIContent("  " + _editor.GetText(TEXT.DLG_ImportPose), _editor.ImageSet.Get(apImageSet.PRESET.Rig_LoadBones)), guiStyleBox, GUILayout.Width(width), GUILayout.Height(35));
                GUILayout.Space(5);

                //2. Pose 리스트 경로 + 변경 + 갱신
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(20));
                int changeBtnWidth  = 70;
                int refreshBtnWidth = 80;
                int pathWidth       = width - (changeBtnWidth + refreshBtnWidth + 4 + 10);

                GUILayout.Space(5);
                EditorGUILayout.TextField(_editor._bonePose_BaseFolderName, GUILayout.Width(pathWidth), GUILayout.Height(20));

                //"Change"
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), GUILayout.Width(changeBtnWidth), GUILayout.Height(20)))
                {
                    string pathResult = EditorUtility.SaveFolderPanel("Set the Pose Folder", _editor._bonePose_BaseFolderName, "");
                    if (!string.IsNullOrEmpty(pathResult))
                    {
                        Uri targetUri = new Uri(pathResult);
                        Uri baseUri   = new Uri(Application.dataPath);

                        string relativePath = baseUri.MakeRelativeUri(targetUri).ToString();

                        _editor._bonePose_BaseFolderName = relativePath;

                        apEditorUtil.SetEditorDirty();

                        _editor.SaveEditorPref();

                        _retarget.LoadSinglePoseFileList(_editor);
                        _selectedBonePoseFile = null;
                        _isValidPose          = false;
                    }
                }
                //"Refresh"
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Refresh), GUILayout.Width(refreshBtnWidth), GUILayout.Height(20)))
                {
                    _retarget.LoadSinglePoseFileList(_editor);
                    _selectedBonePoseFile = null;
                    _isValidPose          = false;
                }

                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //3. Pose 보기 종류
                int categoryBtnWidth  = (width - 10) / 3 - 1;
                int categoryBtnHeight = 20;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(categoryBtnHeight));
                GUILayout.Space(5);

                //"Same MeshGroup"
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_SameGroup), _category == CATEGORY.SameMeshGroup, true, categoryBtnWidth, categoryBtnHeight))
                {
                    _category             = CATEGORY.SameMeshGroup;
                    _selectedBonePoseFile = null;
                    _isValidPose          = false;
                }

                //"Same Portrait"
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_SamePortrait), _category == CATEGORY.SamePortrait, true, categoryBtnWidth, categoryBtnHeight))
                {
                    _category             = CATEGORY.SamePortrait;
                    _selectedBonePoseFile = null;
                    _isValidPose          = false;
                }

                //"All Poses"
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_AllPoses), _category == CATEGORY.AllPoses, true, categoryBtnWidth, categoryBtnHeight))
                {
                    _category             = CATEGORY.AllPoses;
                    _selectedBonePoseFile = null;
                    _isValidPose          = false;
                }

                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //4. Pose 리스트
                int listHeight = height - 450;

                Rect lastRect = GUILayoutUtility.GetLastRect();

                GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
                GUI.Box(new Rect(0, lastRect.y + 5, width + 10, listHeight), "");

                List <apRetargetPoseListFile.FileMetaData> metaDataList = _retarget.SinglePoseList._metaDataList;

                int itemWidth  = width - 20;
                int itemHeight = 20;

                int poseNameWidth      = 120;
                int portraitNameWidth  = 100;
                int meshGroupNameWidth = 100;
                int selectBtnWidth     = (width - 40) - (poseNameWidth + portraitNameWidth + meshGroupNameWidth + 6);

                GUIStyle guiStyle_ItemLabel = new GUIStyle(GUI.skin.label);
                guiStyle_ItemLabel.alignment = TextAnchor.MiddleLeft;

                GUIStyle guiStyle_ItemCategory = new GUIStyle(GUI.skin.label);
                //guiStyle_ItemCategory.alignment = TextAnchor.MiddleCenter;
                if (EditorGUIUtility.isProSkin)
                {
                    guiStyle_ItemCategory.normal.textColor = Color.cyan;
                }
                else
                {
                    guiStyle_ItemCategory.normal.textColor = Color.blue;
                }


                _scrollList = EditorGUILayout.BeginScrollView(_scrollList, false, true, GUILayout.Width(width + 10), GUILayout.Height(listHeight));
                EditorGUILayout.BeginVertical(GUILayout.Width(width - 10));

                if (!_retarget.SinglePoseList._isFolderExist)
                {
                    //"Pose Folder does not exist."
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PoseFolderNotExist), GUILayout.Width(itemWidth));
                }
                else
                {
                    //Pose 이름 / Portrait 이름 / MeshGroup 이름 / 선택

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(itemWidth), GUILayout.Height(itemHeight));
                    GUILayout.Space(5);

                    //"Name"
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Name), guiStyle_ItemCategory, GUILayout.Width(poseNameWidth), GUILayout.Height(itemHeight));

                    //"Portrait"
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Portrait), guiStyle_ItemCategory, GUILayout.Width(portraitNameWidth), GUILayout.Height(itemHeight));

                    //"Mesh Group"
                    EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_MeshGroup), guiStyle_ItemCategory, GUILayout.Width(meshGroupNameWidth), GUILayout.Height(itemHeight));
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(10);

                    apRetargetPoseListFile.FileMetaData metaData = null;
                    for (int i = 0; i < metaDataList.Count; i++)
                    {
                        metaData = metaDataList[i];

                        if (_category == CATEGORY.AllPoses)
                        {
                            //그냥 통과
                        }
                        else if (_category == CATEGORY.SamePortrait)
                        {
                            if (!string.Equals(_portraitName, metaData._portraitName))
                            {
                                //Portrait 이름이 다르면 스킵
                                continue;
                            }
                        }
                        else if (_category == CATEGORY.SameMeshGroup)
                        {
                            if (!string.Equals(_portraitName, metaData._portraitName) ||
                                _meshGroupUniqueID != metaData._meshGroupUniqueID)
                            {
                                //Portrait 이름이 다르거나 MeshGroupUniqueID가 다르다면 스킵
                                continue;
                            }
                        }

                        EditorGUILayout.BeginHorizontal(GUILayout.Width(itemWidth), GUILayout.Height(itemHeight));
                        GUILayout.Space(5);
                        EditorGUILayout.LabelField(metaData._poseName, guiStyle_ItemLabel, GUILayout.Width(poseNameWidth), GUILayout.Height(itemHeight));
                        EditorGUILayout.LabelField(metaData._portraitName, guiStyle_ItemLabel, GUILayout.Width(portraitNameWidth), GUILayout.Height(itemHeight));
                        EditorGUILayout.LabelField(metaData._meshGroupName, guiStyle_ItemLabel, GUILayout.Width(meshGroupNameWidth), GUILayout.Height(itemHeight));

                        //"Selected", "Select"
                        if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.DLG_Selected),
                                                             _editor.GetText(TEXT.DLG_Select), metaData == _selectedBonePoseFile, true, selectBtnWidth, itemHeight))
                        {
                            _selectedBonePoseFile = metaData;

                            _isValidPose = string.Equals(_portraitName, metaData._portraitName) &&
                                           _meshGroupUniqueID == metaData._meshGroupUniqueID;
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(listHeight + 100);

                EditorGUILayout.EndScrollView();

                GUILayout.Space(10);
                //정보를 출력한다.
                //Pose 이름
                //설명
                //Portrait
                //MeshGroup
                //MeshGroup이 다르면 경고를 준다.
                //Bone 개수와 이름들
                //string selectedPoseName = "No Pose Selected";
                string selectedPoseName      = _editor.GetText(TEXT.DLG_NoPoseSelected);
                string selectedDesc          = "";
                string selectedPortrait      = "";
                string selectedMeshGroupName = "";
                int    boneCount             = 0;
                string selectedBoneNames     = "";

                if (_selectedBonePoseFile != null)
                {
                    selectedPoseName      = _selectedBonePoseFile._poseName;
                    selectedDesc          = _selectedBonePoseFile._description;
                    selectedPortrait      = _selectedBonePoseFile._portraitName;
                    selectedMeshGroupName = _selectedBonePoseFile._meshGroupName;
                    boneCount             = _selectedBonePoseFile._nBones;
                    selectedBoneNames     = _selectedBonePoseFile._boneNames;
                }

                GUIStyle guiStyle_Desc = new GUIStyle(GUI.skin.textField);
                guiStyle_Desc.wordWrap = true;

                if (_selectedBonePoseFile != null)
                {
                    GUI.backgroundColor = new Color(GUI.backgroundColor.r * 1.0f, GUI.backgroundColor.g * 1.8f, GUI.backgroundColor.b * 1.2f, 1.0f);
                }
                GUILayout.Box(selectedPoseName, guiStyleBox, GUILayout.Width(width), GUILayout.Height(30));
                if (_selectedBonePoseFile != null)
                {
                    GUI.backgroundColor = prevColor;
                }

                //"Description"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Description), GUILayout.Width(width));
                EditorGUILayout.LabelField(selectedDesc, guiStyle_Desc, GUILayout.Width(width), GUILayout.Height(45));

                GUILayout.Space(5);

                EditorGUILayout.LabelField(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_Portrait), selectedPortrait), GUILayout.Width(width));            //"Portrait : "
                EditorGUILayout.LabelField(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_MeshGroup), selectedMeshGroupName), GUILayout.Width(width));      //"Mesh Group : "
                GUILayout.Space(5);
                EditorGUILayout.LabelField(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_NumberBones), boneCount), GUILayout.Width(width));                //"Number of Bones : "

                if (_selectedBonePoseFile == null)
                {
                    //"No Bones"
                    GUILayout.Box(_editor.GetText(TEXT.DLG_NoBones), GUILayout.Width(width), GUILayout.Height(45));
                }
                else
                {
                    if (_isValidPose)
                    {
                        GUI.backgroundColor = new Color(GUI.backgroundColor.r * 1.0f, GUI.backgroundColor.g * 1.5f, GUI.backgroundColor.b * 1.2f, 1.0f);
                        GUILayout.Box(selectedBoneNames, guiStyleBox, GUILayout.Width(width), GUILayout.Height(45));
                        GUI.backgroundColor = prevColor;
                    }
                    else
                    {
                        GUI.backgroundColor = new Color(GUI.backgroundColor.r * 1.5f, GUI.backgroundColor.g * 0.7f, GUI.backgroundColor.b * 0.7f, 1.0f);
                        //"[Warning. Import may not work properly]\n" + selectedBoneNames
                        GUILayout.Box(string.Format("[{0}]\n{1}", _editor.GetText(TEXT.DLG_Warningproperly), selectedBoneNames), guiStyleBox, GUILayout.Width(width), GUILayout.Height(45));
                        GUI.backgroundColor = prevColor;
                    }
                }

                //"Remove Pose", "Remove Pose"
                if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.DLG_RemovePose), _editor.GetText(TEXT.DLG_RemovePose), false, _selectedBonePoseFile != null, width, 20))
                {
                    bool isResult = EditorUtility.DisplayDialog(_editor.GetText(TEXT.Retarget_RemoveSinglePose_Title),
                                                                _editor.GetTextFormat(TEXT.Retarget_RemoveSinglePose_Body, selectedPoseName),
                                                                _editor.GetText(TEXT.Remove), _editor.GetText(TEXT.Cancel)
                                                                );

                    if (isResult && _selectedBonePoseFile != null)
                    {
                        _retarget.SinglePoseList.RemoveFile(_selectedBonePoseFile);

                        //리스트 갱신
                        _retarget.LoadSinglePoseFileList(_editor);
                        _selectedBonePoseFile = null;
                        _isValidPose          = false;
                    }
                }

                string strImportPose = " " + _editor.GetText(TEXT.DLG_ImportPose);
                GUILayout.Space(10);

                //" Import Pose", " Import Pose"
                if (apEditorUtil.ToggledButton_2Side(_editor.ImageSet.Get(apImageSet.PRESET.Rig_LoadBones),
                                                     strImportPose, strImportPose, false, _selectedBonePoseFile != null, width, 30))
                {
                    //1. Retarget Bone Pose에 선택한 MetaData 정보를 넣자
                    if (_selectedBonePoseFile != null)
                    {
                        bool isSuccess = _retarget.LoadSinglePose(_selectedBonePoseFile._filePath);

                        if (!isSuccess)
                        {
                            EditorUtility.DisplayDialog(_editor.GetText(TEXT.Retarget_SinglePoseImportFailed_Title),
                                                        _editor.GetText(TEXT.Retarget_SinglePoseImportFailed_Body_Error),
                                                        _editor.GetText(TEXT.Close));
                        }
                        else
                        {
                            //2. 리턴 함수 콜
                            if (_funcResult_Anim != null)
                            {
                                _funcResult_Anim(_loadKey, true, _retarget, _targetMeshGroup, _targetAnimClip, _targetAnimTimeline, _targetFrame);
                            }
                            else if (_funcResult_Mod != null)
                            {
                                _funcResult_Mod(_loadKey, true, _retarget, _targetMeshGroup, _targetModifier, _targetParamSet);
                            }

                            //3. 창 닫기
                            CloseDialog();
                        }
                    }
                    else
                    {
                        EditorUtility.DisplayDialog(_editor.GetText(TEXT.Retarget_SinglePoseImportFailed_Title),
                                                    _editor.GetText(TEXT.Retarget_SinglePoseImportFailed_Body_NoFile),
                                                    _editor.GetText(TEXT.Close));
                    }
                }

                //"Close"
                if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Width(width), GUILayout.Height(25)))
                {
                    if (_funcResult_Anim != null)
                    {
                        _funcResult_Anim(null, false, _retarget, _targetMeshGroup, _targetAnimClip, _targetAnimTimeline, _targetFrame);
                    }
                    else if (_funcResult_Mod != null)
                    {
                        _funcResult_Mod(null, false, _retarget, _targetMeshGroup, _targetModifier, _targetParamSet);
                    }

                    CloseDialog();
                }
            }
            catch (Exception)
            {
            }
        }