//
		// Methods
		//
		public override void ModifyMesh (Mesh mesh)
		{
			if (!this.IsActive ())
			{
				return;
			}

            List<UIVertex> verts = new List<UIVertex>();
            using (var helper = new VertexHelper(mesh))
            {
                helper.GetUIVertexStream(verts);
            }

            Text foundtext = GetComponent<Text>();

			float best_fit_adjustment = 1f;

			if (foundtext && foundtext.resizeTextForBestFit)  
			{
				best_fit_adjustment = (float)foundtext.cachedTextGenerator.fontSizeUsedForBestFit / (foundtext.resizeTextMaxSize-1); //max size seems to be exclusive 
			}
			
			int start = 0;
			int count = verts.Count;
			base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment);
			start = count;
			count = verts.Count;
			base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment);
			start = count;
			count = verts.Count;
			base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, base.effectDistance.y*best_fit_adjustment);
			start = count;
			count = verts.Count;
			base.ApplyShadowZeroAlloc(verts, base.effectColor, start, verts.Count, -base.effectDistance.x*best_fit_adjustment, -base.effectDistance.y*best_fit_adjustment);

            using (var helper = new VertexHelper())
            {
                helper.AddUIVertexTriangleStream(verts);
                helper.FillMesh(mesh);
            }
        }
Beispiel #2
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (! IsActive()) return;

            List<UIVertex> verts = new List<UIVertex>();
            vh.GetUIVertexStream(verts);

            Text text = GetComponent<Text>();
			if (text == null)
			{
				Debug.LogWarning("LetterSpacing: Missing Text component");
				return;
			}
			
			string[] lines = text.text.Split('\n');
			Vector3  pos;
			float    letterOffset    = spacing * (float)text.fontSize / 100f;
			float    alignmentFactor = 0;
			int      glyphIdx        = 0;
			
			switch (text.alignment)
			{
			case TextAnchor.LowerLeft:
			case TextAnchor.MiddleLeft:
			case TextAnchor.UpperLeft:
				alignmentFactor = 0f;
				break;
				
			case TextAnchor.LowerCenter:
			case TextAnchor.MiddleCenter:
			case TextAnchor.UpperCenter:
				alignmentFactor = 0.5f;
				break;
				
			case TextAnchor.LowerRight:
			case TextAnchor.MiddleRight:
			case TextAnchor.UpperRight:
				alignmentFactor = 1f;
				break;
			}
			
			for (int lineIdx=0; lineIdx < lines.Length; lineIdx++)
			{
				string line = lines[lineIdx];
				float lineOffset = (line.Length -1) * letterOffset * alignmentFactor;

				for (int charIdx = 0; charIdx < line.Length; charIdx++)
				{
					int idx1 = glyphIdx * 6 + 0;
					int idx2 = glyphIdx * 6 + 1;
					int idx3 = glyphIdx * 6 + 2;
					int idx4 = glyphIdx * 6 + 3;
                    int idx5 = glyphIdx * 6 + 4;
                    int idx6 = glyphIdx * 6 + 5;

                    // Check for truncated text (doesn't generate verts for all characters)
                    if (idx6 > verts.Count - 1) return;

                    UIVertex vert1 = verts[idx1];
                    UIVertex vert2 = verts[idx2];
                    UIVertex vert3 = verts[idx3];
                    UIVertex vert4 = verts[idx4];
                    UIVertex vert5 = verts[idx5];
                    UIVertex vert6 = verts[idx6];

                    pos = Vector3.right * (letterOffset * charIdx - lineOffset);

                    vert1.position += pos;
                    vert2.position += pos;
                    vert3.position += pos;
                    vert4.position += pos;
                    vert5.position += pos;
                    vert6.position += pos;

                    verts[idx1] = vert1;
					verts[idx2] = vert2;
					verts[idx3] = vert3;
					verts[idx4] = vert4;
                    verts[idx5] = vert5;
                    verts[idx6] = vert6;

                    glyphIdx++;
				}
				
				// Offset for carriage return character that still generates verts
				glyphIdx++;
			}
            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
        }
Beispiel #3
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }

        vh.GetUIVertexStream(m_Verts);

        if (m_Verts.Count == 0)
        {
            return;
        }

        Vector2 topLeftPos     = Vector2.zero;
        Vector2 bottomRightPos = Vector2.zero;

        if (m_CurveMode == CurveMode.FullRect)
        {
            Rect rect = GetComponent <RectTransform>().rect;
            topLeftPos     = new Vector2(rect.xMin, rect.yMax);
            bottomRightPos = new Vector2(rect.xMax, rect.yMin);
        }
        else
        {
            topLeftPos     = m_Verts[0].position;
            bottomRightPos = m_Verts[m_Verts.Count - 1].position;

            for (int i = 0; i < m_Verts.Count; i++)
            {
                if (m_Verts[i].position.x < topLeftPos.x)
                {
                    topLeftPos.x = m_Verts[i].position.x;
                }
                if (m_Verts[i].position.y > topLeftPos.y)
                {
                    topLeftPos.y = m_Verts[i].position.y;
                }

                if (m_Verts[i].position.x > bottomRightPos.x)
                {
                    bottomRightPos.x = m_Verts[i].position.x;
                }
                if (m_Verts[i].position.y < bottomRightPos.y)
                {
                    bottomRightPos.y = m_Verts[i].position.y;
                }
            }
        }

        float overallWidth = bottomRightPos.x - topLeftPos.x;

        for (int index = 0; index < m_Verts.Count; index++)
        {
            UIVertex vert = m_Verts[index];
            vert.position.y += curve.Evaluate((vert.position.x - topLeftPos.x) / overallWidth) * strength;
            m_Verts[index]   = vert;
        }

        vh.Clear();
        vh.AddUIVertexTriangleStream(m_Verts);
    }
