public void UpdateSubmesh(bool tesselate, bool curve) { TMP_SubMeshUI TMPsub = gameObject.GetComponent <TMP_SubMeshUI>(); if (TMPsub == null) { return; } CurvedUIVertexEffect crvdVE = gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); if (tesselate || savedMesh == null || vh == null || (!Application.isPlaying)) { vh = new VertexHelper(TMPsub.mesh); ModifyMesh(crvdVE); savedMesh = new Mesh(); vh.FillMesh(savedMesh); crvdVE.TesselationRequired = true; } else if (curve) { ModifyMesh(crvdVE); vh.FillMesh(savedMesh); crvdVE.CurvingRequired = true; } TMPsub.canvasRenderer.SetMesh(savedMesh); }
public void UpdateSubmesh(bool tesselate, bool curve) { //find required components if (TMPsub == null) { TMPsub = gameObject.GetComponent <TMP_SubMeshUI>(); } if (TMPsub == null) { return; } if (TMPtext == null) { TMPtext = GetComponentInParent <TextMeshProUGUI>(); } if (crvdVE == null) { crvdVE = gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); } //perform tesselatio and curving if (tesselate || straightMesh == null || vh == null || (!Application.isPlaying)) { vh = new VertexHelper(TMPsub.mesh); //save straight mesh - it will be curved then every time the object moves on the canvas. straightMesh = new Mesh(); vh.FillMesh(straightMesh); curve = true; } if (curve) { //Debug.Log("Submesh: Curve", this.gameObject); vh = new VertexHelper(straightMesh); crvdVE.ModifyMesh(vh); curvedMesh = new Mesh(); vh.FillMesh(curvedMesh); crvdVE.CurvingRequired = true; } //upload mesh to TMP object's renderer TMPsub.canvasRenderer.SetMesh(curvedMesh); //cleanup for not needed submeshes. if (TMPtext != null && TMPtext.textInfo.materialCount < 2) { //Each submesh uses 1 additional material. //If materialCount is 1, this means Submesh is not needed. Bounce it to toggle cleanup. TMPsub.enabled = false; TMPsub.enabled = true; } }
void ModifyMesh(CurvedUIVertexEffect crvdVE) { #if UNITY_5_1 crvdVE.ModifyMesh(vh.GetUIVertexStream); #else crvdVE.ModifyMesh(vh); #endif }
void DiscoverTMP() { if (this.GetComponent <TextMeshProUGUI>() != null) { tmp = this.gameObject.GetComponent <TextMeshProUGUI>(); crvdVE = this.gameObject.GetComponent <CurvedUIVertexEffect>(); mySettings = GetComponentInParent <CurvedUISettings>(); transform.hasChanged = false; } }
private void FindTMP() { if (base.GetComponent <TextMeshProUGUI>() != null) { this.tmp = base.gameObject.GetComponent <TextMeshProUGUI>(); this.crvdVE = base.gameObject.GetComponent <CurvedUIVertexEffect>(); this.mySettings = base.GetComponentInParent <CurvedUISettings>(); base.transform.hasChanged = false; this.FindSubmeshes(); } }
public void UpdateSubmesh(bool tesselate, bool curve) { if (TMPsub == null) { TMPsub = gameObject.GetComponent <TMP_SubMeshUI>(); } if (TMPsub == null) { return; } if (crvdVE == null) { crvdVE = gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); } if (tesselate || straightMesh == null || vh == null || (!Application.isPlaying)) { //Debug.Log("Submesh: tesselate", this.gameObject); vh = new VertexHelper(TMPsub.mesh); //save straight mesh - it will be curved then every time the object moves on the canvas. straightMesh = new Mesh(); vh.FillMesh(straightMesh); //we do it differently now //curve and save mesh //crvdVE.ModifyMesh(vh); //curvedMesh = new Mesh(); //vh.FillMesh(curvedMesh); curve = true; } if (curve) { //Debug.Log("Submesh: Curve", this.gameObject); vh = new VertexHelper(straightMesh); crvdVE.ModifyMesh(vh); curvedMesh = new Mesh(); vh.FillMesh(curvedMesh); crvdVE.CurvingRequired = true; } TMPsub.canvasRenderer.SetMesh(curvedMesh); }
public void UpdateSubmesh(bool tesselate, bool curve) { TMP_SubMeshUI component = base.gameObject.GetComponent <TMP_SubMeshUI>(); if (component != null) { CurvedUIVertexEffect crvdVE = base.gameObject.AddComponentIfMissing <CurvedUIVertexEffect>(); if (tesselate || ((this.savedMesh == null) || ((this.vh == null) || !Application.isPlaying))) { this.vh = new VertexHelper(component.mesh); this.ModifyMesh(crvdVE); this.savedMesh = new Mesh(); this.vh.FillMesh(this.savedMesh); crvdVE.TesselationRequired = true; } else if (curve) { this.ModifyMesh(crvdVE); this.vh.FillMesh(this.savedMesh); crvdVE.CurvingRequired = true; } component.canvasRenderer.SetMesh(this.savedMesh); } }
private void ModifyMesh(CurvedUIVertexEffect crvdVE) { crvdVE.ModifyMesh(this.vh); }