コード例 #1
0
        private void DrawCreatorSection()
        {
            GUILayout.Label(TileLang.Text("Brushes"), EditorStyles.boldLabel);
            {
                using (var content = ControlContent.Basic(
                           TileLang.ParticularText("Property", "Brushes Folder")
                           )) {
                    this.propertyBrushesFolderRelativePath.stringValue = RotorzEditorGUI.RelativeAssetPathTextField(content, this.propertyBrushesFolderRelativePath.stringValue, false);
                }

                GUILayout.Space(3);
                Rect totalButtonPosition = EditorGUI.IndentedRect(EditorGUILayout.GetControlRect(true, 20));

                Rect buttonPosition = totalButtonPosition;
                buttonPosition.x    += EditorGUIUtility.labelWidth;
                buttonPosition.width = (buttonPosition.width - EditorGUIUtility.labelWidth) / 2f - 2;

                if (GUI.Button(buttonPosition, TileLang.OpensWindow(TileLang.ParticularText("Action", "Browse"))))
                {
                    this.BrushesFolder_Browse_Clicked();
                }

                buttonPosition.x = buttonPosition.xMax + 4;
                if (GUI.Button(buttonPosition, TileLang.ParticularText("Action", "Reset")))
                {
                    this.BrushesFolder_Reset_Clicked();
                }
            }

            GUILayout.Label(TileLang.Text("Tilesets"), EditorStyles.boldLabel);
            {
                using (var content = ControlContent.Basic(
                           TileLang.ParticularText("Property", "Opaque Material Template")
                           )) {
                    EditorGUILayout.PropertyField(this.propertyOpaqueTilesetMaterialTemplate, content);
                }

                using (var content = ControlContent.Basic(
                           TileLang.ParticularText("Property", "Transparent Material Template")
                           )) {
                    EditorGUILayout.PropertyField(this.propertyTransparentTilesetMaterialTemplate, content);
                }

                RotorzEditorGUI.InfoBox(TileLang.Text("Default materials are created when no material templates are specified."));
            }
        }
