當前位置: 首頁>>代碼示例>>C#>>正文


C# Color32.CompareRGB方法代碼示例

本文整理匯總了C#中UnityEngine.Color32.CompareRGB方法的典型用法代碼示例。如果您正苦於以下問題:C# Color32.CompareRGB方法的具體用法?C# Color32.CompareRGB怎麽用?C# Color32.CompareRGB使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Color32的用法示例。


在下文中一共展示了Color32.CompareRGB方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateTextMesh


//.........這裏部分代碼省略.........
                        int index_X4 = m_visibleCharacterCount * 4;

                        //m_textInfo.characterInfo[m_characterCount].isVisible = true;
                        m_textInfo.characterInfo[m_characterCount].vertexIndex = (short)(0 + index_X4);

                        m_vertices[0 + index_X4] = m_textInfo.characterInfo[m_characterCount].bottomLeft;
                        m_vertices[1 + index_X4] = m_textInfo.characterInfo[m_characterCount].topLeft;
                        m_vertices[2 + index_X4] = m_textInfo.characterInfo[m_characterCount].bottomRight;
                        m_vertices[3 + index_X4] = m_textInfo.characterInfo[m_characterCount].topRight;


                        // Determine what color gets assigned to vertex.
                        #region Handle Vertex Colors
                        if (isMissingCharacter)
                            vertexColor = Color.red;
                        else if (m_overrideHtmlColors)
                            vertexColor = m_fontColor32;
                        else
                            vertexColor = m_htmlColor;


                        // Set Alpha to the lesser of vertex color or color tag alpha).
                        vertexColor.a = m_fontColor32.a < vertexColor.a ? m_fontColor32.a : vertexColor.a;

                        if (!m_enableVertexGradient)
                        {
                            m_vertColors[0 + index_X4] = vertexColor;
                            m_vertColors[1 + index_X4] = vertexColor;
                            m_vertColors[2 + index_X4] = vertexColor;
                            m_vertColors[3 + index_X4] = vertexColor;
                        }
                        else
                        {
                            if (!m_overrideHtmlColors && !m_htmlColor.CompareRGB(m_fontColor32))
                            {
                                m_vertColors[0 + index_X4] = vertexColor;
                                m_vertColors[1 + index_X4] = vertexColor;
                                m_vertColors[2 + index_X4] = vertexColor;
                                m_vertColors[3 + index_X4] = vertexColor;
                            }
                            else
                            {
                                m_vertColors[0 + index_X4] = m_fontColorGradient.bottomLeft;
                                m_vertColors[1 + index_X4] = m_fontColorGradient.topLeft;
                                m_vertColors[2 + index_X4] = m_fontColorGradient.bottomRight;
                                m_vertColors[3 + index_X4] = m_fontColorGradient.topRight;
                            }

                            m_vertColors[0 + index_X4].a = vertexColor.a;
                            m_vertColors[1 + index_X4].a = vertexColor.a;
                            m_vertColors[2 + index_X4].a = vertexColor.a;
                            m_vertColors[3 + index_X4].a = vertexColor.a;
                        }
                        #endregion Handle Vertex Colors


                        // Apply style_padding only if this is a SDF Shader.
                        if (!m_sharedMaterial.HasProperty(ShaderUtilities.ID_WeightNormal))
                            style_padding = 0;


                        // Setup UVs for the Mesh
                        #region Setup UVs
                        Vector2 uv0 = new Vector2((m_cached_GlyphInfo.x - m_padding - style_padding) / m_currentFontAsset.fontInfo.AtlasWidth, 1 - (m_cached_GlyphInfo.y + m_padding + style_padding + m_cached_GlyphInfo.height) / m_currentFontAsset.fontInfo.AtlasHeight);  // bottom left
                        Vector2 uv1 = new Vector2(uv0.x, 1 - (m_cached_GlyphInfo.y - m_padding - style_padding) / m_currentFontAsset.fontInfo.AtlasHeight);  // top left
                        Vector2 uv2 = new Vector2((m_cached_GlyphInfo.x + m_padding + style_padding + m_cached_GlyphInfo.width) / m_currentFontAsset.fontInfo.AtlasWidth, uv0.y); // bottom right
