예제 #1
0
        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();
                        }
                    });
                }
            }
        }