Beispiel #4
0
        public override void ModifyMesh(VertexHelper vh)
        {
            var sprite = m_image.overrideSprite;

            if (sprite == null)
            {
                return;
            }

            if (!m_image.hasBorder)
            {
                return;
            }

            var verts = ListPool <UIVertex> .Get();

            var newVert = ListPool <UIVertex> .Get();

            vh.GetUIVertexStream(verts);
            var shapeCount = verts.Count / vertexCountInOneShape;

            if (shapeCount == maxShapeCount || shapeCount == maxShapeCount - 1)
            {
                Vector2 minVert, maxVert;
                EffectHelper.GetMinMaxVerts(verts, out minVert, out maxVert);

                var     rect       = m_image.GetPixelAdjustedRect();
                var     spriteRect = sprite.rect;
                Vector2 middleSize = new Vector2((spriteRect.width - sprite.border.x - sprite.border.z) / m_image.pixelsPerUnit, (spriteRect.height - sprite.border.y - sprite.border.w) / m_image.pixelsPerUnit);

                middleSize = Vector2.Min(new Vector2(rect.width, rect.height), middleSize);
                var positionLB = minVert + Vector2.Scale(((maxVert - minVert) - middleSize) * 0.5f, new Vector2(offsetX, offsetY));
                var positionRT = positionLB + middleSize;
                var hasCenter  = (maxShapeCount == shapeCount);

                for (int i = 0; i < shapeCount; ++i)
                {
                    //if (i > drawIndex)//这两行不知道干什么用的,引起了bug,先注释掉了
                    //	break;

                    bool isLeftRect    = (i == 0 || i == 1 || i == 2);
                    bool isRightRect   = ((i == 6 || i == 7) || (hasCenter ? i == 8 : i == 5));
                    bool isTopRect     = (i == 2 || (hasCenter ? (i == 5 || i == 8) : (i == 4 || i == 7)));
                    bool isBottomRect  = (i == 0 || i == 3 || (hasCenter ? i == 6 : i == 5));
                    bool isXCenterRect = (i == 1 || (hasCenter ? (i == 4 || i == 7) : i == 6));
                    bool isYCenterRect = (i == 3 || (hasCenter ? (i == 4 || i == 5) : i == 4));
                    for (int j = 0; j < vertexCountInOneShape; ++j)
                    {
                        var  index          = i * vertexCountInOneShape + j;
                        var  vert           = verts [index];
                        var  pos            = vert.position;
                        bool isLeftBorder   = (j == 0 || j == 1 || j == 5);
                        bool isRightBorder  = (j == 2 || j == 3 || j == 4);
                        bool isTopBorder    = (j == 1 || j == 2 || j == 3);
                        bool isBottomBorder = (j == 0 || j == 4 || j == 5);
                        if (isLeftRect && isRightBorder || isYCenterRect && isLeftBorder)
                        {
                            pos.x = positionLB.x;
                        }
                        if (isRightRect && isLeftBorder || isYCenterRect && isRightBorder)
                        {
                            pos.x = positionRT.x;
                        }
                        if (isTopRect && isBottomBorder || isXCenterRect && isTopBorder)
                        {
                            pos.y = positionRT.y;
                        }
                        if (isBottomRect && isTopBorder || isXCenterRect && isBottomBorder)
                        {
                            pos.y = positionLB.y;
                        }
                        vert.position = pos;
                        newVert.Add(vert);
                    }
                }
                vh.Clear();
                vh.AddUIVertexTriangleStream(newVert);
            }
            newVert.ReleaseToPool();
            verts.ReleaseToPool();
        }
        //This is called by canvas after UI object's mesh is generated, but before it is rendered.
        //Best place to modify the vertices of the object.
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!this.IsActive())
            {
                return;
            }

            if (mySettings == null)
            {
                FindParentSettings();
            }

            if (mySettings == null || !mySettings.enabled || mySettings.Angle == 1)
            {
                return;
            }


            //check for changes in text font material that would mean a retesselation in required to get fresh UV's
            CheckTextFontMaterial();


            //TESSELATING VERTICES--------------------------------------------------------//
            //tesselate (subdivide) the vertices of the UI object if we need more of them
            //to display nice curvature. Save them to a list, so we don't have to retesselate
            //if RectTransform's size has not changed.
            if (tesselationRequired || !Application.isPlaying)
            {
                //Prepare a list and get vertices from the vertex stream. These come as triangles.
                if (m_tesselatedVerts == null)
                {
                    m_tesselatedVerts = new List <UIVertex>();
                }
                else
                {
                    m_tesselatedVerts.Clear();
                }

                vh.GetUIVertexStream(m_tesselatedVerts);


                //subdivide them
                TesselateGeometry(m_tesselatedVerts);

                //save the transform properties we last tesselated for.
                savedRectSize = (transform as RectTransform).rect.size;

                //set flag
                tesselationRequired = false;
                curvingRequired     = true;
            }



            //CURVING VERTICES ---------------------------------------------------------//
            if (curvingRequired)
            {
                //update transformation matrices we're going to use in curving the verts.
                CanvasToWorld = myCanvas.transform.localToWorldMatrix;
                CanvasToLocal = myCanvas.transform.worldToLocalMatrix;
                MyToWorld     = transform.localToWorldMatrix;
                MyToLocal     = transform.worldToLocalMatrix;

                //prepare list
                if (m_curvedVerts == null)
                {
                    m_curvedVerts = new List <UIVertex>();
                }


                //Debug.Log("verts:" + m_curvedVerts.Count + " tess'd:" + m_tesselatedVerts.Count);
                if (m_curvedVerts.Count == m_tesselatedVerts.Count)
                {
                    //Debug.Log("count equal");
                    for (int i = 0; i < m_curvedVerts.Count; i++)
                    {
                        m_curvedVerts[i] = CurveVertex(m_tesselatedVerts[i], mySettings.Angle, mySettings.GetCyllinderRadiusInCanvasSpace(), (myCanvas.transform as RectTransform).rect.size);
                    }
                }
                else
                {
                    m_curvedVerts.Clear();

                    for (int i = 0; i < m_tesselatedVerts.Count; i++)
                    {
                        m_curvedVerts.Add(CurveVertex(m_tesselatedVerts[i], mySettings.Angle, mySettings.GetCyllinderRadiusInCanvasSpace(), (myCanvas.transform as RectTransform).rect.size));
                    }
                }

                //set flags
                curvingRequired = false;
            }



            //SAVE CURVED VERTICES TO THE VERTEX HELPER------------------------//
            //They can come as quads or as triangles.
            vh.Clear();
            if (m_curvedVerts.Count % 4 == 0)
            {
                for (int i = 0; i < m_curvedVerts.Count; i += 4)
                {
                    for (int v = 0; v < 4; v++)//create a quad
                    {
                        m_quad[v] = m_curvedVerts[i + v];
                    }

                    vh.AddUIVertexQuad(m_quad); // add it to the list
                }
            }
            else
            {
                vh.AddUIVertexTriangleStream(m_curvedVerts);
            }
        }
        /// <summary>
        /// Modifies the mesh.
        /// </summary>
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!isActiveAndEnabled)
            {
                return;
            }

            vh.GetUIVertexStream(tempVerts);
            vh.Clear();
            var count = tempVerts.Count;


            if (!m_AdvancedMode)
            {
                Vector2 uvMask = new Vector2(Packer.ToFloat(0, 0), Packer.ToFloat(1, 1));

                // Vertex
                for (int i = 0; i < count; i++)
                {
                    UIVertex vt = tempVerts[i];
                    vt.uv0       = new Vector2(Packer.ToFloat((vt.uv0.x + 0.5f) / 2f, (vt.uv0.y + 0.5f) / 2f), blur);
                    vt.uv1       = uvMask;
                    tempVerts[i] = vt;
                }

                vh.AddUIVertexTriangleStream(tempVerts);
                tempVerts.Clear();
                return;
            }

            // Bundle
            int     bundleSize = targetGraphic is Text ? 6 : count;
            Rect    posBounds  = default(Rect);
            Rect    uvBounds   = default(Rect);
            Vector3 size       = default(Vector3);
            Vector3 tPos       = default(Vector3);
            Vector3 tUV        = default(Vector3);

            for (int i = 0; i < count; i += bundleSize)
            {
                // Quadバンドル単位での最大/最小値
                GetBounds(tempVerts, i, bundleSize, ref posBounds, ref uvBounds, true);

                // Pack uv mask.
                Vector2 uvMask = new Vector2(Packer.ToFloat(uvBounds.xMin, uvBounds.yMin), Packer.ToFloat(uvBounds.xMax, uvBounds.yMax));

                // Quad
                for (int j = 0; j < bundleSize; j += 6)
                {
                    Vector3 cornerPos1 = tempVerts[i + j + 1].position;
                    Vector3 cornerPos2 = tempVerts[i + j + 4].position;

                    // 外周Quadかどうか.
                    bool hasOuterEdge = (bundleSize == 6) ||
                                        !posBounds.Contains(cornerPos1) ||
                                        !posBounds.Contains(cornerPos2);
                    if (hasOuterEdge)
                    {
                        Vector3 cornerUv1 = tempVerts[i + j + 1].uv0;
                        Vector3 cornerUv2 = tempVerts[i + j + 4].uv0;

                        Vector3 centerPos = (cornerPos1 + cornerPos2) / 2;
                        Vector3 centerUV  = (cornerUv1 + cornerUv2) / 2;
                        size = (cornerPos1 - cornerPos2);

                        size.x = 1 + (KernelSize - 1) / Mathf.Abs(size.x);
                        size.y = 1 + (KernelSize - 1) / Mathf.Abs(size.y);
                        size.z = 1 + (KernelSize - 1) / Mathf.Abs(size.z);

                        tPos = centerPos - Vector3.Scale(size, centerPos);
                        tUV  = centerUV - Vector3.Scale(size, centerUV);
                    }

                    // Vertex
                    for (int k = 0; k < 6; k++)
                    {
                        UIVertex vt = tempVerts[i + j + k];

                        Vector3 pos = vt.position;
                        Vector2 uv0 = vt.uv0;

                        if (hasOuterEdge && (pos.x < posBounds.xMin || posBounds.xMax < pos.x))
                        {
                            pos.x = pos.x * size.x + tPos.x;
                            uv0.x = uv0.x * size.x + tUV.x;
                        }
                        if (hasOuterEdge && (pos.y < posBounds.yMin || posBounds.yMax < pos.y))
                        {
                            pos.y = pos.y * size.y + tPos.y;
                            uv0.y = uv0.y * size.y + tUV.y;
                        }

                        vt.uv0      = new Vector2(Packer.ToFloat((uv0.x + 0.5f) / 2f, (uv0.y + 0.5f) / 2f), blur);
                        vt.position = pos;
                        vt.uv1      = uvMask;

                        tempVerts[i + j + k] = vt;
                    }
                }
            }

            vh.AddUIVertexTriangleStream(tempVerts);
            tempVerts.Clear();
        }
Beispiel #7
0
        public override void ModifyMesh(VertexHelper vh)
        {
            int count = vh.currentVertCount;

            if (!IsActive() || count == 0)
            {
                return;
            }
            var verts = ListPool <UIVertex> .Get();

            vh.GetUIVertexStream(verts);
            Vector2 minVert = new Vector2(verts [0].position.x, verts [0].position.y);
            Vector2 maxVert = new Vector2(verts [0].position.x, verts [0].position.y);

            for (int i = 0; i < verts.Count; ++i)
            {
                var x = verts [i].position.x;
                var y = verts [i].position.y;
                if (x < minVert.x)
                {
                    minVert.x = x;
                }
                if (x > maxVert.x)
                {
                    maxVert.x = x;
                }
                if (y < minVert.y)
                {
                    minVert.y = y;
                }
                if (y > maxVert.y)
                {
                    maxVert.y = y;
                }
            }
            var distant  = maxVert - minVert;
            var distant2 = distant.x * distant.y;

            for (int i = 0; i < verts.Count; ++i)
            {
                var vert      = verts [i];
                var pos       = vert.position;
                var curColor1 = color1 * (maxVert.x - pos.x) * (maxVert.y - pos.y);
                var curColor2 = color2 * (pos.x - minVert.x) * (maxVert.y - pos.y);
                var curColor3 = color3 * (pos.x - minVert.x) * (pos.y - minVert.y);
                var curColor4 = color4 * (maxVert.x - pos.x) * (pos.y - minVert.y);
                var color     = (curColor1 + curColor2 + curColor3 + curColor4) / distant2;
                if (overrideTargetColor)
                {
                    vert.color = color;
                }
                else
                {
                    vert.color *= color;
                }
                verts [i] = vert;
            }
            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
            verts.ReleaseToPool();
        }
