Esempio n. 1
0
    private void OnGUI()
    {
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("选择默认字体");
        EditorGUILayout.Space();
//        EditorGUILayout.ObjectField(m_font, typeof (Font), false);

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField($"默认字体路径:{m_fontPath}");

        EditorGUILayout.Space();
        if (GUILayout.Button("选择默认字体"))
        {
            SelectFontFile();
        }
        EditorGUILayout.Space();
        if (GUILayout.Button("保存"))
        {
            ToolCacheManager.SaveFont(m_fontPath);
            window.Close();
            if (m_doneAction != null)
            {
                m_doneAction();
            }
        }
    }
Esempio n. 2
0
    static void CreatText()
    {
        if (Selection.activeTransform)
        {
            if (Selection.activeTransform.GetComponentInParent <Canvas>())
            {
                GameObject go = new GameObject("Text", typeof(Text));
                go.transform.SetParent(Selection.activeTransform);

                Text text = go.GetComponent <Text>();
                text.raycastTarget = false;
                text.text          = "New Text";
                text.color         = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                Rect rect = text.rectTransform.rect;
                text.rectTransform.sizeDelta = new Vector2(100, 30);
                go.transform.localPosition   = Vector3.zero;
                go.transform.localRotation   = Quaternion.Euler(0, 0, 0);
                go.transform.localScale      = Vector3.one;
                go.layer = LayerMask.NameToLayer("UI");

                Font font = ToolCacheManager.GetFont();
                text.font = font;

                Selection.activeGameObject = go;
            }
        }
    }
Esempio n. 3
0
 public static void OpenWindow(Action aciton = null)
 {
     window         = GetWindow(typeof(SetDefaultFont));
     window.minSize = new Vector2(500, 300);
     m_fontPath     = ToolCacheManager.GetFontPath();
     m_font         = ToolCacheManager.GetFont();
     m_doneAction   = aciton;
 }
Esempio n. 4
0
 private static void ChangeDefaultFont()
 {
     if (Selection.activeGameObject != null)
     {
         Text text = Selection.activeGameObject.GetComponent <Text>();
         if (text != null)
         {
             text.font = ToolCacheManager.GetFont();
         }
     }
 }
Esempio n. 5
0
 private void OnGUI()
 {
     EditorGUILayout.Space();
     EditorGUILayout.LabelField("选择默认字体");
     EditorGUILayout.Space();
     m_font = (Font)EditorGUILayout.ObjectField(m_font, typeof(Font), true);
     EditorGUILayout.Space();
     if (GUILayout.Button("确定"))
     {
         ToolCacheManager.SaveFont(m_font);
         window.Close();
     }
 }
Esempio n. 6
0
 public static void OpenWindow()
 {
     window         = GetWindow(typeof(SetDefaultFont));
     window.minSize = new Vector2(500, 300);
     m_font         = ToolCacheManager.GetFont();
 }