private void Fill() { if (mesh == null) { mesh = new Mesh(); } meshFilter.mesh = mesh; float glWidth = f3Rect.rect.width / 2; float glHeight = f3Rect.rect.height / 2; vertexHelper.Clear(); spriteData = altas.GetSpriteData(spriteName); AddVert(new Vector3(-glWidth, -glHeight, 0), Color.white, spriteData.UV0(altas.rect)); AddVert(new Vector3(-glWidth, glHeight, 0), Color.white, spriteData.UV1(altas.rect)); AddVert(new Vector3(glWidth, -glHeight, 0), Color.white, spriteData.UV2(altas.rect)); AddVert(new Vector3(glWidth, glHeight, 0), Color.white, spriteData.UV3(altas.rect)); AddTriangle(0, 1, 2); AddTriangle(2, 3, 1); Apply(mesh, vertexHelper); }
public void GetPos(Texture2D texture2D, ref int x, ref int y) { int minx = 0, miny = 0; int maxx = text2d.width, maxy = text2d.height; if (list.Count == 0) { x = 0; y = 0; return; } for (int i = 0; i < list.Count; i++) { if (x < minx || x < miny) { break; } if (x + texture2D.width >= maxx) { x = 0; F3SpriteData leftSprite = list.FindLast((tex) => { return(tex.x == 0); }); y = leftSprite.y + leftSprite.height; } else { F3SpriteData lastSprite = list[list.Count - 1]; x = lastSprite.x + lastSprite.width; y = lastSprite.y; } if (y + texture2D.height >= maxy) { Debug.LogError("Max out"); return; } } }
public void AddTexture(string name, Texture2D texture, ref int posx, ref int posy) { F3SpriteData f3SpriteData = new F3SpriteData(); f3SpriteData.name = name; f3SpriteData.width = texture.width; f3SpriteData.height = texture.height; f3SpriteData.x = posx; f3SpriteData.y = posy; try { Graphics.CopyTexture(texture, 0, 0, 0, 0, texture.width, texture.height, text2d, 0, 0, f3SpriteData.x, f3SpriteData.y); } catch { Debug.Log(f3SpriteData.name + " == " + f3SpriteData.x + " : " + f3SpriteData.y + " ::: " + f3SpriteData.width + " : " + f3SpriteData.height); } posx += texture.width; list.Add(f3SpriteData); }
public void OnFill() { float glWidth = rectTransform.rect.width / 2; float glHeight = rectTransform.rect.height / 2; F3FakeDrawcall.Instance.position.Add((transform.localToWorldMatrix * (new Vector4(-glWidth, -glHeight, 0, 1)))); F3FakeDrawcall.Instance.position.Add((transform.localToWorldMatrix * (new Vector4(-glWidth, glHeight, 0, 1)))); F3FakeDrawcall.Instance.position.Add((transform.localToWorldMatrix * (new Vector4(glWidth, -glHeight, 0, 1)))); F3FakeDrawcall.Instance.position.Add((transform.localToWorldMatrix * (new Vector4(glWidth, glHeight, 0, 1)))); F3FakeDrawcall.Instance.color.Add(mColor); F3FakeDrawcall.Instance.color.Add(mColor); F3FakeDrawcall.Instance.color.Add(mColor); F3FakeDrawcall.Instance.color.Add(mColor); spriteData = altas.GetSpriteData(spriteName); F3FakeDrawcall.Instance.uvs.Add(spriteData.UV0(altas.rect)); F3FakeDrawcall.Instance.uvs.Add(spriteData.UV1(altas.rect)); F3FakeDrawcall.Instance.uvs.Add(spriteData.UV2(altas.rect)); F3FakeDrawcall.Instance.uvs.Add(spriteData.UV3(altas.rect)); F3FakeDrawcall.Instance.meshRenderer.sharedMaterial = altas.material; }