示例#1
0
    public static DebugText Create()
    {
        Canvas canvas = FindObjectOfType <Canvas>();

        if (canvas == null)
        {
            Debug.Log("Creating a Canvas object in the Scene for DebugText.");
            canvas = ExhibitBase.CreateCanvas(1920, 1080);
        }

        GameObject textGO = new GameObject();

        RectTransform textTransfrom = textGO.AddComponent <RectTransform>();

        textTransfrom.anchorMin = Vector2.zero;
        textTransfrom.anchorMax = Vector2.one;
        textTransfrom.pivot     = new Vector2(0.5f, 0.5f);
        textTransfrom.offsetMin = Vector2.zero;
        textTransfrom.offsetMax = new Vector2(canvas.pixelRect.width, canvas.pixelRect.height);

        DebugText dt = textGO.AddComponent <DebugText>();

        textGO.name = "Debug Text";
        textTransfrom.SetParent(canvas.gameObject.transform);

        dt.textElement = textGO.AddComponent <Text>();

        dt.SetFont(dt.fontType);
        dt.SetColor(dt.fontColor);
        dt.SetFontSize(dt.fontSize);
        dt.textElement.raycastTarget = false;

        return(dt);
    }
示例#2
0
    public static void LogColor(Color textColor)
    {
        DebugText debugText = DebugText.instance;

        if (debugText == null)
        {
            debugText = DebugText.Create();
        }

        debugText.SetColor(textColor);
    }