開發者ID:SamSeidenberg,項目名稱:HMI-Quiz,代碼行數:67,代碼來源:TMPro_Private.cs

示例2: GenerateTextMesh


//.........這裏部分代碼省略.........
                    }
                    #endregion End Check for Characters Exceeding Width of Text Container

                    // Determine what color gets assigned to vertex.
                    #region Handle Vertex Colors
                    if (isMissingCharacter)
                        vertexColor = Color.red;
                    else if (m_overrideHtmlColors)
                        vertexColor = m_fontColor32;
                    else
                        vertexColor = m_htmlColor;

                    // Set Alpha for Shader to render font as normal or bold. (Alpha channel is being used to let the shader know if the character is bold or normal).
                    if ((m_style & FontStyles.Bold) == FontStyles.Bold || (m_fontStyle & FontStyles.Bold) == FontStyles.Bold)
                    {
                        vertexColor.a = m_fontColor32.a < vertexColor.a ? (byte)(m_fontColor32.a >> 1) : (byte)(vertexColor.a >> 1);
                        vertexColor.a += 128;
                    }
                    else
                    {
                        vertexColor.a = m_fontColor32.a < vertexColor.a ? (byte)(m_fontColor32.a >> 1) : (byte)(vertexColor.a >> 1);
                    }

                    // Vertex Colors
                    if (!m_enableVertexGradient)
                    {
                        m_uiVertices[0 + index_X4].color = vertexColor;
                        m_uiVertices[1 + index_X4].color = vertexColor;
                        m_uiVertices[2 + index_X4].color = vertexColor;
                        m_uiVertices[3 + index_X4].color = vertexColor;
                    }
                    else
                    {
                        if (!m_overrideHtmlColors && !m_htmlColor.CompareRGB(m_fontColor32))
                        {
                            m_uiVertices[0 + index_X4].color = vertexColor;
                            m_uiVertices[1 + index_X4].color = vertexColor;
                            m_uiVertices[2 + index_X4].color = vertexColor;
                            m_uiVertices[3 + index_X4].color = vertexColor;
                        }
                        else
                        {
                            m_uiVertices[0 + index_X4].color = m_fontColorGradient.bottomLeft;
                            m_uiVertices[1 + index_X4].color = m_fontColorGradient.topLeft;
                            m_uiVertices[2 + index_X4].color = m_fontColorGradient.topRight;
                            m_uiVertices[3 + index_X4].color = m_fontColorGradient.bottomRight;
                        }

                        m_uiVertices[0 + index_X4].color.a = vertexColor.a;
                        m_uiVertices[1 + index_X4].color.a = vertexColor.a;
                        m_uiVertices[2 + index_X4].color.a = vertexColor.a;
                        m_uiVertices[3 + index_X4].color.a = vertexColor.a;
                    }
                    #endregion Handle Vertex Colors

                    // Apply style_padding only if this is a SDF Shader.
                    if (!m_sharedMaterial.HasProperty(ShaderUtilities.ID_WeightNormal))
                        style_padding = 0;

                    // Setup UVs for the Mesh
                    #region Setup UVs
                    Vector2 uv0 = new Vector2((m_cached_GlyphInfo.x - m_padding - style_padding) / m_fontAssetArray[m_fontIndex].fontInfo.AtlasWidth, 1 - (m_cached_GlyphInfo.y + m_padding + style_padding + m_cached_GlyphInfo.height) / m_fontAssetArray[m_fontIndex].fontInfo.AtlasHeight);  // bottom left
                    Vector2 uv1 = new Vector2(uv0.x, 1 - (m_cached_GlyphInfo.y - m_padding - style_padding) / m_fontAssetArray[m_fontIndex].fontInfo.AtlasHeight);  // top left
                    Vector2 uv2 = new Vector2((m_cached_GlyphInfo.x + m_padding + style_padding + m_cached_GlyphInfo.width) / m_fontAssetArray[m_fontIndex].fontInfo.AtlasWidth, uv0.y); // bottom right
                    Vector2 uv3 = new Vector2(uv2.x, uv1.y); // top right
開發者ID:marmmotreto,項目名稱:UnityTestRepository,代碼行數:66,代碼來源:TMPro_UGUI_Private.cs


注:本文中的UnityEngine.Color32.CompareRGB方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。