private void DrawTilePreviewSection()
        {
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            RotorzEditorGUI.Title(TileLang.Text("Tile Previews"));

            GUILayout.FlexibleSpace();

            if (GUILayout.Button(TileLang.ParticularText("Action", "Refresh Previews"), RotorzEditorStyles.Instance.ButtonWide))
            {
                this.OnRefreshPreviews();
                GUIUtility.ExitGUI();
            }

            GUILayout.Space(5);
            GUILayout.EndHorizontal();
            ExtraEditorGUI.SeparatorLight();
            GUILayout.Space(-5);

            GUILayout.BeginVertical(RotorzEditorStyles.Instance.PaddedScrollView);
            this.DrawTilePreviews();
            GUILayout.EndVertical();

            GUILayout.Space(-10);
        }
Пример #2
0
        /// <inheritdoc/>
        public override void OnAdvancedToolOptionsGUI()
        {
            this.PlopLocation = (Location)EditorGUILayout.EnumPopup(TileLang.ParticularText("Property", "Location"), this.PlopLocation);
            ++EditorGUI.indentLevel;
            switch (this.PlopLocation)
            {
            case Location.GroupInsideTileSystem:
                this.PlopGroupName = EditorGUILayout.TextField(TileLang.ParticularText("Property", "Group Name"), this.PlopGroupName);
                break;
            }
            --EditorGUI.indentLevel;

            ExtraEditorGUI.SeparatorLight();

            // Repaint scene views when options are changed so that handles updated.
            EditorGUI.BeginChangeCheck();

            this.DisableCycleFunction         = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Disable cycle function"), this.DisableCycleFunction);
            this.InteractWithActiveSystemOnly = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Interact with active system only"), this.InteractWithActiveSystemOnly);
            this.HideWireframeOutline         = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Hide wireframe outline"), this.HideWireframeOutline);

            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
        }
        private void DrawServiceDependents(ServiceEntry service)
        {
            IServiceDescriptor[] sortedDependents;
            this.sortedServiceDependentsLookup.TryGetValue(service.Descriptor, out sortedDependents);

            bool hasProjectDependentUser = (service.Installer != null && service.Installer.IsProjectDependency);
            bool hasServiceDependents    = (sortedDependents != null && sortedDependents.Length != 0);

            if (!hasProjectDependentUser && !hasServiceDependents)
            {
                return;
            }

            ExtraEditorGUI.SeparatorLight(marginTop: 0);

            GUILayout.Label(" Required For:", ExtraEditorStyles.Instance.MetaLabel);
            if (hasProjectDependentUser)
            {
                GUILayout.Label("(Project)", EditorStyles.miniLabel);
            }
            if (hasServiceDependents)
            {
                foreach (var dependent in sortedDependents)
                {
                    GUILayout.Label(dependent.TitleWithNamespace, EditorStyles.miniLabel);
                }
            }
            GUILayout.Space(2);
        }
        /// <summary>
        /// Occurs when header GUI is rendered and for GUI event handling.
        /// </summary>
        /// <remarks>
        /// <para>This means that your <see cref="OnFixedHeaderGUI"/> implementation might
        /// be called several times per frame (one call per event).</para>
        /// <para>The default implementation allows users to:</para>
        /// <list type="bullet">
        ///     <item>Rename brush</item>
        ///     <item>Mark brush as "static"</item>
        ///     <item>Mark brush as "smooth"</item>
        ///     <item>Hide brush</item>
        ///     <item>Set layer and tag for painted tiles</item>
        ///     <item>Categorize brush</item>
        /// </list>
        /// </remarks>
        public override void OnFixedHeaderGUI()
        {
            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(90);

                EditorGUIUtility.labelWidth = 80;
                this.DrawTilesetNameField();

                GUILayout.Label(
                    TileLang.PluralText(
                        /* 0: quantity of brushes */
                        "Contains 1 brush",
                        "Contains {0} brushes",
                        this.tilesetRecord.BrushRecords.Count
                        ),
                    RotorzEditorStyles.Instance.LabelMiddleLeft
                    );

                Rect menuPosition = GUILayoutUtility.GetRect(GUIContent.none, RotorzEditorStyles.Instance.LabelMiddleLeft, GUILayout.Width(45));
                this.DrawMenuButton(new Rect(menuPosition.x, 2, 44, 26), TileLang.Text("Tileset Menu"));

                this.DrawHelpButton();
            }
            GUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = 125;

            ExtraEditorGUI.SeparatorLight(marginTop: 7, marginBottom: 0, thickness: 3);

            this.DrawTabs();
        }
        private void DrawBrushCreatorTabs()
        {
            GUI.Box(new Rect(-1f, -1f, 109f, Screen.height + 6f), GUIContent.none);
            GUILayout.Space(30f);

            for (int i = 0; i < this.brushCreatorGroups.Length; ++i)
            {
                // Draw a separator between each group.
                if (i != 0)
                {
                    ExtraEditorGUI.SeparatorLight();
                }

                // Draw brush creator tabs in group.
                foreach (var brushCreator in this.brushCreatorGroups[i])
                {
                    if (TabButton(brushCreator == this.selectedBrushCreator, brushCreator.Name))
                    {
                        this.SelectedBrushCreatorType          = brushCreator.GetType();
                        this.hintShouldFocusPrimaryNameControl = true;
                    }
                }
            }

            GUILayout.FlexibleSpace();
        }
        private void DrawPaintingTab()
        {
            RtsPreferences.EraseEmptyChunksPreference.Value = (EraseEmptyChunksPreference)EditorGUILayout.EnumPopup(TileLang.Text("Erase empty chunks"), RtsPreferences.EraseEmptyChunksPreference);

            ExtraEditorGUI.SeparatorLight();

            RtsPreferences.ToolPreferredNozzleIndicator.Value = (NozzleIndicator)EditorGUILayout.EnumPopup(TileLang.Text("Preferred nozzle indicator"), RtsPreferences.ToolPreferredNozzleIndicator);
            ++EditorGUI.indentLevel;
            {
                RtsPreferences.ToolWireframeColor.Value = EditorGUILayout.ColorField(TileLang.ParticularText("RenderMode", "Wireframe"), RtsPreferences.ToolWireframeColor);
                RtsPreferences.ToolShadedColor.Value    = EditorGUILayout.ColorField(TileLang.ParticularText("RenderMode", "Shaded"), RtsPreferences.ToolShadedColor);
            }
            --EditorGUI.indentLevel;

            ExtraEditorGUI.SeparatorLight();

            RtsPreferences.ToolImmediatePreviews.Value = EditorGUILayout.ToggleLeft(TileLang.Text("Display immediate previews"), RtsPreferences.ToolImmediatePreviews);
            EditorGUI.BeginDisabledGroup(!RtsPreferences.ToolImmediatePreviews);
            ++EditorGUI.indentLevel;
            {
                RtsPreferences.ToolImmediatePreviewsTintColor.Value = EditorGUILayout.ColorField(TileLang.Text("Preview Tint"), RtsPreferences.ToolImmediatePreviewsTintColor);

                RtsPreferences.ToolImmediatePreviewsSeeThrough.Value = EditorGUILayout.Toggle(TileLang.Text("See-through previews"), RtsPreferences.ToolImmediatePreviewsSeeThrough);
                ExtraEditorGUI.TrailingTip(TileLang.Text("Hold control when painting to temporarily see-through."));
            }
            --EditorGUI.indentLevel;
            EditorGUI.EndDisabledGroup();
        }
