public override void DrawSection() { repaint = false; GUILayout.Space(10); using (new GUILayout.HorizontalScope()) { GUILayout.Box(EUIResourceManager.Instance.GetContent("Asset Header"), EUIResourceManager.Instance.Skin.GetStyle("Texture"), GUILayout.MaxWidth(236), GUILayout.MaxHeight(30)); var blockHelpers = Selection.gameObjects.ToList().Where(x => x.GetComponent <BlockoutHelper>()).Select(x => x.GetComponent <BlockoutHelper>()).ToArray(); int locked = blockHelpers.Where(x => x.Locked).ToList().Count; if (locked > 0) { using (new VerticalCenteredScope(GUILayout.MaxHeight(30))) { using (new HorizontalCenteredScope()) { GUILayout.Label(String.Format("{0} object(s) locked!", locked), GUILayout.MaxWidth(120)); GUILayout.Label(EUIResourceManager.Instance.GetTexture("Lock_Closed"), GUILayout.Height(15), GUILayout.Width(15)); } } } else { GUILayout.Space(125); } } // Draw quick jump using (new HorizontalCenteredScope()) { if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Block Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Block_1x1x1", "Block_Slope_1x1x1"); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Walls Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Wall_025x1x1", "Wall_025x3x1"); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Floors Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Floor_1x-025x1", "Floor_Angle_3x - 025x3"); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Dynamic Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Barrel", "Crate_1x1x1"); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Foliage Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Bush_1", "Vines_Large"); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Particles Quickjump"), GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutStaticFunctions.PingAssetInProjectWindow("Fire_Ground_1x1", "Water_Drip_1"); } } // Draw grid textures using (new HorizontalCenteredScope()) { // Loop through all the loaded grid textures and display them in a button. // If its selected then apply that texture to every gameobject in the scene for (var i = 0; i < EUIResourceManager.Instance.GridTextures.Length; ++i) { if (i >= EUIResourceManager.Instance.GridIcons.Length) { continue; } if (GUILayout.Button(m_gridIconLabels[i], GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth))) { BlockoutEditorSettings.CurrentGirdTexture = i; BlockoutStaticFunctions.ApplyTextureIncChildren(EUIResourceManager.Instance.GridTextures[BlockoutEditorSettings.CurrentGirdTexture], blockoutHierarchy.root); } } } // Draw themes using (new HorizontalCenteredScope()) { for (var i = 0; i < EUIResourceManager.Instance.BlockoutThemes.Length; ++i) { if (GUILayout.Button(m_themeLabels[i], GUILayout.Width(BlockoutEditorSettings.SixColumnWidth), GUILayout.Height(BlockoutEditorSettings.SixColumnWidth / 2))) { BlockoutEditorSettings.CurrentMaterialTheme = i; BlockoutEditorSettings.CurrentPallet = PalletType.Preset; BlockoutStaticFunctions.ApplyCurrentTheme(); } } } // User color pallet using (new HorizontalCenteredScope()) { if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Randomize Pallet"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { GenerateRandomTheme(); BlockoutEditorSettings.CurrentMaterialTheme = EUIResourceManager.Instance.BlockoutThemes.Length + 1; BlockoutStaticFunctions.ApplyTheme(EUIResourceManager.Instance.UserTheme); BlockoutEditorSettings.CurrentPallet = PalletType.User; } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Apply Pallet"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { BlockoutEditorSettings.CurrentMaterialTheme = EUIResourceManager.Instance.BlockoutThemes.Length + 1; BlockoutStaticFunctions.ApplyTheme(EUIResourceManager.Instance.UserTheme); BlockoutEditorSettings.CurrentPallet = PalletType.User; } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Edit Pallet"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { m_userPalletFoldout = !m_userPalletFoldout; } } // User color pickers if (m_userPalletFoldout) { using (new HorizontalCenteredScope()) { using (new GUILayout.VerticalScope(GUILayout.MaxWidth(375))) { if (!Application.isPlaying && Application.isEditor) { for (var i = 0; i < m_colorStrings.Length; ++i) { GUILayout.BeginHorizontal(); m_userThemeColors[i] = EditorGUILayout.ColorField(m_colorStrings[i], m_userThemeColors[i]); m_lockColors[i] = GUILayout.Toggle(m_lockColors[i], EUIResourceManager.Instance.GetContent("Lock Color"), EUIResourceManager.Instance.Skin.FindStyle("padlock"), GUILayout.Height(15), GUILayout.Width(15)); GUILayout.EndHorizontal(); } } else { GUILayout.Label("Feature not availble during play mode."); } GUILayout.Space(5); } } } // Replace Assets using (new HorizontalCenteredScope()) { if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Select Asset"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { BlockoutStaticFunctions.SelectAsset(); } if (!Application.isPlaying && Application.isEditor) { m_targetReplacementAsset = EditorGUILayout.ObjectField(new GUIContent(""), m_targetReplacementAsset, typeof(GameObject), false, GUILayout.Width(124)) as GameObject; if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Replace Asset"), GUILayout.Width(124))) { BlockoutStaticFunctions.ReplaceObject(Selection.gameObjects, m_targetReplacementAsset); } } else { GUILayout.Label("Feature not availble during play mode."); } } using (new HorizontalCenteredScope()) { if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Lock Asset"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { Selection.gameObjects.ToList().Where(x => x.GetComponent <BlockoutHelper>()).Select(x => x.GetComponent <BlockoutHelper>()).ToList().ForEach(x => x.SetLock(!x.Locked)); } if (GUILayout.Button(EUIResourceManager.Instance.GetContent("Toggle Locked Asset"), GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { globalLocked = !globalLocked; var helpers = FindObjectsOfType <BlockoutHelper>().ToList(); helpers.ForEach(x => x.SetLock(globalLocked)); } var content = EUIResourceManager.Instance.GetContent("Toggle Lockd Visability"); content.text = lockedVisability ? "Show Locked (On)" : "Show Locked (Off)"; if (GUILayout.Button(content, GUILayout.Width(BlockoutEditorSettings.ThreeColumnWidth))) { lockedVisability = !lockedVisability; var helpers = FindObjectsOfType <BlockoutHelper>().ToList(); helpers.ForEach(x => { if (lockedVisability) { x.ShowLockedState(); } else { x.HideLockedState(); } }); } } }
private static void OnScene(SceneView view) { var e = Event.current; if (!targetEditor) { targetEditor = EditorWindow.GetWindow <BlockoutEditorWindow>(); } if (e.control && e.alt && e.keyCode == KeyCode.B && e.type == EventType.KeyDown) { if (!BlockoutEditorWindow.isVisible) { BlockoutEditorWindow.Init(); e.Use(); } else { targetEditor.Close(); SceneView.currentDrawingSceneView.Focus(); e.Use(); } } if (!targetEditor) { return; } if (e != null && e.delta != Vector2.zero && e.type == EventType.ScrollWheel && scrollPicker) { SceneView.lastActiveSceneView.size = size; amount += e.delta.y; if (amount >= 5.0f && targetEditor.suggestedSection.shownItems.Count > 0) { int first = targetEditor.suggestedSection.shownItems[0]; targetEditor.suggestedSection.shownItems.RemoveAt(0); targetEditor.suggestedSection.shownItems.Add(first); amount -= 5f; } else if (amount <= -5f && targetEditor.suggestedSection.shownItems.Count > 0) { int last = targetEditor.suggestedSection .shownItems[targetEditor.suggestedSection.shownItems.Count - 1]; targetEditor.suggestedSection.shownItems .RemoveAt(targetEditor.suggestedSection.shownItems.Count - 1); targetEditor.suggestedSection.shownItems.Insert(0, last); amount += 5f; } e.Use(); SceneView.lastActiveSceneView.Repaint(); } else if (e != null && e.keyCode != KeyCode.None) { // Snapping Toggle if (e.alt && e.keyCode == KeyCode.S && e.type == EventType.KeyDown) { if (BlockoutEditorWindow.isVisible) { BlockoutEditorSettings.AutoSnap = !BlockoutEditorSettings.AutoSnap; targetEditor.Repaint(); SceneView.currentDrawingSceneView.Focus(); e.Use(); } } // Increase snap value else if (e.alt && e.control && e.keyCode == KeyCode.Z && e.type == EventType.KeyDown) { if (BlockoutEditorWindow.isVisible) { var window = targetEditor; window.gridSnapping.IncreaseSnapValue(); targetEditor.Repaint(); SceneView.currentDrawingSceneView.Focus(); e.Use(); } } // Decrease Snap Value else if (e.alt && e.control && e.keyCode == KeyCode.X && e.type == EventType.KeyDown) { if (BlockoutEditorWindow.isVisible) { var window = targetEditor; window.gridSnapping.DecreaseSnapValue(); targetEditor.Repaint(); SceneView.currentDrawingSceneView.Focus(); e.Use(); } } // Snap To Floor else if (e.keyCode == KeyCode.End && e.type == EventType.KeyDown) { var tempDoSnap = BlockoutEditorSettings.AutoSnap; if (tempDoSnap) { BlockoutEditorSettings.AutoSnap = !BlockoutEditorSettings.AutoSnap; } BlockoutStaticFunctions.Snap(Vector3.down, BlockoutAxis.Y, true); if (tempDoSnap) { BlockoutEditorSettings.AutoSnap = !BlockoutEditorSettings.AutoSnap; } e.Use(); } // Toggle Comments else if (e.alt && e.keyCode == KeyCode.C && e.type == EventType.KeyDown) { if (BlockoutEditorWindow.isVisible) { var window = targetEditor; window.commentsSection.showSection = !window.commentsSection.showSection; if (window.commentsSection.showSection) { window.commentsSection.showSceneInformation = true; } SceneView.currentDrawingSceneView.Focus(); e.Use(); } } // Initialise Quick Picker else if (e.keyCode == KeyCode.C && e.type == EventType.KeyDown && !scrollPicker) { if (Selection.activeGameObject) { scrollPicker = true; size = SceneView.lastActiveSceneView.size; Selection.activeGameObject.GetComponent <Collider>().enabled = false; targetEditor.suggestedSection.InitialiseScrollPicker(); } e.Use(); } else if (e.keyCode == KeyCode.Space && e.type == EventType.KeyDown) { if (!quickPicker && !scrollPicker) { quickPicker = true; targetEditor.suggestedSection.InitialiseQuickPicker(); e.Use(); } else if (scrollPicker) { scrollPicker = false; targetEditor.suggestedSection.ConfirmSpawn(); e.Use(); } } else if (e.keyCode == KeyCode.Escape && e.type == EventType.KeyDown && quickPicker) { quickPicker = false; targetEditor.suggestedSection.CancelQickpicker(); e.Use(); } else if (e.keyCode == KeyCode.C && e.type == EventType.KeyUp && scrollPicker) { scrollPicker = false; targetEditor.suggestedSection.ConfirmSwap(); e.Use(); } else if (e.keyCode == KeyCode.Space && e.type == EventType.KeyUp && scrollPicker && !quickPicker) { scrollPicker = false; targetEditor.suggestedSection.ConfirmSwap(); e.Use(); } else if (e.alt && e.keyCode == KeyCode.Space && e.type == EventType.KeyUp && scrollPicker) { scrollPicker = false; targetEditor.suggestedSection.ConfirmSpawn(); e.Use(); } // Select asset else if (e.keyCode == KeyCode.G && e.type == EventType.KeyDown) { BlockoutStaticFunctions.SelectAsset(); e.Use(); } // Lock selected else if (e.keyCode == KeyCode.L && e.type == EventType.KeyDown) { Selection.gameObjects.Where(x => x.GetComponent <BlockoutHelper>()) .Select(x => x.GetComponent <BlockoutHelper>()).ToList() .ForEach(x => x.SetLock(!x.Locked)); e.Use(); } if (quickPicker) { if (e.keyCode == KeyCode.LeftArrow && e.type == EventType.KeyDown) { targetEditor.suggestedSection.selected--; targetEditor.suggestedSection.scroll.y = (float)targetEditor.suggestedSection.selected / (float)targetEditor.suggestedSection.SuggestedItemCount; e.Use(); } else if (e.keyCode == KeyCode.RightArrow && e.type == EventType.KeyDown) { targetEditor.suggestedSection.selected++; targetEditor.suggestedSection.scroll.y = (float)targetEditor.suggestedSection.selected / (float)targetEditor.suggestedSection.SuggestedItemCount; e.Use(); } else if (e.keyCode == KeyCode.UpArrow && e.type == EventType.KeyDown) { targetEditor.suggestedSection.selected -= targetEditor.suggestedSection.maxPerRow; targetEditor.suggestedSection.scroll.y = (float)targetEditor.suggestedSection.selected / (float)targetEditor.suggestedSection.SuggestedItemCount; e.Use(); } else if (e.keyCode == KeyCode.DownArrow && e.type == EventType.KeyDown) { targetEditor.suggestedSection.selected += targetEditor.suggestedSection.maxPerRow; targetEditor.suggestedSection.scroll.y = (float)targetEditor.suggestedSection.selected / (float)targetEditor.suggestedSection.SuggestedItemCount; e.Use(); } else if ((e.keyCode == KeyCode.Space || e.keyCode == KeyCode.Return) && e.type == EventType.KeyDown) { targetEditor.suggestedSection.SpawnSelected(targetEditor.suggestedSection.selected); targetEditor.suggestedSection.scroll.y = (float)targetEditor.suggestedSection.selected / (float)targetEditor.suggestedSection.SuggestedItemCount; e.Use(); } else if (e.keyCode == KeyCode.Escape && e.type == EventType.KeyDown) { targetEditor.suggestedSection.CancelQickpicker(); e.Use(); } } } }