// 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; } //Bake 설정 EditorGUILayout.LabelField("Bake Setting"); GUILayout.Space(5); EditorGUILayout.ObjectField("Portait", _targetPortrait, typeof(apPortrait), true); GUILayout.Space(5); float nextRootScale = EditorGUILayout.DelayedFloatField("Bake Scale", _targetPortrait._bakeScale); //GUILayout.Space(5); //float nextPhysicsScale = EditorGUILayout.DelayedFloatField("Physic Scale", _targetPortrait._physicBakeScale); CheckChangedProperties(nextRootScale); GUILayout.Space(10); if (GUILayout.Button("Bake", GUILayout.Height(30))) { GUI.FocusControl(null); CheckChangedProperties(nextRootScale); _editor.Controller.PortraitBake(); _editor.Notification("[" + _targetPortrait.name + "] is Baked", false, false); } GUILayout.Space(5); if (GUILayout.Button("Optimized Bake", GUILayout.Height(30))) { GUI.FocusControl(null); CheckChangedProperties(nextRootScale); Debug.LogError("TODO : Opt Bake"); _editor.Notification("[" + _targetPortrait.name + "] is Baked (Optimized)", false, false); } }
// GUI //------------------------------------------------------------------------ void OnGUI() { int width = (int)position.width; int height = (int)position.height; if (_editor == null || _funcResult == null || _targetMeshGroup == null) { CloseDialog(); return; } Color prevColor = GUI.backgroundColor; //레이아웃 구조 //1. Save // - 저장 버튼 //2. Load // - 로드 버튼 // - 본 정보 리스트 // - <색상> 인덱스, 이름 -> 적용 여부 + IK + 색상 로드 // - 전체 선택 / 해제 // - 전체 IK 포함 여부, // - 옵션 : 크기 width -= 10; //1. Save GUIStyle guiStyleBox = new GUIStyle(GUI.skin.box); guiStyleBox.alignment = TextAnchor.MiddleCenter; guiStyleBox.normal.textColor = apEditorUtil.BoxTextColor; GUIStyle guiStyleBox_Left = new GUIStyle(GUI.skin.textField); guiStyleBox_Left.alignment = TextAnchor.MiddleLeft; //" Export Bone Structure" GUILayout.Box(new GUIContent(" " + _editor.GetText(TEXT.DLG_ExportBoneStructure), _editor.ImageSet.Get(apImageSet.PRESET.Rig_SaveLoad)), guiStyleBox, GUILayout.Width(width), GUILayout.Height(35)); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); int nBones = _targetMeshGroup._boneList_All.Count; //int nBones = _targetMeshGroup._boneList_All string strBones = ""; if (nBones == 0) { //strBones = "No Bones to Export"; strBones = _editor.GetText(TEXT.DLG_NoBonesToExport); } else if (nBones == 1) { //strBones = "1 Bone to Export"; strBones = _editor.GetText(TEXT.DLG_1BoneToExport); } else { //strBones = nBones + " Bones to Export"; strBones = _editor.GetTextFormat(TEXT.DLG_NBonesToExport, nBones); } if (nBones > 0) { GUI.backgroundColor = new Color(prevColor.r * 0.8f, prevColor.g * 1.5f, prevColor.b * 1.5f, 1.0f); } else { GUI.backgroundColor = new Color(prevColor.r * 1.5f, prevColor.g * 0.8f, prevColor.b * 0.8f, 1.0f); } GUILayout.Box(strBones, guiStyleBox, GUILayout.Width(width - 120), GUILayout.Height(25)); GUI.backgroundColor = prevColor; //" Export" if (apEditorUtil.ToggledButton(_editor.ImageSet.Get(apImageSet.PRESET.Rig_SaveLoad), " " + _editor.GetText(TEXT.Export), false, (nBones > 0), 115, 25)) { string saveFilePath = EditorUtility.SaveFilePanel("Save Bone Structure", "", "", "apb"); if (!string.IsNullOrEmpty(saveFilePath)) { //Save를 하자 bool isResult = apRetarget.SaveBaseStruct(_targetMeshGroup, saveFilePath); if (isResult) { _editor.Notification("[" + saveFilePath + "] is Saved", false, false); //Debug.Log("[" + saveFilePath + "] is Saved"); } else { //Debug.LogError("File Save Failed"); } } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); apEditorUtil.GUI_DelimeterBoxH(width); GUILayout.Space(10); //2. Load // - 로드 버튼 // - 본 정보 리스트 // - <색상> 인덱스, 이름 -> 적용 여부 + IK + 색상 로드 // - 전체 선택 / 해제 // - 전체 IK 포함 여부, // - 옵션 : 크기 //" Import Bone Structure" GUILayout.Box(new GUIContent(" " + _editor.GetText(TEXT.DLG_ImportBoneStructure), _editor.ImageSet.Get(apImageSet.PRESET.Rig_LoadBones)), guiStyleBox, GUILayout.Width(width), GUILayout.Height(35)); GUILayout.Space(5); //로드한 파일 정보 EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); //TODO : bool isFileLoaded = _retargetData.IsBaseFileLoaded; string strFileName = _retargetData.BaseLoadedFilePath; if (isFileLoaded) { GUI.backgroundColor = new Color(prevColor.r * 0.8f, prevColor.g * 2.0f, prevColor.b * 0.8f, 1.0f); } else { //strFileName = "No File is Imported"; strFileName = _editor.GetText(TEXT.DLG_NoFileIsImported); GUI.backgroundColor = new Color(prevColor.r * 1.5f, prevColor.g * 0.8f, prevColor.b * 0.8f, 1.0f); } EditorGUILayout.TextField(strFileName, guiStyleBox_Left, GUILayout.Width(width - 120), GUILayout.Height(25)); GUI.backgroundColor = prevColor; //"Load File" if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_LoadFile), false, true, 115, 25)) { string loadFilePath = EditorUtility.OpenFilePanel("Open Bone Structure", "", "apb"); if (!string.IsNullOrEmpty(loadFilePath)) { bool loadResult = _retargetData.LoadBaseStruct(loadFilePath); if (loadResult) { _editor.Notification("[" + loadFilePath + "] is Loaded", false, false); //Debug.Log("[" + loadFilePath + "] is Loaded"); } } } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); int listHeight = height - 450; Rect lastRect = GUILayoutUtility.GetLastRect(); GUI.backgroundColor = new Color(0.7f, 0.7f, 0.7f); GUI.Box(new Rect(0, lastRect.y + 5, width + 10, listHeight), ""); GUI.backgroundColor = prevColor; List <apRetargetBoneUnit> baseBoneUnits = _retargetData.BaseBoneUnits; _scrollList = EditorGUILayout.BeginScrollView(_scrollList, false, true, GUILayout.Width(width + 10), GUILayout.Height(listHeight)); EditorGUILayout.BeginVertical(GUILayout.Width(width - 20)); if (baseBoneUnits != null) { GUIStyle guiStyle_ItemLabel = new GUIStyle(GUI.skin.label); guiStyle_ItemLabel.alignment = TextAnchor.MiddleLeft; GUIStyle guiStyle_ItemTextBox = new GUIStyle(GUI.skin.textField); guiStyle_ItemTextBox.alignment = TextAnchor.MiddleLeft; // - <색상> 인덱스, 이름 -> 적용 여부 + IK + 색상 로드 apRetargetBoneUnit boneUnit = null; int itemWidth = width - 20; int itemHeight = 20; string strImport = _editor.GetText(TEXT.DLG_Import); string strNoImport = _editor.GetText(TEXT.DLG_NoImport); string strIK = "IK"; //<<이건 고유명사 string strNoIK = _editor.GetText(TEXT.DLG_NoIK); string strShape = _editor.GetText(TEXT.DLG_Shape); string strNoShape = _editor.GetText(TEXT.DLG_NoShape); for (int i = 0; i < baseBoneUnits.Count; i++) { boneUnit = baseBoneUnits[i]; EditorGUILayout.BeginHorizontal(GUILayout.Width(itemWidth), GUILayout.Height(itemHeight)); GUILayout.Space(10); GUI.backgroundColor = boneUnit._color; GUILayout.Box("", apEditorUtil.WhiteGUIStyle_Box, GUILayout.Width(16), GUILayout.Height(16)); GUI.backgroundColor = prevColor; EditorGUILayout.LabelField(boneUnit._unitID.ToString(), guiStyle_ItemLabel, GUILayout.Width(30), GUILayout.Height(itemHeight)); boneUnit._name = EditorGUILayout.TextField(boneUnit._name, guiStyle_ItemTextBox, GUILayout.Width(120), GUILayout.Height(itemHeight)); GUILayout.Space(20); //"Import", "Not Import" if (apEditorUtil.ToggledButton_2Side(strImport, strNoImport, boneUnit._isImportEnabled, true, 100, itemHeight)) { boneUnit._isImportEnabled = !boneUnit._isImportEnabled; } GUILayout.Space(10); //"IK", "No IK" if (apEditorUtil.ToggledButton_2Side(strIK, strNoIK, boneUnit._isIKEnabled, boneUnit._isImportEnabled, 70, itemHeight)) { boneUnit._isIKEnabled = !boneUnit._isIKEnabled; } //"Shape", "No Shape" if (apEditorUtil.ToggledButton_2Side(strShape, strNoShape, boneUnit._isShapeEnabled, boneUnit._isImportEnabled, 70, itemHeight)) { boneUnit._isShapeEnabled = !boneUnit._isShapeEnabled; } EditorGUILayout.EndHorizontal(); } } EditorGUILayout.EndVertical(); GUILayout.Space(listHeight + 100); EditorGUILayout.EndScrollView(); GUILayout.Space(20); // - 전체 선택 / 해제 // - 전체 IK 포함 여부, // - 옵션 : 크기 int widthHalf = (width / 2) - 4; EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_EnableAllBones), false, isFileLoaded, widthHalf, 25)) //"Enable All Bones" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isImportEnabled = true; } } } if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_DisableAllBones), false, isFileLoaded, widthHalf, 25)) //"Disable All Bones" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isImportEnabled = false; } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_EnableAllIK), false, isFileLoaded, widthHalf, 25)) //"Enable All IK" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isIKEnabled = true; } } } if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_DisableAllIK), false, isFileLoaded, widthHalf, 25)) //"Disable All IK" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isIKEnabled = false; } } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_EnableAllShape), false, isFileLoaded, widthHalf, 25)) //"Enable All Shape" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isShapeEnabled = true; } } } if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_DisableAllShape), false, isFileLoaded, widthHalf, 25)) //"Disable All Shape" { if (baseBoneUnits != null) { for (int i = 0; i < baseBoneUnits.Count; i++) { baseBoneUnits[i]._isShapeEnabled = false; } } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); int widthLabel = 150; int widthValue = width - 155; EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(20)); GUILayout.Space(5); //"Import Scale" EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_ImportScale), GUILayout.Width(widthLabel)); _retargetData._importScale = EditorGUILayout.FloatField(_retargetData._importScale, GUILayout.Width(widthValue)); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); bool isClose = false; bool isSelectBtnAvailable = _retargetData.IsBaseFileLoaded; //<<TODO : 파일을 연게 있다면 이게 true //" Import to [" + _targetMeshGroup._name + "]" if (apEditorUtil.ToggledButton(_editor.ImageSet.Get(apImageSet.PRESET.Rig_LoadBones), " " + _editor.GetTextFormat(TEXT.DLG_ImportToMeshGroup, _targetMeshGroup._name), false, isSelectBtnAvailable, width, 30)) { _funcResult(true, _loadKey, _retargetData, _targetMeshGroup); isClose = true; } GUILayout.Space(10); apEditorUtil.GUI_DelimeterBoxH(width); GUILayout.Space(10); if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Close), false, true, width, 30)) //"Close" { //_funcResult(false, _loadKey, null, null); _funcResult(false, _loadKey, null, _targetMeshGroup); isClose = true; } if (isClose) { CloseDialog(); } }
// 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 || _targetMeshGroup == null) { CloseDialog(); return; } try { Color prevColor = GUI.backgroundColor; //레이아웃 구조 //1. Save // - 저장 버튼 //2. Load // - 로드 버튼 // - 본 정보 리스트 // - <색상> 인덱스, 이름 -> 적용 여부 + IK + 색상 로드 // - 전체 선택 / 해제 // - 전체 IK 포함 여부, // - 옵션 : 크기 width -= 10; //1. 다이얼로그 타이틀 GUIStyle guiStyleBox = new GUIStyle(GUI.skin.box); guiStyleBox.alignment = TextAnchor.MiddleCenter; guiStyleBox.normal.textColor = apEditorUtil.BoxTextColor; GUIStyle guiStyleBox_Left = new GUIStyle(GUI.skin.textField); guiStyleBox_Left.alignment = TextAnchor.MiddleLeft; //" Export Pose" GUILayout.Box(new GUIContent(" " + _editor.GetText(TEXT.DLG_ExportPose), _editor.ImageSet.Get(apImageSet.PRESET.Rig_SaveLoad)), guiStyleBox, GUILayout.Width(width), GUILayout.Height(35)); GUILayout.Space(5); //2. 기본 정보 int widthLabel = 120; int widthValue = width - (widthLabel + 10 + 5); EditorGUILayout.LabelField(_retarget.SinglePoseFile._portraitName + " - " + _retarget.SinglePoseFile._meshGroupName); GUILayout.Space(10); EditorGUILayout.BeginHorizontal(GUILayout.Width(width)); GUILayout.Space(5); //"Pose Name.. EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PoseName) + " : ", GUILayout.Width(widthLabel)); _retarget.SinglePoseFile._poseName = EditorGUILayout.TextField(_retarget.SinglePoseFile._poseName, GUILayout.Width(widthValue)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUILayout.Width(width)); GUILayout.Space(5); //"Description EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Description) + " : ", GUILayout.Width(widthLabel)); _retarget.SinglePoseFile._description = EditorGUILayout.TextField(_retarget.SinglePoseFile._description, GUILayout.Width(widthValue)); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); //3. Export할 Bone 선택 int listHeight = height - 240; Rect lastRect = GUILayoutUtility.GetLastRect(); GUI.backgroundColor = new Color(0.9f, 0.9f, 0.9f); GUI.Box(new Rect(0, lastRect.y + 5, width + 10, listHeight), ""); List <apRetargetBonePoseUnit> bonePoseUnits = _retarget.SinglePoseFile._bones; int itemWidth = width - 20; int itemHeight = 20; GUIStyle guiStyle_ItemLabel = new GUIStyle(GUI.skin.label); guiStyle_ItemLabel.alignment = TextAnchor.MiddleLeft; _scrollList = EditorGUILayout.BeginScrollView(_scrollList, false, true, GUILayout.Width(width + 10), GUILayout.Height(listHeight)); EditorGUILayout.BeginVertical(GUILayout.Width(width - 10)); for (int i = 0; i < bonePoseUnits.Count; i++) { apRetargetBonePoseUnit boneUnit = bonePoseUnits[i]; EditorGUILayout.BeginHorizontal(GUILayout.Width(itemWidth), GUILayout.Height(itemHeight)); GUILayout.Space(5); EditorGUILayout.LabelField(new GUIContent("", _imgIcon_Bone), GUILayout.Width(itemHeight), GUILayout.Height(itemHeight)); EditorGUILayout.LabelField(boneUnit._name, guiStyle_ItemLabel, GUILayout.Width(200), GUILayout.Height(itemHeight)); GUILayout.Space(10); //"Export", "Export" if (apEditorUtil.ToggledButton_2Side(_editor.GetText(TEXT.DLG_Export), _editor.GetText(TEXT.DLG_Export), boneUnit._isExported, true, 120, itemHeight)) { boneUnit._isExported = !boneUnit._isExported; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); GUILayout.Space(listHeight + 100); EditorGUILayout.EndScrollView(); GUILayout.Space(10); // Select All / Deselect All EditorGUILayout.BeginHorizontal(GUILayout.Width(width + 10), GUILayout.Height(25)); GUILayout.Space(5); //"Select All" if (GUILayout.Button(_editor.GetText(TEXT.DLG_SelectAll), GUILayout.Width((width - 6) / 2), GUILayout.Height(25))) { for (int i = 0; i < bonePoseUnits.Count; i++) { apRetargetBonePoseUnit boneUnit = bonePoseUnits[i]; boneUnit._isExported = true; } } //"Deselect All" if (GUILayout.Button(_editor.GetText(TEXT.DLG_DeselectAll), GUILayout.Width((width - 6) / 2), GUILayout.Height(25))) { for (int i = 0; i < bonePoseUnits.Count; i++) { apRetargetBonePoseUnit boneUnit = bonePoseUnits[i]; boneUnit._isExported = false; } } GUILayout.Space(10); EditorGUILayout.EndHorizontal(); string strExportBtn = " " + _editor.GetText(TEXT.DLG_ExportPose); if (apEditorUtil.ToggledButton_2Side(_editor.ImageSet.Get(apImageSet.PRESET.Rig_SaveLoad), strExportBtn, strExportBtn, false, !string.IsNullOrEmpty(_retarget.SinglePoseFile._poseName), width, 30)) { //TODO. string fileFolderPath = Application.dataPath + "/../" + _editor._bonePose_BaseFolderName; string savedFileName = _retarget.SaveSinglePose(fileFolderPath); if (string.IsNullOrEmpty(savedFileName)) { _editor.Notification("Pose Save Failed", false, true); } else { _editor.Notification("Pose Saved [" + savedFileName + "]", false, false); } CloseDialog(); } if (GUILayout.Button(_editor.GetText(TEXT.DLG_Close), GUILayout.Width(width), GUILayout.Height(25))) //"Close" { CloseDialog(); } } catch (Exception ex) { Debug.LogError("Exception : " + ex); } }
// GUI //------------------------------------------------------------------ void OnGUI() { int width = (int)position.width; int height = (int)position.height; if (_editor == null || _targetPortrait == null) { //Debug.LogError("Exit - Editor / Portrait is Null"); CloseDialog(); return; } //만약 Portriat가 바뀌었거나 Editor가 리셋되면 닫자 if (_editor != apEditor.CurrentEditor || _targetPortrait != apEditor.CurrentEditor._portrait) { //Debug.LogError("Exit - Editor / Portrait Missmatch"); CloseDialog(); return; } int tabBtnHeight = 25; int tabBtnWidth = ((width - 10) / 3) - 4; EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(tabBtnHeight)); GUILayout.Space(5); if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Portrait), _tab == TAB.PortriatSetting, tabBtnWidth, tabBtnHeight)) //"Portrait" { _tab = TAB.PortriatSetting; } if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_Editor), _tab == TAB.EditorSetting, tabBtnWidth, tabBtnHeight)) //"Editor" { _tab = TAB.EditorSetting; } if (apEditorUtil.ToggledButton(_editor.GetText(TEXT.DLG_About), _tab == TAB.About, tabBtnWidth, tabBtnHeight)) //"About" { _tab = TAB.About; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); int scrollHeight = height - 40; _scroll = EditorGUILayout.BeginScrollView(_scroll, false, true, GUILayout.Width(width), GUILayout.Height(scrollHeight)); width -= 25; GUILayout.BeginVertical(GUILayout.Width(width)); switch (_tab) { case TAB.PortriatSetting: { //Portrait 설정 EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_PortraitSetting)); //"Portrait Settings" GUILayout.Space(10); string nextName = EditorGUILayout.DelayedTextField(_editor.GetText(TEXT.DLG_Name), _targetPortrait.name); //"Name" if (nextName != _targetPortrait.name) { apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false); _targetPortrait.name = nextName; } //"FPS (Important Off)" int nextFPS = EditorGUILayout.DelayedIntField(new GUIContent(_editor.GetText(TEXT.DLG_Setting_FPS), "This setting is used when <Important> is off"), _targetPortrait._FPS); if (_targetPortrait._FPS != nextFPS) { apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false); if (nextFPS < 10) { nextFPS = 10; } _targetPortrait._FPS = nextFPS; } //"Is Important" bool nextImportant = EditorGUILayout.Toggle(new GUIContent(_editor.GetText(TEXT.DLG_Setting_IsImportant), "When this setting is on, it always updates and the physics effect works."), _targetPortrait._isImportant); if (nextImportant != _targetPortrait._isImportant) { apEditorUtil.SetRecord_Portrait(apUndoGroupData.ACTION.Portrait_SettingChanged, _editor, _targetPortrait, null, false); _targetPortrait._isImportant = nextImportant; } GUILayout.Space(10); //수동으로 백업하기 if (GUILayout.Button(_editor.GetText(TEXT.DLG_Setting_ManualBackUp), GUILayout.Height(30))) //"Save Backup (Manual)" { if (_editor.Backup.IsAutoSaveWorking()) { EditorUtility.DisplayDialog(_editor.GetText(TEXT.BackupError_Title), _editor.GetText(TEXT.BackupError_Body), _editor.GetText(TEXT.Okay)); } else { string defaultBackupFileName = _targetPortrait.name + "_backup_" + apBackup.GetCurrentTimeString(); string savePath = EditorUtility.SaveFilePanel("Backup File Path", "", defaultBackupFileName, "bck"); if (string.IsNullOrEmpty(savePath)) { _editor.Notification("Backup Canceled", true, false); } else { _editor.Backup.SaveBackup(savePath, _targetPortrait); _editor.Notification("Backup Saved [" + savePath + "]", false, true); } CloseDialog(); } } } break; case TAB.EditorSetting: { EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_EditorSetting)); //"Editor Settings" GUILayout.Space(10); apEditor.LANGUAGE prevLanguage = _editor._language; int prevLangIndex = -1; for (int i = 0; i < _validLanguageIndex.Length; i++) { if (_validLanguageIndex[i] == (int)prevLanguage) { prevLangIndex = i; } } if (prevLangIndex < 0) { prevLangIndex = 0; //English 강제 } bool prevGUIFPS = _editor._guiOption_isFPSVisible; bool prevGUIStatistics = _editor._guiOption_isStatisticsVisible; Color prevColor_Background = _editor._colorOption_Background; Color prevColor_GridCenter = _editor._colorOption_GridCenter; Color prevColor_Grid = _editor._colorOption_Grid; Color prevColor_MeshEdge = _editor._colorOption_MeshEdge; Color prevColor_MeshHiddenEdge = _editor._colorOption_MeshHiddenEdge; Color prevColor_Outline = _editor._colorOption_Outline; Color prevColor_TFBorder = _editor._colorOption_TransformBorder; Color prevColor_VertNotSelected = _editor._colorOption_VertColor_NotSelected; Color prevColor_VertSelected = _editor._colorOption_VertColor_Selected; Color prevColor_GizmoFFDLine = _editor._colorOption_GizmoFFDLine; Color prevColor_GizmoFFDInnerLine = _editor._colorOption_GizmoFFDInnerLine; Color prevColor_ToneColor = _editor._colorOption_OnionToneColor; bool prevBackup_IsAutoSave = _editor._backupOption_IsAutoSave; string prevBackup_Path = _editor._backupOption_BaseFolderName; int prevBackup_Time = _editor._backupOption_Minute; string prevBonePose_Path = _editor._bonePose_BaseFolderName; //"Language" //이전 방식은 Enum을 모두 조회 //_editor._language = (apEditor.LANGUAGE)EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Setting_Language), (int)_editor._language, _strLanguageName); //사용 가능한 Language만 따로 조회 int nextLangIndex = EditorGUILayout.Popup(_editor.GetText(TEXT.DLG_Setting_Language), prevLangIndex, _strLanguageName); _editor._language = (apEditor.LANGUAGE)_validLanguageIndex[nextLangIndex]; GUILayout.Space(10); _editor._guiOption_isFPSVisible = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_ShowFPS), _editor._guiOption_isFPSVisible); //"Show FPS" _editor._guiOption_isStatisticsVisible = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_ShowStatistics), _editor._guiOption_isStatisticsVisible); // "Show Statistics" GUILayout.Space(10); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_AutoBackupSetting)); //"Auto Backup Option" _editor._backupOption_IsAutoSave = EditorGUILayout.Toggle(_editor.GetText(TEXT.DLG_Setting_AutoBackup), _editor._backupOption_IsAutoSave); //"Auto Backup" if (_editor._backupOption_IsAutoSave) { //경로와 시간 //"Time (Min)" _editor._backupOption_Minute = EditorGUILayout.IntField(_editor.GetText(TEXT.DLG_Setting_BackupTime), _editor._backupOption_Minute, GUILayout.Width(width)); EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(18)); GUILayout.Space(5); //"Save Path" _editor._backupOption_BaseFolderName = EditorGUILayout.TextField(_editor.GetText(TEXT.DLG_Setting_BackupPath), _editor._backupOption_BaseFolderName, GUILayout.Width(width - 100), GUILayout.Height(18)); if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), GUILayout.Width(90), GUILayout.Height(18))) //"Change" { string pathResult = EditorUtility.SaveFolderPanel("Set the Backup Folder", _editor._backupOption_BaseFolderName, ""); if (!string.IsNullOrEmpty(pathResult)) { //Debug.Log("백업 폴더 경로 [" + pathResult + "] - " + Application.dataPath); Uri targetUri = new Uri(pathResult); Uri baseUri = new Uri(Application.dataPath); string relativePath = baseUri.MakeRelativeUri(targetUri).ToString(); _editor._backupOption_BaseFolderName = relativePath; //Debug.Log("상대 경로 [" + relativePath + "]"); apEditorUtil.SetEditorDirty(); } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_PoseSnapshotSetting)); //"Pose Snapshot Option" EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(18)); GUILayout.Space(5); //"Save Path" _editor._bonePose_BaseFolderName = EditorGUILayout.TextField(_editor.GetText(TEXT.DLG_Setting_BackupPath), _editor._bonePose_BaseFolderName, GUILayout.Width(width - 100), GUILayout.Height(18)); if (GUILayout.Button(_editor.GetText(TEXT.DLG_Change), GUILayout.Width(90), GUILayout.Height(18))) //"Change" { string pathResult = EditorUtility.SaveFolderPanel("Set the Pose Folder", _editor._bonePose_BaseFolderName, ""); if (!string.IsNullOrEmpty(pathResult)) { Uri targetUri = new Uri(pathResult); Uri baseUri = new Uri(Application.dataPath); string relativePath = baseUri.MakeRelativeUri(targetUri).ToString(); _editor._bonePose_BaseFolderName = relativePath; apEditorUtil.SetEditorDirty(); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); try { //int width_Btn = 65; //int width_Color = width - (width_Btn + 8); //int height_Color = 18; EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_BackgroundColors)); //"Background Colors" //"Background" _editor._colorOption_Background = ColorUI(_editor.GetText(TEXT.DLG_Setting_Background), _editor._colorOption_Background, width, apEditor.DefaultColor_Background); //"Grid Center" _editor._colorOption_GridCenter = ColorUI(_editor.GetText(TEXT.DLG_Setting_GridCenter), _editor._colorOption_GridCenter, width, apEditor.DefaultColor_GridCenter); //"Grid" _editor._colorOption_Grid = ColorUI(_editor.GetText(TEXT.DLG_Setting_Grid), _editor._colorOption_Grid, width, apEditor.DefaultColor_Grid); //"Atlas Border" _editor._colorOption_AtlasBorder = ColorUI(_editor.GetText(TEXT.DLG_Setting_AtlasBorder), _editor._colorOption_AtlasBorder, width, apEditor.DefaultColor_AtlasBorder); GUILayout.Space(5); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_MeshGUIColors)); //"Mesh GUI Colors" //"Mesh Edge" _editor._colorOption_MeshEdge = ColorUI(_editor.GetText(TEXT.DLG_Setting_MeshEdge), _editor._colorOption_MeshEdge, width, apEditor.DefaultColor_MeshEdge); //"Mesh Hidden Edge" _editor._colorOption_MeshHiddenEdge = ColorUI(_editor.GetText(TEXT.DLG_Setting_MeshHiddenEdge), _editor._colorOption_MeshHiddenEdge, width, apEditor.DefaultColor_MeshHiddenEdge); //"Outline" _editor._colorOption_Outline = ColorUI(_editor.GetText(TEXT.DLG_Setting_Outline), _editor._colorOption_Outline, width, apEditor.DefaultColor_Outline); //"Transform Border" _editor._colorOption_TransformBorder = ColorUI(_editor.GetText(TEXT.DLG_Setting_TransformBorder), _editor._colorOption_TransformBorder, width, apEditor.DefaultColor_TransformBorder); //"Vertex" _editor._colorOption_VertColor_NotSelected = ColorUI(_editor.GetText(TEXT.DLG_Setting_Vertex), _editor._colorOption_VertColor_NotSelected, width, apEditor.DefaultColor_VertNotSelected); //"Selected Vertex" _editor._colorOption_VertColor_Selected = ColorUI(_editor.GetText(TEXT.DLG_Setting_SelectedVertex), _editor._colorOption_VertColor_Selected, width, apEditor.DefaultColor_VertSelected); GUILayout.Space(5); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_GizmoColors)); //"Gizmo Colors" //"FFD Line" _editor._colorOption_GizmoFFDLine = ColorUI(_editor.GetText(TEXT.DLG_Setting_FFDLine), _editor._colorOption_GizmoFFDLine, width, apEditor.DefaultColor_GizmoFFDLine); //"FFD Inner Line" _editor._colorOption_GizmoFFDInnerLine = ColorUI(_editor.GetText(TEXT.DLG_Setting_FFDInnerLine), _editor._colorOption_GizmoFFDInnerLine, width, apEditor.DefaultColor_GizmoFFDInnerLine); GUILayout.Space(5); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_Setting_OnionSkinColor)); //"Onion Skin Color" //"Onion Skin (2x)" _editor._colorOption_OnionToneColor = ColorUI(_editor.GetText(TEXT.DLG_Setting_OnionSkinColor2X), _editor._colorOption_OnionToneColor, width, apEditor.DefaultColor_OnionToneColor); } catch (Exception) { } GUILayout.Space(10); bool prevStartupScreen = _editor._startScreenOption_IsShowStartup; EditorGUILayout.BeginHorizontal(GUILayout.Width(width), GUILayout.Height(25)); GUILayout.Space(5); EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_StartPage_AlawysOn), GUILayout.Width((width - (10 + 30)))); _editor._startScreenOption_IsShowStartup = EditorGUILayout.Toggle(_editor._startScreenOption_IsShowStartup, GUILayout.Width(30)); EditorGUILayout.EndHorizontal(); GUILayout.Space(20); //"Restore Editor Default Setting" if (GUILayout.Button(_editor.GetText(TEXT.DLG_Setting_RestoreDefaultSetting), GUILayout.Height(20))) { _editor.RestoreEditorPref(); } if (prevLanguage != _editor._language || prevGUIFPS != _editor._guiOption_isFPSVisible || prevGUIStatistics != _editor._guiOption_isStatisticsVisible || prevColor_Background != _editor._colorOption_Background || prevColor_GridCenter != _editor._colorOption_GridCenter || prevColor_Grid != _editor._colorOption_Grid || prevColor_MeshEdge != _editor._colorOption_MeshEdge || prevColor_MeshHiddenEdge != _editor._colorOption_MeshHiddenEdge || prevColor_Outline != _editor._colorOption_Outline || prevColor_TFBorder != _editor._colorOption_TransformBorder || prevColor_VertNotSelected != _editor._colorOption_VertColor_NotSelected || prevColor_VertSelected != _editor._colorOption_VertColor_Selected || prevColor_GizmoFFDLine != _editor._colorOption_GizmoFFDLine || prevColor_GizmoFFDInnerLine != _editor._colorOption_GizmoFFDInnerLine || prevColor_ToneColor != _editor._colorOption_OnionToneColor || prevBackup_IsAutoSave != _editor._backupOption_IsAutoSave || !prevBackup_Path.Equals(_editor._backupOption_BaseFolderName) || prevBackup_Time != _editor._backupOption_Minute || !prevBonePose_Path.Equals(_editor._bonePose_BaseFolderName) || prevStartupScreen != _editor._startScreenOption_IsShowStartup ) { bool isLanguageChanged = (prevLanguage != _editor._language); _editor.SaveEditorPref(); apEditorUtil.SetEditorDirty(); apGL.SetToneColor(_editor._colorOption_OnionToneColor); if (isLanguageChanged) { _editor.ResetHierarchyAll(); _editor.RefreshTimelineLayers(true); _editor.RefreshControllerAndHierarchy(); } } } break; case TAB.About: { EditorGUILayout.LabelField(_editor.GetText(TEXT.DLG_About)); //"About" GUILayout.Space(20); apEditorUtil.GUI_DelimeterBoxH(width); GUILayout.Space(20); EditorGUILayout.LabelField("[AnyPortrait]"); EditorGUILayout.LabelField("Build : " + apVersion.I.APP_VERSION_NUMBER_ONLY); GUILayout.Space(20); apEditorUtil.GUI_DelimeterBoxH(width); GUILayout.Space(20); EditorGUILayout.LabelField("[Open Source Library License]"); GUILayout.Space(20); EditorGUILayout.LabelField("[PSD File Import Library]"); GUILayout.Space(10); EditorGUILayout.LabelField("Ntreev Photoshop Document Parser for .Net"); GUILayout.Space(10); EditorGUILayout.LabelField("Released under the MIT License."); GUILayout.Space(10); EditorGUILayout.LabelField("Copyright (c) 2015 Ntreev Soft co., Ltd."); GUILayout.Space(10); EditorGUILayout.LabelField("Permission is hereby granted, free of charge,"); EditorGUILayout.LabelField("to any person obtaining a copy of this software"); EditorGUILayout.LabelField("and associated documentation files (the \"Software\"),"); EditorGUILayout.LabelField("to deal in the Software without restriction,"); EditorGUILayout.LabelField("including without limitation the rights "); EditorGUILayout.LabelField("to use, copy, modify, merge, publish, distribute,"); EditorGUILayout.LabelField("sublicense, and/or sell copies of the Software, "); EditorGUILayout.LabelField("and to permit persons to whom the Software is furnished"); EditorGUILayout.LabelField("to do so, subject to the following conditions:"); GUILayout.Space(10); EditorGUILayout.LabelField("The above copyright notice and "); EditorGUILayout.LabelField("this permission notice shall be included"); EditorGUILayout.LabelField("in all copies or substantial portions of the Software."); GUILayout.Space(10); EditorGUILayout.LabelField("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT "); EditorGUILayout.LabelField("WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, "); EditorGUILayout.LabelField("INCLUDING BUT NOT LIMITED TO THE WARRANTIES "); EditorGUILayout.LabelField("OF MERCHANTABILITY, FITNESS FOR A PARTICULAR "); EditorGUILayout.LabelField("PURPOSE AND NONINFRINGEMENT. "); EditorGUILayout.LabelField("IN NO EVENT SHALL THE AUTHORS OR "); EditorGUILayout.LabelField("COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES "); EditorGUILayout.LabelField("OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, "); EditorGUILayout.LabelField("TORT OR OTHERWISE, ARISING FROM, OUT OF OR "); EditorGUILayout.LabelField("IN CONNECTION WITH THE SOFTWARE OR "); EditorGUILayout.LabelField("THE USE OR OTHER DEALINGS IN THE SOFTWARE."); GUILayout.Space(20); apEditorUtil.GUI_DelimeterBoxH(width); GUILayout.Space(20); EditorGUILayout.LabelField("[GIF Export Library]"); GUILayout.Space(10); EditorGUILayout.LabelField("NGif, Animated GIF Encoder for .NET"); GUILayout.Space(10); EditorGUILayout.LabelField("Released under the CPOL 1.02."); GUILayout.Space(10); } break; } GUILayout.Space(height); EditorGUILayout.EndVertical(); EditorGUILayout.EndScrollView(); }
// GUI //------------------------------------------------------------------ void OnGUI() { int width = (int)position.width; int height = (int)position.height; if (_editor == null || _targetPortrait == null) { 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); } }
// 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); }