コード例 #2
0
        private void OnSection_BuildOptions()
        {
            float initialLabelWidth = EditorGUIUtility.labelWidth;

            GUILayout.Space(3);

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Combine Method")
                       )) {
                EditorGUILayout.PropertyField(this.propertyCombineMethod, content);
            }

            if (!this.propertyCombineMethod.hasMultipleDifferentValues)
            {
                if ((BuildCombineMethod)this.propertyCombineMethod.intValue == BuildCombineMethod.CustomChunkInTiles)
                {
                    GUILayout.BeginHorizontal();
                    ++EditorGUI.indentLevel;
                    {
                        EditorGUIUtility.labelWidth = 65;

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

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

                        EditorGUIUtility.labelWidth = initialLabelWidth;
                    }
                    --EditorGUI.indentLevel;
                    GUILayout.EndHorizontal();
                }

                if ((BuildCombineMethod)this.propertyCombineMethod.intValue != BuildCombineMethod.None)
                {
                    ++EditorGUI.indentLevel;
                    {
                        this.propertyCombineIntoSubmeshes.boolValue = EditorGUILayout.ToggleLeft(TileLang.ParticularText("Property", "Combine into submeshes"), this.propertyCombineIntoSubmeshes.boolValue);
                        if (ControlContent.TrailingTipsVisible)
                        {
                            ExtraEditorGUI.TrailingTip(TileLang.Text("Determines whether to use submeshes, or an individual mesh for each material."));
                        }
                    }
                    --EditorGUI.indentLevel;

                    RotorzEditorGUI.InfoBox(TileLang.Text("Avoid generation of meshes with vertices in excess of 64k."), MessageType.Warning);
                }
            }

            EditorGUILayout.Space();

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Vertex Snap Threshold"),
                       TileLang.Text("Increase threshold to snap vertices that are more widely spread.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyVertexSnapThreshold, content);
                if (!this.propertyVertexSnapThreshold.hasMultipleDifferentValues)
                {
                    if (this.propertyVertexSnapThreshold.floatValue == 0f)
                    {
                        EditorGUILayout.HelpBox(TileLang.Text("No snapping occurs when threshold is 0."), MessageType.Warning, true);
                    }
                }
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Static Snapping"),
                       TileLang.Text("Applies vertex snapping to static tiles to avoid tiny gaps due to numerical inaccuracies. Vertex snapping is always applied to 'smooth' tiles.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyStaticVertexSnapping, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Generate Lightmap UVs")
                       )) {
                EditorGUILayout.PropertyField(this.propertyGenerateSecondUVs, content);
                if (this.propertyGenerateSecondUVs.boolValue)
                {
                    ++EditorGUI.indentLevel;

                    s_ToggleBuildOptions_AdvancedUV2 = EditorGUILayout.Foldout(s_ToggleBuildOptions_AdvancedUV2, TileLang.ParticularText("Section", "Advanced"));
                    if (s_ToggleBuildOptions_AdvancedUV2)
                    {
                        float hardAngle  = this.propertySecondUVsHardAngle.floatValue;
                        float packMargin = this.propertySecondUVsPackMargin.floatValue * 1024f;
                        float angleError = this.propertySecondUVsAngleError.floatValue * 100f;
                        float areaError  = this.propertySecondUVsAreaError.floatValue * 100f;

                        using (var content2 = ControlContent.WithTrailableTip(
                                   TileLang.ParticularText("Property", "Hard Angle"),
                                   TileLang.Text("Angle between neighbor triangles that will generate seam.")
                                   )) {
                            EditorGUI.BeginChangeCheck();
                            EditorGUI.showMixedValue = this.propertySecondUVsHardAngle.hasMultipleDifferentValues;
                            hardAngle = EditorGUILayout.Slider(content, hardAngle, 0f, 180f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                this.propertySecondUVsHardAngle.floatValue = Mathf.Ceil(hardAngle);
                            }
                            ExtraEditorGUI.TrailingTip(content2);
                        }

                        using (var content2 = ControlContent.WithTrailableTip(
                                   TileLang.ParticularText("Property", "Pack Margin"),
                                   TileLang.Text("Measured in pixels, assuming mesh will cover an entire 1024x1024 lightmap.")
                                   )) {
                            EditorGUI.BeginChangeCheck();
                            EditorGUI.showMixedValue = this.propertySecondUVsPackMargin.hasMultipleDifferentValues;
                            packMargin = EditorGUILayout.Slider(content, packMargin, 1f, 64f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                this.propertySecondUVsPackMargin.floatValue = Mathf.Ceil(packMargin) / 1024f;
                            }
                            ExtraEditorGUI.TrailingTip(content2);
                        }

                        using (var content2 = ControlContent.WithTrailableTip(
                                   TileLang.ParticularText("Property", "Angle Error"),
                                   TileLang.Text("Measured in percents. Angle error measures deviation of UV angles from geometry angles. Area error measure deviation of UV triangles area from geometry triangles if they were uniformly scaled.")
                                   )) {
                            EditorGUI.BeginChangeCheck();
                            EditorGUI.showMixedValue = this.propertySecondUVsAngleError.hasMultipleDifferentValues;
                            angleError = EditorGUILayout.Slider(content, angleError, 1f, 75f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                this.propertySecondUVsAngleError.floatValue = Mathf.Ceil(angleError) / 100f;
                            }
                            ExtraEditorGUI.TrailingTip(content2);
                        }

                        using (var content2 = ControlContent.Basic(
                                   TileLang.ParticularText("Property", "Area Error")
                                   )) {
                            EditorGUI.BeginChangeCheck();
                            EditorGUI.showMixedValue = this.propertySecondUVsAreaError.hasMultipleDifferentValues;
                            areaError = EditorGUILayout.Slider(content2, areaError, 1f, 75f);
                            if (EditorGUI.EndChangeCheck())
                            {
                                this.propertySecondUVsAreaError.floatValue = Mathf.Ceil(areaError) / 100f;
                            }
                        }

                        EditorGUI.showMixedValue = false;
                    }

                    --EditorGUI.indentLevel;
                }
            }

            using (var content = ControlContent.WithTrailableTip(
                       TileLang.ParticularText("Property", "Pre-generate Procedural"),
                       TileLang.Text("Increases size of scene but allows brushes to be stripped from builds.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyPregenerateProcedural, content);
                ExtraEditorGUI.TrailingTip(content);
            }

            RotorzEditorGUI.InfoBox(TileLang.Text("Stripping capabilities are reduced when procedural tiles are present but are not pre-generated since they are otherwise generated at runtime."), MessageType.Info);
            GUILayout.Space(5);

            using (var content = ControlContent.Basic(
                       TileLang.ParticularText("Property", "Reduce Box Colliders"),
                       TileLang.Text("Reduces count of box colliders by coalescing adjacent colliders.")
                       )) {
                EditorGUILayout.PropertyField(this.propertyReduceColliders, content);
            }
        }
コード例 #3
0
        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);
        }