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)); } }
protected override void OnInitialize() { title = "Brush Setting"; w = 330; h = 175; m_positionOffset = Vector3.zero; m_angleOffset = Vector3.zero; windowId = EUI.GetWindowId(); selectedSnapping = 1; m_brushTools = CubeWorldEditorWindow.Inst.sceneWindow.brushTools; }
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 OnInitialize() { title = "Selecter Setting"; w = 330; h = 225; windowId = EUI.GetWindowId(); m_positionSelectedSnapping = 1; m_scaleSelectedSnapping = 1; m_selectorTools = CubeWorldEditorWindow.Inst.sceneWindow.selectorTools; if (m_selectorTools.selectGrid != null) { m_positionOffset = m_selectorTools.selectGrid.positionOffset; m_angleOffset = m_selectorTools.selectGrid.angleOffset; m_scaleOffset = m_selectorTools.selectGrid.scaleOffset; } }
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; }
protected override void OnInitialize() { // 创建工具 if (m_selectorTools == null) { m_selectorTools = new SelectorTools(); } if (m_brushTools == null) { m_brushTools = new BrushTools(); } if (m_suckerTools == null) { m_suckerTools = new SuckerTools(); } if (m_eraseTools == null) { m_eraseTools = new EraseTools(); } // 工具事件注册 m_selectorTools.toolsEventHandler -= OnSelectorToolsEventHandler; m_selectorTools.toolsEventHandler += OnSelectorToolsEventHandler; m_brushTools.toolsEventHandler -= OnBrushToolsEventHandler; m_brushTools.toolsEventHandler += OnBrushToolsEventHandler; m_suckerTools.toolsEventHandler -= OnSuckerToolsEventHandler; m_suckerTools.toolsEventHandler += OnSuckerToolsEventHandler; m_eraseTools.toolsEventHandler -= OnEraseToolsEventHandler; m_eraseTools.toolsEventHandler += OnEraseToolsEventHandler; // 创建窗口 if (m_brushWindow == null) { m_brushWindow = new BrushWindow(); } if (m_selecterWindow == null) { m_selecterWindow = new SelectorWindow(); } // 模版格子 if (m_templateGrid == null) { m_templateGrid = GameObject.Find(typeof(TemplateGrid).Name).gameObject.GetComponent <TemplateGrid>(); } // 注册场景事件 m_templateGrid.SceneRenderHandler -= OnSceneRender; m_templateGrid.SceneRenderHandler += OnSceneRender; // window id m_toolsWindowId = EUI.GetWindowId(); m_operationWindowId = EUI.GetWindowId(); // GUILayoutOption m_layoutWidth = GUILayout.Width(SettingManager.Inst.Setting.sceneToolsIconSize); m_layoutHeight = GUILayout.Height(SettingManager.Inst.Setting.sceneToolsIconSize); // 场景视角设置 m_sceneViewQuaIndex = 0; }