Exemple #1
0
        /// <summary>
        /// Prepare the given font to render our characters and build our mesh.
        /// </summary>
        /// <param name="mesh">The FontAtlasMesh to build.</param>
        /// <param name="font">The font to use.</param>
        /// <param name="fontSize">The fontsize to set.</param>
        /// <param name="input">The input string.</param>
        /// <param name="mat">The material to use for this font.</param>
        /// <param name="verticalAdjust">Vertical offset.</param>
        void SetupFontAndMesh(FontAtlasMesh mesh, Font font, int fontSize, string input, Material mat, int verticalAdjust)
        {
            font.RequestCharactersInTexture(input, fontSize);
            font.material.mainTexture.filterMode = FilterMode.Point;
            mat.mainTexture = font.material.mainTexture;
            mat.color       = textColor_;

            mesh.AddCharactersToMesh(input, font, fontSize, 16, glyphDimensions_, verticalAdjust);
        }
        void RebuildMesh()
        {
            if (string.IsNullOrEmpty(str_) || font_ == null)
            {
                Debug.Log("NullStr");
                return;
            }

            int columns = 16;

            mesh_.AddCharactersToMesh(str_, font_, fontSize_, columns, glyphSize_, verticalAdjust_);

            filter_.sharedMesh = mesh_.Mesh_;

            if (renderer_.sharedMaterial != null)
            {
                renderer_.sharedMaterial.mainTexture = font_.material.mainTexture;
            }
        }