Пример #7
0
        /// <inheritdoc/>
        protected override void DoGUI()
        {
            GUILayout.Space(10);

            GUILayout.BeginVertical(this.paddedArea1Style);
            RotorzEditorGUI.Title(TileLang.ParticularText("Action", "Refresh Tiles"));
            GUILayout.Space(5);
            GUILayout.Label(TileLang.Text("Tiles are replaced if obvious changes are detected. You can force refresh all tiles if necessary."), EditorStyles.wordWrappedLabel);

            ExtraEditorGUI.SeparatorLight(marginTop: 5, marginBottom: 5, thickness: 3);

            GUILayout.BeginVertical(this.paddedArea2Style);
            s_ForceRefreshTiles = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Force refresh all tiles"), s_ForceRefreshTiles);

            GUILayout.Space(2);
            EditorGUI.indentLevel += 2;
            if (!s_ForceRefreshTiles)
            {
                s_UpdateProcedural = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Update procedural tiles"), s_UpdateProcedural);
            }
            else
            {
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Update procedural tiles"), true);
                EditorGUI.EndDisabledGroup();
            }
            EditorGUI.indentLevel -= 2;
            GUILayout.Space(2);
            s_PreserveManualOffset = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Preserve manual offsets"), s_PreserveManualOffset);
            GUILayout.Space(2);
            s_PreserveFlags = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Preserve painted user flags"), s_PreserveFlags);
            GUILayout.EndVertical();
            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();

            EditorGUILayout.HelpBox(TileLang.Text("Some manual changes may be lost when refreshing tiles."), MessageType.Warning, true);

            GUILayout.Space(8);

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(TileLang.ParticularText("Action", "Refresh"), ExtraEditorStyles.Instance.BigButtonPadded))
            {
                this.OnButtonRefresh();
                GUIUtility.ExitGUI();
            }
            GUILayout.Space(3);
            if (GUILayout.Button(TileLang.ParticularText("Action", "Cancel"), ExtraEditorStyles.Instance.BigButtonPadded))
            {
                this.Close();
                GUIUtility.ExitGUI();
            }
            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.Space(8);
        }
Пример #8
0
        /// <inheritdoc/>
        public override void OnGUI()
        {
            GUILayout.Label(
                TileLang.Text("Two-dimensional tile brushes can be created from a tileset."),
                EditorStyles.wordWrappedLabel
                );
            GUILayout.Space(10f);

            this.DrawTilesetNameField();

            GUILayout.Space(5f);

            EditorGUI.BeginChangeCheck();
            {
                GUILayout.BeginHorizontal();
                {
                    this.DrawAtlasTextureField();
                    GUILayout.Space(7f);
                    this.DrawAtlasParametersGUI();
                    GUILayout.Space(20f);
                    this.DrawEdgeCorrectionGUI();
                    GUILayout.FlexibleSpace();
                }
                GUILayout.EndHorizontal();
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.RecalculateMetrics();
            }

            // Display warning message if another similar tileset already exists.
            if (!string.IsNullOrEmpty(this.otherTilesetName))
            {
                EditorGUILayout.HelpBox(string.Format(
                                            /* 0: name of the similar tileset */
                                            TileLang.Text("Another similar tileset '{0}' exists that uses the same atlas texture."),
                                            this.otherTilesetName
                                            ), MessageType.Warning, true);
            }

            // Display warning message if texture is not power-of-two.
            if (this.tilesetTexture != null && (!Mathf.IsPowerOfTwo(this.tilesetTexture.width) || !Mathf.IsPowerOfTwo(this.tilesetTexture.height) || this.tilesetTexture.width != this.tilesetTexture.height))
            {
                EditorGUILayout.HelpBox(TileLang.Text("Texture is not power of two and/or is not square."), MessageType.Warning, true);
            }

            ExtraEditorGUI.SeparatorLight(marginTop: 12, marginBottom: 5, thickness: 3);

            if (this.tilesetPreviewUtility == null)
            {
                this.tilesetPreviewUtility = new TilesetPreviewUtility(this.Context);
            }

            if (!this.tilesetPreviewUtility.DrawTilePreviews(this.tilesetTexture, this.tilesetMetrics))
            {
                GUILayout.Label(TileLang.Text("No previews to display..."));
            }
        }
Пример #9
0
        /// <inheritdoc/>
        protected override void DoGUI()
        {
            Event e = Event.current;
            Rect  position;

            GUILayout.Space(10);

            // Draw header area.
            using (var titleContent = ControlContent.Basic(ProductInfo.Name)) {
                position = GUILayoutUtility.GetRect(1, 100);
                if (e.type == EventType.Repaint)
                {
                    Rect headerBackgroundPosition = new Rect(position.x - 2, position.y - 12, position.width + 4, position.height);

                    if (EditorGUIUtility.isProSkin)
                    {
                        GUI.DrawTexture(headerBackgroundPosition, EditorGUIUtility.whiteTexture);
                    }
                    else
                    {
                        RotorzEditorStyles.Instance.TransparentBox.Draw(headerBackgroundPosition, GUIContent.none, false, false, false, false);
                    }

                    Texture2D texAssetBadge = RotorzEditorStyles.Skin.Badge;
                    GUI.DrawTexture(new Rect(position.x + position.width - texAssetBadge.width - 6, position.y - 3, texAssetBadge.width, texAssetBadge.height), texAssetBadge);
                }

                position.x     += 10;
                position.width -= 10;

                GUI.Label(position, titleContent, this.labelTitleStyle);

                Rect versionLabelPosition = new Rect(position.x, position.y + this.labelTitleStyle.CalcHeight(titleContent, position.width), position.width, 42);
                GUI.Label(versionLabelPosition, this.versionString, this.labelVersionStyle);

                GUILayout.BeginHorizontal();
                this.AddLink(TileLang.ParticularText("Online", "Repository"), "https://github.com/rotorz/unity3d-tile-system", "https://github.com/rotorz/unity3d-tile-system");
                GUILayout.EndHorizontal();
            }

            ExtraEditorGUI.SeparatorLight(marginTop: 17, marginBottom: 7);

            // Draw footer area.
            var vendorBadge = RotorzEditorStyles.Skin.VendorBadge;

            position = GUILayoutUtility.GetRect(1, vendorBadge.height + 5);
            if (e.type == EventType.Repaint)
            {
                GUI.DrawTexture(new Rect(position.x + 7, position.y - 2, vendorBadge.width, vendorBadge.height), vendorBadge);

                position.y -= 4;
                this.labelLowerRightStyle.Draw(position, "©2011-2017 Rotorz Limited. All rights reserved.", false, false, false, false);
            }
        }
Пример #10
0
        /// <inheritdoc/>
        public override void OnToolOptionsGUI()
        {
            this.TemporarilyDisableVariationShifting = ToolUtility.RandomizeVariations;

            GUILayout.BeginHorizontal();
            this.DrawStandardOptionsGUI();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            ExtraEditorGUI.SeparatorLight();
        }
        private void OnGUI_Title()
        {
            GUILayout.BeginVertical();
            {
                RotorzEditorGUI.Title(TileLang.ParticularText("Action", "Delete Tileset"));
                GUILayout.Space(5);
                GUILayout.Label(this.headingText, RotorzEditorStyles.Instance.BoldLabel);
                GUILayout.Space(7);
                GUILayout.Label(TileLang.Text("Caution, proceeding will delete tileset which will cause damage to any scenes or assets that require it.\n\nAll contained brushes will also be deleted."), EditorStyles.wordWrappedLabel);
                GUILayout.Space(5);
            }
            GUILayout.EndVertical();

            ExtraEditorGUI.SeparatorLight(thickness: 3);
        }