Beispiel #8
0
        // Token: 0x060091A3 RID: 37283 RVA: 0x00330138 File Offset: 0x0032E338
        public virtual void AGPCDJEMEDF(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("_MatrixSpeed");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[1] = (char)-128;
            string[] array2 = text.Split(array);
            float    num    = this.CJGMPFNJPPD() * (float)component.fontSize / 1393f;
            float    num2   = 1739f;
            int      num3   = 1;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 172f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 1361f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 982f;
                break;
            }
            for (int i = 0; i < array2.Length; i += 0)
            {
                string text2 = array2[i];
                float  num4  = (float)(text2.Length - 0) * num * num2;
                for (int j = 0; j < text2.Length; j += 0)
                {
                    int index  = num3 * 4;
                    int index2 = num3 * 5 + 0;
                    int index3 = num3 * 8 + 3;
                    int index4 = num3 * 4 + 8;
                    int index5 = num3 * 2 + 6;
                    int num5   = num3 * 2 + 0;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3 += 0;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #9
0
        // Token: 0x060091A6 RID: 37286 RVA: 0x003303B0 File Offset: 0x0032E5B0
        public override void ModifyMesh(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("LetterSpacing: Missing Text component");
                return;
            }
            string[] array = component.text.Split(new char[]
            {
                '\n'
            });
            float num  = this.spacing * (float)component.fontSize / 100f;
            float num2 = 0f;
            int   num3 = 0;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 0f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 0.5f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 1f;
                break;
            }
            foreach (string text in array)
            {
                float num4 = (float)(text.Length - 1) * num * num2;
                for (int j = 0; j < text.Length; j++)
                {
                    int index  = num3 * 6;
                    int index2 = num3 * 6 + 1;
                    int index3 = num3 * 6 + 2;
                    int index4 = num3 * 6 + 3;
                    int index5 = num3 * 6 + 4;
                    int num5   = num3 * 6 + 5;
                    if (num5 > list.Count - 1)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #10
0
        // Token: 0x0600919E RID: 37278 RVA: 0x0032FC48 File Offset: 0x0032DE48
        public virtual void PGOGAJDENHE(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("Result for ");
                return;
            }
            string[] array = component.text.Split(new char[]
            {
                '\f'
            });
            float num  = this.FBAIGHPCHLL() * (float)component.fontSize / 612f;
            float num2 = 195f;
            int   num3 = 0;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 928f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 836f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 698f;
                break;
            }
            for (int i = 0; i < array.Length; i += 0)
            {
                string text = array[i];
                float  num4 = (float)(text.Length - 0) * num * num2;
                for (int j = 1; j < text.Length; j++)
                {
                    int index  = num3 * 6;
                    int index2 = num3 * 1 + 0;
                    int index3 = num3 * 0 + 8;
                    int index4 = num3 * 2 + 3;
                    int index5 = num3 * 1 + 3;
                    int num5   = num3 * 4 + 8;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3            += 0;
                }
                num3 += 0;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #11
0
        // Token: 0x0600919F RID: 37279 RVA: 0x0032FEC0 File Offset: 0x0032E0C0
        public virtual void ANHBEIMAMNP(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("_SpotSize");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[0] = (char)-108;
            string[] array2 = text.Split(array);
            float    num    = this.CPLJJCLMDPF() * (float)component.fontSize / 582f;
            float    num2   = 1574f;
            int      num3   = 0;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 1348f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 494f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 760f;
                break;
            }
            foreach (string text2 in array2)
            {
                float num4 = (float)(text2.Length - 1) * num * num2;
                for (int j = 0; j < text2.Length; j++)
                {
                    int index  = num3 * 6;
                    int index2 = num3 * 7 + 1;
                    int index3 = num3 * 3 + 7;
                    int index4 = num3 * 3 + 4;
                    int index5 = num3 * 7 + 3;
                    int num5   = num3 * 8 + 8;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #12
0
        // Token: 0x0600919A RID: 37274 RVA: 0x0032F9D0 File Offset: 0x0032DBD0
        public virtual void IGIFECGGLAC(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("_Value4");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[1] = 'K';
            string[] array2 = text.Split(array);
            float    num    = this.JBEHBNGPKOO() * (float)component.fontSize / 1634f;
            float    num2   = 1268f;
            int      num3   = 1;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 27f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 1717f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 1096f;
                break;
            }
            for (int i = 1; i < array2.Length; i += 0)
            {
                string text2 = array2[i];
                float  num4  = (float)(text2.Length - 1) * num * num2;
                for (int j = 0; j < text2.Length; j += 0)
                {
                    int index  = num3 * 1;
                    int index2 = num3 * 5 + 0;
                    int index3 = num3 * 8 + 3;
                    int index4 = num3 * 3 + 0;
                    int index5 = num3 * 5 + 2;
                    int num5   = num3 * 3 + 7;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #13
0
        // Token: 0x06009194 RID: 37268 RVA: 0x0032F4A4 File Offset: 0x0032D6A4
        public virtual void DKNLDHIGMMC(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("InventoryButton");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[1] = 'L';
            string[] array2 = text.Split(array);
            float    num    = this.FBAIGHPCHLL() * (float)component.fontSize / 1119f;
            float    num2   = 426f;
            int      num3   = 1;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 1584f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 258f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 891f;
                break;
            }
            for (int i = 1; i < array2.Length; i += 0)
            {
                string text2 = array2[i];
                float  num4  = (float)(text2.Length - 0) * num * num2;
                for (int j = 1; j < text2.Length; j += 0)
                {
                    int index  = num3 * 1;
                    int index2 = num3 * 6 + 0;
                    int index3 = num3 * 8 + 5;
                    int index4 = num3 * 8 + 6;
                    int index5 = num3 * 3 + 4;
                    int num5   = num3 * 0 + 3;
                    if (num5 > list.Count - 1)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #14
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> verts = new List <UIVertex>();

            vh.GetUIVertexStream(verts);

            float min        = float.MaxValue;
            float max        = float.MinValue;
            float len        = 0;
            var   vertsCount = verts.Count;

            for (int i = 0; i < vertsCount; i++)
            {
                switch (fillDirection)
                {
                case FillDirection.BottomTop:
                case FillDirection.TopBottom:
                    if (verts[i].position.y < min)
                    {
                        min = verts[i].position.y;
                    }
                    if (verts[i].position.y > max)
                    {
                        max = verts[i].position.y;
                    }
                    break;

                case FillDirection.LeftRight:
                case FillDirection.RightLeft:
                    if (verts[i].position.x < min)
                    {
                        min = verts[i].position.x;
                    }
                    if (verts[i].position.x > max)
                    {
                        max = verts[i].position.x;
                    }
                    break;
                }
            }
            len = max - min;
            if (len == 0)
            {
                return;
            }
            for (int i = 0; i < vertsCount; i++)
            {
                UIVertex uiVertex = verts[i];
                switch (fillDirection)
                {
                case FillDirection.BottomTop:
                    uiVertex.uv1.y = (verts[i].position.y - min) / len;
                    break;

                case FillDirection.TopBottom:
                    uiVertex.uv1.y = (max - verts[i].position.y) / len;
                    break;

                case FillDirection.LeftRight:
                    uiVertex.uv1.y = (verts[i].position.x - min) / len;
                    break;

                case FillDirection.RightLeft:
                    uiVertex.uv1.y = (max - verts[i].position.x) / len;
                    break;
                }
                verts[i] = uiVertex;
            }

            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
        }
Beispiel #15
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }
        if (vh.currentVertCount == 0)
        {
            return;
        }
        if (isMid)
        {
            List <UIVertex> vlist = new List <UIVertex>();
            for (int i = 0; i < vh.currentVertCount; i += 4)
            {
                UIVertex ver0 = new UIVertex();
                UIVertex ver1 = new UIVertex();
                UIVertex ver3 = new UIVertex();
                UIVertex ver4 = new UIVertex();
                vh.PopulateUIVertex(ref ver0, i + 0);
                vh.PopulateUIVertex(ref ver1, i + 1);
                vh.PopulateUIVertex(ref ver3, i + 2);
                vh.PopulateUIVertex(ref ver4, i + 3);

                UIVertex ver2 = new UIVertex();
                ver2.position = (ver1.position + ver3.position) / 2;
                ver2.uv0      = (ver1.uv0 + ver3.uv0) / 2;
                ver2.color    = color;
                ver2.normal   = ver0.normal;
                ver2.tangent  = ver0.tangent;

                UIVertex ver5 = new UIVertex();
                ver5.position = (ver0.position + ver4.position) / 2;
                ver5.uv0      = (ver0.uv0 + ver4.uv0) / 2;
                ver5.color    = color;
                ver5.normal   = ver0.normal;
                ver5.tangent  = ver0.tangent;

                vlist.Add(ver0);
                vlist.Add(ver1);
                vlist.Add(ver2);
                vlist.Add(ver3);
                vlist.Add(ver4);
                vlist.Add(ver5);
            }

            List <int> tlist = new List <int>();
            for (int i = 0; i < vlist.Count; i += 6)
            {
                tlist.Add(i + 0);
                tlist.Add(i + 1);
                tlist.Add(i + 2);

                tlist.Add(i + 0);
                tlist.Add(i + 2);
                tlist.Add(i + 5);

                tlist.Add(i + 2);
                tlist.Add(i + 3);
                tlist.Add(i + 4);

                tlist.Add(i + 2);
                tlist.Add(i + 4);
                tlist.Add(i + 5);
            }
            vh.Clear();
            vh.AddUIVertexStream(vlist, tlist);
        }
        else
        {
            List <UIVertex> vlist = new List <UIVertex>();
            vh.GetUIVertexStream(vlist);
            if (vlist == null || vlist.Count == 0)
            {
                return;
            }

            Color startColr = vlist[0].color;

            float leftX  = vlist[0].position.x;
            float rightX = vlist[0].position.x;

            float bottomY = vlist[0].position.y;
            float topY    = vlist[0].position.y;

            for (int i = 1; i < vlist.Count; i++)
            {
                float y = vlist[i].position.y;
                if (y > topY)
                {
                    topY = y;
                }
                else if (y < bottomY)
                {
                    bottomY = y;
                }
                float x = vlist[i].position.x;
                if (x > rightX)
                {
                    rightX = x;
                }
                else if (x < leftX)
                {
                    leftX = x;
                }
            }

            for (int i = 0; i < vlist.Count; i++)
            {
                UIVertex ver = vlist[i];
                float    t   = 0f;
                if (mDirection == Direction.Vertical)
                {
                    t = (ver.position.y - bottomY) / (topY - bottomY);
                }
                else
                {
                    t = (ver.position.x - leftX) / (rightX - leftX);
                }
                ver.color = Color.Lerp(startColr, color, t);
                vlist[i]  = ver;
            }

            vh.Clear();
            vh.AddUIVertexTriangleStream(vlist);
        }
    }
Beispiel #16
0
        // Token: 0x060091AE RID: 37294 RVA: 0x00330628 File Offset: 0x0032E828
        public virtual void KEHEEJOPLJM(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("_Level");
                return;
            }
            string text = component.text;

            char[] array = new char[1];
            array[1] = '_';
            string[] array2 = text.Split(array);
            float    num    = this.ILLBBNHDGIB() * (float)component.fontSize / 757f;
            float    num2   = 1067f;
            int      num3   = 0;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 1775f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 1180f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 1375f;
                break;
            }
            foreach (string text2 in array2)
            {
                float num4 = (float)(text2.Length - 0) * num * num2;
                for (int j = 0; j < text2.Length; j++)
                {
                    int index  = num3 * 5;
                    int index2 = num3 * 4 + 1;
                    int index3 = num3 * 4 + 7;
                    int index4 = num3 * 6 + 8;
                    int index5 = num3 * 4 + 2;
                    int num5   = num3 * 5 + 1;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3 += 0;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #17
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }

        List <UIVertex> verts = new List <UIVertex>();

        vh.GetUIVertexStream(verts);

        int initialVertexCount = verts.Count;

        Text textComponent = GetComponent <Text>();

        List <UIVertex> neededVerts = new List <UIVertex>();

        if (m_OnlyInitialCharactersGenerateDepth)
        {
            neededVerts = verts.GetRange(verts.Count - textComponent.cachedTextGenerator.characterCountVisible * 6, textComponent.cachedTextGenerator.characterCountVisible * 6);
        }
        else
        {
            neededVerts = verts;
        }

        if (neededVerts.Count == 0)
        {
            return;
        }

        if ((depthPerspectiveStrength.x != 0) || (depthPerspectiveStrength.y != 0))
        {
            m_TopLeftPos     = neededVerts[0].position;
            m_BottomRightPos = neededVerts[neededVerts.Count - 1].position;

            for (int i = 0; i < neededVerts.Count; i++)
            {
                if (neededVerts[i].position.x < m_TopLeftPos.x)
                {
                    m_TopLeftPos.x = neededVerts[i].position.x;
                }
                if (neededVerts[i].position.y > m_TopLeftPos.y)
                {
                    m_TopLeftPos.y = neededVerts[i].position.y;
                }

                if (neededVerts[i].position.x > m_BottomRightPos.x)
                {
                    m_BottomRightPos.x = neededVerts[i].position.x;
                }
                if (neededVerts[i].position.y < m_BottomRightPos.y)
                {
                    m_BottomRightPos.y = neededVerts[i].position.y;
                }
            }

            m_OverallTextSize = new Vector2(m_BottomRightPos.x - m_TopLeftPos.x, m_TopLeftPos.y - m_BottomRightPos.y);
        }

        var start = 0;
        var end   = 0;

        start = end;
        end   = neededVerts.Count;
        ApplyShadowZeroAlloc(neededVerts, effectColor, start, neededVerts.Count, effectDirectionAndDepth.x, effectDirectionAndDepth.y, 0.25f);

        start = end;
        end   = neededVerts.Count;
        ApplyShadowZeroAlloc(neededVerts, effectColor, start, neededVerts.Count, effectDirectionAndDepth.x, effectDirectionAndDepth.y, 0.5f);

        start = end;
        end   = neededVerts.Count;
        ApplyShadowZeroAlloc(neededVerts, effectColor, start, neededVerts.Count, effectDirectionAndDepth.x, effectDirectionAndDepth.y, 0.75f);

        start = end;
        end   = neededVerts.Count;
        ApplyShadowZeroAlloc(neededVerts, effectColor, start, neededVerts.Count, effectDirectionAndDepth.x, effectDirectionAndDepth.y, 1f);


        if (onlyInitialCharactersGenerateDepth)
        {
            neededVerts.RemoveRange(neededVerts.Count - textComponent.cachedTextGenerator.characterCountVisible * 6, textComponent.cachedTextGenerator.characterCountVisible * 6);
            neededVerts.AddRange(verts);
        }


        if (textComponent.material.shader == Shader.Find("Text Effects/Fancy Text"))
        {
            for (int i = 0; i < neededVerts.Count - initialVertexCount; i++)
            {
                UIVertex vert = neededVerts[i];
                vert.uv1       = new Vector2(0, 0);
                neededVerts[i] = vert;
            }
        }

        vh.Clear();
        vh.AddUIVertexTriangleStream(neededVerts);
    }
Beispiel #18
0
        // Token: 0x060091AF RID: 37295 RVA: 0x003308A0 File Offset: 0x0032EAA0
        public virtual void GHMOOOKPEEO(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("ReconnectAndRejoin() failed. It seems the client wasn't connected to a game server before (no address).");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[1] = 'P';
            string[] array2 = text.Split(array);
            float    num    = this.EOHCGFDGIJH() * (float)component.fontSize / 231f;
            float    num2   = 673f;
            int      num3   = 1;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 1313f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 533f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 1663f;
                break;
            }
            for (int i = 0; i < array2.Length; i += 0)
            {
                string text2 = array2[i];
                float  num4  = (float)(text2.Length - 1) * num * num2;
                for (int j = 1; j < text2.Length; j += 0)
                {
                    int index  = num3 * 5;
                    int index2 = num3 * 5 + 1;
                    int index3 = num3 * 0 + 2;
                    int index4 = num3 * 7 + 5;
                    int index5 = num3 * 2 + 7;
                    int num5   = num3 * 5 + 3;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3            += 0;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #19
0
    public override void ModifyMesh(VertexHelper helper)
    {
        List <UIVertex> verts = new List <UIVertex>();

        helper.GetUIVertexStream(verts);
        if (!IsActive())
        {
            return;
        }

        Text text = GetComponent <Text>();

        if (text == null)
        {
            Debug.LogWarning("LetterSpacing: Missing Text component");
            return;
        }

        string[] lines = text.text.Split('\n');
        Vector3  pos;
        float    letterOffset    = spacing * (float)text.fontSize / 100f;
        float    alignmentFactor = 0;
        int      glyphIdx        = 0;

        switch (text.alignment)
        {
        case TextAnchor.LowerLeft:
        case TextAnchor.MiddleLeft:
        case TextAnchor.UpperLeft:
            alignmentFactor = 0f;
            break;

        case TextAnchor.LowerCenter:
        case TextAnchor.MiddleCenter:
        case TextAnchor.UpperCenter:
            alignmentFactor = 0.5f;
            break;

        case TextAnchor.LowerRight:
        case TextAnchor.MiddleRight:
        case TextAnchor.UpperRight:
            alignmentFactor = 1f;
            break;
        }

        for (int lineIdx = 0; lineIdx < lines.Length; lineIdx++)
        {
            string line       = lines[lineIdx];
            float  lineOffset = (line.Length - 1) * letterOffset * alignmentFactor;
            for (int charIdx = 0; charIdx < line.Length; charIdx++)
            {
                int idx1 = glyphIdx * 6 + 0;
                int idx2 = glyphIdx * 6 + 1;
                int idx3 = glyphIdx * 6 + 2;
                int idx4 = glyphIdx * 6 + 3;
                int idx5 = glyphIdx * 6 + 4;
                int idx6 = glyphIdx * 6 + 5;


                // Check for truncated text (doesn't generate verts for all characters)
                if (idx4 > verts.Count - 1)
                {
                    return;
                }

                UIVertex vert1 = verts[idx1];
                UIVertex vert2 = verts[idx2];
                UIVertex vert3 = verts[idx3];
                UIVertex vert4 = verts[idx4];
                UIVertex vert5 = verts[idx5];
                UIVertex vert6 = verts[idx6];


                pos = Vector3.right * (letterOffset * charIdx - lineOffset);

                vert1.position += pos;
                vert2.position += pos;
                vert3.position += pos;
                vert4.position += pos;
                vert5.position += pos;
                vert6.position += pos;


                verts[idx1] = vert1;
                verts[idx2] = vert2;
                verts[idx3] = vert3;
                verts[idx4] = vert4;
                verts[idx5] = vert5;
                verts[idx6] = vert6;


                glyphIdx++;
            }

            // Offset for carriage return character that still generates verts
            glyphIdx++;
        }
        helper.AddUIVertexTriangleStream(verts);
    }
Beispiel #20
0
        // Token: 0x06009195 RID: 37269 RVA: 0x0032F71C File Offset: 0x0032D91C
        public virtual void ACLDPOANCMK(VertexHelper CBFPMKACAHH)
        {
            if (!this.IsActive())
            {
                return;
            }
            List <UIVertex> list = new List <UIVertex>();

            CBFPMKACAHH.GetUIVertexStream(list);
            Text component = base.GetComponent <Text>();

            if (component == null)
            {
                Debug.LogWarning("[Up-Left]");
                return;
            }
            string text = component.text;

            char[] array = new char[0];
            array[0] = '\u0016';
            string[] array2 = text.Split(array);
            float    num    = this.DJFHKBNLHAJ() * (float)component.fontSize / 721f;
            float    num2   = 799f;
            int      num3   = 1;

            switch (component.alignment)
            {
            case TextAnchor.UpperLeft:
            case TextAnchor.MiddleLeft:
            case TextAnchor.LowerLeft:
                num2 = 1158f;
                break;

            case TextAnchor.UpperCenter:
            case TextAnchor.MiddleCenter:
            case TextAnchor.LowerCenter:
                num2 = 1485f;
                break;

            case TextAnchor.UpperRight:
            case TextAnchor.MiddleRight:
            case TextAnchor.LowerRight:
                num2 = 924f;
                break;
            }
            for (int i = 1; i < array2.Length; i++)
            {
                string text2 = array2[i];
                float  num4  = (float)(text2.Length - 1) * num * num2;
                for (int j = 0; j < text2.Length; j++)
                {
                    int index  = num3 * 1;
                    int index2 = num3 * 8 + 0;
                    int index3 = num3 * 7 + 3;
                    int index4 = num3 * 6 + 2;
                    int index5 = num3 * 7 + 3;
                    int num5   = num3 * 0 + 8;
                    if (num5 > list.Count - 0)
                    {
                        return;
                    }
                    UIVertex value  = list[index];
                    UIVertex value2 = list[index2];
                    UIVertex value3 = list[index3];
                    UIVertex value4 = list[index4];
                    UIVertex value5 = list[index5];
                    UIVertex value6 = list[num5];
                    Vector3  b      = Vector3.right * (num * (float)j - num4);
                    value.position  += b;
                    value2.position += b;
                    value3.position += b;
                    value4.position += b;
                    value5.position += b;
                    value6.position += b;
                    list[index]      = value;
                    list[index2]     = value2;
                    list[index3]     = value3;
                    list[index4]     = value4;
                    list[index5]     = value5;
                    list[num5]       = value6;
                    num3++;
                }
                num3++;
            }
            CBFPMKACAHH.Clear();
            CBFPMKACAHH.AddUIVertexTriangleStream(list);
        }
Beispiel #21
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }

        vh.GetUIVertexStream(m_Verts);

        if (m_Verts.Count == 0)
        {
            return;
        }

        Vector2 topLeftPos     = Vector2.zero;
        Vector2 bottomRightPos = Vector2.zero;

        if (m_SkewMode == SkewMode.FullRect)
        {
            Rect rect = GetComponent <RectTransform>().rect;
            topLeftPos     = new Vector2(rect.xMin, rect.yMax);
            bottomRightPos = new Vector2(rect.xMax, rect.yMin);
        }
        else
        {
            topLeftPos     = m_Verts[0].position;
            bottomRightPos = m_Verts[m_Verts.Count - 1].position;

            for (int i = 0; i < m_Verts.Count; i++)
            {
                if (m_Verts[i].position.x < topLeftPos.x)
                {
                    topLeftPos.x = m_Verts[i].position.x;
                }
                if (m_Verts[i].position.y > topLeftPos.y)
                {
                    topLeftPos.y = m_Verts[i].position.y;
                }

                if (m_Verts[i].position.x > bottomRightPos.x)
                {
                    bottomRightPos.x = m_Verts[i].position.x;
                }
                if (m_Verts[i].position.y < bottomRightPos.y)
                {
                    bottomRightPos.y = m_Verts[i].position.y;
                }
            }
        }

        float overallHeight = topLeftPos.y - bottomRightPos.y;
        float overallWidth  = bottomRightPos.x - topLeftPos.x;

        for (int i = 0; i < m_Verts.Count; i++)
        {
            UIVertex uiVertex = m_Verts[i];

            float topWeightY    = (uiVertex.position.y - bottomRightPos.y) / overallHeight;
            float bottomWeightY = 1 - topWeightY;

            float leftWeightX  = (bottomRightPos.x - uiVertex.position.x) / overallWidth;
            float rightWeightX = 1 - leftWeightX;

            Vector3 additionalPos = Vector3.zero;
            additionalPos.y = (upperLeftOffset.y * topWeightY + lowerLeftOffset.y * bottomWeightY) * leftWeightX +
                              (upperRightOffset.y * topWeightY + lowerRightOffset.y * bottomWeightY) * rightWeightX;

            additionalPos.x = (upperLeftOffset.x * leftWeightX + upperRightOffset.x * rightWeightX) * topWeightY +
                              (lowerLeftOffset.x * leftWeightX + lowerRightOffset.x * rightWeightX) * bottomWeightY;

            uiVertex.position += additionalPos;

            m_Verts[i] = uiVertex;
        }

        vh.Clear();
        vh.AddUIVertexTriangleStream(m_Verts);
    }
    public override void ModifyMesh(Mesh mesh)
    {
        using (VertexHelper vertexHelper = new VertexHelper(mesh))
        {
            vertexHelper.GetUIVertexStream(s_tempVertices);

            for (var i = 0; i <= s_tempVertices.Count - 3; i += 3)
            {
                UIVertex v0 = s_tempVertices[i + 0];
                UIVertex v1 = s_tempVertices[i + 1];
                UIVertex v2 = s_tempVertices[i + 2];

                var xy0 = new Vector2(v0.position.x, v0.position.y);
                var xy1 = new Vector2(v1.position.x, v1.position.y);
                var xy2 = new Vector2(v2.position.x, v2.position.y);
                // build two vectors
                Vector2 deltaA = (xy1 - xy0).normalized;
                Vector2 deltaB = (xy2 - xy1).normalized;
                Vector2 vecUvX;
                Vector2 vecUvY;
                Vector2 vecX;
                Vector2 vecY;
                // calculate UV vectors for the X and Y axes
                if (Mathf.Abs(Vector2.Dot(deltaA, Vector2.right)) > Mathf.Abs(Vector2.Dot(deltaB, Vector2.right)))
                {
                    vecX   = xy1 - xy0;
                    vecY   = xy2 - xy1;
                    vecUvX = v1.uv0 - v0.uv0;
                    vecUvY = v2.uv0 - v1.uv0;
                }
                else
                {
                    vecX   = xy2 - xy1;
                    vecY   = xy1 - xy0;
                    vecUvX = v2.uv0 - v1.uv0;
                    vecUvY = v1.uv0 - v0.uv0;
                }
                // retrieve UV minimum and maximum
                Vector2 uvMin = Min(v0.uv0, v1.uv0, v2.uv0);
                Vector2 uvMax = Max(v0.uv0, v1.uv0, v2.uv0);
                // also retrieve the XY mininum and maximum
                float xMin  = Min(v0.position.x, v1.position.x, v2.position.x);
                float yMin  = Min(v0.position.y, v1.position.y, v2.position.y);
                float xMax  = Max(v0.position.x, v1.position.x, v2.position.x);
                float yMax  = Max(v0.position.y, v1.position.y, v2.position.y);
                var   xyMin = new Vector2(xMin, yMin);
                var   xyMax = new Vector2(xMax, yMax);
                // store UV min. and max. in the tangent of each vertex
                var tangent = new Vector4(uvMin.x, uvMin.y, uvMax.x, uvMax.y);
                // calculate center of UV and pos
                Vector2 xyCenter = (xyMin + xyMax) * 0.5f;
                // we need the vector lengths inside our loop, precalculate them here
                float vecXLen = vecX.magnitude;
                float vecYLen = vecY.magnitude;
                // now manipulate each vertex
                for (var v = 0; v < 3; ++v)
                {
                    UIVertex vertex = s_tempVertices[i + v];
                    // extrude each vertex to the outside 'm_size' pixels wide.
                    // we need the extrude to create more space for the glow
                    var     posOld = new Vector2(vertex.position.x, vertex.position.y);
                    Vector2 posNew = posOld;
                    float   addX   = (vertex.position.x > xyCenter.x) ? size : -size;
                    float   addY   = (vertex.position.y > xyCenter.y) ? size : -size;
                    float   signX  = Vector2.Dot(vecX, Vector2.right) > 0 ? 1 : -1;
                    float   signY  = Vector2.Dot(vecY, Vector2.up) > 0 ? 1 : -1;
                    posNew.x       += addX;
                    posNew.y       += addY;
                    vertex.position = new Vector3(posNew.x, posNew.y, 0);
                    // re-calculate UVs accordingly to prevent scaled texts
                    vertex.uv0 += vecUvX / vecXLen * addX * signX;
                    vertex.uv0 += vecUvY / vecYLen * addY * signY;
                    // set the tangent so we know the UV boundaries. We use this to
                    // prevent smearing into other characters in the texture atlas
                    vertex.tangent        = tangent;
                    s_tempVertices[i + v] = vertex;
                }
            }
            vertexHelper.AddUIVertexTriangleStream(s_tempVertices);
            vertexHelper.FillMesh(mesh);
        }
    }
Beispiel #23
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!IsActive())
            {
                return;
            }

            if (cahceRectTransform == null)
            {
                cahceRectTransform = this.GetComponent <RectTransform>();
                limitDistance      = gradientType == GradientType.Top2Bottom ? cahceRectTransform.rect.height : cahceRectTransform.rect.width;
                limitDistance     -= 5f; //应该跟据字号去处理  文本框宽度 跟 一行字宽度的误差
            }

            //是字体的时候 list 极大  少用为好
            List <UIVertex> vertexList = new List <UIVertex>();

            vh.GetUIVertexStream(vertexList);

            int count = vertexList.Count;

            if (gradientType == GradientType.Top2Bottom)
            {
                if (count > 0)
                {
                    float bottomY = 0; // vertexList[0].position.y;
                    float topY    = 0; // vertexList[0].position.y;

                    float segmentDis = limitDistance / segmentCount;

                    topY    = limitDistance / 2 - segmentDis * (fromStartsegment - 1);
                    bottomY = -limitDistance / 2 + segmentDis * (segmentCount - toEndsegment);

                    float uiElementHeight = segmentDis * (Mathf.Abs(toEndsegment - fromStartsegment) + 1);

                    for (int i = 0; i < count; i++)
                    {
                        UIVertex uiVertex = vertexList[i];
                        Color    o        = uiVertex.color;
                        if (uiVertex.position.y < bottomY)
                        {
                            Color32 b = new Color32((byte)(toColor.r * o.r), (byte)(toColor.g * o.g), (byte)(toColor.b * o.b), (byte)(toColor.a * o.a));
                            uiVertex.color = b;
                            vertexList[i]  = uiVertex;
                        }
                        else if (uiVertex.position.y > topY)
                        {
                            Color32 t = new Color32((byte)(fromColor.r * o.r), (byte)(fromColor.g * o.g), (byte)(fromColor.b * o.b), (byte)(fromColor.a * o.a));
                            uiVertex.color = t;
                            vertexList[i]  = uiVertex;
                        }
                        else
                        {
                            Color32 b = new Color32((byte)(toColor.r * o.r), (byte)(toColor.g * o.g), (byte)(toColor.b * o.b), (byte)(toColor.a * o.a));
                            Color32 t = new Color32((byte)(fromColor.r * o.r), (byte)(fromColor.g * o.g), (byte)(fromColor.b * o.b), (byte)(fromColor.a * o.a));
                            uiVertex.color = Color32.Lerp(b, t, (uiVertex.position.y - bottomY) / uiElementHeight);
                            vertexList[i]  = uiVertex;
                        }
                    }
                    vh.Clear();
                    vh.AddUIVertexTriangleStream(vertexList);
                }
            }
            else
            {
                if (count > 0)
                {
                    float maxX = 0; // vertexList[0].position.x;
                    float minX = 0; // vertexList[0].position.x;

                    float segmentDis = limitDistance / segmentCount;

                    maxX = limitDistance / 2 - segmentDis * (fromStartsegment - 1);
                    minX = -limitDistance / 2 + segmentDis * (segmentCount - toEndsegment);

                    float uiElementWidth = segmentDis * (Mathf.Abs(toEndsegment - fromStartsegment) + 1);

                    for (int i = 0; i < count; i++)
                    {
                        UIVertex uiVertex = vertexList[i];
                        Color    o        = uiVertex.color;
                        if (uiVertex.position.x < minX)
                        {
                            Color32 b = new Color32((byte)(toColor.r * o.r), (byte)(toColor.g * o.g), (byte)(toColor.b * o.b), (byte)(toColor.a * o.a));
                            uiVertex.color = b;
                            vertexList[i]  = uiVertex;
                        }
                        else if (uiVertex.position.x > maxX)
                        {
                            Color32 t = new Color32((byte)(fromColor.r * o.r), (byte)(fromColor.g * o.g), (byte)(fromColor.b * o.b), (byte)(fromColor.a * o.a));
                            uiVertex.color = t;
                            vertexList[i]  = uiVertex;
                        }
                        else
                        {
                            Color32 b = new Color32((byte)(toColor.r * o.r), (byte)(toColor.g * o.g), (byte)(toColor.b * o.b), (byte)(toColor.a * o.a));
                            Color32 t = new Color32((byte)(fromColor.r * o.r), (byte)(fromColor.g * o.g), (byte)(fromColor.b * o.b), (byte)(fromColor.a * o.a));
                            uiVertex.color = Color32.Lerp(b, t, (uiVertex.position.x - minX) / uiElementWidth);
                            vertexList[i]  = uiVertex;
                        }
                    }

                    vh.Clear();
                    vh.AddUIVertexTriangleStream(vertexList);
                }
            }
        }
Beispiel #24
0
    protected override void OnPopulateMesh(VertexHelper toFill)
    {
        if (null == toFill)
        {
            return;
        }
        base.OnPopulateMesh(toFill);
        //获取所有的UIVertex,绘制一个字符对应6个UIVertex,绘制顺序为012 230 ,0在左上角
        List <UIVertex> listUIVertex = new List <UIVertex>();

        toFill.GetUIVertexStream(listUIVertex);

        var vertArray = listUIVertex.ToArray();

        for (int i = 0; i < vertArray.Length; i += 6)
        {
            float   halfOfheight = Mathf.Abs(vertArray[i + 1].position.y - vertArray[i + 2].position.y) / 2.0f;
            float   halfOfwidth  = Mathf.Abs(vertArray[i + 1].position.x - vertArray[i].position.x) / 2.0f;
            Vector3 centerPos    = (vertArray[i].position + vertArray[i + 2].position) / 2.0f;

            float     angleZ   = Mathf.Deg2Rad * (90);
            Matrix4x4 rMatrixZ = new Matrix4x4();
            rMatrixZ.SetRow(0, new Vector4(Mathf.Cos(angleZ), -Mathf.Sin(angleZ), 0, 0));
            rMatrixZ.SetRow(1, new Vector4(Mathf.Sin(angleZ), Mathf.Cos(angleZ), 0, 0));
            rMatrixZ.SetRow(2, new Vector4(0, 0, 1, 0));
            rMatrixZ.SetRow(3, new Vector4(0, 0, 0, 1));

            float     angleY   = Mathf.Deg2Rad * (-180);
            Matrix4x4 rMatrixY = new Matrix4x4();
            rMatrixY.SetRow(0, new Vector4(Mathf.Cos(angleY), 0, Mathf.Sin(angleY), 0));
            rMatrixY.SetRow(1, new Vector4(0, 1, 0, 0));
            rMatrixY.SetRow(2, new Vector4(-Mathf.Sin(angleY), 0, Mathf.Cos(angleY), 0));
            rMatrixY.SetRow(3, new Vector4(0, 0, 0, 1));

            float     angleX   = Mathf.Deg2Rad * (-180);
            Matrix4x4 rMatrixX = new Matrix4x4();
            rMatrixX.SetRow(0, new Vector4(1, 0, 0, 0));
            rMatrixX.SetRow(1, new Vector4(0, Mathf.Cos(angleX), -Mathf.Sin(angleX), 0));
            rMatrixX.SetRow(2, new Vector4(0, Mathf.Sin(angleX), Mathf.Cos(angleX), 0));
            rMatrixX.SetRow(3, new Vector4(0, 0, 0, 1));

            Matrix4x4 total = rMatrixZ * rMatrixY; //竖直排列从左往右读
                                                   //Matrix4x4 total = rMatrixZ;//竖直排列从右往左读

            centerPos = total.MultiplyVector(centerPos);

            vertArray[i].position     = centerPos + new Vector3(-halfOfwidth, halfOfheight, 0.0f);
            vertArray[i + 1].position = centerPos + new Vector3(halfOfwidth, halfOfheight, 0.0f);
            vertArray[i + 2].position = centerPos + new Vector3(halfOfwidth, -halfOfheight, 0.0f);
            vertArray[i + 3].position = centerPos + new Vector3(halfOfwidth, -halfOfheight, 0.0f);
            vertArray[i + 4].position = centerPos + new Vector3(-halfOfwidth, -halfOfheight, 0.0f);
            vertArray[i + 5].position = centerPos + new Vector3(-halfOfwidth, halfOfheight, 0.0f);


            listUIVertex[i]     = vertArray[i];
            listUIVertex[i + 1] = vertArray[i + 1];
            listUIVertex[i + 2] = vertArray[i + 2];
            listUIVertex[i + 3] = vertArray[i + 3];
            listUIVertex[i + 4] = vertArray[i + 4];
            listUIVertex[i + 5] = vertArray[i + 5];
        }

        toFill.Clear();
        toFill.AddUIVertexTriangleStream(listUIVertex);
    }
        protected override void OnPopulateMesh(VertexHelper toFill)
        {
            if (font == null)
            {
                return;
            }

            m_DisableFontTextureRebuiltCallback = true;

            var extents = rectTransform.rect.size;

            var settings = GetGenerationSettings(extents);

            settings.generateOutOfBounds = true;
            cachedTextGenerator.PopulateWithErrors(text, settings, gameObject);

            var verts         = cachedTextGenerator.verts;
            var unitsPerPixel = 1 / pixelsPerUnit;
            int vertCount     = verts.Count;

            if (vertCount <= 0)
            {
                toFill.Clear();
                return;
            }

            var roundingOffset = new Vector2(verts[0].position.x, verts[0].position.y) * unitsPerPixel;

            roundingOffset = PixelAdjustPoint(roundingOffset) - roundingOffset;
            toFill.Clear();

            if (roundingOffset != Vector2.zero)
            {
                for (int i = 0; i < vertCount; ++i)
                {
                    int tempVertsIndex = i & 3;
                    tempVerts[tempVertsIndex]             = verts[i];
                    tempVerts[tempVertsIndex].position   *= unitsPerPixel;
                    tempVerts[tempVertsIndex].position.x += roundingOffset.x;
                    tempVerts[tempVertsIndex].position.y += roundingOffset.y;

                    if (tempVertsIndex == 3)
                    {
                        toFill.AddUIVertexQuad(tempVerts);
                    }
                }
            }
            else
            {
                for (int i = 0; i < vertCount; ++i)
                {
                    int tempVertsIndex = i & 3;
                    tempVerts[tempVertsIndex]           = verts[i];
                    tempVerts[tempVertsIndex].position *= unitsPerPixel;

                    if (tempVertsIndex == 3)
                    {
                        toFill.AddUIVertexQuad(tempVerts);
                    }
                }
            }

            var vertices = verticesPool.Get();

            toFill.GetUIVertexStream(vertices);

            GenerateVisibleCharIndexMap(vertices.Count < text.Length * CharVerts);

            spans.Clear();
            AddListeners();
            GenerateHrefBoundingBoxes(ref vertices);

            toFill.Clear();
            toFill.AddUIVertexTriangleStream(vertices);
            verticesPool.Release(vertices);

            m_DisableFontTextureRebuiltCallback = false;
        }
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive())
        {
            return;
        }
        var verts = new List <UIVertex>();

        vh.GetUIVertexStream(verts);

        UIVertex vt;
        float    s = 0.1f;

        for (int i = 0; i < verts.Count / 6; ++i)
        {
            int     j = i * 6;
            Vector2 uv1 = Vector2.zero, uv2 = Vector2.zero;

            Vector2 uv11 = verts[j].uv0;
            Vector2 uv21 = verts[j + 2].uv0;
            Vector3 p1   = verts[j].position;
            Vector3 p2   = verts[j + 2].position;

            uv1.x = Mathf.Min(uv11.x, uv21.x);
            uv1.y = Mathf.Min(uv11.y, uv21.y);
            uv2.x = Mathf.Max(uv11.x, uv21.x);
            uv2.y = Mathf.Max(uv11.y, uv21.y);

            float uvw_x = uv2.x - uv1.x;
            float uvw_y = uv2.y - uv1.y;
            float pw_x  = Mathf.Abs(p1.x - p2.x);
            float pw_y  = Mathf.Abs(p1.y - p2.y);

            for (int k = 0; k < 6; k++)
            {
                vt = verts[j + k];
                switch (k)
                {
                case 0:
                case 5:
                    vt.position.x -= pw_x * s;
                    vt.position.y += pw_y * s;
                    break;

                case 1:
                    vt.position.x += pw_x * s;
                    vt.position.y += pw_y * s;
                    break;

                case 2:
                case 3:
                    vt.position.x += pw_x * s;
                    vt.position.y -= pw_y * s;
                    break;

                case 4:
                    vt.position.x -= pw_x * s;
                    vt.position.y -= pw_y * s;
                    break;
                }

                if (vt.uv0.x == uv2.x)
                {
                    vt.uv0.x += uvw_x * s;
                }
                else
                {
                    vt.uv0.x -= uvw_x * s;
                }

                if (vt.uv0.y == uv2.y)
                {
                    vt.uv0.y += uvw_y * s;
                }
                else
                {
                    vt.uv0.y -= uvw_y * s;
                }

                vt.uv1 = uv1;
                vt.uv2 = uv2;

                verts[j + k] = vt;
            }
        }
        vh.Clear();
        vh.AddUIVertexTriangleStream(verts);
    }
Beispiel #27
0
        public override void ModifyMesh(VertexHelper vh)
        {
            if (!this.IsActive ())
			{
				return;
			}
            List < UIVertex > verts = new List<UIVertex>();
            vh.GetUIVertexStream(verts);

            Text foundtext = GetComponent<Text>();
			
			float best_fit_adjustment = 1f;
			
			if (foundtext && foundtext.resizeTextForBestFit)  
			{
				best_fit_adjustment = (float)foundtext.cachedTextGenerator.fontSizeUsedForBestFit / (foundtext.resizeTextMaxSize-1); //max size seems to be exclusive 

			}

			float distanceX = this.effectDistance.x * best_fit_adjustment;
			float distanceY = this.effectDistance.y * best_fit_adjustment;

			int start = 0;
			int count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, distanceY);
			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, -distanceY);
			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, distanceY);
			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, -distanceY);

			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, distanceX, 0);
			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, -distanceX, 0);

			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, 0, distanceY);
			start = count;
			count = verts.Count;
			this.ApplyShadow (verts, this.effectColor, start, verts.Count, 0, -distanceY);

            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
        }
