Example #1
0
        private void DrawTextNative(MeshGenerationContextUtils.TextParams textParams, TextHandle handle, float pixelsPerPoint)
        {
            float scaling = TextHandle.ComputeTextScaling(this.currentElement.worldTransform, pixelsPerPoint);
            TextNativeSettings textNativeSettings = MeshGenerationContextUtils.TextParams.GetTextNativeSettings(textParams, scaling);

            using (NativeArray <UnityEngine.UIElements.TextVertex> vertices = TextNative.GetVertices(textNativeSettings))
            {
                bool flag = vertices.Length == 0;
                if (!flag)
                {
                    Vector2 offset = TextNative.GetOffset(textNativeSettings, textParams.rect);
                    this.m_CurrentEntry.isTextEntry      = true;
                    this.m_CurrentEntry.clipRectID       = this.m_ClipRectID;
                    this.m_CurrentEntry.isStencilClipped = this.m_StencilClip;
                    MeshBuilder.MakeText(vertices, offset, new MeshBuilder.AllocMeshData
                    {
                        alloc = this.m_AllocRawVertsIndicesDelegate
                    });
                    this.m_CurrentEntry.font = textParams.font.material.mainTexture;
                    this.m_Entries.Add(this.m_CurrentEntry);
                    this.totalVertices += this.m_CurrentEntry.vertices.Length;
                    this.totalIndices  += this.m_CurrentEntry.indices.Length;
                    this.m_CurrentEntry = default(UIRStylePainter.Entry);
                    this.currentElement.renderChainData.usesLegacyText = true;
                    this.currentElement.renderChainData.disableNudging = true;
                }
            }
        }
Example #2
0
        public void DrawText(MeshGenerationContextUtils.TextParams textParams, TextHandle handle, float pixelsPerPoint)
        {
            bool flag = textParams.font == null;

            if (!flag)
            {
                bool flag2 = this.m_CurrentElement.panel.contextType == ContextType.Editor;
                if (flag2)
                {
                    textParams.fontColor *= textParams.playmodeTintColor;
                }
                float scaling = TextNative.ComputeTextScaling(this.m_CurrentElement.worldTransform, pixelsPerPoint);
                TextNativeSettings textNativeSettings = MeshGenerationContextUtils.TextParams.GetTextNativeSettings(textParams, scaling);
                using (NativeArray <TextVertex> vertices = TextNative.GetVertices(textNativeSettings))
                {
                    List <RenderChainTextEntry> arg_91_0 = this.m_CurrentElement.renderChainData.textEntries;
                    int textEntryIndex = this.m_TextEntryIndex;
                    this.m_TextEntryIndex = textEntryIndex + 1;
                    RenderChainTextEntry renderChainTextEntry = arg_91_0[textEntryIndex];
                    Vector2 offset = TextNative.GetOffset(textNativeSettings, textParams.rect);
                    MeshBuilder.UpdateText(vertices, offset, this.m_CurrentElement.renderChainData.verticesSpace, this.m_XFormClipPages, this.m_IDsFlags, this.m_OpacityPagesSettingsIndex, this.m_MeshDataVerts.Slice(renderChainTextEntry.firstVertex, renderChainTextEntry.vertexCount));
                    renderChainTextEntry.command.state.font = textParams.font.material.mainTexture;
                }
            }
        }