Beispiel #1
0
    private GameObject CreateText(string txt, FontId fontId, float size, Vector3 newPosition, TextAnchor newAchor)
    {
        // A custom method that creates a gameobject based on the fontPrefab and write the string in it
        FontOptions fontOptions = UFE.GetFont(fontId);

        if (fontOptions.fontPrefab == null)
        {
            Debug.LogError("Font prefab not found! Make sure you have all font prefabs set in the Global Editor");
        }
        GameObject guiTextGO = (GameObject)Instantiate(fontOptions.fontPrefab, newPosition, Quaternion.identity);

        guiTextGO.guiText.anchor        = newAchor;
        guiTextGO.guiText.text          = txt;
        guiTextGO.transform.localScale *= size;

        return(guiTextGO);
    }