Пример #12
0
        /// <inheritdoc/>
        public override void OnGUI()
        {
            GUILayout.Space(-5f);

            this.DrawLayoutSelectionGUI();
            GUILayout.Space(3f);

            this.DrawTilesetNameField();
            this.DrawInnerJoinsField();

            ExtraEditorGUI.SeparatorLight(marginBottom: 7);

            this.DrawAtlasDetailsGUI();

            if (this.autotileTextureUncompressed == null)
            {
                ExtraEditorGUI.SeparatorLight(marginTop: 12, marginBottom: 5, thickness: 3);
                GUILayout.Label(TileLang.Text("No previews to display..."));
                return;
            }

            Rect r = EditorGUILayout.BeginHorizontal();

            {
                GUILayout.Space(241f);

                if (GUILayout.Button(TileLang.ParticularText("Action", "Refresh Previews"), RotorzEditorStyles.ContractWidth))
                {
                    this.OnButtonRefreshAtlas();
                    GUIUtility.ExitGUI();
                }
            }
            EditorGUILayout.EndHorizontal();

            GUI.Label(new Rect(r.x, r.y + 4f, r.width, r.height), this.metricSummary, EditorStyles.miniLabel);

            ExtraEditorGUI.SeparatorLight(marginBottom: 5, thickness: 3);

            if (this.previews == null)
            {
                this.previews = new TilesetPreviewUtility(this.Context);
            }

            if (!this.previews.DrawTilePreviews(s_SelectedAutotileLayout, this.atlasTexture, s_InnerJoins, this.metrics))
            {
                GUILayout.Label(TileLang.Text("No previews to display..."));
            }
        }
Пример #13
0
        private void OnGUI()
        {
            GUILayout.Space(10);

            switch (Event.current.type)
            {
            case EventType.KeyDown:
                this.OnKeyDownEvent(Event.current.keyCode);
                break;

            case EventType.Repaint:
                if (this.ShownAsDropDown)
                {
                    RotorzEditorStyles.Instance.WindowGreyBorder.Draw(new Rect(0, 0, position.width, position.height), GUIContent.none, false, false, false, false);
                    ExtraEditorGUI.SeparatorLight(new Rect(1, 21, position.width - 2, 1));
                }
                break;
            }

            if (this.ShownAsDropDown)
            {
                GUILayout.Space(-7);
                GUILayout.Label(this.titleContent, EditorStyles.boldLabel);
                GUILayout.Space(5);
            }

            GUILayout.BeginHorizontal();

            GUILayout.Space(5);

            this.DrawOrientationButtons();

            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();
            {
                GUILayout.Space(2);
                this.DrawDialogButtons();
                GUILayout.Space(5);
            }
            GUILayout.EndVertical();

            GUILayout.Space(5);

            GUILayout.EndHorizontal();

            RotorzEditorGUI.DrawHoverTip(this);
        }
        private void DrawAtlasTexture()
        {
            GUILayout.Space(10);

            RotorzEditorGUI.Title(TileLang.Text("Atlas Texture"));
            ExtraEditorGUI.SeparatorLight(marginBottom: 0);

            this.scrollingAtlasPreview = GUILayout.BeginScrollView(this.scrollingAtlasPreview);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            GUILayout.Box(this.tileset.AtlasTexture);

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }
        public void OnGUI()
        {
            GUILayout.Space(15);

            GUILayout.BeginHorizontal();
            this.OnModifyTilesetGUI();
            this.DrawButtonStrip();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (this.inputProcedural != this.tileset.procedural)
            {
                EditorGUILayout.HelpBox(TileLang.Text("Tiles painted using this tileset will need to be refreshed when switching between procedural and non-procedural."), MessageType.Warning, true);
            }

            ExtraEditorGUI.SeparatorLight(marginTop: 12, marginBottom: 2, thickness: 3);

            this.DrawTilePreviewSection();
        }
        /// <inheritdoc/>
        public override void OnToolOptionsGUI()
        {
            Rect position;

            GUILayout.BeginHorizontal();
            this.DrawStandardOptionsGUI();

            GUILayout.FlexibleSpace();

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.GetActive(RotorzEditorStyles.Skin.RectangleFill, ToolUtility.FillCenter),
                       TileLang.ParticularText("Property", "Fill Center")
                       )) {
                position = GUILayoutUtility.GetRect(21 + 12, 19 + 5);
                if (RotorzEditorGUI.HoverToggle(position, content, ToolUtility.FillCenter, RotorzEditorStyles.Instance.FlatButtonNoMargin))
                {
                    ToolUtility.FillCenter = true;
                }
            }

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.GetActive(RotorzEditorStyles.Skin.RectangleOutline, !ToolUtility.FillCenter),
                       TileLang.ParticularText("Property", "Draw Outline")
                       )) {
                position = GUILayoutUtility.GetRect(21 + 12, 19 + 5);
                if (RotorzEditorGUI.HoverToggle(position, content, !ToolUtility.FillCenter, RotorzEditorStyles.Instance.FlatButtonNoMargin))
                {
                    ToolUtility.FillCenter = false;
                }
            }

            RotorzEditorGUI.VerticalSeparatorLight();

            // "Paint Around Existing Tiles"
            this.DrawPaintAroundExistingTilesOption();

            GUILayout.Space(3);

            GUILayout.EndHorizontal();

            ExtraEditorGUI.SeparatorLight();
        }
Пример #17
0
        /// <summary>
        /// OnGUI is called for rendering and handling GUI events.
        /// </summary>
        /// <remarks>
        /// <para>This means that your OnGUI implementation might be called several
        /// times per frame (one call per event).</para>
        /// </remarks>
        public void OnGUI()
        {
            // Show material mappings.
            int mappingCount = Mathf.Min(this.mappings.MaterialMappingFrom.Length, this.mappings.MaterialMappingTo.Length);

            for (int i = 0; i < mappingCount; ++i)
            {
                this.DrawMaterialMappingEntry(i);
                if (i + 1 < mappingCount)
                {
                    ExtraEditorGUI.SeparatorLight(marginBottom: 5);
                }
            }

            // Button to define new mapping.
            if (GUILayout.Button(TileLang.ParticularText("Action", "Add Material Mapping"), ExtraEditorStyles.Instance.BigButton))
            {
                this.OnAddMaterialMapping();
            }
        }
Пример #18
0
        /// <inheritdoc/>
        public override void OnToolOptionsGUI()
        {
            GUILayout.BeginHorizontal();
            {
                this.DrawStandardOptionsGUI();

                GUILayout.FlexibleSpace();

                GUILayout.Space(5);

                float spacingFieldHeight = RotorzEditorStyles.Instance.TextFieldRoundEdge.fixedHeight;
                float toggleWidth        = 13;

                Rect spacingFieldPosition = GUILayoutUtility.GetRect(110 + toggleWidth, 0);
                spacingFieldPosition.y     -= 5;
                spacingFieldPosition.width -= toggleWidth;
                spacingFieldPosition.height = spacingFieldHeight;
                SpacingCoordinateField(spacingFieldPosition, "X", this.SnapAxisX);

                Rect linkFieldsPosition = spacingFieldPosition;
                linkFieldsPosition.x  = spacingFieldPosition.xMax;
                linkFieldsPosition.y += 7;

                if (this.LinkSnapAxis)
                {
                    this.SnapAxisY.SetFrom(this.SnapAxisX);
                }

                EditorGUI.BeginDisabledGroup(this.LinkSnapAxis);
                spacingFieldPosition.y += spacingFieldPosition.height + 1;
                SpacingCoordinateField(spacingFieldPosition, "Y", this.SnapAxisY);
                EditorGUI.EndDisabledGroup();

                this.LinkSnapAxis = LinkFields(linkFieldsPosition, this.LinkSnapAxis);

                GUILayout.Space(3);
            }
            GUILayout.EndHorizontal();

            ExtraEditorGUI.SeparatorLight();
        }
