Beispiel #1
0
        public static UIConsole CreateGUI()
        {
            var go     = new GameObject("UI CONSOLE");
            var canvas = go.AddComponent <Canvas>();
            var textgo = new GameObject("CONSOLE TEXT");

            textgo.transform.parent = go.transform;
            uitext = textgo.AddComponent <Text>();

            canvas.renderMode         = RenderMode.ScreenSpaceOverlay;
            uitext.font               = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            uitext.verticalOverflow   = VerticalWrapMode.Overflow;
            uitext.horizontalOverflow = HorizontalWrapMode.Overflow;
            uitext.alignment          = TextAnchor.UpperCenter;
            //uitext.rectTransform.anchoredPosition = new Vector2(-Screen.width / 2, Screen.height / 2);
            //uitext.rectTransform.offsetMin = new Vector2(Screen.width / 2, -Screen.height / 2);
            uitext.rectTransform.pivot     = new Vector2(0, 0);
            uitext.rectTransform.anchorMin = new Vector2(0, 0);
            uitext.rectTransform.anchorMax = new Vector2(1, 1);
            uitext.rectTransform.offsetMax = new Vector2(0, 0);
            //uitext.rectTransform.anchorMax = new Vector2(1, 1);
            //uitext.rectTransform.anchorMax = new Vector2(Screen.width / 2, Screen.height / 2);


            single = textgo.AddComponent <UIConsole>();
            return(single);
        }
Beispiel #2
0
 // Start is called before the first frame update
 void Awake()
 {
     single      = this;
     uitext      = GetComponent <Text>();
     uitext.text = strb.ToString();
 }