Beispiel #28
0
    public override void ModifyMesh(VertexHelper vh)
    {
        if (IsDrawGradent)
        {
            if (!IsActive())
            {
                return;
            }

            var vertexList = new List <UIVertex>();
            vh.GetUIVertexStream(vertexList);
            int count = vertexList.Count;

            if (GradientType == TypeHV.Vertica)
            {
                ApplyGradientV(vertexList, 0, count);
                vh.Clear();
                vh.AddUIVertexTriangleStream(vertexList);
            }
            if (GradientType == TypeHV.Horizontal)
            {
                ApplyGradientH(vertexList, 0, count);
                vh.Clear();
                vh.AddUIVertexTriangleStream(vertexList);
            }
            if (GradientType == TypeHV.VerticaThreeColor)
            {
                ModifyVertices(vh);
            }
        }
        if (IsDrawOutline)
        {
            var verts = new List <UIVertex>();
            vh.GetUIVertexStream(verts);
            var neededCpacity = verts.Count * 2;
            if (verts.Capacity < neededCpacity)
            {
                verts.Capacity = neededCpacity;
            }


            //4point
            var start = 0;
            var end   = verts.Count;
            ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x, Outline_effectDistance.y);
            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x, -Outline_effectDistance.y);
            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x, Outline_effectDistance.y);
            start = end;
            end   = verts.Count;
            ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x, -Outline_effectDistance.y);

            //8point
            switch (ShadowType)
            {
            case OutLineVector.Shadow_4:
                break;

            case OutLineVector.Shadow_8:
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x, 0);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x, 0);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, 0, Outline_effectDistance.y);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, 0, -Outline_effectDistance.y);
                break;

            //16point
            case OutLineVector.Shadow_16:
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x, Outline_effectDistance.y / 2);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x, Outline_effectDistance.y / 2);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x, -Outline_effectDistance.y / 2);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x, -Outline_effectDistance.y / 2);

                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x / 2, Outline_effectDistance.y);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, -Outline_effectDistance.x / 2, -Outline_effectDistance.y);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x / 2, Outline_effectDistance.y);
                start = end;
                end   = verts.Count;
                ApplyShadowZeroAlloc(verts, Outline_effectColor, start, verts.Count, Outline_effectDistance.x / 2, -Outline_effectDistance.y);
                break;
            }

            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
        }



        if (IsDrawShadow)
        {
            var verts = new List <UIVertex>();
            vh.GetUIVertexStream(verts);
            var neededCpacity = verts.Count * 2;
            if (verts.Capacity < neededCpacity)
            {
                verts.Capacity = neededCpacity;
            }
            //4点绘制
            var start = 0;
            var end   = verts.Count;
            ApplyShadowZeroAlloc(verts, Shadow_effectColor, start, verts.Count, Shadow_effectDistance.x, Shadow_effectDistance.y);

            vh.Clear();
            vh.AddUIVertexTriangleStream(verts);
        }
    }
        /// <summary>
        /// Update the UI renderer mesh.
        /// </summary>
        protected override void OnPopulateMesh(Mesh toFill)
        {
            List<UIVertex> vbo = new List<UIVertex>();
            using (var helper = new VertexHelper(toFill))
            {
                helper.GetUIVertexStream(vbo);
            }

            switch (type)
            {
                case Type.Simple:
                    GenerateSimpleSprite(vbo, m_PreserveAspect);
                    break;
                case Type.Sliced:
                    GenerateSlicedSprite(vbo);
                    break;
                case Type.Tiled:
                    GenerateTiledSprite(vbo);
                    break;
                case Type.Filled:
                    GenerateFilledSprite(vbo, m_PreserveAspect);
                    break;
            }

            using (var helper = new VertexHelper())
            {
                helper.AddUIVertexTriangleStream(vbo);
                helper.FillMesh(toFill);
            }
        }