Пример #19
0
        /// <inheritdoc/>
        public override void OnGUI()
        {
            // Permit shortcut key "F3"
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.F3)
            {
                Event.current.Use();
                this.OnViewTileset();
                GUIUtility.ExitGUI();
            }

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();

            this.DrawLargeTilePreview();

            this.DrawTilesetBrushInfoSection();

            GUILayout.EndHorizontal();
            ExtraEditorGUI.SeparatorLight(marginTop: 10, thickness: 3);
        }
        public override void OnInspectorGUI()
        {
            float initialLabelWidth = EditorGUIUtility.labelWidth;

            RotorzEditorGUI.UseExtendedLabelWidthForLocalization();

            this.serializedObject.Update();

            this.DrawTileSystemNameField();
            ExtraEditorGUI.SeparatorLight(marginTop: 7);

            this.OnSection_TileSystem();

            s_SectionStripping.Value = RotorzEditorGUI.FoldoutSection(s_SectionStripping,
                                                                      label: TileLang.ParticularText("Section", "Stripping"),
                                                                      callback: this.OnSection_Stripping
                                                                      );

            s_SectionBuildOptions.Value = RotorzEditorGUI.FoldoutSection(s_SectionBuildOptions,
                                                                         label: TileLang.ParticularText("Section", "Build Options"),
                                                                         callback: this.OnSection_BuildOptions
                                                                         );

            s_SectionRuntimeOptions.Value = RotorzEditorGUI.FoldoutSection(s_SectionRuntimeOptions,
                                                                           label: TileLang.ParticularText("Section", "Runtime Options"),
                                                                           callback: this.OnSection_RuntimeOptions
                                                                           );

            if (this.DisableUndoOnSerializedObject)
            {
                this.serializedObject.ApplyModifiedPropertiesWithoutUndo();
            }
            else
            {
                this.serializedObject.ApplyModifiedProperties();
            }

            EditorGUIUtility.labelWidth = initialLabelWidth;
        }
Пример #21
0
        /// <inheritdoc/>
        public override void OnToolOptionsGUI()
        {
            GUILayout.BeginHorizontal();
            {
                this.DrawStandardOptionsGUI();

                GUILayout.FlexibleSpace();

                GUILayout.Space(5);

                EditorGUI.BeginChangeCheck();

                using (var content = ControlContent.Basic(
                           RotorzEditorStyles.Skin.GetActive(RotorzEditorStyles.Skin.BrushRound, ToolUtility.BrushNozzle == BrushNozzle.Round),
                           TileLang.Text("Round Nozzle")
                           )) {
                    Rect togglePosition = GUILayoutUtility.GetRect(28, 24);
                    if (RotorzEditorGUI.HoverToggle(togglePosition, content, ToolUtility.BrushNozzle == BrushNozzle.Round, RotorzEditorStyles.Instance.SmallFlatButton))
                    {
                        ToolUtility.BrushNozzle = BrushNozzle.Round;
                    }
                }

                using (var content = ControlContent.Basic(
                           RotorzEditorStyles.Skin.GetActive(RotorzEditorStyles.Skin.BrushSquare, ToolUtility.BrushNozzle == BrushNozzle.Square),
                           TileLang.Text("Square Nozzle")
                           )) {
                    Rect togglePosition = GUILayoutUtility.GetRect(28, 24);
                    if (RotorzEditorGUI.HoverToggle(togglePosition, content, ToolUtility.BrushNozzle == BrushNozzle.Square, RotorzEditorStyles.Instance.SmallFlatButton))
                    {
                        ToolUtility.BrushNozzle = BrushNozzle.Square;
                    }
                }

                // Repaint scene views if nozzle index has changed.
                if (EditorGUI.EndChangeCheck())
                {
                    SceneView.RepaintAll();
                }

                if (this.SupportsPaintAroundExistingTiles)
                {
                    RotorzEditorGUI.VerticalSeparatorLight();

                    this.DrawPaintAroundExistingTilesOption();
                }

                GUILayout.Space(3);
            }
            GUILayout.EndHorizontal();

            ExtraEditorGUI.SeparatorLight();

            bool usingNozzleRadius = (ToolUtility.BrushNozzle == BrushNozzle.Round);

            // Repaint scene views if brush radius has changed.
            EditorGUI.BeginChangeCheck();
            if (usingNozzleRadius)
            {
                this.NozzleRadius = EditorGUILayout.IntSlider(TileLang.ParticularText("Property", "Nozzle Radius"), this.NozzleRadius, 1, 10);
            }
            else
            {
                this.NozzleSize = EditorGUILayout.IntSlider(TileLang.ParticularText("Property", "Nozzle Size"), this.NozzleSize, 1, 19);
            }
            if (EditorGUI.EndChangeCheck())
            {
                SceneView.RepaintAll();
            }
        }
        /// <inheritdoc/>
        public override void OnExtendedPropertiesGUI()
        {
            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Always Add Container"),
                       TileLang.Text("Add tile container object even when not needed by brush.")
                       )) {
                if (this.AutotileBrush.IsProcedural)
                {
                    this.AutotileBrush.alwaysAddContainer = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.alwaysAddContainer);
                    ExtraEditorGUI.TrailingTip(content);

                    if (this.brushAttachPrefabTick)
                    {
                        ExtraEditorGUI.SeparatorLight();
                    }
                }
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Attach Prefab"),
                       TileLang.Text("Additional game objects can be painted by attaching a prefab.")
                       )) {
                bool newAttachPrefabTick = EditorGUILayout.ToggleLeft(content, this.brushAttachPrefabTick);
                if (!newAttachPrefabTick)
                {
                    ExtraEditorGUI.TrailingTip(content);
                }

                // Has state of prefab tick changed?
                if (newAttachPrefabTick != this.brushAttachPrefabTick)
                {
                    this.brushAttachPrefabTick = newAttachPrefabTick;
                    // Should attachment be cleared?
                    if (!this.brushAttachPrefabTick)
                    {
                        TilesetBrush.attachPrefab = null;
                    }
                }
            }

            if (this.brushAttachPrefabTick)
            {
                ++EditorGUI.indentLevel;

                this.TilesetBrush.attachPrefab = EditorGUILayout.ObjectField(TilesetBrush.attachPrefab, typeof(GameObject), false) as GameObject;
                GUILayout.Space(3);
                this.OnExtendedGUI_ScaleMode();

                --EditorGUI.indentLevel;
            }

            ExtraEditorGUI.SeparatorLight(marginBottom: 2);

            float restoreLabelWidth = EditorGUIUtility.labelWidth;
            float restoreFieldWidth = EditorGUIUtility.fieldWidth;

            bool autoInitCollider = false;

            EditorGUIUtility.labelWidth = 70;
            EditorGUIUtility.fieldWidth = 1;

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginVertical();
                {
                    RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Edge Tiles"));

                    using (var content = ControlContent.Basic(
                               TileLang.ParticularText("Flaggable", "Solid Flag"),
                               TileLang.Text("Solid flag can be used to assist with user defined collision detection or pathfinding.")
                               )) {
                        this.AutotileBrush.SolidFlag = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.SolidFlag);
                    }

                    using (var content = ControlContent.Basic(
                               TileLang.ParticularText("Property", "Add Collider"),
                               TileLang.Text("Automatically adds box collider to painted tile.")
                               )) {
                        EditorGUI.BeginChangeCheck();
                        this.AutotileBrush.addCollider = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.addCollider);
                        autoInitCollider |= (EditorGUI.EndChangeCheck() && this.AutotileBrush.addCollider);
                    }
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical();
                {
                    RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Inner Tiles"));

                    using (var content = ControlContent.Basic(
                               TileLang.ParticularText("Flaggable", "Solid Flag"),
                               TileLang.Text("Solid flag can be used to assist with user defined collision detection or pathfinding.")
                               )) {
                        this.AutotileBrush.InnerSolidFlag = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.InnerSolidFlag);
                    }

                    using (var content = ControlContent.Basic(
                               TileLang.ParticularText("Property", "Add Collider"),
                               TileLang.Text("Automatically adds box collider to painted tile.")
                               )) {
                        EditorGUI.BeginChangeCheck();
                        this.AutotileBrush.addInnerCollider = EditorGUILayout.ToggleLeft(content, this.AutotileBrush.addInnerCollider);
                        autoInitCollider |= (EditorGUI.EndChangeCheck() && this.AutotileBrush.addInnerCollider);
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            if (autoInitCollider)
            {
                this.AutotileBrush.colliderType = BrushUtility.AutomaticColliderType;
            }

            if (this.AutotileBrush.addCollider || this.AutotileBrush.addInnerCollider)
            {
                ++EditorGUI.indentLevel;
                this.AutotileBrush.colliderType = (ColliderType)EditorGUILayout.EnumPopup(this.AutotileBrush.colliderType);
                --EditorGUI.indentLevel;
            }

            EditorGUIUtility.labelWidth = restoreLabelWidth;
            EditorGUIUtility.fieldWidth = restoreFieldWidth;

            if (ControlContent.TrailingTipsVisible)
            {
                ExtraEditorGUI.TrailingTip(TileLang.Text("Edge and Inner 'solid' flag can be used for custom collision detection. Avoid inner colliders where possible."));
            }
        }
