public override void ClosePopup(bool bSave) { if (enabled == false) { return; } // Save Material if (bSave && m_SelectedMaterial != null && NgMaterial.IsSameMaterial(m_SelectedMaterial, m_OriMaterial, true) == false) { SaveMaterial(m_SelectedMaterial); } m_SelectedMaterial = null; base.ClosePopup(bSave); }
void DrawBottomMenuRect(Rect baseRect) { GUI.Box(baseRect, ""); Rect imageRect = baseRect; imageRect.width = m_nOriginalBottomHeight - 1; Rect rightRect = baseRect; rightRect.x += imageRect.width; rightRect.width -= imageRect.width; rightRect = FXMakerLayout.GetOffsetRect(rightRect, 5, 3, -5, -3); Rect buttonRect = FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 0, 5); int nButtonWidht = 70; buttonRect.width = nButtonWidht / 2; if (m_SelectedMaterial != null && m_SelObjectContent != null) { // image if (GUI.Button(imageRect, new GUIContent("", m_SelObjectContent.image, m_SelObjectContent.tooltip), GUI.skin.GetStyle("PopupBottom_ImageButton"))) { if (Input.GetMouseButtonUp(0)) { if (0 <= m_nNewShaderMaterialIndex) { FXMakerAsset.SetPingObject(m_SelectedTransform.gameObject); } else { FXMakerAsset.SetPingObject(m_SelectedMaterial); } FXMakerMain.inst.CreateCurrentInstanceEffect(true); } if (Input.GetMouseButtonUp(1)) { FXMakerAsset.SetPingObject(m_SelObjectContent.image); } } // Current Color Color matColor = NgMaterial.GetMaterialColor(m_SelectedMaterial); Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 5, 7), 0, 2, 0, 0); colorRect.width = nButtonWidht / 2; if (NgMaterial.IsMaterialColor(m_SelectedMaterial)) { EditorGUIUtility.DrawColorSwatch(colorRect, matColor); } // text rightRect.x += colorRect.width; rightRect.width -= colorRect.width; GUI.Label(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 5, 3), m_SelObjectContent.text); GUI.Label(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 7, 5), (m_SelectedMaterial.shader != null ? m_SelectedMaterial.shader.name : "[Not Selected]")); bool bChange = (NgMaterial.IsSameMaterial(m_SelectedMaterial, m_OriMaterial, true) == false); // Undo if (FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Undo"), bChange)) { UndoObject(); return; } // UniqueSave buttonRect.x += buttonRect.width + 5; buttonRect.width = nButtonWidht; if (FXMakerLayout.GUIButton(buttonRect, GetHelpContent("UniqueSave"), bChange)) { m_bUniqueSave = true; ClosePopup(true); return; } } // close buttonRect.x += buttonRect.width + 5; buttonRect.width = baseRect.width - buttonRect.x; if (GUI.Button(buttonRect, GetHelpContent("Close"))) { ClosePopup(true); } // ���õȰ�, ������, ��ġ, ȸ��, ����, �ݱ�, ��� }
void SaveMaterial(Material addMat) { string path = ""; string newPath = ""; string uniquePath; Object existsObj; int nUniqueCount = 0; // Find Same Material if (m_bUniqueSave == false && m_SelectedTextureMaterials != null) { foreach (Material mat in m_SelectedTextureMaterials) { if (NgMaterial.IsSameMaterial(mat, addMat, false)) { NgUtil.LogMessage(FXMakerTooltip.GetHsToolMessage("MATERIAL_EXISTSAVED", "")); SetSelectedTransformMaterial(mat); return; } } } // Create Path bool bUseDefaultFolder = false; string devMatDir = "_MaterialsTool"; string userMatDir = "_MaterialsUser"; string matDir; if (FXMakerLayout.m_bDevelopState) { matDir = devMatDir; } else { matDir = userMatDir; } if ((addMat.mainTexture != null)) { path = AssetDatabase.GetAssetPath(addMat.mainTexture); if (path == "") { bUseDefaultFolder = true; } else { newPath = NgFile.CombinePath(NgFile.TrimFilenameExt(path), matDir); // Default SubDirectory if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(NgFile.TrimFilenameExt(path), matDir); } } } else { newPath = NgFile.TrimFilenameExt(AssetDatabase.GetAssetPath(m_OriMaterial)); if (newPath == "") { bUseDefaultFolder = true; } else { string tmpPath = NgFile.TrimLastFolder(newPath); string tmpLast = NgFile.GetLastFolder(newPath); if (FXMakerLayout.m_bDevelopState) { if (tmpLast != devMatDir) { newPath = NgFile.CombinePath(tmpPath, devMatDir); if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(tmpPath, matDir); } } } else { if (tmpLast != userMatDir) { newPath = NgFile.CombinePath(tmpPath, userMatDir); if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(tmpPath, matDir); } } } } } if (bUseDefaultFolder) { path = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.BACKGROUNDRESOURCES); newPath = NgFile.CombinePath(path, matDir); // Default SubDirectory if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(path, matDir); } } // Unique Name string texname = addMat.name; if (addMat.mainTexture != null) { texname = addMat.mainTexture.name; } int nLoopCount = 0; while (true) { string matName = texname + (0 < nUniqueCount ? "_" + nUniqueCount.ToString() : "") + ".mat"; uniquePath = NgFile.CombinePath(newPath, matName); existsObj = AssetDatabase.LoadAssetAtPath(uniquePath, typeof(Material)); if (existsObj == null) { break; } nLoopCount++; nUniqueCount++; if (999 < nUniqueCount) { nUniqueCount = 1; } if (999 < nLoopCount) { Debug.LogError("Over Loop ----------------------"); return; } } AssetDatabase.CreateAsset(addMat, uniquePath); NgUtil.LogMessage(FXMakerTooltip.GetHsToolMessage("MATERIAL_NEWSAVED", "") + "\n" + uniquePath); FXMakerAsset.AssetDatabaseRefresh(); FXMakerAsset.AssetDatabaseSaveAssets(); }