public void ConfirmSpawn() { if (!Selection.activeGameObject && !showScrollPicker) { return; } showScrollPicker = false; if (originalMesh) { Selection.activeGameObject.GetComponent <MeshFilter>().sharedMesh = originalMesh; Selection.activeGameObject.GetComponent <Collider>().enabled = true; } else { Debug.LogError("BLOCKOUT :: INTERNAL :: No original mesh defined"); } GameObject go = PrefabUtility.InstantiatePrefab(targetPrefabSwap) as GameObject; go.transform.position = Selection.activeGameObject.transform.position; go.transform.rotation = targetPrefabSwap.transform.rotation; Selection.activeGameObject = go; GetFavorites(); BlockoutStaticFunctions.ApplyCurrentTheme(); }
public void CancelScrollPicker() { showScrollPicker = false; if (originalMesh) { Selection.activeGameObject.GetComponent <MeshFilter>().sharedMesh = originalMesh; } BlockoutStaticFunctions.ApplyCurrentTheme(); }
public void CancelQickpicker() { showQuickPicker = false; EditorHotkeysTracker.quickPicker = false; if (originalMesh && Selection.activeGameObject) { Selection.activeGameObject.GetComponent <MeshFilter>().sharedMesh = originalMesh; } BlockoutStaticFunctions.ApplyCurrentTheme(); }
public void ConfirmSwap() { if (showScrollPicker) { showScrollPicker = false; GameObject[] target; BlockoutStaticFunctions.ReplaceObject(new[] { Selection.activeGameObject }, targetPrefabSwap, out target); Selection.activeGameObject = target[0]; BlockoutStaticFunctions.ApplyCurrentTheme(); } }
void CreateWhiteScreenShot(int i) { CommentBoxSceneGUI.Disable(); var helpers = FindObjectsOfType <BlockoutHelper>().ToList(); helpers.ForEach(x => x.HideLockedState()); BlockoutStaticFunctions.ApplyNewMaterialSchemeWithoutUndo(screenshotWhiteMaterial, blockoutHierarchy.root.gameObject); CaptureScreenShot(i); BlockoutStaticFunctions.ApplyCurrentTheme(); helpers.ForEach(x => x.ShowLockedState()); }
/// <summary> /// Creates a tri planer asset in front of the camera. /// </summary> /// <param name="prefab">The target tri planar prefab</param> private void CreateTriPlanerAsset(GameObject prefab) { var target = Instantiate(prefab); Undo.RegisterCreatedObjectUndo(target, "Created Tri-Planer Asset"); target.transform.position = BlockoutStaticFunctions.GetSceneViewSpawnPosition(); target.name = prefab.name + " (Tri-Planar)"; Selection.activeGameObject = target; BlockoutStaticFunctions.SnapPositionSelection(); SceneView.lastActiveSceneView.FrameSelected(); Tools.current = Tool.Scale; BlockoutStaticFunctions.ApplyCurrentTheme(); }
/// Apply a new parent transform to the target gameobjects /// <param name="targets"> The gameobjects to reparent</param> /// <param name="blockoutSection"> The new section that it needs to find in the level above to parent to</param> private void ApplyParentTransformFromSection(GameObject[] targets, SectionID blockoutSection) { for (var i = 0; i < targets.Length; ++i) { var vl = targets[i].GetComponentsInParent <BlockoutSection>().Where(x => x.Section == SectionID.Root) .ToList(); var localRoot = vl.Count > 0 ? vl[0].gameObject : blockoutHierarchy.root.gameObject; BlockoutStaticFunctions.CreateBlockoutSubHeirachyWithRoot(localRoot.transform, localRoot.name + "_"); var targetTransform = localRoot.GetComponentsInChildren <BlockoutSection>() .Where(x => x.Section == blockoutSection) .ToList()[0].transform; targets[i].transform.SetParent(targetTransform); BlockoutStaticFunctions.TrimTargetBlockoutHierarchy(localRoot); } BlockoutStaticFunctions.ApplyCurrentTheme(); }
void OnInspectorUpdate() { if (previousGameObject != Selection.activeGameObject) { previousGameObject = Selection.activeGameObject; if (Selection.activeGameObject) { var bh = Selection.activeGameObject.GetComponent <BlockoutHelper>(); if (bh) { if (bh.ReapplyMaterialTheme) { BlockoutStaticFunctions.ApplyCurrentTheme(); } } } } if (sections.Count(x => x.Repaint) > 0) { Repaint(); } }
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(); } }); } } }