コード例 #1
0
        void DrawGlyphGUI()
        {
            EditorGUI.indentLevel++;
            {
                selectedGlyphs_ = (SelectedGlyphs)EditorGUILayout.EnumPopup("Characters", selectedGlyphs_);

                if (selectedGlyphs_ == SelectedGlyphs.Custom)
                {
                    EditorGUI.indentLevel++;
                    {
                        customString_ = EditorGUILayout.TextField("Custom Characters", customString_);
                    }
                    EditorGUI.indentLevel--;
                }

                glyphDimensions_.x = EditorGUILayout.IntField("Glyph Width", glyphDimensions_.x);
                glyphDimensions_.y = EditorGUILayout.IntField("Glyph Height", glyphDimensions_.y);
                string tooltip =
                    "Vertical offset applied to each glyph on the tilesheet. May need slight tweaking from font to font.";
                var vertOffsetContent = new GUIContent(
                    "Vertical Offset", tooltip);
                verticalOffset_ = EditorGUILayout.IntField(vertOffsetContent, verticalOffset_);

                EditorGUILayout.LabelField("Unsupported Glyph Handling", EditorStyles.boldLabel);
                EditorGUI.indentLevel++;
                {
                    if (font_.dynamic)
                    {
                        {
                            EditorGUILayout.LabelField("Font is currently set to dynamic. For dynamic fonts Unity doesn't provide" +
                                                       " a way to distinguis unsupported characters - they will automatically be replaced with fallback characters." +
                                                       " For unsupported glyph handling you must set the font asset to unicode in the project view.",
                                                       EditorStyles.wordWrappedLabel);
                        }
                    }
                    else
                    {
                        unsupportedGlyphHandling_ =
                            (UnsupportedGlyphHandling)EditorGUILayout.EnumPopup(unsupportedGlyphHandling_);

                        if (unsupportedGlyphHandling_ == UnsupportedGlyphHandling.Fallback)
                        {
                            fallbackFont_ = (Font)EditorGUILayout.ObjectField("Fallback Font", fallbackFont_, typeof(Font), false);

                            if (fallbackFont_ != null)
                            {
                                if (fallbackFont_.dynamic)
                                {
                                    fallbackFontSize_ = EditorGUILayout.IntField("Fallback Font Size", fallbackFontSize_);
                                }
                                fallbackVerticalOffset_ = EditorGUILayout.IntField("Fallback Vertical Offset", fallbackVerticalOffset_);
                            }
                        }
                    }
                }
                EditorGUI.indentLevel--;
            }
            EditorGUI.indentLevel--;
        }
コード例 #2
0
        public void ImportGlyphData()
        {
            string path = dialogService.GetFileOpenPath("Import Glyph from Image", "Image Files|*.bmp;*.jpg;*.png;*.gif|Icon Files|*.ico|Meta Files|*.wmf;*.emf");

            if (path == null)
            {
                return;
            }

            Glyph first = SelectedGlyphs.FirstOrDefault();

            if (first == null)
            {
                dialogService.ShowError("Import Error", "You must have a glyph selected before you can import!", null);
                return;
            }

            string import = first.ImportImage(path);

            if (import != null)
            {
                dialogService.ShowError("Import Error", import, null);
            }
        }