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