Пример #23
0
        internal void DrawExtendedPropertiesGUI()
        {
            float leaderSpace = -1;

            string extendedPropertiesLabel = TileLang.ParticularText("Section", "Extended Properties");

            if (DisplayExtendedProperties)
            {
                // Display expanded "Extended Properties" panel.
                Rect hsplitPos = EditorGUILayout.BeginVertical(GUILayout.Width(ExtendedPropertiesPanelWidth));

                GUILayout.Space(leaderSpace);

                DisplayExtendedProperties = GUILayout.Toggle(true, extendedPropertiesLabel, RotorzEditorStyles.Instance.ExtendedProperties_TitleShown);

                this.scrollingExtendedProperties = EditorGUILayout.BeginScrollView(this.scrollingExtendedProperties, RotorzEditorStyles.Instance.ExtendedProperties_ScrollView);
                {
                    float restoreLabelWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 105;

                    GUILayout.BeginVertical(RotorzEditorStyles.Instance.ExtendedPropertiesLeader);
                    {
                        this.BeginChangeCheck();
                        this.BeginExtendedProperties();
                        ExtraEditorGUI.SeparatorLight();
                        this.OnExtendedPropertiesGUI();
                    }
                    GUILayout.EndVertical();

                    this.EndExtendedProperties();
                    this.EndChangeCheck();

                    EditorGUIUtility.labelWidth = restoreLabelWidth;
                    GUILayout.FlexibleSpace();
                }
                EditorGUILayout.EndScrollView();

                EditorGUILayout.EndVertical();

                hsplitPos.y      += 15;
                hsplitPos.height -= 15;

                hsplitPos.width = 6;
                GUI.Box(hsplitPos, GUIContent.none, RotorzEditorStyles.Instance.ExtendedProperties_HSplit);
            }
            else
            {
                // Display collapsed "Extended Properties" panel.
                GUILayout.BeginVertical(GUILayout.Width(RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden.fixedWidth));
                GUILayout.Space(leaderSpace);
                DisplayExtendedProperties = GUILayout.Button(GUIContent.none, RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden);

                Rect position = GUILayoutUtility.GetLastRect();
                position.x      += RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden.padding.left;
                position.y      += RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden.padding.top;
                position.width  -= RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden.padding.horizontal;
                position.height -= RotorzEditorStyles.Instance.ExtendedProperties_TitleHidden.padding.vertical;
                RotorzEditorGUI.VerticalLabel(position, extendedPropertiesLabel, EditorStyles.whiteLabel);

                GUILayout.Space(4);
                GUILayout.EndVertical();
            }
        }
        private void OnSection_RuntimeOptions()
        {
            GUILayout.Space(3);

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Erase Empty Chunks"),
                       TileLang.Text("Hints that empty chunks should be erased when they become empty at runtime.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyHintEraseEmptyChunks, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Apply Basic Stripping"),
                       TileLang.Text("Applies a basic degree of stripping at runtime upon awakening.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyApplyRuntimeStripping, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            ExtraEditorGUI.SeparatorLight();

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Update Procedural at Start"),
                       TileLang.Text("Automatically updates procedural meshes at runtime upon awakening.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyUpdateProceduralAtStart, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Mark Procedural Dynamic"),
                       TileLang.Text("Helps to improve performance when procedural tiles are updated frequently at runtime. Unset if only updated at start of level.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyMarkProceduralDynamic, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Add Procedural Normals"),
                       TileLang.Text("Adds normals to procedural meshes.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyAddProceduralNormals, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            ExtraEditorGUI.SeparatorLight();

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Procedural Sorting Layer"),
                       TileLang.Text("Sorting layer for procedural tileset meshes.")
                       )) {
                RotorzEditorGUI.SortingLayerField(this.propertySortingLayerID, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Procedural Order in Layer"),
                       TileLang.Text("Order in sorting layer.")
                       )) {
                EditorGUILayout.PropertyField(this.propertySortingOrder, content);
                ExtraEditorGUI.TrailingTip(content);
            }
        }
        private void OnSection_TileSystem()
        {
            float initialLabelWidth = EditorGUIUtility.labelWidth;

            BeginMultiPartField(TileLang.ParticularText("Property", "Grid Size (in tiles)"));
            {
                EditorGUIUtility.labelWidth = 65;

                EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Rows"));
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.propertyRows, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyRows.intValue = Mathf.Max(1, this.propertyRows.intValue);
                }

                EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Columns"));
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.propertyColumns, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyColumns.intValue = Mathf.Max(1, this.propertyColumns.intValue);
                }

                EditorGUIUtility.labelWidth = initialLabelWidth;
            }
            EndMultiPartField();

            BeginMultiPartField(TileLang.ParticularText("Property", "Chunk Size (in tiles)"));
            {
                EditorGUIUtility.labelWidth = 65;

                EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Height"));
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.propertyChunkHeight, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyChunkHeight.intValue = Mathf.Max(1, this.propertyChunkHeight.intValue);
                }

                EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Width"));
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.propertyChunkWidth, GUIContent.none);
                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyChunkWidth.intValue = Mathf.Max(1, this.propertyChunkWidth.intValue);
                }

                EditorGUIUtility.labelWidth = initialLabelWidth;
            }
            EndMultiPartField();

            if (!this.propertyChunkHeight.hasMultipleDifferentValues && !this.propertyChunkWidth.hasMultipleDifferentValues)
            {
                if (this.propertyChunkHeight.intValue * this.propertyChunkWidth.intValue > 10000)
                {
                    RotorzEditorGUI.InfoBox(TileLang.Text("Do not exceed an area of 100x100 tiles per chunk when using procedural tilesets."), MessageType.Warning);
                }
            }

            if (ControlContent.TrailingTipsVisible)
            {
                ExtraEditorGUI.TrailingTip(TileLang.Text("Number of tiles that contribute to a chunk."));
            }

            ExtraEditorGUI.SeparatorLight();

            BeginMultiPartField(TileLang.ParticularText("Property", "Cell Size"));
            {
                EditorGUI.showMixedValue = this.propertyTileWidth.hasMultipleDifferentValues || this.propertyTileHeight.hasMultipleDifferentValues || this.propertyTileDepth.hasMultipleDifferentValues;

                Vector3 cellSize = new Vector3(this.propertyTileWidth.floatValue, this.propertyTileHeight.floatValue, this.propertyTileDepth.floatValue);
                EditorGUI.BeginChangeCheck();
                cellSize = EditorGUILayout.Vector3Field(GUIContent.none, cellSize);
                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyTileWidth.floatValue  = Mathf.Max(0.0001f, cellSize.x);
                    this.propertyTileHeight.floatValue = Mathf.Max(0.0001f, cellSize.y);
                    this.propertyTileDepth.floatValue  = Mathf.Max(0.0001f, cellSize.z);
                }

                EditorGUI.showMixedValue = false;
            }
            EndMultiPartField();
            if (ControlContent.TrailingTipsVisible)
            {
                ExtraEditorGUI.TrailingTip(TileLang.Text("Span of an individual tile."));
            }

            GUILayout.Space(10);

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Tiles Facing"),
                       TileLang.Text("Direction that tiles will face when painted. 'Sideways' is good for platform and 2D games. 'Upwards' is good for top-down.")
                       )) {
                EditorGUI.BeginChangeCheck();

                EditorGUILayout.PropertyField(this.propertyTilesFacing, content);
                ExtraEditorGUI.TrailingTip(content);

                if (EditorGUI.EndChangeCheck() && this.propertyAutoAdjustDirection.boolValue)
                {
                    switch ((TileFacing)this.propertyTilesFacing.intValue)
                    {
                    case TileFacing.Sideways:
                        this.propertyDirection.intValue = (int)WorldDirection.Forward;
                        break;

                    case TileFacing.Upwards:
                        this.propertyDirection.intValue = (int)WorldDirection.Up;
                        break;
                    }
                }
            }

            GUILayout.Space(3);

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Initial Direction"),
                       TileLang.Text("Initial direction of tile system upon creation. If in doubt assume default and rotate afterwards.")
                       )) {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(this.propertyDirection, content);
                ExtraEditorGUI.TrailingTip(content);

                if (EditorGUI.EndChangeCheck())
                {
                    this.propertyAutoAdjustDirection.boolValue = false;
                }
            }

            GUILayout.Space(5);
        }
        /// <inheritdoc/>
        protected override void DoGUI()
        {
            EditorGUIUtility.labelWidth = FIELD_LABEL_WIDTH;
            EditorGUIUtility.wideMode   = true;

            this.VerifySelectedPresetValue();

            if (ExtraEditorGUI.AcceptKeyboardReturn())
            {
                this.OnButton_Create();
                return;
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(5);

                Rect presetsPosition = EditorGUILayout.BeginVertical(GUILayout.Width(150));
                if (Event.current.type == EventType.Repaint)
                {
                    GUI.skin.box.Draw(new Rect(presetsPosition.x - 7, presetsPosition.y - 2, presetsPosition.width + 9, presetsPosition.height + 4), GUIContent.none, false, false, false, false);
                }
                this.OnGUI_Presets();
                EditorGUILayout.EndVertical();

                GUILayout.Space(4);

                GUILayout.BeginVertical();
                {
                    this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition);
                    {
                        GUILayout.BeginHorizontal();
                        {
                            GUILayout.Space(5);

                            GUILayout.BeginVertical();
                            this.DrawCurrentPresetEditor();
                            GUILayout.EndVertical();

                            GUILayout.Space(5);
                        }
                        GUILayout.EndHorizontal();
                    }
                    EditorGUILayout.EndScrollView();

                    ExtraEditorGUI.SeparatorLight(marginTop: -1);

                    GUILayout.BeginHorizontal();
                    {
                        this.OnGUI_Buttons();
                        GUILayout.Space(3);
                    }
                    GUILayout.EndHorizontal();

                    GUILayout.Space(5);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            if (!this.hasFocusedName)
            {
                this.hasFocusedName = true;
                this.currentPresetInspector.FocusNameField();
            }
        }
Пример #27
0
        private void DrawRuntimeOptionsSection()
        {
            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Erase Empty Chunks"),
                       TileLang.Text("Hints that empty chunks should be erased when they become empty at runtime.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyHintEraseEmptyChunks, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Apply Basic Stripping"),
                       TileLang.Text("Applies a basic degree of stripping at runtime upon awakening.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyApplyRuntimeStripping, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            ExtraEditorGUI.SeparatorLight();

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Update Procedural at Start"),
                       TileLang.Text("Automatically updates procedural meshes at runtime upon awakening.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyUpdateProceduralAtStart, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Mark Procedural Dynamic"),
                       TileLang.Text("Helps to improve performance when procedural tiles are updated frequently at runtime. Unset if only updated at start of level.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyMarkProceduralDynamic, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Add Procedural Normals"),
                       TileLang.Text("Adds normals to procedural meshes.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyAddProceduralNormals, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            ExtraEditorGUI.SeparatorLight();

            EditorGUI.BeginChangeCheck();

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Procedural Sorting Layer"),
                       TileLang.Text("Sorting layer for procedural tileset meshes.")
                       )) {
                RotorzEditorGUI.SortingLayerField(this.propertySortingLayerID, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Procedural Order in Layer"),
                       TileLang.Text("Order in sorting layer.")
                       )) {
                EditorGUILayout.PropertyField(this.propertySortingOrder, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            if (EditorGUI.EndChangeCheck())
            {
                int sortingLayerID = this.propertySortingLayerID.intValue;
                int sortingOrder   = this.propertySortingOrder.intValue;

                // Update existing procedurally generated tileset meshes immediately.
                foreach (var target in this.targets)
                {
                    ((TileSystem)target).ApplySortingPropertiesToExistingProceduralMeshes(sortingLayerID, sortingOrder);
                }
            }
        }
Пример #28
0
        private void DrawModifyGridSection()
        {
            if (this.targets.Length > 1)
            {
                EditorGUILayout.HelpBox(TileLang.Text("Cannot modify structure of multiple tile systems at the same time."), MessageType.Info);
                return;
            }

            var tileSystem = this.target as TileSystem;

            if (PrefabUtility.GetPrefabType(tileSystem) == PrefabType.Prefab)
            {
                EditorGUILayout.HelpBox(TileLang.Text("Prefab must be instantiated in order to modify tile system structure."), MessageType.Info);
                return;
            }

            float restoreLabelWidth = EditorGUIUtility.labelWidth;

            bool hasGridSizeChanged;
            bool hasOffsetChanged;

            if (s_ModifyGridGroupStyle == null)
            {
                s_ModifyGridGroupStyle = new GUIStyle();
                s_ModifyGridGroupStyle.margin.right = 55;
            }

            Rect modifyGroupRect = EditorGUILayout.BeginVertical(s_ModifyGridGroupStyle);

            {
                ExtraEditorGUI.MultiPartPrefixLabel(TileLang.ParticularText("Property", "Grid Size (in tiles)"));
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(18);
                    EditorGUIUtility.labelWidth = 65;

                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Rows"));
                    this.inputNewRows = Mathf.Max(1, EditorGUILayout.IntField(this.inputNewRows));
                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Columns"));
                    this.inputNewColumns = Mathf.Max(1, EditorGUILayout.IntField(this.inputNewColumns));

                    EditorGUIUtility.labelWidth = restoreLabelWidth;
                }
                GUILayout.EndHorizontal();

                ExtraEditorGUI.MultiPartPrefixLabel(TileLang.ParticularText("Property", "Offset Amount (in tiles)"));
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(18);
                    EditorGUIUtility.labelWidth = 65;

                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Rows"));
                    this.inputRowOffset = EditorGUILayout.IntField(this.inputRowOffset);
                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Columns"));
                    this.inputColumnOffset = EditorGUILayout.IntField(this.inputColumnOffset);

                    EditorGUIUtility.labelWidth = restoreLabelWidth;
                }
                GUILayout.EndHorizontal();

                hasGridSizeChanged = (this.inputNewRows != tileSystem.RowCount || this.inputNewColumns != tileSystem.ColumnCount);
                hasOffsetChanged   = (this.inputRowOffset != 0 || this.inputColumnOffset != 0);

                if (hasGridSizeChanged)
                {
                    this.DrawMaintainTilePositionsInWorld(ref this.inputMaintainTilePositionsInWorldResize);
                }
                else if (hasOffsetChanged)
                {
                    this.DrawMaintainTilePositionsInWorld(ref this.inputMaintainTilePositionsInWorldOffset);
                }

                EditorGUIUtility.labelWidth = restoreLabelWidth;

                ExtraEditorGUI.MultiPartPrefixLabel(TileLang.ParticularText("Property", "Chunk Size (in tiles)"));
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Space(18);
                    EditorGUIUtility.labelWidth = 65;

                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Height"));
                    this.inputNewChunkHeight = Mathf.Max(1, EditorGUILayout.IntField(this.inputNewChunkHeight));
                    EditorGUILayout.PrefixLabel(TileLang.ParticularText("Property", "Width"));
                    this.inputNewChunkWidth = Mathf.Max(1, EditorGUILayout.IntField(this.inputNewChunkWidth));

                    EditorGUIUtility.labelWidth = restoreLabelWidth;
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();


            Rect buttonRect = new Rect(modifyGroupRect.xMax + 5, modifyGroupRect.y + 3, 45, 35);

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.Trim,
                       TileLang.ParticularText("Action", "Trim")
                       )) {
                if (GUI.Button(buttonRect, content))
                {
                    this.OnTrimTileSystem();
                    GUIUtility.ExitGUI();
                }
            }

            buttonRect.y = buttonRect.yMax + 3;

            EditorGUI.BeginDisabledGroup(!hasGridSizeChanged);
            {
                using (var content = ControlContent.Basic(
                           RotorzEditorStyles.Skin.CentralizeUsed,
                           TileLang.ParticularText("Action", "Centralize Tile Bounds")
                           )) {
                    if (GUI.Button(buttonRect, content))
                    {
                        this.OnCentralizeUsedTileSystem();
                        GUIUtility.ExitGUI();
                    }
                }

                buttonRect.y = buttonRect.yMax + 3;

                using (var content = ControlContent.Basic(
                           RotorzEditorStyles.Skin.Centralize,
                           TileLang.ParticularText("Action", "Centralize")
                           )) {
                    if (GUI.Button(buttonRect, content))
                    {
                        this.OnCentralizeTileSystem();
                        GUIUtility.ExitGUI();
                    }
                }
            }
            EditorGUI.EndDisabledGroup();


            bool hasChunkSizeChanged = (this.inputNewChunkWidth != tileSystem.ChunkWidth || this.inputNewChunkHeight != tileSystem.ChunkHeight);

            // Display "Rebuild" button?
            if (hasGridSizeChanged || hasOffsetChanged || hasChunkSizeChanged)
            {
                GUILayout.Space(6);
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.HelpBox(TileLang.Text("Tile system must be reconstructed, some tiles may be force refreshed."), MessageType.Warning);

                    if (GUILayout.Button(TileLang.ParticularText("Action", "Rebuild"), GUILayout.Width(75), GUILayout.Height(40)))
                    {
                        GUIUtility.keyboardControl = 0;
                        this.OnResizeTileSystem();
                        GUIUtility.ExitGUI();
                    }
                    if (GUILayout.Button(TileLang.ParticularText("Action", "Cancel"), GUILayout.Width(75), GUILayout.Height(40)))
                    {
                        GUIUtility.keyboardControl = 0;
                        this.RefreshModifyGridParamsFromTileSystem();
                        GUIUtility.ExitGUI();
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(2);
            }

            ExtraEditorGUI.SeparatorLight();

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Cell Size"),
                       TileLang.Text("Span of an individual tile.")
                       )) {
                Vector3 newCellSize = Vector3.Max(new Vector3(0.0001f, 0.0001f, 0.0001f), EditorGUILayout.Vector3Field(content, tileSystem.CellSize));
                if (tileSystem.CellSize != newCellSize)
                {
                    this.propertyCellSize.vector3Value      = newCellSize;
                    this.propertyHintForceRefresh.boolValue = true;
                }
            }

            GUILayout.Space(5);

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Tiles Facing"),
                       TileLang.Text("Direction that tiles will face when painted. 'Sideways' is good for platform and 2D games. 'Upwards' is good for top-down.")
                       )) {
                TileFacing newTilesFacing = (TileFacing)EditorGUILayout.EnumPopup(content, tileSystem.TilesFacing);
                if (tileSystem.TilesFacing != newTilesFacing)
                {
                    this.propertyTilesFacing.intValue       = (int)newTilesFacing;
                    this.propertyHintForceRefresh.boolValue = true;
                }
            }

            GUILayout.Space(5);

            // Display suitable warning message when force refresh is required.
            if (this.propertyHintForceRefresh.boolValue)
            {
                if (!RotorzEditorGUI.InfoBoxClosable(TileLang.Text("Changes may not take effect until tile system is force refreshed without preserving manual offsets, or cleared."), MessageType.Warning))
                {
                    this.propertyHintForceRefresh.boolValue = false;
                    this.serializedObject.ApplyModifiedProperties();
                    GUIUtility.ExitGUI();
                }
            }
            else
            {
                ExtraEditorGUI.SeparatorLight(marginTop: 0, marginBottom: 0, thickness: 1);
            }

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            {
                // Display extra padding to right of buttons to avoid accidental click when
                // clicking close button of warning message.
                GUILayoutOption columnWidth = GUILayout.Width((EditorGUIUtility.currentViewWidth - 30) / 3 - GUI.skin.button.margin.horizontal);

                GUILayout.BeginVertical(columnWidth);
                if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Refresh"))))
                {
                    TileSystemCommands.Command_Refresh(this.target);
                    GUIUtility.ExitGUI();
                }
                GUILayout.Space(2);
                if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Refresh Plops"))))
                {
                    TileSystemCommands.Command_RefreshPlops(this.target);
                    GUIUtility.ExitGUI();
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(columnWidth);
                if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Repair"))))
                {
                    TileSystemCommands.Command_Repair(this.target);
                    GUIUtility.ExitGUI();
                }
                GUILayout.Space(2);
                if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Clear Plops"))))
                {
                    TileSystemCommands.Command_ClearPlops(this.target);
                    GUIUtility.ExitGUI();
                }
                GUILayout.EndVertical();

                GUILayout.BeginVertical(columnWidth);
                if (GUILayout.Button(TileLang.OpensWindow(TileLang.ParticularText("Action", "Clear"))))
                {
                    TileSystemCommands.Command_Clear(this.target);
                    GUIUtility.ExitGUI();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
        }
        private void OnToolSelectorGUI()
        {
            GUILayout.Space(6);

            this.FilterRegisteredTools();

            // Calculate metrics.
            int buttonColumns = Screen.width / 46;

            if (buttonColumns > this.filteredToolList.Count + 1)
            {
                buttonColumns = this.filteredToolList.Count + 1;
            }

            // Prepare style for tool button.
            if (s_ToolButtonStyle == null)
            {
                s_ToolButtonStyle = new GUIStyle(RotorzEditorStyles.Instance.ToolButton);
            }
            s_ToolButtonStyle.fixedWidth = Mathf.FloorToInt((float)Screen.width / (float)buttonColumns) - 3;

            // Display tool items.
            GUILayout.BeginHorizontal();
            GUILayout.Space(4);

            using (var content = ControlContent.Basic(
                       RotorzEditorStyles.Skin.MenuButton,
                       TileLang.ParticularText("Action", "Main Menu")
                       )) {
                if (EditorInternalUtility.DropdownMenu(content, s_ToolButtonStyle))
                {
                    EditorUtility.DisplayPopupMenu(this.menuPosition, "CONTEXT/_RTS_TOOLS_", new MenuCommand(this, 0));
                }
                if (Event.current.type == EventType.Repaint)
                {
                    this.menuPosition = GUILayoutUtility.GetLastRect();
                }
            }

            int currentColumn = 1;

            for (int i = 0; i < this.filteredToolList.Count; ++i)
            {
                var tool = this.filteredToolList[i];

                // Place tool button at start of new row upon overflowing width of palette.
                if (currentColumn++ >= buttonColumns)
                {
                    currentColumn = 0;
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    GUILayout.Space(4);
                }

                bool selected = ToolManager.Instance.CurrentTool == tool;

                // Get label for tool button and select icon based upon tool selection.
                var toolIconTexture = selected ? tool.IconActive : tool.IconNormal;
                using (var buttonContent = ControlContent.Basic(tool.Label, toolIconTexture)) {
                    // Fallback to 'normal' icon if 'active' icon is not specified.
                    if (selected && toolIconTexture == null)
                    {
                        buttonContent.LabelContent.image = tool.IconNormal;
                    }

                    if (this.ToolButton(buttonContent, selected))
                    {
                        ToolManager.Instance.CurrentTool = !selected ? tool : null;
                    }
                }
            }
            GUILayout.EndHorizontal();

            ExtraEditorGUI.SeparatorLight(marginBottom: 0);

            this.scrolling = GUILayout.BeginScrollView(this.scrolling);

            if (ToolManager.Instance.CurrentTool != null)
            {
                GUILayout.Space(6);

                float restoreLabelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 130;
                {
                    var tool = ToolManager.Instance.CurrentTool;
                    tool.OnToolOptionsGUI();

                    if (tool.HasAdvancedToolOptionsGUI)
                    {
                        GUILayout.Space(-2);

                        tool.ShowAdvancedOptionsGUI = GUILayout.Toggle(tool.ShowAdvancedOptionsGUI, TileLang.ParticularText("Section", "Advanced"), RotorzEditorStyles.Instance.FlatToggle);
                        if (tool.ShowAdvancedOptionsGUI)
                        {
                            tool.OnAdvancedToolOptionsGUI();
                        }
                    }
                }
                EditorGUIUtility.labelWidth = restoreLabelWidth;
            }
            else
            {
                GUILayout.Space(6 + 2);
                GUILayout.Label(TileLang.Text("No tool selected"), EditorStyles.miniLabel);
            }

            GUILayout.Space(3);
            GUILayout.FlexibleSpace();

            GUILayout.EndScrollView();
        }
Пример #30
0
        /// <inheritdoc/>
        public override void OnExtendedPropertiesGUI()
        {
            bool autoInitCollider;

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Add Collider"),
                       TileLang.Text("Automatically adds box collider to painted tile.")
                       )) {
                EditorGUI.BeginChangeCheck();
                this.TilesetBrush.addCollider = EditorGUILayout.ToggleLeft(content, this.TilesetBrush.addCollider);
                autoInitCollider = (EditorGUI.EndChangeCheck() && this.TilesetBrush.addCollider);
                if (this.TilesetBrush.addCollider)
                {
                    ++EditorGUI.indentLevel;
                    this.TilesetBrush.colliderType = (ColliderType)EditorGUILayout.EnumPopup(this.TilesetBrush.colliderType);
                    --EditorGUI.indentLevel;
                }
                ExtraEditorGUI.TrailingTip(content);
            }

            if (autoInitCollider)
            {
                this.TilesetBrush.colliderType = BrushUtility.AutomaticColliderType;
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Always Add Container"),
                       TileLang.Text("Add tile container object even when not needed by brush.")
                       )) {
                if (this.TilesetBrush.IsProcedural)
                {
                    this.TilesetBrush.alwaysAddContainer = EditorGUILayout.ToggleLeft(content, this.TilesetBrush.alwaysAddContainer);
                    ExtraEditorGUI.TrailingTip(content);
                }
            }

            if (this.brushAttachPrefabTick)
            {
                ExtraEditorGUI.SeparatorLight();
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Attach Prefab"),
                       TileLang.Text("Additional game objects can be painted by attaching a prefab.")
                       )) {
                bool newAttachPrefabTick = EditorGUILayout.ToggleLeft(content, this.brushAttachPrefabTick);
                if (!newAttachPrefabTick)
                {
                    ExtraEditorGUI.TrailingTip(content);
                }

                // Has state of prefab tick changed?
                if (newAttachPrefabTick != this.brushAttachPrefabTick)
                {
                    this.brushAttachPrefabTick = newAttachPrefabTick;
                    // Should attachment be cleared?
                    if (!this.brushAttachPrefabTick)
                    {
                        this.TilesetBrush.attachPrefab = null;
                    }
                }

                if (this.brushAttachPrefabTick)
                {
                    ++EditorGUI.indentLevel;

                    this.TilesetBrush.attachPrefab = EditorGUILayout.ObjectField(this.TilesetBrush.attachPrefab, typeof(GameObject), false) as GameObject;
                    GUILayout.Space(2);
                    this.OnExtendedGUI_ScaleMode();

                    --EditorGUI.indentLevel;
                }
            }
        }