Guest User

Untitled

a guest
Nov 16th, 2017
8
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. public Font trajanBold;
  2. public Font trajanNormal
  3. public void stuff(){
  4.     foreach (Font f in Resources.FindObjectsOfTypeAll<UnityEngine.Font>())
  5.     {
  6.         if (f != null && f.name == "TrajanPro-Bold") trajanBold = f;
  7.         if (f != null && f.name == "TrajanPro-Regular") trajanNormal = f;
  8.     }
  9.     GameObject c = new GameObject();
  10.     c.AddComponent<Canvas>().renderMode = renderMode;
  11.     CanvasScaler cs = c.AddComponent<CanvasScaler>();
  12.     cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
  13.     cs.referenceResolution = new Vector2(1920,1080);
  14.     c.AddComponent<GraphicRaycaster>();
  15.     GameObject panel = new GameObject();
  16.     panel.transform.parent = c.transform;
  17.     panel.AddComponent<CanvasRenderer>();
  18.  
  19.     RectTransform rt = panel.AddComponent<RectTransform>();
  20.     rt.anchorMax =  new Vector2(1, 0);
  21.     rt.anchorMin = new Vector2(0, 0);
  22.     rt.pivot = new Vector2(0.5f, 0.5f);
  23.     rt.sizeDelta = new Vector2(0, 50);
  24.     rt.anchoredPosition = new Vector2(0, 25);
  25.  
  26.     Text textObj = panel.AddComponent<Text>();
  27.     textObj.font = trajanBold;
  28.     textObj.text = "subtitles";
  29.     textObj.fontSize = 24;
  30.     textObj.alignment = TextAnchor.MiddleCenter;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment