示例#1
0
        [OvldGenCallTarget] public static void Text(Vector3 pos,
                                                    [OvldDefault("Quaternion.identity")] Quaternion rot,
                                                    string content,
                                                    [OvldDefault(nameof(Font))] TMP_FontAsset font,
                                                    [OvldDefault(nameof(FontSize))] float fontSize,
                                                    [OvldDefault(nameof(TextAlign))] TextAlign align,
                                                    [OvldDefault(nameof(Color))] Color color)
        {
            TextMeshPro tmp = ShapesTextDrawer.Instance.tmp;

            // Statics
            tmp.font     = font;
            tmp.color    = color;
            tmp.fontSize = fontSize;

            // Per-instance
            tmp.text                   = content;
            tmp.alignment              = align.GetTMPAlignment();
            tmp.rectTransform.pivot    = align.GetPivot();
            tmp.transform.position     = pos;
            tmp.rectTransform.rotation = rot;
            tmp.ForceMeshUpdate();

            // Actually draw
            font.material.SetPass(0);
            Matrix4x4 mtx = GetDrawingMatrix(tmp.transform.position, tmp.transform.rotation);

            for (int sm = 0; sm < tmp.mesh.subMeshCount; sm++)
            {
                Graphics.DrawMeshNow(tmp.mesh, mtx, sm);
            }
        }
示例#2
0
        [OvldGenCallTarget] static void Text_Internal(string content,
                                                      [OvldDefault(nameof(Font))] TMP_FontAsset font,
                                                      [OvldDefault(nameof(FontSize))] float fontSize,
                                                      [OvldDefault(nameof(TextAlign))] TextAlign align,
                                                      [OvldDefault(nameof(Color))] Color color)
        {
            TextMeshPro tmp = ShapesTextDrawer.Instance.tmp;

            // styling
            tmp.font             = font;
            tmp.color            = color;
            tmp.fontSize         = fontSize;
            tmp.fontStyle        = FontStyle;
            tmp.characterSpacing = TextCharacterSpacing;
            tmp.wordSpacing      = TextWordSpacing;
            tmp.lineSpacing      = TextLineSpacing;
            tmp.paragraphSpacing = TextParagraphSpacing;
            tmp.margin           = TextMargins;

            // content
            tmp.text = content;

            // positioning
            tmp.alignment              = align.GetTMPAlignment();
            tmp.rectTransform.pivot    = align.GetPivot();
            tmp.transform.position     = Matrix.GetColumn(3);
            tmp.rectTransform.rotation = Matrix.rotation;
            tmp.ForceMeshUpdate();

            using (new IMDrawer(mpbText, font.material, tmp.mesh, drawType: IMDrawer.DrawType.Text, allowInstancing: false)) {
                // will draw on dispose
            }
        }
示例#3
0
        [OvldGenCallTarget] static void Text_Internal(string content,
                                                      [OvldDefault(nameof(Font))] TMP_FontAsset font,
                                                      [OvldDefault(nameof(FontSize))] float fontSize,
                                                      [OvldDefault(nameof(TextAlign))] TextAlign align,
                                                      [OvldDefault(nameof(Color))] Color color)
        {
            TextMeshPro tmp = ShapesTextDrawer.Instance.tmp;

            // Statics
            tmp.font     = font;
            tmp.color    = color;
            tmp.fontSize = fontSize;

            // Per-instance
            tmp.text                   = content;
            tmp.alignment              = align.GetTMPAlignment();
            tmp.rectTransform.pivot    = align.GetPivot();
            tmp.transform.position     = Matrix.GetColumn(3);
            tmp.rectTransform.rotation = Matrix.rotation;
            tmp.ForceMeshUpdate();

            using (new IMDrawer(mpbText, font.material, tmp.mesh, cachedTMP: true)) {
                // will draw on dispose
            }
        }
示例#4
0
        [OvldGenCallTarget] static void Text_Internal(string content,
                                                      [OvldDefault(nameof(Font))] TMP_FontAsset font,
                                                      [OvldDefault(nameof(FontSize))] float fontSize,
                                                      [OvldDefault(nameof(TextAlign))] TextAlign align,
                                                      [OvldDefault(nameof(Color))] Color color)
        {
            TextMeshPro tmp = ShapesTextDrawer.Instance.tmp;

            // styling
            tmp.font             = font;
            tmp.color            = color;
            tmp.fontSize         = fontSize;
            tmp.fontStyle        = FontStyle;
            tmp.characterSpacing = TextCharacterSpacing;
            tmp.wordSpacing      = TextWordSpacing;
            tmp.lineSpacing      = TextLineSpacing;
            tmp.paragraphSpacing = TextParagraphSpacing;
            tmp.margin           = TextMargins;

            // content
            tmp.text = content;

            // positioning
            tmp.alignment              = align.GetTMPAlignment();
            tmp.rectTransform.pivot    = align.GetPivot();
            tmp.transform.position     = Matrix.GetColumn(3);
            tmp.rectTransform.rotation = Matrix.rotation;
            tmp.ForceMeshUpdate();

            using (new IMDrawer(mpbText, font.material, tmp.mesh, drawType: IMDrawer.DrawType.Text, allowInstancing: false)) {
                // will draw on dispose
            }

            // ;-;
            if (tmp.textInfo.materialCount > 1)
            {
                // we have fallback fonts so GreaT!! let's just draw everything because f**k me
                for (int i = 0; i < tmp.transform.childCount; i++)
                {
                    TMP_SubMesh sm = tmp.transform.GetChild(i).GetComponent <TMP_SubMesh>();
                    using (new IMDrawer(mpbText, sm.material, sm.mesh, drawType: IMDrawer.DrawType.Text, allowInstancing: false)) {
                        // will draw on dispose
                    }
                }
            }
        }