/// <summary>
        /// [Please do not use it] Set Frame in Editor
        /// </summary>
        /// <param name="frame"></param>
        public void SetFrame_Editor(int frame)
        {
            if (_curRootUnitInEditor == null || _curAnimClipInEditor == null)
            {
                return;
            }

            int startFrame = _curAnimClipInEditor.StartFrame;
            int endFrame   = _curAnimClipInEditor.EndFrame;

            int nextFrame = Mathf.Clamp(frame, startFrame, endFrame);

            _curAnimClipInEditor.SetFrame_Editor(nextFrame);
        }
Example #2
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();


            //-----------------------------------------------------------------------------------------------------------------------
            //-----------------------------------------------------------------------------------------------------------------------
        }
Example #3
0
        // GUI
        //------------------------------------------------------------------------------------------------
        private void OnGUI()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

            width -= 10;

            //만약 이 다이얼로그가 켜진 상태로 뭔가 바뀌었다면 종료
            bool isClose                  = false;
            bool isMoveAnimKeyframe       = false;
            bool isMoveAnimKeyframeToNext = false;

            if (_editor == null || _meshGroup == null || _modifier == null || _modMesh == null || _renderUnit == null)
            {
                //데이터가 없다.
                isClose = true;
            }
            else if (_editor.Select.SelectionType != _selectionType)
            {
                //선택 타입이 바뀌었다.
                isClose = true;
            }
            else
            {
                if (!_isAnimEdit)
                {
                    //1. 일반 모디파이어 편집시
                    //- 현재 선택된 MeshGroup이 바뀌었다면
                    //- 현재 선택된 Modifier가 바뀌었다면
                    //- Modifier 메뉴가 아니라면
                    //- ExEditingMode가 꺼졌다면
                    //> 해제
                    if (_editor.Select.ExEditingMode == apSelection.EX_EDIT.None ||
                        _editor.Select.MeshGroup != _meshGroup ||
                        _editor.Select.Modifier != _modifier ||
                        _editor._meshGroupEditMode != apEditor.MESHGROUP_EDIT_MODE.Modifier)
                    {
                        isClose = true;
                    }
                }
                else
                {
                    //2. 애니메이션 편집 시
                    //- 현재 선택된 AnimationClip이 바뀌었다면
                    //- 현재 선택된 MeshGroup이 바뀌었다면 (AnimClip이 있을 때)
                    //- AnimExEditingMode가 꺼졌다면
                    //- 재생 중이라면
                    //> 해제
                    if (_editor.Select.ExAnimEditingMode == apSelection.EX_EDIT.None ||
                        _editor.Select.AnimClip != _animClip ||
                        _animClip == null ||
                        _keyframe == null ||
                        _editor.Select.AnimClip._targetMeshGroup != _meshGroup ||
                        _editor.Select.IsAnimPlaying)
                    {
                        isClose = true;
                    }
                }
            }

            if (isClose)
            {
                CloseDialog();
                return;
            }


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

            //1. 선택된 객체 정보
            //- RenderUnit 아이콘과 이름

            //2. <애니메이션인 경우>
            //- 현재 키프레임과 키프레임 이동하기

            //3. 가중치
            //- [일반] Weight CutOut
            //- [Anim] Prev / Next CutOut

            // (구분선)

            //4. Depth
            //- 아이콘과 Chainging Depth 레이블
            //- On / Off 버튼
            //- Depth 증감과 리스트 (좌우에 배치)

            //5. Texture (RenderUnit이 MeshTransform인 경우)
            //- 현재 텍스쳐
            //- 바뀔 텍스쳐
            //- 텍스쳐 선택하기 버튼

            //1. 선택된 객체 정보
            //- RenderUnit 아이콘과 이름
            //int iconSize = 25;
            GUIStyle guiStyle_TargetBox = new GUIStyle(GUI.skin.box);

            guiStyle_TargetBox.alignment = TextAnchor.MiddleCenter;
            Color prevColor = GUI.backgroundColor;

            // RenderUnit 이름
            Texture2D iconRenderUnit = null;

            if (_renderUnit._meshTransform != null)
            {
                iconRenderUnit = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Mesh);
            }
            else
            {
                iconRenderUnit = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_MeshGroup);
            }
            GUI.backgroundColor = new Color(0.5f, 1.0f, 1.0f, 1.0f);
            GUILayout.Box(new GUIContent("  " + _renderUnit.Name, iconRenderUnit), guiStyle_TargetBox, GUILayout.Width(width), GUILayout.Height(30));
            GUI.backgroundColor = prevColor;

            GUILayout.Space(5);

            //"Extra Property ON", "Extra Property OFF"
            if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_ExtraPropertyOn), _editor.GetText(TEXT.ExtraOpt_ExtraPropertyOff), _modMesh._isExtraValueEnabled, true, width, 25))
            {
                apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                _modMesh._isExtraValueEnabled = !_modMesh._isExtraValueEnabled;
                _meshGroup.RefreshModifierLink();                //<<옵션의 형태가 바뀌면 Modifier의 Link를 다시 해야한다.
                apEditorUtil.ReleaseGUIFocus();
            }

            GUILayout.Space(5);

            if (_isAnimEdit)
            {
                GUILayout.Space(10);

                //2. <애니메이션인 경우>
                //- 현재 키프레임과 키프레임 이동하기

                //"Target Frame"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_TargetFrame));
                int frameBtnSize      = 20;
                int frameCurBtnWidth  = 100;
                int frameMoveBtnWidth = (width - (10 + frameCurBtnWidth)) / 2;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(frameBtnSize));
                GUILayout.Space(5);
                if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Anim_MoveToPrevFrame), GUILayout.Width(frameMoveBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    //이전 프레임으로 이동하기
                    isMoveAnimKeyframe       = true;
                    isMoveAnimKeyframeToNext = false;
                }
                if (GUILayout.Button(_keyframe._frameIndex.ToString(), GUILayout.Width(frameCurBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    _animClip.SetFrame_Editor(_keyframe._frameIndex);
                    _editor.SetRepaint();
                }
                if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Anim_MoveToNextFrame), GUILayout.Width(frameMoveBtnWidth), GUILayout.Height(frameBtnSize)))
                {
                    //다음 프레임으로 이동하기
                    isMoveAnimKeyframe       = true;
                    isMoveAnimKeyframeToNext = true;
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            //3. 가중치
            //- [일반] Weight CutOut
            //- [Anim] Prev / Next CutOut

            EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_WeightSettings));            //"Weight Settings"
            GUILayout.Space(5);
            if (!_isAnimEdit)
            {
                //일반이면 CutOut이 1개
                float cutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_Offset), _modMesh._extraValue._weightCutout);                //"Offset (0~1)"

                if (cutOut != _modMesh._extraValue._weightCutout)
                {
                    cutOut = Mathf.Clamp01(cutOut);
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._weightCutout = cutOut;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }
            else
            {
                //애니메이션이면 CutOut이 2개
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_Offset));
                float animPrevCutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_OffsetPrevKeyframe), _modMesh._extraValue._weightCutout_AnimPrev);                //"Prev Keyframe"
                float animNextCutOut = EditorGUILayout.DelayedFloatField(_editor.GetText(TEXT.ExtraOpt_OffsetNextKeyframe), _modMesh._extraValue._weightCutout_AnimNext);                //"Next Keyframe"

                if (animPrevCutOut != _modMesh._extraValue._weightCutout_AnimPrev ||
                    animNextCutOut != _modMesh._extraValue._weightCutout_AnimNext
                    )
                {
                    animPrevCutOut = Mathf.Clamp01(animPrevCutOut);
                    animNextCutOut = Mathf.Clamp01(animNextCutOut);
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._weightCutout_AnimPrev = animPrevCutOut;
                    _modMesh._extraValue._weightCutout_AnimNext = animNextCutOut;
                    apEditorUtil.ReleaseGUIFocus();
                }
            }

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

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

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight));
            GUILayout.Space(5);
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_Tab_Depth), _tab == TAB.Depth, tabBtnWidth, tabBtnHeight))           //"Depth"
            {
                _tab = TAB.Depth;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_Tab_Image), _tab == TAB.Image, tabBtnWidth, tabBtnHeight))           //"Image"
            {
                _tab = TAB.Image;
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);

            if (_tab == TAB.Depth)
            {
                //4. Depth
                //- 아이콘과 Chainging Depth 레이블
                //- On / Off 버튼
                //- Depth 증감과 리스트 (좌우에 배치)

                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_ChangingDepth));                //"Changing Depth"
                GUILayout.Space(5);

                //"Depth Option ON", "Depth Option OFF"
                if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_DepthOptOn), _editor.GetText(TEXT.ExtraOpt_DepthOptOff), _modMesh._extraValue._isDepthChanged, _modMesh._isExtraValueEnabled, width, 25))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._isDepthChanged = !_modMesh._extraValue._isDepthChanged;
                    _meshGroup.RefreshModifierLink();                    //<<Modifier Link를 다시 해야한다.
                    _editor.SetRepaint();
                }
                GUILayout.Space(5);

                bool isDepthAvailable = _modMesh._extraValue._isDepthChanged && _modMesh._isExtraValueEnabled;

                int depthListWidth_Left       = 80;
                int depthListWidth_Right      = width - (10 + depthListWidth_Left);
                int depthListWidth_RightInner = depthListWidth_Right - 20;
                int depthListHeight           = 276;
                //int depthListHeight_LeftBtn = (depthListHeight - 40) / 2;
                int depthListHeight_LeftBtn   = 40;
                int depthListHeight_LeftSpace = (depthListHeight - (40 + depthListHeight_LeftBtn * 2)) / 2;
                int depthListHeight_RightList = 20;

                //리스트 배경
                Rect lastRect = GUILayoutUtility.GetLastRect();
                if (!isDepthAvailable)
                {
                    GUI.backgroundColor = new Color(1.0f, 0.6f, 0.6f, 1.0f);
                }
                GUI.Box(new Rect(5 + depthListWidth_Left + 8, lastRect.y + 8, depthListWidth_Right, depthListHeight), "");
                if (!isDepthAvailable)
                {
                    GUI.backgroundColor = prevColor;
                }

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(depthListHeight));
                GUILayout.Space(5);
                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight));
                // Depth List의 왼쪽
                // Depth 증감 버튼과 값
                GUILayout.Space(depthListHeight_LeftSpace);

                Texture2D img_AddWeight      = _editor.ImageSet.Get(apImageSet.PRESET.Rig_AddWeight);
                Texture2D img_SubtractWeight = _editor.ImageSet.Get(apImageSet.PRESET.Rig_SubtractWeight);


                //if (GUILayout.Button(, GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight_LeftBtn)))
                if (apEditorUtil.ToggledButton(img_AddWeight, false, isDepthAvailable, depthListWidth_Left, depthListHeight_LeftBtn))
                {
                    //Depth 증가
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._deltaDepth++;
                    _editor.SetRepaint();
                    apEditorUtil.ReleaseGUIFocus();
                }

                //"Delta Depth"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_DeltaDepth), GUILayout.Width(depthListWidth_Left));
                int deltaDepth = EditorGUILayout.DelayedIntField(_modMesh._extraValue._deltaDepth, GUILayout.Width(depthListWidth_Left));
                if (deltaDepth != _modMesh._extraValue._deltaDepth)
                {
                    if (isDepthAvailable)
                    {
                        apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                        _modMesh._extraValue._deltaDepth = deltaDepth;
                        _editor.SetRepaint();
                        apEditorUtil.ReleaseGUIFocus();
                    }
                }

                //if (GUILayout.Button(_editor.ImageSet.Get(apImageSet.PRESET.Rig_SubtractWeight), GUILayout.Width(depthListWidth_Left), GUILayout.Height(depthListHeight_LeftBtn)))
                if (apEditorUtil.ToggledButton(img_SubtractWeight, false, isDepthAvailable, depthListWidth_Left, depthListHeight_LeftBtn))
                {
                    //Depth 감소
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._deltaDepth--;
                    _editor.SetRepaint();
                    apEditorUtil.ReleaseGUIFocus();
                }

                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_Right), GUILayout.Height(depthListHeight));
                // RenderUnit 리스트와 변환될 Depth 위치
                _scrollList = EditorGUILayout.BeginScrollView(_scrollList, false, true, GUILayout.Width(depthListWidth_Right), GUILayout.Height(depthListHeight));

                EditorGUILayout.BeginVertical(GUILayout.Width(depthListWidth_RightInner), GUILayout.Height(depthListHeight));
                GUILayout.Space(5);

                SubUnit curSubUnit = null;



                //int cursorDepth = _renderUnit.GetDepth() + _modMesh._extraValue._deltaDepth;
                int cursorDepth = _targetDepth + _modMesh._extraValue._deltaDepth;

                //GUI Content 생성 [11.16 수정]
                if (_guiContent_DepthMidCursor == null)
                {
                    _guiContent_DepthMidCursor = apGUIContentWrapper.Make(_img_DepthMidCursor);
                }
                if (_guiContent_DepthCursor == null)
                {
                    _guiContent_DepthCursor = apGUIContentWrapper.Make(_img_DepthCursor);
                }
                if (_guiContent_MeshIcon == null)
                {
                    _guiContent_MeshIcon = apGUIContentWrapper.Make(_img_MeshTF);
                }
                if (_guiContent_MeshGroupIcon == null)
                {
                    _guiContent_MeshGroupIcon = apGUIContentWrapper.Make(_img_MeshGroupTF);
                }
                //이전 코드
                //GUIContent guiContent_DepthMidCursor = new GUIContent(_img_DepthMidCursor);
                //GUIContent guiContent_DepthCursor = new GUIContent(_img_DepthCursor);
                //GUIContent guiContent_MeshIcon = new GUIContent(_img_MeshTF);
                //GUIContent guiContent_MeshGroupIcon = new GUIContent(_img_MeshGroupTF);

                int depthCursorSize = depthListHeight_RightList;

                for (int i = 0; i < _subUnits_All.Count; i++)
                {
                    curSubUnit = _subUnits_All[i];

                    if (curSubUnit._isTarget)
                    {
                        //타겟이면 배경색을 그려주자
                        lastRect = GUILayoutUtility.GetLastRect();
                        if (EditorGUIUtility.isProSkin)
                        {
                            GUI.backgroundColor = new Color(0.0f, 1.0f, 1.0f, 1.0f);
                        }
                        else
                        {
                            GUI.backgroundColor = new Color(0.4f, 0.8f, 1.0f, 1.0f);
                        }

                        int yOffset = 6;
                        if (i == 0)
                        {
                            yOffset = 7 - depthListHeight_RightList;
                        }
                        GUI.Box(new Rect(lastRect.x, lastRect.y + depthListHeight_RightList + yOffset, depthListWidth_RightInner + 10, depthListHeight_RightList), "");
                        GUI.backgroundColor = prevColor;
                    }

                    EditorGUILayout.BeginHorizontal(GUILayout.Width(depthListWidth_RightInner), GUILayout.Height(depthListHeight_RightList));


                    //TODO : Depth 커서 그려주기
                    //GUILayout.Space(20);

                    DEPTH_CURSOR_TYPE depthCursorType = DEPTH_CURSOR_TYPE.None;
                    if (!curSubUnit._isTarget)
                    {
                        if (cursorDepth != _targetDepth)
                        {
                            if (cursorDepth == curSubUnit._depth)
                            {
                                depthCursorType = DEPTH_CURSOR_TYPE.Target;
                            }
                            else
                            {
                                if (cursorDepth > _targetDepth)
                                {
                                    //Depth가 증가했을 때
                                    if (_targetDepth < curSubUnit._depth && curSubUnit._depth < cursorDepth)
                                    {
                                        depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                                    }
                                }
                                else
                                {
                                    //Depth가 감소했을 때
                                    if (cursorDepth < curSubUnit._depth && curSubUnit._depth < _targetDepth)
                                    {
                                        depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        if (cursorDepth != _targetDepth)
                        {
                            depthCursorType = DEPTH_CURSOR_TYPE.Mid;
                        }
                        else
                        {
                            depthCursorType = DEPTH_CURSOR_TYPE.Target;
                        }
                    }
                    GUILayout.Space(5);
                    switch (depthCursorType)
                    {
                    case DEPTH_CURSOR_TYPE.None:
                        GUILayout.Space(depthCursorSize + 4);
                        break;

                    case DEPTH_CURSOR_TYPE.Mid:
                        EditorGUILayout.LabelField(_guiContent_DepthMidCursor.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                        break;

                    case DEPTH_CURSOR_TYPE.Target:
                        EditorGUILayout.LabelField(_guiContent_DepthCursor.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                        break;
                    }

                    EditorGUILayout.LabelField(curSubUnit._isMeshTransform ? _guiContent_MeshIcon.Content : _guiContent_MeshGroupIcon.Content, GUILayout.Width(depthCursorSize), GUILayout.Height(depthCursorSize));
                    EditorGUILayout.LabelField(curSubUnit._depth.ToString(), GUILayout.Width(20), GUILayout.Height(depthListHeight_RightList));
                    EditorGUILayout.LabelField(curSubUnit._name,
                                               GUILayout.Width(depthListWidth_RightInner - (24 + 5 + depthCursorSize + depthCursorSize + 20 + 8)),
                                               GUILayout.Height(depthListHeight_RightList)
                                               );

                    EditorGUILayout.EndHorizontal();
                }

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

                EditorGUILayout.EndScrollView();
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                //5. Texture (RenderUnit이 MeshTransform인 경우)
                //- 현재 텍스쳐
                //- 바뀔 텍스쳐
                //- 텍스쳐 선택하기 버튼

                //"Changing Image"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_ChangingImage));
                GUILayout.Space(5);

                //"Image Option ON", "Image Option OFF"
                if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.ExtraOpt_ImageOptOn), _editor.GetText(TEXT.ExtraOpt_ImageOptOff), _modMesh._extraValue._isTextureChanged, _isImageChangable && _modMesh._isExtraValueEnabled, width, 25))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);

                    _modMesh._extraValue._isTextureChanged = !_modMesh._extraValue._isTextureChanged;
                    _meshGroup.RefreshModifierLink();                    //<<Modifier Link를 다시 해야한다.
                    _editor.SetRepaint();
                }
                GUILayout.Space(5);

                bool isTextureAvailable = _modMesh._extraValue._isTextureChanged && _isImageChangable && _modMesh._isExtraValueEnabled;

                int imageSlotSize      = 170;
                int imageSlotSpaceSize = width - (imageSlotSize * 2 + 6 + 10);
                int imageSlotHeight    = imageSlotSize + 50;

                Texture2D img_Src    = null;
                Texture2D img_Dst    = null;
                string    strSrcName = "< None >";
                string    strDstName = "< None >";

                if (_srcTexureData != null && _srcTexureData._image != null)
                {
                    img_Src    = _srcTexureData._image;
                    strSrcName = _srcTexureData._name;
                }
                if (_dstTexureData != null && _dstTexureData._image != null)
                {
                    img_Dst    = _dstTexureData._image;
                    strDstName = _dstTexureData._name;
                }

                GUIStyle guiStyle_ImageSlot = new GUIStyle(GUI.skin.box);
                guiStyle_ImageSlot.alignment = TextAnchor.MiddleCenter;

                GUIStyle guiStyle_ImageName = new GUIStyle(GUI.skin.label);
                guiStyle_ImageName.alignment = TextAnchor.MiddleCenter;

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(imageSlotHeight));
                GUILayout.Space(5);

                //이미지 슬롯 1 : 원래 이미지
                EditorGUILayout.BeginVertical(GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotHeight));
                //"Original"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_SlotOriginal), GUILayout.Width(imageSlotSize));
                GUILayout.Box(img_Src, guiStyle_ImageSlot, GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotSize));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(strSrcName, guiStyle_ImageName, GUILayout.Width(imageSlotSize));
                EditorGUILayout.EndVertical();

                GUILayout.Space(imageSlotSpaceSize);

                //이미지 슬롯 1 : 원래 이미지
                EditorGUILayout.BeginVertical(GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotHeight));
                //"Changed"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.ExtraOpt_SlotChanged), GUILayout.Width(imageSlotSize));
                GUILayout.Box(img_Dst, guiStyle_ImageSlot, GUILayout.Width(imageSlotSize), GUILayout.Height(imageSlotSize));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(strDstName, guiStyle_ImageName, GUILayout.Width(imageSlotSize));
                EditorGUILayout.EndVertical();

                EditorGUILayout.EndHorizontal();
                //"Set Image"
                if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.ExtraOpt_SelectImage), false, isTextureAvailable, width, 30))
                {
                    //이미지 열기 열기
                    _loadKey_TextureSelect = apDialog_SelectTextureData.ShowDialog(_editor, null, OnTextureDataSelected);
                }
                //"Reset Image"
                if (GUILayout.Button(_editor.GetText(TEXT.ExtraOpt_ResetImage), GUILayout.Width(width), GUILayout.Height(20)))
                {
                    apEditorUtil.SetRecord_Modifier(apUndoGroupData.ACTION.Modifier_SettingChanged, _editor, _modifier, _modMesh._extraValue, false);
                    _modMesh._extraValue._textureDataID     = -1;
                    _modMesh._extraValue._linkedTextureData = null;

                    RefreshImagePreview();

                    Repaint();
                }
            }

            GUILayout.Space(10);
            apEditorUtil.GUI_DelimeterBoxH(width);
            GUILayout.Space(10);
            //"Close"
            if (GUILayout.Button(_editor.GetText(TEXT.Close), GUILayout.Height(30)))
            {
                isClose = true;
            }
            if (isClose)
            {
                CloseDialog();
            }

            if (isMoveAnimKeyframe)
            {
                //키프레임 이동의 경우,
                //타임라인 레이어를 따라서 전,후로 이동한다.
                //이때 ModMesh가 아예 바뀌기 때문에 여기서 처리해야한다.
                if (_keyframe != null && _keyframe._parentTimelineLayer != null && _animClip != null)
                {
                    apAnimKeyframe moveKeyframe = (isMoveAnimKeyframeToNext ? _keyframe._nextLinkedKeyframe : _keyframe._prevLinkedKeyframe);
                    if (moveKeyframe != null && moveKeyframe._linkedModMesh_Editor != null)
                    {
                        _keyframe = moveKeyframe;
                        _modMesh  = _keyframe._linkedModMesh_Editor;
                        _animClip.SetFrame_Editor(moveKeyframe._frameIndex);

                        RefreshImagePreview();

                        apEditorUtil.ReleaseGUIFocus();

                        Repaint();
                        _editor.SetRepaint();
                    }
                }
            }
        }
        /// <summary>
        /// GIF Animation을 만든다.
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="meshGroup"></param>
        /// <param name="animClip"></param>
        /// <param name="loopCount"></param>
        /// <param name="winPosX"></param>
        /// <param name="winPosY"></param>
        /// <param name="srcSizeWidth"></param>
        /// <param name="srcSizeHeight"></param>
        /// <param name="dstSizeWidth"></param>
        /// <param name="dstSizeHeight"></param>
        /// <param name="clearColor"></param>
        /// <param name="quality">1 ~ 256</param>
        /// <returns></returns>
        public bool MakeGIFAnimation(string filePath,
                                     apMeshGroup meshGroup,
                                     apAnimClip animClip,
                                     int loopCount,
                                     int winPosX, int winPosY,
                                     int srcSizeWidth, int srcSizeHeight,
                                     int dstSizeWidth, int dstSizeHeight,
                                     Color clearColor,
                                     int quality)
        {
            if (_editor == null || _editor._portrait == null || meshGroup == null || animClip == null)
            {
                return(false);
            }

            int startFrame = animClip.StartFrame;
            int endFrame   = animClip.EndFrame;

            if (endFrame < startFrame)
            {
                endFrame = startFrame;
            }
            if (loopCount < 1)
            {
                loopCount = 1;
            }

            //모든 AnimClip 정지
            for (int i = 0; i < _editor._portrait._animClips.Count; i++)
            {
                _editor._portrait._animClips[i].Stop_Editor();
            }
            _editor._portrait._animPlayManager.Stop_Editor();
            _editor._portrait._animPlayManager.SetAnimClip_Editor(animClip);
            meshGroup.RefreshForce();

            int  curFrame = startFrame;
            bool isLoop   = animClip.IsLoop;
            //Loop라면 마지막 프레임을 생략한다.
            int lastFrame = endFrame;

            if (isLoop)
            {
                lastFrame = endFrame - 1;
            }
            if (lastFrame < startFrame)
            {
                lastFrame = startFrame;
            }

            float secPerFrame = 1.0f / (float)animClip.FPS;


            FileStream fs = null;

            try
            {
                fs = new FileStream(filePath, FileMode.Create, FileAccess.Write);

                _ngif.WriteHeader(fs);
                _ngif.SetGIFSetting((int)((secPerFrame * 100.0f) + 0.5f), 0, dstSizeWidth, dstSizeHeight);

                //WriteString("GIF89a", fs); // header
                //_gifDelay = (int)((secPerFrame * 100.0f) + 0.5f);//Delay
                //_gifRepeatCount = 0;//반복
                //_gifWidth = dstSizeWidth;
                //_gifHeight = dstSizeHeight;
                //_gifPixels = null;
                //_gifIndexedPixels = null;
                //_gifColorDepth = 0;
                //_gifColorTab = null;
                //_gifPalSize = 7;

                //for (int i = 0; i < _gifUsedEntry.Length; i++)
                //{
                //	_gifUsedEntry[i] = false;
                //}

                bool isFirstFrame = true;



                //애니메이션을 돌면서 Bake를 한다.
                for (int iLoop = 0; iLoop < loopCount; iLoop++)
                {
                    curFrame = startFrame;


                    while (true)
                    {
                        animClip.SetFrame_Editor(curFrame);                        //메시가 자동으로 업데이트를 한다.
                        meshGroup.UpdateRenderUnits(secPerFrame, true);

                        Texture2D bakeImage = RenderToTexture(meshGroup, winPosX, winPosY, srcSizeWidth, srcSizeHeight, dstSizeWidth, dstSizeHeight, clearColor);

                        _ngif.AddFrame(bakeImage, fs, isFirstFrame, quality);
                        isFirstFrame = false;

                        UnityEngine.Object.DestroyImmediate(bakeImage);

                        curFrame++;
                        if (curFrame > lastFrame)
                        {
                            break;
                        }
                    }
                }

                _ngif.Finish(fs);

                fs.Close();
                fs = null;
                return(true);
            }
            catch (Exception ex)
            {
                Debug.LogError("GIF Exception : " + ex);
            }
            if (fs != null)
            {
                fs.Close();
                fs = null;
            }


            return(false);
        }