/// <inheritdoc/>
        protected override void DoGUI()
        {
            this.hasDrawnGUI = true;

            if (this.tileSystem == null)
            {
                return;
            }

            GUISkin skin = GUI.skin;

            GUILayout.Space(15f);

            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Prefab Output Path:"));
            GUILayout.BeginHorizontal();
            {
                this.PrefabOutputPath = RotorzEditorGUI.RelativeAssetPathTextField(GUIContent.none, this.PrefabOutputPath, ".prefab");
                if (GUILayout.Button("...", GUILayout.Width(40)))
                {
                    GUIUtility.keyboardControl = 0;
                    this.PrefabOutputPath      = this.DoSelectPrefabPath(
                        TileLang.ParticularText("Action", "Save Prefab Output"),
                        TileLang.Text("Specify path for prefab output"),
                        this.PrefabOutputPath
                        );
                }
            }
            GUILayout.EndHorizontal();

            EditorGUILayout.Space();

            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Data Output Path:"));
            GUILayout.BeginHorizontal();
            {
                this.DataOutputPath = RotorzEditorGUI.RelativeAssetPathTextField(GUIContent.none, this.DataOutputPath, ".asset");
                if (GUILayout.Button("...", GUILayout.Width(40)))
                {
                    GUIUtility.keyboardControl = 0;
                    this.DataOutputPath        = this.DoSelectAssetPath(
                        TileLang.ParticularText("Action", "Save Data Output"),
                        TileLang.Text("Specify path for mesh output"),
                        this.DataOutputPath
                        );
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            ExtraEditorGUI.Separator(marginBottom: 10);

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                this.OnGUI_Buttons();
                GUILayout.Space(5f);
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(8f);
        }
Exemplo n.º 2
0
        private void OnGUI_BrushSelection()
        {
            if (this.arrowStyle == null)
            {
                this.arrowStyle = new GUIStyle(GUI.skin.label);
                this.arrowStyle.stretchHeight = true;
                this.arrowStyle.alignment     = TextAnchor.MiddleCenter;
            }

            GUILayout.BeginVertical();
            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Source Brush"), RotorzEditorStyles.Instance.BoldLabel);
            {
                this.sourceBrush = RotorzEditorGUI.BrushField(this.sourceBrush);
                EditorGUILayout.Space();
                this.sourceBrush = this.DrawBrushPreviewField(this.sourceBrush);
            }
            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();
            GUILayout.Label("=>", this.arrowStyle);
            GUILayout.FlexibleSpace();

            GUILayout.BeginVertical();
            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Replacement Brush"), RotorzEditorStyles.Instance.BoldLabel);
            {
                this.replacementBrush = RotorzEditorGUI.BrushField(this.replacementBrush);
                EditorGUILayout.Space();
                this.replacementBrush = this.DrawBrushPreviewField(this.replacementBrush);
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draws the "Tileset Name" input field.
        /// </summary>
        /// <remarks>
        /// <para>User input is a shared property that is stored under the key
        /// <see cref="BrushCreatorSharedPropertyKeys.TilesetName"/>.</para>
        /// </remarks>
        protected void DrawTilesetNameField()
        {
            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tileset Name:"));
            GUI.SetNextControlName(this.Context.PrimaryAssetNameControlName);

            string tilesetName = this.Context.GetSharedProperty(BrushCreatorSharedPropertyKeys.TilesetName, "");

            tilesetName = EditorGUILayout.TextField(tilesetName).Trim();
            this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.TilesetName, tilesetName);
        }
 private void DrawTileSystemNameField()
 {
     ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile System Name"));
     GUI.SetNextControlName("NameField");
     EditorGUI.BeginChangeCheck();
     EditorGUILayout.PropertyField(this.propertySystemName, GUIContent.none);
     if (EditorGUI.EndChangeCheck())
     {
         this.HasModifiedTileSystemName = true;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Draws the "Brush Name" input field.
        /// </summary>
        /// <remarks>
        /// <para>User input is a shared property that is stored under the key
        /// <see cref="BrushCreatorSharedPropertyKeys.BrushName"/>.</para>
        /// </remarks>
        protected void DrawBrushNameField()
        {
            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Name:"));
            GUI.SetNextControlName(this.Context.PrimaryAssetNameControlName);

            string brushName = this.Context.GetSharedProperty(BrushCreatorSharedPropertyKeys.BrushName, "");

            brushName = EditorGUILayout.TextField(brushName).Trim();
            this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.BrushName, brushName);

            RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Must start with alphanumeric character (A-Z a-z 0-9) and can contain hyphens (-), underscores (_) and spaces."));
        }
Exemplo n.º 6
0
        private void DrawEdgeCorrectionGUI()
        {
            EditorGUIUtility.labelWidth = 1;
            EditorGUIUtility.fieldWidth = 125;

            GUILayout.BeginVertical();

            ExtraEditorGUI.AbovePrefixLabel(TileLang.Text("Edge Correction"));
            this.inputEdgeCorrectionPreset = (EdgeCorrectionPreset)EditorGUILayout.EnumPopup(this.inputEdgeCorrectionPreset);

            if (this.inputEdgeCorrectionPreset == EdgeCorrectionPreset.Custom)
            {
                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Border Size (px)"));
                this.inputBorderSize = EditorGUILayout.IntField(this.inputBorderSize, GUILayout.Width(60));

                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Delta (% of 1px)"));
                GUILayout.BeginHorizontal();
                {
                    this.inputDelta = Mathf.Clamp(EditorGUILayout.FloatField(this.inputDelta, GUILayout.Width(60)), 0f, 1f);

                    float newDelta = GUILayout.HorizontalSlider(this.inputDelta, 0f, +1f, GUILayout.Width(80));
                    if (newDelta != this.inputDelta)
                    {
                        this.inputDelta = (float)((int)(newDelta * 100f)) / 100f;
                    }
                }
                GUILayout.EndHorizontal();
            }
            else
            {
                this.inputBorderSize = 0;
                this.inputDelta      = (this.inputEdgeCorrectionPreset == EdgeCorrectionPreset.InsetUVs) ? 0.5f : 0f;

                EditorGUI.BeginDisabledGroup(true);

                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Border Size (px)"));
                EditorGUILayout.IntField(this.inputBorderSize, GUILayout.Width(60));

                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Delta (% of 1px)"));
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.FloatField(this.inputDelta, GUILayout.Width(60));
                    GUILayout.HorizontalSlider(this.inputDelta, 0f, +1f, GUILayout.Width(80));
                }
                GUILayout.EndHorizontal();

                EditorGUI.EndDisabledGroup();
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 7
0
        private void DrawAtlasParametersGUI()
        {
            EditorGUIUtility.labelWidth = 1;
            EditorGUIUtility.fieldWidth = 105;

            GUILayout.BeginVertical();

            EditorGUI.BeginChangeCheck();
            {
                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Width (px)"));
                this.inputTileWidth = EditorGUILayout.IntField(this.inputTileWidth, GUILayout.Width(60));
                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Height (px)"));
                this.inputTileHeight = EditorGUILayout.IntField(this.inputTileHeight, GUILayout.Width(60));
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.ClearExpandedAutotileAtlas();

                // Automatically load uncompressed version of autotile artwork if it has
                // not already been loaded.
                if (this.inputNewAutotileArtworkUncompressed == null)
                {
                    this.LoadUncompressedAutotileArtwork(this.inputNewAutotileArtwork);
                }
            }

            GUILayout.Space(10);

            //this.alpha = GUILayout.Toggle(this.alpha, "Alpha Blending");

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Procedural"),
                       TileLang.Text("Autotile brushes are always procedural, however atlas brushes of an autotile atlas can be non-procedural if desired.")
                       )) {
                this.inputProcedural = GUILayout.Toggle(this.inputProcedural, content);
            }

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Clamp Edges"),
                       TileLang.Text("Indicates if outer edges should always be clamped. Often not appropriate when secondary tile acts as ground.")
                       )) {
                if (this.autotileTileset.AutotileLayout == AutotileLayout.Extended && this.inputBorderSize > 0)
                {
                    this.inputClampEdges = GUILayout.Toggle(this.inputClampEdges, content);
                }
            }

            GUILayout.EndVertical();
        }
Exemplo n.º 8
0
        /// <inheritdoc/>
        public override void OnGUI()
        {
            GUILayout.Space(10f);

            this.DrawBrushNameField();

            GUILayout.Space(10f);

            ExtraEditorGUI.AbovePrefixLabel(TileLang.Text("Select target brush to create duplicate from:"));

            var targetBrush = this.Context.GetSharedProperty <Brush>(BrushCreatorSharedPropertyKeys.TargetBrush);

            targetBrush = RotorzEditorGUI.BrushField(targetBrush);
            this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.TargetBrush, targetBrush);
        }
        /// <inheritdoc/>
        public override void OnGUI()
        {
            GUILayout.Label(TileLang.Text("Create new brush that is based upon an existing brush to override properties and materials."), EditorStyles.wordWrappedLabel);
            GUILayout.Space(10f);

            this.DrawBrushNameField();

            GUILayout.Space(10f);

            ExtraEditorGUI.AbovePrefixLabel(TileLang.Text("Select target brush to create an alias of:"));
            var targetBrush = this.Context.GetSharedProperty <Brush>(BrushCreatorSharedPropertyKeys.TargetBrush);

            targetBrush = RotorzEditorGUI.BrushField(targetBrush, false);
            this.Context.SetSharedProperty(BrushCreatorSharedPropertyKeys.TargetBrush, targetBrush);

            RotorzEditorGUI.MiniFieldDescription(TileLang.Text("Note: You cannot create an alias of another alias brush."));
        }
