コード例 #1
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void CreateNewBitmapFont(string _path, string _name, Object _fontInfo)
    {
        try {
            // create atlas info
            EditorUtility.DisplayProgressBar("Creating BitmapFont...",
                                             "Creating BitmapFont Asset...",
                                             0.1f);

            // check if there have
            exBitmapFont bitmapFont = exBitmapFontUtility.Create(_path, _name);

            // check if we have the texture and textasset with the same name of bitmapfont
            EditorUtility.DisplayProgressBar("Creating BitmapFont...",
                                             "Check building ...",
                                             0.2f);

            // if we have enough information, try to build the exBitmapFont asset
            bitmapFont.Build(_fontInfo);
            EditorUtility.ClearProgressBar();

            //
            Selection.activeObject = bitmapFont;
            EditorGUIUtility.PingObject(bitmapFont);
        }
        catch (System.Exception) {
            EditorUtility.ClearProgressBar();
            throw;
        }
    }
コード例 #2
0
    // ------------------------------------------------------------------
    // Desc:
    // ------------------------------------------------------------------

    void OnGUI()
    {
        EditorGUI.indentLevel = 0;

        if (curEdit == null)
        {
            GUILayout.Space(10);
            GUILayout.Label("Please select an BitmapFont asset");
            return;
        }

        // ========================================================
        // toolbar
        // ========================================================

        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        GUILayout.FlexibleSpace();

        // ========================================================
        // Build
        // ========================================================

        GUI.enabled = curEdit.editorNeedRebuild;
        if (GUILayout.Button("Build", EditorStyles.toolbarButton, GUILayout.Width(80)))
        {
            curEdit.Build(curFontInfo);
        }
        GUI.enabled = true;

        // ========================================================
        // Help
        // ========================================================

        if (GUILayout.Button(exEditorHelper.HelpTexture(), EditorStyles.toolbarButton))
        {
            Help.BrowseURL("http://www.ex-dev.com/ex2d/wiki/doku.php?id=manual:font_editor");
        }
        GUILayout.EndHorizontal();

        GUILayout.Space(5);

        // ========================================================
        // if we have curEdit
        // ========================================================

        scrollPos = EditorGUILayout.BeginScrollView(scrollPos,
                                                    GUILayout.Width(position.width),
                                                    GUILayout.Height(position.height));


        // ========================================================
        // font info
        // ========================================================

        Object newFontInfo = EditorGUILayout.ObjectField("Font Info"
                                                         , curFontInfo
                                                         , typeof(Object)
                                                         , false
                                                         , GUILayout.Width(300)
                                                         );

        if (newFontInfo != curFontInfo)
        {
            curFontInfo = newFontInfo;
            curEdit.editorNeedRebuild = true;
        }

        // ========================================================
        // page info
        // ========================================================

        GUI.enabled = false;
        foreach (exBitmapFont.PageInfo pi in curEdit.pageInfos)
        {
            EditorGUILayout.ObjectField(pi.texture.name
                                        , pi.texture
                                        , typeof(Texture2D)
                                        , false
                                        , GUILayout.Width(50)
                                        , GUILayout.Height(50)
                                        );
        }
        GUI.enabled = true;

        EditorGUILayout.EndScrollView();
    }