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

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

            Texture2D iconImageCategory = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_FoldDown);

            int   height_List = height - 480;
            Color prevColor   = GUI.backgroundColor;

            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
            GUI.Box(new Rect(0, 156, width, height_List), "");
            GUI.backgroundColor = prevColor;

            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_SelectedPhysicsSetting));            //"Selected Physics Setting"

            //현재 선택한 Physics Param을 등록하는 UI

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

            boxGUIStyle.alignment        = TextAnchor.MiddleCenter;
            boxGUIStyle.normal.textColor = apEditorUtil.BoxTextColor;

            GUILayout.Box(_targetModMesh._renderUnit.Name, boxGUIStyle, GUILayout.Width(width - 8), GUILayout.Height(20));

            GUILayout.Space(5);
            int width_Left  = 90;
            int width_Right = width - 110;

            //Icon 이미지		|	이름	Icon 타입
            //					|	(저장)
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(70));
            GUILayout.Space(5);
            EditorGUILayout.BeginVertical(GUILayout.Width(width_Left), GUILayout.Height(70));
            //Icon을 출력하자
            Texture2D addParamIcon = _editor.ImageSet.Get(apEditorUtil.GetPhysicsPresetIconType(_addParamIcon));

            GUILayout.Box(addParamIcon, boxGUIStyle, GUILayout.Width(65), GUILayout.Height(65));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.Width(width_Right), GUILayout.Height(70));
            //이름, Icon 및 등록 버튼

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Right));
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Name), GUILayout.Width(80));            //"Name"
            _strAddParamName = EditorGUILayout.TextField(_strAddParamName, GUILayout.Width(width_Right - 88));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Right));
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Icon), GUILayout.Width(80));            //"Icon"
            _addParamIcon = (apPhysicsPresetUnit.ICON)EditorGUILayout.EnumPopup(_addParamIcon, GUILayout.Width(width_Right - 88));
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Right));
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_RegistToPreset), GUILayout.Width(150)))            //"Regist To Preset"
            {
                //TODO
                if (_targetModMesh.PhysicParam != null)
                {
                    //bool result = EditorUtility.DisplayDialog("Regist to Preset", "Regist Preset [" + _strAddParamName + "] ?", "Regist", "Cancel");
                    bool result = EditorUtility.DisplayDialog(_editor.GetText(TEXT.PhysicPreset_Regist_Title),
                                                              _editor.GetTextFormat(TEXT.PhysicPreset_Regist_Body, _strAddParamName),
                                                              _editor.GetText(TEXT.PhysicPreset_Regist_Okay),
                                                              _editor.GetText(TEXT.Cancel));

                    if (result)
                    {
                        _editor.PhysicsPreset.AddNewPreset(_targetModMesh.PhysicParam, _strAddParamName, _addParamIcon);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

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


            GUIStyle guiStyle = new GUIStyle(GUIStyle.none);

            guiStyle.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle.alignment        = TextAnchor.MiddleLeft;

            GUIStyle guiStyle_NotSelectable = new GUIStyle(GUIStyle.none);

            guiStyle_NotSelectable.normal.textColor = Color.red;
            guiStyle_NotSelectable.alignment        = TextAnchor.MiddleLeft;


            GUIStyle guiStyle_Center = new GUIStyle(GUIStyle.none);

            guiStyle_Center.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle_Center.alignment        = TextAnchor.MiddleCenter;

            //GUIContent guiContent_Bone = new GUIContent(iconBone);

            GUILayout.Space(10);
            //GUILayout.Button("Select a Physics Preset", guiStyle_Center, GUILayout.Width(width), GUILayout.Height(15));//<투명 버튼


            _scrollList = EditorGUILayout.BeginScrollView(_scrollList, GUILayout.Width(width), GUILayout.Height(height_List));

            //"Presets"
            GUILayout.Button(new GUIContent(_editor.GetText(TEXT.DLG_Presets), iconImageCategory), guiStyle, GUILayout.Height(20));            //<투명 버튼

            for (int i = 0; i < _editor.PhysicsPreset.Presets.Count; i++)
            {
                //DrawBoneUnit(_boneUnits_Root[i], 0, width, iconImage_FoldDown, iconImage_FoldRight, guiContent_Bone, guiStyle, guiStyle_NotSelectable, _scrollList.x);
                DrawPresetUnit(_editor.PhysicsPreset.Presets[i], i, width - 18, _scrollList.x);
            }

            GUILayout.Space(310);

            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);



            //선택한 정보를 보여주자
            //string curName = "<Not Selected>";
            string    curName = "<" + _editor.GetText(TEXT.DLG_NotSelected) + ">";
            Texture2D curIcon = null;

            float curMoveRange = 0.0f;
            //float curStretchRange_Min = 0.0f;
            float curStretchRange_Max       = 0.0f;
            float curStretchK               = 0.0f;
            float curInertiaK               = 0.0f;
            float curDamping                = 0.0f;
            float curMass                   = 100.0f;
            bool  curIsRestrictMoveRange    = false;
            bool  curIsRestrictStretchRange = false;


            Vector2 curGravityConstValue = Vector2.zero;
            Vector2 curWindConstValue    = Vector2.zero;
            Vector2 curWindRandomRange   = Vector2.zero;

            float curAirDrag   = 0.0f;
            float curViscosity = 0.0f;
            float curRestoring = 1.0f;

            if (_selectedUnit != null)
            {
                curName = _selectedUnit._name;
                curIcon = _editor.ImageSet.Get(apEditorUtil.GetPhysicsPresetIconType(_selectedUnit._icon));
                //curStretchRange_Min = _selectedUnit._stretchRange_Min;
                curStretchRange_Max = _selectedUnit._stretchRange_Max;

                curIsRestrictMoveRange    = _selectedUnit._isRestrictMoveRange;
                curIsRestrictStretchRange = _selectedUnit._isRestrictStretchRange;

                curMoveRange = _selectedUnit._moveRange;
                curStretchK  = _selectedUnit._stretchK;
                curInertiaK  = _selectedUnit._inertiaK;
                curDamping   = _selectedUnit._damping;
                curMass      = _selectedUnit._mass;


                curGravityConstValue = _selectedUnit._gravityConstValue;
                curWindConstValue    = _selectedUnit._windConstValue;
                curWindRandomRange   = _selectedUnit._windRandomRange;

                curAirDrag   = _selectedUnit._airDrag;
                curViscosity = _selectedUnit._viscosity;
                curRestoring = _selectedUnit._restoring;
            }

            Texture2D imgIcon_Stretch   = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Stretch);
            Texture2D imgIcon_Inertia   = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Inertia);
            Texture2D imgIcon_Restoring = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Recover);
            Texture2D imgIcon_Viscosity = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Viscosity);
            Texture2D imgIcon_Gravity   = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Gravity);
            Texture2D imgIcon_Wind      = _editor.ImageSet.Get(apImageSet.PRESET.Physic_Wind);
            //반반 나눠서 그려주자
            int width_Info      = ((width - 10) / 2) - 10;
            int height_Info     = 270;
            int width_InfoLabel = 120;
            int width_InfoValue = (width_Info - width_InfoLabel) - 4;

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(height_Info));
            GUILayout.Space(5);
            EditorGUILayout.BeginVertical(GUILayout.Width(width_Info), GUILayout.Height(height_Info));
            //Icon, Name, Basic Setting, Gravity, Wind를 보여주자
            if (curIcon == null)
            {
                EditorGUILayout.LabelField(curName, GUILayout.Width(width_Info), GUILayout.Height(26));
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("  " + curName, curIcon), GUILayout.Width(width_Info), GUILayout.Height(26));
            }
            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.Mass), GUILayout.Width(width_InfoLabel));            //"Mass"
            EditorGUILayout.FloatField(curMass, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.Damping), GUILayout.Width(width_InfoLabel));            //"Damping"
            EditorGUILayout.FloatField(curDamping, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.AirDrag), GUILayout.Width(width_InfoLabel));            //"Air Drag"
            EditorGUILayout.FloatField(curAirDrag, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();


            if (curIsRestrictMoveRange)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
                EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.MoveRange), GUILayout.Width(width_InfoLabel));                //"Move Range"
                EditorGUILayout.FloatField(curMoveRange, GUILayout.Width(width_InfoValue));
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
                EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.MoveRangeUnlimited), GUILayout.Width(width_Info));                //"Move Range : (Unlimited)"
                EditorGUILayout.EndHorizontal();
            }



            GUILayout.Space(5);

            //"  Gravity"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Gravity), imgIcon_Gravity), GUILayout.Width(width_Info), GUILayout.Height(25));
            apEditorUtil.DelayedVector2Field(curGravityConstValue, width_Info - 4);

            GUILayout.Space(5);
            //"  Wind"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Wind), imgIcon_Wind), GUILayout.Width(width_Info), GUILayout.Height(25));
            apEditorUtil.DelayedVector2Field(curWindConstValue, width_Info - 4);
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.WindRandomRangeSize), GUILayout.Width(width_Info));            //"Wind Random Size"
            apEditorUtil.DelayedVector2Field(curWindRandomRange, width_Info - 4);

            EditorGUILayout.EndVertical();

            GUILayout.Space(4);

            EditorGUILayout.BeginVertical(GUILayout.Width(width_Info), GUILayout.Height(height_Info));
            //Stretchiness, Inertia, Restoring, Viscosity를 보여주고, 삭제 버튼(또는 Reserved) 표시

            //"  Stretchiness"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Stretchiness), imgIcon_Stretch), GUILayout.Width(width_Info), GUILayout.Height(25));
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.K_Value), GUILayout.Width(width_InfoLabel));            //"K-Value"
            EditorGUILayout.FloatField(curStretchK, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            if (curIsRestrictStretchRange)
            {
                //EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
                //EditorGUILayout.LabelField("Shorten Range", GUILayout.Width(width_InfoLabel));
                //EditorGUILayout.FloatField(curStretchRange_Min, GUILayout.Width(width_InfoValue));
                //EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
                EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.LengthenRatio), GUILayout.Width(width_InfoLabel));                //"Lengthen Range"
                EditorGUILayout.FloatField(curStretchRange_Max, GUILayout.Width(width_InfoValue));
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                //EditorGUILayout.LabelField("Shorten Range : (Unlimited)", GUILayout.Width(width_Info));
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
                EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.LengthenRatioUnlimited), GUILayout.Width(width_Info));                //"Lengthen Range : (Unlimited)"
                EditorGUILayout.EndHorizontal();
            }


            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            //"  Inertia"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Inertia), imgIcon_Inertia), GUILayout.Width(width_InfoLabel), GUILayout.Height(25));
            EditorGUILayout.FloatField(curInertiaK, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            //"  Restoring"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Restoring), imgIcon_Restoring), GUILayout.Width(width_InfoLabel), GUILayout.Height(25));
            EditorGUILayout.FloatField(curRestoring, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width_Info));
            //"  Viscosity"
            EditorGUILayout.LabelField(new GUIContent("  " + _editor.GetUIWord(UIWORD.Viscosity), imgIcon_Viscosity), GUILayout.Width(width_InfoLabel), GUILayout.Height(25));
            EditorGUILayout.FloatField(curViscosity, GUILayout.Width(width_InfoValue));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            if (_selectedUnit != null)
            {
                //삭제 가능한지 체크
                if (!_selectedUnit._isReserved)
                {
                    //"Remove Preset"
                    if (GUILayout.Button(_editor.GetText(TEXT.DLG_RemovePreset), GUILayout.Width(width_Info - 4)))
                    {
                        //bool result = EditorUtility.DisplayDialog("Remove Preset", "Remove Preset [" + _selectedUnit._name + "] ?", "Remove", "Cancel");
                        bool result = EditorUtility.DisplayDialog(_editor.GetText(TEXT.PhysicPreset_Remove_Title),
                                                                  _editor.GetTextFormat(TEXT.PhysicPreset_Remove_Body, _selectedUnit._name),
                                                                  _editor.GetText(TEXT.Remove),
                                                                  _editor.GetText(TEXT.Cancel));

                        if (result)
                        {
                            int targetID = _selectedUnit._uniqueID;
                            _selectedUnit = null;

                            _editor.PhysicsPreset.RemovePreset(targetID);
                        }
                    }
                }
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            bool isClose = false;
            bool isSelectBtnAvailable = _selectedUnit != null;

            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Apply), false, isSelectBtnAvailable, (width / 2) - 8, 30))            //"Apply"
            {
                _funcResult(true, _loadKey, _selectedUnit, _targetModMesh);
                isClose = true;
            }
            if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Close), false, true, (width / 2) - 8, 30))            //"Close"
            {
                //_funcResult(false, _loadKey, null, null);
                _funcResult(false, _loadKey, null, _targetModMesh);
                isClose = true;
            }
            EditorGUILayout.EndHorizontal();

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

            if (_editor == null || _editor._portrait == null || _editor._portrait != _portrait)
            {
                return;
            }

            bool isGUIEvent = (Event.current.type == EventType.Repaint || Event.current.type == EventType.Layout);


            EditorGUILayout.BeginVertical();

            Texture2D iconImageAnimation = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Animation);
            Texture2D iconImageCategory  = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_FoldDown);
            Texture2D iconImageAddParam  = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_Add);
            Texture2D iconImageLayerUp   = _editor.ImageSet.Get(apImageSet.PRESET.Modifier_LayerUp);
            Texture2D iconImageLayerDown = _editor.ImageSet.Get(apImageSet.PRESET.Modifier_LayerDown);
            Texture2D iconImageRemove    = _editor.ImageSet.Get(apImageSet.PRESET.Hierarchy_RemoveTransform);

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

            guiStyleBox.alignment        = TextAnchor.MiddleCenter;
            guiStyleBox.normal.textColor = apEditorUtil.BoxTextColor;

            //"  [ " + _animClip._name + " ] Animation Events"

            //변경
            if (_guiContent_AnimClipName == null)
            {
                _guiContent_AnimClipName = apGUIContentWrapper.Make(string.Format("  [ {0} ] {1}", _animClip._name, _editor.GetText(TEXT.DLG_AnimationEvents)), false, iconImageAnimation);
            }
            if (_guiContent_Range == null)
            {
                _guiContent_Range = apGUIContentWrapper.Make(string.Format("{0} : {1} ~ {2}", _editor.GetText(TEXT.DLG_Range), _animClip.StartFrame, _animClip.EndFrame), false);
            }
            if (_guiContent_IsLoop == null)
            {
                _guiContent_IsLoop = apGUIContentWrapper.Make(string.Format("{0} : {1}", _editor.GetText(TEXT.DLG_IsLoopAnimation), _animClip.IsLoop), false);
            }


            GUILayout.Box(_guiContent_AnimClipName.Content, guiStyleBox, GUILayout.Width(width - 10), GUILayout.Height(35));

            GUILayout.Space(5);
            //"Range : " + _animClip.StartFrame + " ~ " + _animClip.EndFrame
            EditorGUILayout.LabelField(_guiContent_Range.Content);

            //"Is Loop Animation : " + _animClip.IsLoop
            EditorGUILayout.LabelField(_guiContent_IsLoop.Content);

            GUILayout.Space(10);

            GUIStyle guiStyle_None = new GUIStyle(GUIStyle.none);

            guiStyle_None.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle_None.alignment        = TextAnchor.MiddleLeft;

            GUIStyle guiStyle_Selected = new GUIStyle(GUIStyle.none);

            if (EditorGUIUtility.isProSkin)
            {
                guiStyle_Selected.normal.textColor = Color.cyan;
            }
            else
            {
                guiStyle_Selected.normal.textColor = Color.white;
            }
            guiStyle_Selected.alignment = TextAnchor.MiddleLeft;

            GUIStyle guiStyle_Center = new GUIStyle(GUIStyle.none);

            guiStyle_Center.normal.textColor = GUI.skin.label.normal.textColor;
            guiStyle_Center.alignment        = TextAnchor.MiddleCenter;


            int topHeight    = 120;
            int bottomHeight = 380;


            Color prevColor = GUI.backgroundColor;

            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
            GUI.Box(new Rect(0, topHeight - 26, width, height - (topHeight + bottomHeight)), "");
            GUI.backgroundColor = prevColor;



            _scrollList = EditorGUILayout.BeginScrollView(_scrollList, GUILayout.Width(width), GUILayout.Height(height - (topHeight + bottomHeight)));
            GUILayout.Space(5);
            //"Animation Events"
            if (_guiContent_AnimEventCategory == null)
            {
                _guiContent_AnimEventCategory = apGUIContentWrapper.Make(_editor.GetText(TEXT.DLG_AnimationEvents), false, iconImageCategory);
            }


            GUILayout.Button(_guiContent_AnimEventCategory.Content, guiStyle_None, GUILayout.Height(20));            //<투명 버튼//

            int nAnimEvents = 0;

            if (_animClip._animEvents != null)
            {
                nAnimEvents = _animClip._animEvents.Count;
            }

            //GUILayout.Space(10);
            apAnimEvent animEvent = null;

            for (int i = 0; i < nAnimEvents; i++)
            {
                GUIStyle curGUIStyle = guiStyle_None;
                animEvent = _animClip._animEvents[i];

                if (animEvent == _curSelectedEvent)
                {
                    Rect lastRect = GUILayoutUtility.GetLastRect();
                    prevColor = GUI.backgroundColor;

                    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);
                    }

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

                    curGUIStyle = guiStyle_Selected;
                }


                EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                GUILayout.Space(15);
                if (GUILayout.Button("[" + i + "] " + animEvent._eventName, curGUIStyle, GUILayout.Width(width - 80), GUILayout.Height(20)))
                {
                    _curSelectedEvent = animEvent;
                }

                if (animEvent._callType == apAnimEvent.CALL_TYPE.Once)
                {
                    if (GUILayout.Button(animEvent._frameIndex.ToString(), curGUIStyle, GUILayout.Width(45), GUILayout.Height(20)))
                    {
                        _curSelectedEvent = animEvent;
                    }
                }
                else
                {
                    if (GUILayout.Button(animEvent._frameIndex + " ~ " + animEvent._frameIndex_End, curGUIStyle, GUILayout.Width(45), GUILayout.Height(20)))
                    {
                        _curSelectedEvent = animEvent;
                    }
                }

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.Space((height - (topHeight + bottomHeight)) + 100);
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndVertical();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal(GUILayout.Height(30));
            GUILayout.Space(5);

            //"Add Event"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_AddEvent), GUILayout.Width(width - (10 + 6 + (160))), GUILayout.Height(30)))
            {
                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_AddEvent, _editor, _animClip._portrait, null, false);

                if (_animClip._animEvents == null)
                {
                    _animClip._animEvents = new List <apAnimEvent>();
                }

                apAnimEvent newEvent = new apAnimEvent();
                //새로운 이름을 찾자
                int    iNewName = 0;
                string newName  = "NewAnimEvent_" + iNewName;

                int cnt = 0;
                while (true)
                {
                    if (cnt > 500)
                    {
                        newName = "NewAnimEvent_Infinity";
                        break;
                    }
                    //중복되는 이름이 있는가
                    newName = "NewAnimEvent_" + iNewName;
                    bool isExist = _animClip._animEvents.Exists(delegate(apAnimEvent a)
                    {
                        return(string.Equals(a._eventName, newName));
                    });
                    if (!isExist)
                    {
                        //중복되지 않는 이름이다.
                        break;
                    }

                    //이름이 중복되는 군염
                    cnt++;
                    iNewName++;
                }

                newEvent._eventName  = newName;
                newEvent._frameIndex = _defaultFrame;

                _animClip._animEvents.Add(newEvent);

                _curSelectedEvent = newEvent;
            }

            //추가 3.29 : 이벤트 복사하기 : 프레임은 무조건 다음 프레임에
            string strCopy = _editor.GetUIWord(UIWORD.Copy);

            //if(GUILayout.Button(_editor.GetUIWord(UIWORD.Copy), GUILayout.Width(80), GUILayout.Height(30)))
            if (apEditorUtil.ToggledButton_2Side(strCopy, strCopy, false, _curSelectedEvent != null, 80, 30))
            {
                if (_curSelectedEvent != null)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_AddEvent, _editor, _animClip._portrait, null, false);

                    if (_animClip._animEvents == null)
                    {
                        _animClip._animEvents = new List <apAnimEvent>();
                    }

                    apAnimEvent newEvent = new apAnimEvent();

                    //선택한 이벤트와 동일한 속성으로 설정.
                    //- _defaultFrame과 다르다면, 거기에 복사
                    //- _defaultFrame과 같다면 +1프레임
                    newEvent._eventName = _curSelectedEvent._eventName;
                    newEvent._callType  = _curSelectedEvent._callType;

                    if (newEvent._callType == apAnimEvent.CALL_TYPE.Once)
                    {
                        if (_curSelectedEvent._frameIndex == _defaultFrame)
                        {
                            newEvent._frameIndex     = _curSelectedEvent._frameIndex + 1;
                            newEvent._frameIndex_End = _curSelectedEvent._frameIndex_End + 1;
                        }
                        else
                        {
                            int frameLength = Mathf.Max(_curSelectedEvent._frameIndex_End - _curSelectedEvent._frameIndex, 0);

                            newEvent._frameIndex     = _defaultFrame;
                            newEvent._frameIndex_End = newEvent._frameIndex + frameLength;
                        }
                    }
                    else
                    {
                        int frameLength = Mathf.Max(_curSelectedEvent._frameIndex_End - _curSelectedEvent._frameIndex, 0);

                        if (_curSelectedEvent._frameIndex <= _defaultFrame && _defaultFrame <= _curSelectedEvent._frameIndex + frameLength)
                        {
                            //DefaultFrame이 기존 이벤트 영역에 포함되어 있다.
                            //기존 영역의 밖에서 생성
                            newEvent._frameIndex     = _curSelectedEvent._frameIndex + frameLength + 1;
                            newEvent._frameIndex_End = newEvent._frameIndex + frameLength;
                        }
                        else
                        {
                            //DefaultFrame이 기존 이벤트 영역 밖에 있다.
                            //DefaultFrame부터 생성
                            newEvent._frameIndex     = _defaultFrame;
                            newEvent._frameIndex_End = newEvent._frameIndex + frameLength;
                        }
                    }

                    if (_curSelectedEvent._subParams == null)
                    {
                        _curSelectedEvent._subParams = new List <apAnimEvent.SubParameter>();
                    }
                    if (_curSelectedEvent._subParams != null)
                    {
                        for (int iParam = 0; iParam < _curSelectedEvent._subParams.Count; iParam++)
                        {
                            apAnimEvent.SubParameter existParam = _curSelectedEvent._subParams[iParam];
                            apAnimEvent.SubParameter newParam   = new apAnimEvent.SubParameter();

                            //속성들 복사
                            newParam._paramType      = existParam._paramType;
                            newParam._boolValue      = existParam._boolValue;
                            newParam._intValue       = existParam._intValue;
                            newParam._floatValue     = existParam._floatValue;
                            newParam._vec2Value      = existParam._vec2Value;
                            newParam._strValue       = existParam._strValue;
                            newParam._intValue_End   = existParam._intValue_End;
                            newParam._floatValue_End = existParam._floatValue_End;
                            newParam._vec2Value_End  = existParam._vec2Value_End;

                            newEvent._subParams.Add(newParam);
                        }
                    }


                    _animClip._animEvents.Add(newEvent);

                    _curSelectedEvent = newEvent;
                }
            }

            //"Sort"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Sort), GUILayout.Width(80), GUILayout.Height(30)))
            {
                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_SortEvents, _editor, _animClip._portrait, null, false);

                //프레임 순으로 정렬을 한다.
                if (_animClip._animEvents != null)
                {
                    _animClip._animEvents.Sort(delegate(apAnimEvent a, apAnimEvent b)
                    {
                        if (a._frameIndex == b._frameIndex)
                        {
                            return(string.Compare(a._eventName, b._eventName));
                        }
                        return(a._frameIndex - b._frameIndex);
                    });

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

            //선택된 AnimEvent에 대한 설정을 하자
            GUILayout.Space(5);
            apEditorUtil.GUI_DelimeterBoxH(width - 10);
            GUILayout.Space(5);

            //선택이 안되었다면 더미 데이터로 채워야함
            int    curFrameIndex     = 0;
            int    curFrameIndex_End = 0;
            string curName           = "<None>";

            apAnimEvent.CALL_TYPE           curCallType  = apAnimEvent.CALL_TYPE.Once;
            List <apAnimEvent.SubParameter> curSubParams = null;
            int curNumSubParams = 0;

            bool isSelected = _curSelectedEvent != null && _animClip._animEvents.Contains(_curSelectedEvent);

            if (isSelected)
            {
                curFrameIndex     = _curSelectedEvent._frameIndex;
                curFrameIndex_End = _curSelectedEvent._frameIndex_End;
                curName           = _curSelectedEvent._eventName;
                curCallType       = _curSelectedEvent._callType;
                curSubParams      = _curSelectedEvent._subParams;
                curNumSubParams   = curSubParams.Count;
            }

            if (isSelected)
            {
                GUI.backgroundColor = new Color(0.6f, 0.8f, 0.9f, 1.0f);
            }

            //"(Not Selected)"
            GUILayout.Box((isSelected) ? curName : "(" + _editor.GetText(TEXT.DLG_NotSelected) + ")", guiStyleBox, GUILayout.Width(width - 10), GUILayout.Height(25));

            GUI.backgroundColor = prevColor;

            GUILayout.Space(5);

            EditorGUILayout.BeginVertical(GUILayout.Height(90));
            curName     = EditorGUILayout.DelayedTextField(_editor.GetText(TEXT.DLG_EventName), curName);                      //"Event(Function) Name"
            curCallType = (apAnimEvent.CALL_TYPE)EditorGUILayout.EnumPopup(_editor.GetText(TEXT.DLG_CallMethod), curCallType); //"Call Method"
            if (curCallType == apAnimEvent.CALL_TYPE.Once)
            {
                curFrameIndex = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_TargetFrame), curFrameIndex);                //"Target Frame"
            }
            else
            {
                curFrameIndex     = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_StartFrame), curFrameIndex);            //"Start Frame"
                curFrameIndex_End = EditorGUILayout.DelayedIntField(_editor.GetText(TEXT.DLG_EndFrame), curFrameIndex_End);          //"End Frame"
            }
            EditorGUILayout.EndVertical();

            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Parameters));            //"Parameters"
            GUILayout.Space(5);


            GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f);
            GUI.Box(new Rect(0, (height - (bottomHeight - 171)) + 22, width, 100), "");
            GUI.backgroundColor = prevColor;

            if (!isSelected)
            {
                if (!isGUIEvent)
                {
                    curNumSubParams = _prevNumSubParams;
                }
            }

            _scrollList_Param = EditorGUILayout.BeginScrollView(_scrollList_Param, GUILayout.Width(width), GUILayout.Height(100));

            GUILayout.Space(5);
            int valueWidth     = width - (10 + 35 + 130 + 36 + 36 + 36 + 20);
            int valueHalfWidth = ((valueWidth / 2) - 10);
            int midWaveWidth   = 20;

            valueWidth += 7;

            GUIStyle guiStyleListBtn = new GUIStyle(GUI.skin.button);

            guiStyleListBtn.margin = GUI.skin.textField.margin;

            apAnimEvent.SubParameter targetSubParam = null;
            bool isLayerUp     = false;
            bool isLayerDown   = false;
            bool isRemoveParam = false;

            //SubParam 리스트를 출력하자
            if (curNumSubParams > 0)
            {
                if (isSelected && curSubParams != null && curSubParams.Count == curNumSubParams)
                {
                    for (int i = 0; i < curNumSubParams; i++)
                    {
                        EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50), GUILayout.Height(24));
                        GUILayout.Space(15);
                        GUILayout.Label("[" + i + "]", GUILayout.Width(30), GUILayout.Height(20));

                        curSubParams[i]._paramType = (apAnimEvent.PARAM_TYPE)EditorGUILayout.EnumPopup(curSubParams[i]._paramType, GUILayout.Width(120), GUILayout.Height(20));

                        switch (curSubParams[i]._paramType)
                        {
                        case apAnimEvent.PARAM_TYPE.Bool:
                        {
                            bool nextValue = EditorGUILayout.Toggle(curSubParams[i]._boolValue, GUILayout.Width(valueWidth));

                            if (curSubParams[i]._boolValue != nextValue)
                            {
                                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                curSubParams[i]._boolValue = nextValue;
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Integer:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                int nextValue = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue, GUILayout.Width(valueWidth));

                                if (curSubParams[i]._intValue != nextValue)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._intValue = nextValue;
                                }
                            }
                            else
                            {
                                int nextValue_Prev = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue, GUILayout.Width(valueHalfWidth));
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                int nextValue_Next = EditorGUILayout.DelayedIntField(curSubParams[i]._intValue_End, GUILayout.Width(valueHalfWidth));

                                if (curSubParams[i]._intValue != nextValue_Prev ||
                                    curSubParams[i]._intValue_End != nextValue_Next)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._intValue     = nextValue_Prev;
                                    curSubParams[i]._intValue_End = nextValue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Float:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                float nextValue = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue, GUILayout.Width(valueWidth));
                                if (curSubParams[i]._floatValue != nextValue)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._floatValue = nextValue;
                                }
                            }
                            else
                            {
                                float nextValue_Prev = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue, GUILayout.Width(valueHalfWidth));
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                float nextVelue_Next = EditorGUILayout.DelayedFloatField(curSubParams[i]._floatValue_End, GUILayout.Width(valueHalfWidth));

                                if (curSubParams[i]._floatValue != nextValue_Prev ||
                                    curSubParams[i]._floatValue_End != nextVelue_Next)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                                    curSubParams[i]._floatValue     = nextValue_Prev;
                                    curSubParams[i]._floatValue_End = nextVelue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.Vector2:
                        {
                            if (curCallType == apAnimEvent.CALL_TYPE.Once)
                            {
                                Vector2 nextValue = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value, valueWidth);
                                if (curSubParams[i]._vec2Value.x != nextValue.x ||
                                    curSubParams[i]._vec2Value.y != nextValue.y)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                    curSubParams[i]._vec2Value = nextValue;
                                }
                            }
                            else
                            {
                                Vector2 nextValue_Prev = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value, valueHalfWidth);
                                EditorGUILayout.LabelField(" ~ ", GUILayout.Width(midWaveWidth));
                                Vector2 nextValue_Next = apEditorUtil.DelayedVector2Field(curSubParams[i]._vec2Value_End, valueHalfWidth);


                                if (curSubParams[i]._vec2Value.x != nextValue_Prev.x ||
                                    curSubParams[i]._vec2Value.y != nextValue_Prev.y ||
                                    curSubParams[i]._vec2Value_End.x != nextValue_Next.x ||
                                    curSubParams[i]._vec2Value_End.y != nextValue_Next.y)
                                {
                                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                                    curSubParams[i]._vec2Value     = nextValue_Prev;
                                    curSubParams[i]._vec2Value_End = nextValue_Next;
                                }
                            }
                        }
                        break;

                        case apAnimEvent.PARAM_TYPE.String:
                        {
                            string nextValue = EditorGUILayout.DelayedTextField(curSubParams[i]._strValue, GUILayout.Width(valueWidth));
                            if (!string.Equals(curSubParams[i]._strValue, nextValue))
                            {
                                apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                                curSubParams[i]._strValue = nextValue;
                            }
                        }
                        break;
                        }

                        if (GUILayout.Button(iconImageLayerUp, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isLayerUp      = true;
                        }
                        if (GUILayout.Button(iconImageLayerDown, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isLayerDown    = true;
                        }
                        if (GUILayout.Button(iconImageRemove, guiStyleListBtn, GUILayout.Width(30), GUILayout.Height(20)))
                        {
                            targetSubParam = curSubParams[i];
                            isRemoveParam  = true;
                        }


                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    for (int i = 0; i < curNumSubParams; i++)
                    {
                        EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
                        GUILayout.Space(15);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width - 50));
            GUILayout.Space(15);

            //변경
            if (_guiContent_AddParameter == null)
            {
                _guiContent_AddParameter = new apGUIContentWrapper();
                _guiContent_AddParameter.ClearText(false);
                _guiContent_AddParameter.AppendSpaceText(1, false);
                _guiContent_AddParameter.AppendText(_editor.GetText(TEXT.DLG_AddParameter), true);

                _guiContent_AddParameter.SetImage(iconImageAddParam);
            }

            if (isSelected)
            {
                //" Add Parameter"
                if (GUILayout.Button(_guiContent_AddParameter.Content, guiStyle_None, GUILayout.Height(20)))
                {
                    if (isSelected && curSubParams != null && curSubParams.Count == curNumSubParams)
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                        curSubParams.Add(new apAnimEvent.SubParameter());
                    }
                }
            }
            else
            {
                if (GUILayout.Button(apEditorUtil.Text_EMPTY, guiStyle_None, GUILayout.Height(20)))
                {
                    //Nooo..
                }
            }
            EditorGUILayout.EndHorizontal();



            GUILayout.Space(150);

            EditorGUILayout.EndScrollView();

            GUILayout.Space(10);

            EditorGUILayout.BeginVertical(GUILayout.Width(width), GUILayout.Height(40));
            if (isSelected)
            {
                //"Remove Event [" + curName + "]"
                if (GUILayout.Button(string.Format("{0} [{1}]", _editor.GetText(TEXT.DLG_RemoveEvent), curName), GUILayout.Height(20)))
                {
                    if (_curSelectedEvent != null && _animClip._animEvents.Contains(_curSelectedEvent))
                    {
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_RemoveEvent, _editor, _animClip._portrait, null, false);
                        _animClip._animEvents.Remove(_curSelectedEvent);

                        _curSelectedEvent = null;
                        isSelected        = false;
                    }
                }
            }
            else
            {
                if (GUILayout.Button("", guiStyle_None, GUILayout.Height(20)))
                {
                }
            }
            EditorGUILayout.EndVertical();



            if (isSelected && _curSelectedEvent != null)
            {
                //순서를 바꾸거나 SubParam을 삭제하는 요청이 있으면 처리해주자
                if (targetSubParam != null && _curSelectedEvent._subParams.Contains(targetSubParam))
                {
                    if (isLayerUp)
                    {
                        //Index -1

                        int index = _curSelectedEvent._subParams.IndexOf(targetSubParam);
                        if (index > 0)
                        {
                            apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                            _curSelectedEvent._subParams.Remove(targetSubParam);
                            _curSelectedEvent._subParams.Insert(index - 1, targetSubParam);
                        }
                    }
                    else if (isLayerDown)
                    {
                        //Index +1
                        int index = _curSelectedEvent._subParams.IndexOf(targetSubParam);
                        if (index < _curSelectedEvent._subParams.Count - 1)
                        {
                            apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                            _curSelectedEvent._subParams.Remove(targetSubParam);
                            _curSelectedEvent._subParams.Insert(index + 1, targetSubParam);
                        }
                    }
                    else if (isRemoveParam)
                    {
                        //삭제한다.
                        apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);
                        _curSelectedEvent._subParams.Remove(targetSubParam);
                    }
                }


                if (_curSelectedEvent._frameIndex != curFrameIndex ||
                    _curSelectedEvent._frameIndex_End != curFrameIndex_End ||
                    _curSelectedEvent._eventName != curName ||
                    _curSelectedEvent._callType != curCallType)
                {
                    apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Anim_EventChanged, _editor, _animClip._portrait, null, false);

                    _curSelectedEvent._frameIndex     = curFrameIndex;
                    _curSelectedEvent._frameIndex_End = curFrameIndex_End;
                    _curSelectedEvent._eventName      = curName;
                    _curSelectedEvent._callType       = curCallType;
                }
            }


            EditorGUILayout.BeginHorizontal();
            bool isClose = false;

            //"Close"
            if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Height(30)))
            {
                isClose = true;
                apEditorUtil.ReleaseGUIFocus();
            }
            EditorGUILayout.EndHorizontal();


            if (isGUIEvent)
            {
                _prevNumSubParams = curNumSubParams;
            }

            if (isClose)
            {
                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()
        {
            int width  = (int)position.width;
            int height = (int)position.height;

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

            //오프셋과 자식 복사 여부
            int width_Label = 30;
            int width_Value = (width - 10) - 34;

            GUILayout.Space(5);

            EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PositionOffset));
            GUILayout.Space(5);

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField("X", GUILayout.Width(width_Label));
            _offsetX = EditorGUILayout.FloatField(_offsetX, GUILayout.Width(width_Value));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField("Y", GUILayout.Width(width_Label));
            _offsetY = EditorGUILayout.FloatField(_offsetY, GUILayout.Width(width_Value));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            GUILayout.Space(5);
            EditorGUILayout.LabelField(_editor.GetUIWord(UIWORD.DuplicateWithChildBones), GUILayout.Width(width - (10 + 30)));            //"Duplicate with Child Bones"
            _isDuplicateChildren = EditorGUILayout.Toggle(_isDuplicateChildren, GUILayout.Width(30));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
            int width_Btn = ((width - 10) / 2) - 4;

            bool isCloseDialog = false;

            if (GUILayout.Button(_editor.GetUIWord(UIWORD.Duplicate), GUILayout.Width(width_Btn), GUILayout.Height(30)))            //"Start Edit"
            {
                _funcResult(true, _targetBone, _loadKey, _offsetX, _offsetY, _isDuplicateChildren);
                isCloseDialog = true;
            }
            if (GUILayout.Button(_editor.GetText(TEXT.Cancel), GUILayout.Width(width_Btn), GUILayout.Height(30)))            //"Close"
            {
                _funcResult(false, _targetBone, null, _offsetX, _offsetY, _isDuplicateChildren);
                isCloseDialog = true;
            }
            EditorGUILayout.EndHorizontal();

            if (isCloseDialog)
            {
                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));

            if (_guiContent_IsImportant == null)
            {
                _guiContent_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_FPS == null)
            {
                _guiContent_FPS = apGUIContentWrapper.Make(_editor.GetText(TEXT.DLG_Setting_FPS), false, "This setting is used when <Important> is off");
            }


            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;
                }

                //"Is Important"
                bool nextImportant = EditorGUILayout.Toggle(_guiContent_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_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);
                //수동으로 백업하기
                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.SaveBackupManual(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)
                {
                }

                //고급 옵션들

                //변경 3.22 : 이하는 고급 옵션으로 분리한다.
                //텍스트를 길게 작성할 수 있게 만든다.
                GUILayout.Space(20);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_Advanced));
                GUILayout.Space(10);


                GUIStyle guiStyle_WrapLabel = new GUIStyle(GUI.skin.label);
                guiStyle_WrapLabel.wordWrap  = true;
                guiStyle_WrapLabel.alignment = TextAnchor.MiddleLeft;

                int labelWidth  = width - (30 + 20);
                int toggleWidth = 20;

                bool prevStartupScreen = _editor._startScreenOption_IsShowStartup;
                //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));                                //Height 삭제
                GUILayout.Space(5);
                _editor._startScreenOption_IsShowStartup = EditorGUILayout.Toggle(_editor._startScreenOption_IsShowStartup, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_ShowStartPageOn), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //GUILayout.Space(10);
                bool prevCheckVersion = _editor._isCheckLiveVersion_Option;
                //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));                                //Height 삭제
                GUILayout.Space(5);
                _editor._isCheckLiveVersion_Option = EditorGUILayout.Toggle(_editor._isCheckLiveVersion_Option, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.CheckLatestVersionOption), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //추가 3.1 : 유휴 상태에서는 업데이트 빈도를 낮춤
                bool prevLowCPUOption = _editor._isLowCPUOption;
                //EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25));
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));                                //Height 삭제
                GUILayout.Space(5);
                _editor._isLowCPUOption = EditorGUILayout.Toggle(_editor._isLowCPUOption, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                //"Editor frame is low when idle"
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_LowCPU), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //추가 3.29 : Ambient 자동으로 보정하기 기능
                bool prevAmbientCorrection = _editor._isAmbientCorrectionOption;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));                                //Height 삭제
                GUILayout.Space(5);
                _editor._isAmbientCorrectionOption = EditorGUILayout.Toggle(_editor._isAmbientCorrectionOption, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_AmbientColorCorrection), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //추가 19.6.28 : 자동으로 Controller Tab으로 전환할 지 여부 (Mod, Anim)
                bool prevAutoSwitchController_Mod = _editor._isAutoSwitchControllerTab_Mod;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isAutoSwitchControllerTab_Mod = EditorGUILayout.Toggle(_editor._isAutoSwitchControllerTab_Mod, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.Setting_SwitchContTab_Mod), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                bool prevAutoSwitchController_Anim = _editor._isAutoSwitchControllerTab_Anim;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isAutoSwitchControllerTab_Anim = EditorGUILayout.Toggle(_editor._isAutoSwitchControllerTab_Anim, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.Setting_SwitchContTab_Anim), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                GUILayout.Space(5);

                //추가 19.6.28 : 작업 종료시 메시의 작업용 보이기/숨기기를 초기화 할 지 여부
                bool prevTempMeshVisibility = _editor._isRestoreTempMeshVisibilityWhenTackEnded;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isRestoreTempMeshVisibilityWhenTackEnded = EditorGUILayout.Toggle(_editor._isRestoreTempMeshVisibilityWhenTackEnded, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.Setting_TempVisibilityMesh), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();


                //추가 19.8.13 : 리깅 관련 옵션
                bool prevRigOpt_ColorLikeParent = _editor._rigOption_NewChildBoneColorIsLikeParent;
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._rigOption_NewChildBoneColorIsLikeParent = EditorGUILayout.Toggle(_editor._rigOption_NewChildBoneColorIsLikeParent, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.Setting_RigOpt_ColorLikeParent), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();


                GUILayout.Space(10);

                //선택 잠금에 대해서
                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(34);
                EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_EnableSelectionLockEditMode), guiStyle_WrapLabel);
                EditorGUILayout.EndHorizontal();
                bool prevSelectionEnableOption_RigPhy          = _editor._isSelectionLockOption_RiggingPhysics;
                bool prevSelectionEnableOption_Morph           = _editor._isSelectionLockOption_Morph;
                bool prevSelectionEnableOption_Transform       = _editor._isSelectionLockOption_Transform;
                bool prevSelectionEnableOption_ControlTimeline = _editor._isSelectionLockOption_ControlParamTimeline;

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isSelectionLockOption_Morph = EditorGUILayout.Toggle(_editor._isSelectionLockOption_Morph, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField("- Morph " + _editor.GetText(TEXT.DLG_Modifier), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isSelectionLockOption_Transform = EditorGUILayout.Toggle(_editor._isSelectionLockOption_Transform, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField("- Transform " + _editor.GetText(TEXT.DLG_Modifier), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isSelectionLockOption_RiggingPhysics = EditorGUILayout.Toggle(_editor._isSelectionLockOption_RiggingPhysics, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField("- Rigging/Physic " + _editor.GetText(TEXT.DLG_Modifier), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal(GUILayout.Width(width));
                GUILayout.Space(5);
                _editor._isSelectionLockOption_ControlParamTimeline = EditorGUILayout.Toggle(_editor._isSelectionLockOption_ControlParamTimeline, GUILayout.Width(toggleWidth));
                GUILayout.Space(5);
                EditorGUILayout.LabelField("- Control Parameter " + _editor.GetUIWord(UIWORD.Timeline), guiStyle_WrapLabel, GUILayout.Width(labelWidth));
                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 ||
                    prevCheckVersion != _editor._isCheckLiveVersion_Option ||
                    prevLowCPUOption != _editor._isLowCPUOption ||
                    prevAmbientCorrection != _editor._isAmbientCorrectionOption ||
                    prevAutoSwitchController_Mod != _editor._isAutoSwitchControllerTab_Mod ||
                    prevAutoSwitchController_Anim != _editor._isAutoSwitchControllerTab_Anim ||

                    prevTempMeshVisibility != _editor._isRestoreTempMeshVisibilityWhenTackEnded ||
                    prevRigOpt_ColorLikeParent != _editor._rigOption_NewChildBoneColorIsLikeParent ||

                    prevSelectionEnableOption_RigPhy != _editor._isSelectionLockOption_RiggingPhysics ||
                    prevSelectionEnableOption_Morph != _editor._isSelectionLockOption_Morph ||
                    prevSelectionEnableOption_Transform != _editor._isSelectionLockOption_Transform ||
                    prevSelectionEnableOption_ControlTimeline != _editor._isSelectionLockOption_ControlParamTimeline
                    )
                {
                    bool isLanguageChanged = (prevLanguage != _editor._language);

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

                    //apGL.SetToneColor(_editor._colorOption_OnionToneColor);

                    if (isLanguageChanged)
                    {
                        _editor.ResetHierarchyAll();

                        //이전
                        //_editor.RefreshTimelineLayers(true);
                        //_editor.RefreshControllerAndHierarchy();

                        //변경 19.5.21
                        _editor.RefreshControllerAndHierarchy(true);                                        //<<True를 넣으면 RefreshTimelineLayer 함수가 같이 호출된다.
                    }
                }
            }
            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)
            {
                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.º 7
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);
        }