Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Font trajanBold;
- public Font trajanNormal
- public void stuff(){
- foreach (Font f in Resources.FindObjectsOfTypeAll<UnityEngine.Font>())
- {
- if (f != null && f.name == "TrajanPro-Bold") trajanBold = f;
- if (f != null && f.name == "TrajanPro-Regular") trajanNormal = f;
- }
- GameObject c = new GameObject();
- c.AddComponent<Canvas>().renderMode = renderMode;
- CanvasScaler cs = c.AddComponent<CanvasScaler>();
- cs.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
- cs.referenceResolution = new Vector2(1920,1080);
- c.AddComponent<GraphicRaycaster>();
- GameObject panel = new GameObject();
- panel.transform.parent = c.transform;
- panel.AddComponent<CanvasRenderer>();
- RectTransform rt = panel.AddComponent<RectTransform>();
- rt.anchorMax = new Vector2(1, 0);
- rt.anchorMin = new Vector2(0, 0);
- rt.pivot = new Vector2(0.5f, 0.5f);
- rt.sizeDelta = new Vector2(0, 50);
- rt.anchoredPosition = new Vector2(0, 25);
- Text textObj = panel.AddComponent<Text>();
- textObj.font = trajanBold;
- textObj.text = "subtitles";
- textObj.fontSize = 24;
- textObj.alignment = TextAnchor.MiddleCenter;
- }
Advertisement
Add Comment
Please, Sign In to add comment