コード例 #1
0
        public void Start()
        {
            foreach (string font in OSFonts)
            {
                _font = Font.CreateDynamicFontFromOSFont(font, 12);

                // Found a monospace OS font.
                if (_font != null)
                {
                    break;
                }

                Logger.APILogger.Log($"Font {font} not found.");
            }

            // Fallback
            if (_font == null)
            {
                _font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            }

            DontDestroyOnLoad(gameObject);

            if (_overlayCanvas != null)
            {
                return;
            }

            CanvasUtil.CreateFonts();

            _overlayCanvas      = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
            _overlayCanvas.name = "ModdingApiConsoleLog";

            DontDestroyOnLoad(_overlayCanvas);

            GameObject background = CanvasUtil.CreateImagePanel
                                    (
                _overlayCanvas,
                CanvasUtil.NullSprite(new byte[] { 0x80, 0x00, 0x00, 0x00 }),
                new CanvasUtil.RectData(new Vector2(500, 800), Vector2.zero, Vector2.zero, Vector2.zero, Vector2.zero)
                                    );

            _textPanel = CanvasUtil.CreateTextPanel
                         (
                background,
                string.Join(string.Empty, _messages.ToArray()),
                12,
                TextAnchor.LowerLeft,
                new CanvasUtil.RectData(new Vector2(-5, -5), Vector2.zero, Vector2.zero, Vector2.one),
                _font
                         );

            _textPanel.GetComponent <Text>().horizontalOverflow = HorizontalWrapMode.Wrap;
        }
コード例 #2
0
        public void Start()
        {
            Arial = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            DontDestroyOnLoad(gameObject);

            if (OverlayCanvas == null)
            {
                CanvasUtil.CreateFonts();
                OverlayCanvas      = CanvasUtil.CreateCanvas(RenderMode.ScreenSpaceOverlay, new Vector2(1920, 1080));
                OverlayCanvas.name = "ModdingApiConsoleLog";
                DontDestroyOnLoad(OverlayCanvas);

                GameObject background = CanvasUtil.CreateImagePanel(OverlayCanvas,
                                                                    CanvasUtil.NullSprite(new byte[] { 0x80, 0x00, 0x00, 0x00 }),
                                                                    new CanvasUtil.RectData(new Vector2(500, 800), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0)));

                _textPanel = CanvasUtil.CreateTextPanel(background, string.Join(string.Empty, _messages.ToArray()), 12, TextAnchor.LowerLeft,
                                                        new CanvasUtil.RectData(new Vector2(-5, -5), new Vector2(0, 0), new Vector2(0, 0), new Vector2(1, 1)), Arial);

                _textPanel.GetComponent <Text>().horizontalOverflow = HorizontalWrapMode.Wrap;
            }
        }