Exemple #1
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;
            }
        }
    }
Exemple #2
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;
 }
Exemple #3
0
 private static void ChangeDefaultFont()
 {
     if (Selection.activeGameObject != null)
     {
         Text text = Selection.activeGameObject.GetComponent <Text>();
         if (text != null)
         {
             text.font = ToolCacheManager.GetFont();
         }
     }
 }
Exemple #4
0
 public static void OpenWindow()
 {
     window         = GetWindow(typeof(SetDefaultFont));
     window.minSize = new Vector2(500, 300);
     m_font         = ToolCacheManager.GetFont();
 }