Exemplo n.º 10
0
        private void DrawAtlasParametersGUI()
        {
            EditorGUIUtility.fieldWidth = 105f;

            GUILayout.BeginVertical();
            {
                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Width (px)"));
                this.tileWidth = EditorGUILayout.IntField(this.tileWidth, GUILayout.Width(60f));

                ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Height (px)"));
                this.tileHeight = EditorGUILayout.IntField(this.tileHeight, GUILayout.Width(60f));

                GUILayout.Space(10f);

                this.alpha      = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Alpha Blending"), this.alpha);
                this.procedural = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Procedural"), this.procedural);
            }
            GUILayout.EndVertical();
        }
        public void OnGUI()
        {
            GUILayout.Space(10);

            string assetPath = Path.GetDirectoryName(this.tilesetRecord.AssetPath) + "/";

            ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Asset Path:"), RotorzEditorStyles.Instance.BoldLabel);
            EditorGUILayout.SelectableLabel(assetPath, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
            string buttonTextShowInOS = TileLang.OpensWindow(
                Application.platform == RuntimePlatform.OSXEditor
                    ? TileLang.ParticularText("Action", "Show In Finder")
                    : TileLang.ParticularText("Action", "Show In Explorer"));

            if (GUILayout.Button(buttonTextShowInOS, RotorzEditorStyles.Instance.ButtonWide))
            {
                EditorUtility.OpenWithDefaultApp(assetPath);
                GUIUtility.ExitGUI();
            }

            var atlasTexture = this.tileset.AtlasTexture;

            if (atlasTexture == null)
            {
                GUILayout.Space(10);
                GUILayout.Label(TileLang.Text("Atlas texture is missing."));
                return;
            }

            if (atlasTexture.width != atlasTexture.height || !Mathf.IsPowerOfTwo(atlasTexture.width))
            {
                GUILayout.Space(3);
                EditorGUILayout.HelpBox(TileLang.Text("Atlas texture is not square and/or not a power of two size. This can lead to poor quality results."), MessageType.Warning, true);
                GUILayout.Space(3);
            }
            else
            {
                GUILayout.Space(5);
            }

            this.DrawAtlasTexture();
        }
Exemplo n.º 12
0
        private void DrawAtlasParametersGUI()
        {
            EditorGUIUtility.fieldWidth = 105f;

            GUILayout.BeginVertical();
            {
                EditorGUI.BeginChangeCheck();
                {
                    ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Width (px)"));
                    this.tileWidth = EditorGUILayout.IntField(this.tileWidth, GUILayout.Width(60f));
                    ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Tile Height (px)"));
                    this.tileHeight = EditorGUILayout.IntField(this.tileHeight, GUILayout.Width(60f));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    this.clearPreviews = true;
                }

                GUILayout.Space(10f);

                using (var content = ControlContent.Basic(
                           TileLang.ParticularText("Property", "Alpha Blending")
                           )) {
                    this.enableAlphaBlending = EditorGUILayout.ToggleLeft(content, this.enableAlphaBlending);
                }

                if (s_SelectedAutotileLayout == AutotileLayout.Extended && s_BorderSize > 0)
                {
                    using (var content = ControlContent.Basic(
                               TileLang.ParticularText("Property", "Clamp Edges"),
                               TileLang.Text("Indicates if outer edges should always be clamped. Often not appropriate when secondary tile acts as ground.")
                               )) {
                        s_EnableClampEdges = EditorGUILayout.ToggleLeft(content, s_EnableClampEdges);
                    }
                }
            }
            GUILayout.EndVertical();
        }
        /// <inheritdoc/>
        public override void OnGUI()
        {
            // Permit shortcut key "F3".
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.F3)
            {
                Event.current.Use();
                this.ShowTargetBrushInDesigner();
                GUIUtility.ExitGUI();
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.BeginHorizontal(GUILayout.Width(114));
                {
                    // Draw preview.
                    string tooltipText = !this.isTargetMasterBrush ? TileLang.Text("Double-click to edit target...") : "";
                    using (var content = ControlContent.Basic("", tooltipText)) {
                        GUILayout.Box(content, GUILayout.Width(114), GUILayout.Height(114));
                        Rect previewRect = GUILayoutUtility.GetLastRect();
                        previewRect.x      += 2;
                        previewRect.y      += 2;
                        previewRect.width  -= 4;
                        previewRect.height -= 4;
                        RotorzEditorGUI.DrawBrushPreview(previewRect, this.AliasBrush.target);

                        // Select target brush for editing upon double-clicking
                        Event e = Event.current;
                        if (e.isMouse && e.clickCount == 2 && previewRect.Contains(e.mousePosition) && !this.isTargetMasterBrush)
                        {
                            this.ShowTargetBrushInDesigner();
                            GUIUtility.ExitGUI();
                        }
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(10);

                GUILayout.BeginVertical();
                {
                    GUILayout.Space(15);

                    ExtraEditorGUI.AbovePrefixLabel(TileLang.ParticularText("Property", "Alias Target:"), RotorzEditorStyles.Instance.BoldLabel);

                    Brush newAliasTarget = RotorzEditorGUI.BrushField(this.AliasBrush.target, false);
                    if (newAliasTarget != this.AliasBrush.target)
                    {
                        this.SetAliasTarget(newAliasTarget);
                    }

                    GUILayout.Space(5);

                    EditorGUI.BeginDisabledGroup(this.AliasBrush.target == null);
                    if (GUILayout.Button(TileLang.ParticularText("Action", "Revert To Target"), RotorzEditorStyles.Instance.ButtonWide))
                    {
                        if (EditorUtility.DisplayDialog(
                                TileLang.ParticularText("Dialog Title", "Confirmation"),
                                TileLang.Text("Revert properties of alias brush to target brush?"),
                                TileLang.ParticularText("Action", "Yes"),
                                TileLang.ParticularText("Action", "No")
                                ))
                        {
                            Undo.RecordObject(this.Brush, TileLang.ParticularText("Action", "Revert To Target"));
                            GUIUtility.keyboardControl = 0;
                            this.AliasBrush.RevertToTarget();
                        }
                        GUIUtility.ExitGUI();
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            // Do not display material mapper for 'tileset' targets.
            if (!(this.AliasBrush.target is TilesetBrush))
            {
                this.Section_MaterialMapper();
            }
        }