예제 #1
0
    public void CreateText(Breakable obstacle, bool notVisible)
    {
        GameObject go = new GameObject(obstacle.name + " Text");

        go.transform.SetParent(this.transform);

        go.AddComponent(typeof(Text));
        go.GetComponent <Text>().text      = obstacle.GetBreakCount().ToString();
        go.GetComponent <Text>().font      = font;
        go.GetComponent <Text>().fontSize  = 50;
        go.GetComponent <Text>().alignment = TextAnchor.MiddleCenter;
        go.GetComponent <Text>().fontStyle = FontStyle.Bold;

        go.GetComponent <RectTransform>().localScale = Vector3.one;

        go.transform.rotation = obstacle.gameObject.transform.rotation;

        go.AddComponent(typeof(Canvas));
        go.GetComponent <Canvas>().overrideSorting  = true;
        go.GetComponent <Canvas>().sortingLayerName = "Text";
        if (notVisible)
        {
            go.transform.localScale = Vector3.zero;
        }
        breakables.Add(obstacle);
        texts.Add(go);
    }