private void OnToolsGUI(int id) { using (new VerticalCenteredScope()) { // 选择工具 if (GUILayout.Toggle(m_sceneToolType == SceneToolsType.Selector, EUI.GetTextureContent("iconCursor"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { SwitchTools(SceneToolsType.Selector); } // 笔刷工具 if (GUILayout.Toggle(m_sceneToolType == SceneToolsType.Brush, EUI.GetTextureContent("iconBlockMode"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { SwitchTools(SceneToolsType.Brush); } // 吸管工具 if (GUILayout.Toggle(m_sceneToolType == SceneToolsType.Sucker, EUI.GetTextureContent("iconPicker"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { SwitchTools(SceneToolsType.Sucker); } // 擦除工具 if (GUILayout.Toggle(m_sceneToolType == SceneToolsType.Erase, EUI.GetTextureContent("iconErase"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { SwitchTools(SceneToolsType.Erase); } } }
/// <summary> /// 创建界面 /// </summary> private void DrawCreate() { // logo using (new HorizontalCenteredScope()) { GUILayout.Box(EUI.GetTextureContent("cubeWorld"), "texture", GUILayout.Width(SettingManager.Inst.Setting.EditorWidth), GUILayout.Height(120)); } using (new HorizontalCenteredScope()) { GUILayout.Box(EUI.GetTextureContent("sceneName"), "texture", GUILayout.Width(SettingManager.Inst.Setting.EditorWidth), GUILayout.Height(48)); } m_sceneName = EditorGUILayout.TextField(m_sceneName); using (new HorizontalCenteredScope()) { if (GUILayout.Button(EUI.GetTextureContent("createScene"), GUILayout.Width(SettingManager.Inst.Setting.EditorWidth), GUILayout.Height(55))) { if (string.IsNullOrEmpty(m_sceneName)) { ShowNotification(new GUIContent("please input scene name.")); return; } // 首字母转成大写 m_sceneName = Utils.ToUpperFirstChar(m_sceneName); // 判断场景是否已经存在 if (Directory.Exists(Utils.GetSceneDirectory(m_sceneName)) || Directory.Exists(Utils.GetScenePath(m_sceneName))) { if (EditorUtility.DisplayDialog("Create Cube World Scene", "The scene already exists to create a new one?", "Create New", "Cancel")) { Directory.Delete(Utils.GetSceneDirectory(Utils.GetSceneDirectory(m_sceneName), true), true); CreateScene(); } } else { CreateScene(); } } } using (new VerticalCenteredScope()) { } using (new HorizontalCenteredScope()) { GUILayout.Box(EUI.GetTextureContent("fasthro"), "texture", GUILayout.Width(SettingManager.Inst.Setting.EditorWidth), GUILayout.Height(48)); } }
private void OnOperationGUI(int id) { using (new HorizontalCenteredScope()) { // Template Grid 背景 templateGrid.transparentEnabled = GUILayout.Toggle(templateGrid.transparentEnabled, EUI.GetTextureContent("iconIsolate"), GUI.skin.button, m_layoutHeight, m_layoutWidth); // Template Grid 高度 if (GUILayout.Toggle(false, EUI.GetTextureContent("iconGridUp"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { m_sceneToolType = SceneToolsType.None; templateGrid.height++; CubeWorldEditorWindow.Inst.Repaint(); } // GizmoPanelDown if (GUILayout.Toggle(false, EUI.GetTextureContent("iconGridDown"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { m_sceneToolType = SceneToolsType.None; templateGrid.height--; CubeWorldEditorWindow.Inst.Repaint(); } // camera view if (GUILayout.Button(EUI.GetTextureContent("iconEye"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { m_sceneViewQuaIndex++; if (m_sceneViewQuaIndex >= m_sceneViewQuas.Length) { m_sceneViewQuaIndex = 0; } SceneView.lastActiveSceneView.LookAt(Vector3.zero, m_sceneViewQuas[m_sceneViewQuaIndex]); } // 截图 if (GUILayout.Button(EUI.GetTextureContent("iconCapture"), GUI.skin.button, m_layoutHeight, m_layoutWidth)) { SwitchTools(SceneToolsType.None); var path = Utils.GetPathToAssets(Utils.GetSceneDirectory(Environment.Inst.sceneName, false)) + "/ScreenShot/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".png"; Utils.CaptureScreenShot(path, SettingManager.Inst.Setting.screenshotOpenFinder); EditorUtility.DisplayDialog("Capture ScreenShot", "Capture ScreenShot Succeed!", "ok"); } } }
protected override void OnGUI(int id) { GUILayout.Label("-Rotation"); using (new HorizontalCenteredScope()) { var originalColour = GUI.backgroundColor; GUI.backgroundColor = backgroundRed; if (GUILayout.Button(EUI.GetTextureContent("iconX90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.x += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconX180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.x += 180; } GUI.backgroundColor = backgroundGreen; if (GUILayout.Button(EUI.GetTextureContent("iconY90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.y += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconY180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.y += 180; } GUI.backgroundColor = backgroundBlue; if (GUILayout.Button(EUI.GetTextureContent("iconZ90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.z += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconZ180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.z += 180; } GUI.backgroundColor = originalColour; } GUILayout.Label("-Position"); m_positionSelectedSnapping = GUILayout.SelectionGrid(m_positionSelectedSnapping, m_positionOptions, m_positionOptions.Length, EditorStyles.miniButton); if (m_positionSelectedSnapping < m_positionOptionValues.Length && m_positionSelectedSnapping > 0) { m_positionSnapValue = m_positionOptionValues[m_positionSelectedSnapping]; } else { m_positionSnapValue = EditorGUILayout.FloatField("Custom Value", m_positionSnapValue); } using (new HorizontalCenteredScope()) { var originalColour = GUI.backgroundColor; GUI.backgroundColor = backgroundRed;; if (GUILayout.Button(EUI.GetTextContent("+X"), GUILayout.Width(50))) { m_positionOffset.x += m_positionSnapValue; } if (GUILayout.Button(EUI.GetTextContent("-X"), GUILayout.Width(50))) { m_positionOffset.x -= m_positionSnapValue; } GUI.backgroundColor = backgroundGreen; if (GUILayout.Button(EUI.GetTextContent("+Y"), GUILayout.Width(50))) { m_positionOffset.y += m_positionSnapValue; } if (GUILayout.Button(EUI.GetTextContent("-Y"), GUILayout.Width(50))) { m_positionOffset.y -= m_positionSnapValue; } GUI.backgroundColor = backgroundBlue; if (GUILayout.Button(EUI.GetTextContent("+Z"), GUILayout.Width(50))) { m_positionOffset.z += m_positionSnapValue; } if (GUILayout.Button(EUI.GetTextContent("-Z"), GUILayout.Width(50))) { m_positionOffset.z -= m_positionSnapValue; } GUI.backgroundColor = originalColour; } GUILayout.Label("-Scale"); m_scaleSelectedSnapping = GUILayout.SelectionGrid(m_scaleSelectedSnapping, m_scaleOptions, m_scaleOptions.Length, EditorStyles.miniButton); if (m_scaleSelectedSnapping < m_scaleOptionValues.Length && m_scaleSelectedSnapping > 0) { m_scaleSnapValue = m_scaleOptionValues[m_scaleSelectedSnapping]; } else { m_scaleSnapValue = EditorGUILayout.FloatField("Custom Value", m_scaleSnapValue); } using (new HorizontalCenteredScope()) { var originalColour = GUI.backgroundColor; GUI.backgroundColor = backgroundRed;; if (GUILayout.Button(EUI.GetTextContent("X"), GUILayout.Width(103))) { m_scaleOffset.x = m_scaleSnapValue; } GUI.backgroundColor = backgroundGreen; if (GUILayout.Button(EUI.GetTextContent("Y"), GUILayout.Width(103))) { m_scaleOffset.y = m_scaleSnapValue; } GUI.backgroundColor = backgroundBlue; if (GUILayout.Button(EUI.GetTextContent("Z"), GUILayout.Width(103))) { m_scaleOffset.z = m_scaleSnapValue; } GUI.backgroundColor = originalColour; } // 设置笔刷 m_selectorTools.selectGrid.positionOffset = m_positionOffset; m_selectorTools.selectGrid.angleOffset = m_angleOffset; m_selectorTools.selectGrid.scaleOffset = m_scaleOffset; m_selectorTools.selectGrid.Refresh(); }
protected override void OnGUI(int id) { GUILayout.Label("-Rotation"); using (new HorizontalCenteredScope()) { var originalColour = GUI.backgroundColor; GUI.backgroundColor = backgroundRed; if (GUILayout.Button(EUI.GetTextureContent("iconX90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.x += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconX180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.x += 180; } GUI.backgroundColor = backgroundGreen; if (GUILayout.Button(EUI.GetTextureContent("iconY90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.y += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconY180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.y += 180; } GUI.backgroundColor = backgroundBlue; if (GUILayout.Button(EUI.GetTextureContent("iconZ90"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.z += 90; } if (GUILayout.Button(EUI.GetTextureContent("iconZ180"), GUILayout.Width(50), GUILayout.Height(50))) { m_angleOffset.z += 180; } GUI.backgroundColor = originalColour; } GUILayout.Label("-Position"); selectedSnapping = GUILayout.SelectionGrid(selectedSnapping, Options, Options.Length, EditorStyles.miniButton); if (selectedSnapping < OptionValues.Length && selectedSnapping > 0) { snapValue = OptionValues[selectedSnapping]; } else { snapValue = EditorGUILayout.FloatField("Custom Value", snapValue); } using (new HorizontalCenteredScope()) { var originalColour = GUI.backgroundColor; GUI.backgroundColor = backgroundRed;; if (GUILayout.Button(EUI.GetTextContent("+X"), GUILayout.Width(50))) { m_positionOffset.x += snapValue; } if (GUILayout.Button(EUI.GetTextContent("-X"), GUILayout.Width(50))) { m_positionOffset.x -= snapValue; } GUI.backgroundColor = backgroundGreen; if (GUILayout.Button(EUI.GetTextContent("+Y"), GUILayout.Width(50))) { m_positionOffset.y += snapValue; } if (GUILayout.Button(EUI.GetTextContent("-Y"), GUILayout.Width(50))) { m_positionOffset.y -= snapValue; } GUI.backgroundColor = backgroundBlue; if (GUILayout.Button(EUI.GetTextContent("+Z"), GUILayout.Width(50))) { m_positionOffset.z += snapValue; } if (GUILayout.Button(EUI.GetTextContent("-Z"), GUILayout.Width(50))) { m_positionOffset.z -= snapValue; } GUI.backgroundColor = originalColour; } // 设置笔刷 m_brushTools.positionOffset = m_positionOffset; m_brushTools.angleOffset = m_angleOffset; }