Beispiel #30
0
        public override void ModifyMesh(VertexHelper vh)
        {
#endif
            if (!this.IsActive())
            {
                return;
            }

            if (mySettings == null)
            {
                FindParentSettings();
            }

            if (mySettings == null || !mySettings.enabled)
            {
                return;
            }

            //check for changes in text font material that would mean a retesselation in required to get fresh UV's
            CheckTextFontMaterial();

            //if curving or tesselation is required, we'll run the code to calculate vertices.
            if (tesselationRequired || curvingRequired || SavedVertexHelper == null || SavedVertexHelper.currentVertCount == 0)
            {
                //Debug.Log("updating: tes:" + tesselationRequired + ", crv:" + curvingRequired, this.gameObject);
                //Get vertices from the vertex stream. These come as triangles.
                SavedVerteees = new List <UIVertex>();
                vh.GetUIVertexStream(SavedVerteees);

                // calls the old ModifyVertices which was used on pre 5.2.
                ModifyVerts(SavedVerteees);

                //create or reuse our temp vertexhelper
                if (SavedVertexHelper == null)
                {
                    SavedVertexHelper = new VertexHelper();
                }
                else
                {
#if UNITY_5_2_0 || UNITY_5_2_1
                    SavedVertexHelper = new VertexHelper();
#else
                    SavedVertexHelper.Clear();
#endif
                }


                //Save our tesselated and curved vertices to new vertex helper. They can come as quads or as triangles.
                if (SavedVerteees.Count % 4 == 0)
                {
                    for (int i = 0; i < SavedVerteees.Count; i += 4)
                    {
                        SavedVertexHelper.AddUIVertexQuad(new UIVertex[] {
                            SavedVerteees[i + 0], SavedVerteees[i + 1], SavedVerteees[i + 2], SavedVerteees[i + 3],
                        });
                    }
                }
                else
                {
                    SavedVertexHelper.AddUIVertexTriangleStream(SavedVerteees);
                }

                //download proper vertex stream to a list we're going to save
                SavedVertexHelper.GetUIVertexStream(SavedVerteees);
                curvingRequired = false;
            }

            //copy the saved verts list to current VertexHelper
#if UNITY_5_2_0 || UNITY_5_2_1
            vh = new VertexHelper();
            vh.AddUIVertexTriangleStream(SavedVerteees);
            vh.FillMesh(mesh);
#else
            vh.Clear();
            vh.AddUIVertexTriangleStream(SavedVerteees);
#endif
        }
        /// <summary>
        /// Update the UI renderer mesh.
        /// </summary>

        protected override void OnPopulateMesh(VertexHelper vh)
        {
            List<UIVertex> vbo = new List<UIVertex>();
            vh.GetUIVertexStream(vbo);

            switch (type)
            {
                case Type.Simple:
                    GenerateSimpleSprite(vbo, m_PreserveAspect);
                    break;
                case Type.Sliced:
                    GenerateSlicedSprite(vbo);
                    break;
                case Type.Tiled:
                    GenerateTiledSprite(vbo);
                    break;
                case Type.Filled:
                    GenerateFilledSprite(vbo, m_PreserveAspect);
                    break;
            }
            vh.Clear();
            vh.AddUIVertexTriangleStream(vbo);
        }
Beispiel #32
0
    //public Color32 topColor = Color.white;
    //public Color32 bottomColor = Color.black;

    //public override void ModifyMesh(VertexHelper helper)
    //{
    //    if (!this.IsActive() || helper.currentVertCount == 0)
    //        return;

    //    List<UIVertex> vertexs = new List<UIVertex>();
    //    helper.GetUIVertexStream(vertexs);

    //    float bottomY = vertexs[0].position.y;
    //    float topY = vertexs[0].position.y;

    //    for (int i = 1; i < vertexs.Count; i++)
    //    {
    //        float y = vertexs[i].position.y;
    //        if (y > topY)
    //        {
    //            topY = y;
    //        }
    //        else if (y < bottomY)
    //        {
    //            bottomY = y;
    //        }
    //    }

    //    float uiElementHeight = topY - bottomY;

    //    UIVertex v = new UIVertex();

    //    for (int i = 0; i < helper.currentVertCount; i++)
    //    {
    //        helper.PopulateUIVertex(ref v, i);
    //        v.color = Color32.Lerp(bottomColor, topColor, (v.position.y - bottomY) / uiElementHeight);
    //        helper.SetUIVertex(v, i);
    //    }
    //}
    public override void ModifyMesh(VertexHelper vh)
    {
        if (!IsActive() || mGradient == null)
        {
            return;
        }

        List <UIVertex> vertexList = new List <UIVertex>();

        vh.GetUIVertexStream(vertexList);

        if (vertexList == null || vertexList.Count == 0)
        {
            return;
        }

        float leftX  = vertexList[0].position.x;
        float rightX = vertexList[0].position.x;

        float bottomY = vertexList[0].position.y;
        float topY    = vertexList[0].position.y;

        for (int i = 1; i < vertexList.Count; i++)
        {
            float y = vertexList[i].position.y;
            if (y > topY)
            {
                topY = y;
            }
            else if (y < bottomY)
            {
                bottomY = y;
            }

            float x = vertexList[i].position.x;
            if (x > rightX)
            {
                rightX = x;
            }
            else if (x < leftX)
            {
                leftX = x;
            }
        }

        for (int i = 0; i < vertexList.Count; i++)
        {
            UIVertex uiVertex = vertexList[i];
            if (mDirection == Direction.Vertical)
            {
                uiVertex.color = mGradient.Evaluate((uiVertex.position.y - bottomY) / (topY - bottomY));
            }
            else
            {
                uiVertex.color = mGradient.Evaluate((uiVertex.position.x - leftX) / (rightX - leftX));
            }
            vertexList[i] = uiVertex;
        }

        vh.Clear();
        vh.AddUIVertexTriangleStream(vertexList);
    }