IEnumerator Animation() { TMP_TextInfo textInfo = text.textInfo; for (int i = 0; i < textContent.Length; i++) // fills the TMP with text { text.text += textContent.Substring(i, 1); yield return(new WaitForSeconds(0.25f)); } while (true) // loops through the text to add an effect { int charCount = textInfo.characterCount; for (int i = 0; i < charCount; i++) { TMP_CharacterInfo charInfo = textInfo.characterInfo[i]; if (!charInfo.isVisible) { continue; } text.text = textContent.Insert(i, startString[i % 2]).Insert(i + startString[i % 2].Length + 1, endString[i % 2]); yield return(new WaitForSeconds(0.25f)); } Array.Reverse(startString); Array.Reverse(endString); } }
void Update() { tmpText.ForceMeshUpdate(); mesh = tmpText.mesh; vertices = mesh.vertices; //for(int i =0; i < vertices.Length; i++) //{ // Vector3 offset = Wobble(Time.time + 1); // vertices[i] += offset; //} for (int i = 0; i < tmpText.textInfo.characterCount; i++) { TMP_CharacterInfo c = tmpText.textInfo.characterInfo[i]; if (!c.isVisible) { continue; } int idx = c.vertexIndex; Vector3 offset = Wobble(Time.time + i); for (int j = 0; j < 4; j++) { vertices[idx + j] += offset; } } mesh.vertices = vertices; tmpText.canvasRenderer.SetMesh(mesh); }
/// <summary> /// It turns out charInfo.index is the actual character position in the string /// If you have tags like <color> etc. it will be included in the index. /// Therefore we need to pass in the actual index from our loop here. /// </summary> /// <param name="charInfo">charInfo struct for character being modified</param> /// <param name="index">index of the character. This is excluding characters in tags.</param> private void ApplyTransforms(TMP_CharacterInfo charInfo, int index) { var materialIndex = charInfo.materialReferenceIndex; var vertexIndex = charInfo.vertexIndex; //Do Vertices var sourceVertices = meshCache[materialIndex].vertices; var sourceBottomLeft = sourceVertices[vertexIndex + 0]; var sourceTopLeft = sourceVertices[vertexIndex + 1]; var sourceTopRight = sourceVertices[vertexIndex + 2]; var sourceBottomRight = sourceVertices[vertexIndex + 3]; var offset = sourceBottomLeft + (sourceBottomRight - sourceBottomLeft) * pivot.x + (sourceTopLeft - sourceBottomLeft) * pivot.y; var anim = effectDatas[index]; var matrix = Matrix4x4.TRS(anim.localPosition, anim.localRotation, anim.localScale); var destinationTopLeft = matrix.MultiplyPoint3x4(sourceTopLeft - offset) + offset; var destinationTopRight = matrix.MultiplyPoint3x4(sourceTopRight - offset) + offset; var destinationBottomLeft = matrix.MultiplyPoint3x4(sourceBottomLeft - offset) + offset; var destinationBottomRight = matrix.MultiplyPoint3x4(sourceBottomRight - offset) + offset; var destinationVertices = text.textInfo.meshInfo[materialIndex].vertices; destinationVertices[vertexIndex + 0] = destinationBottomLeft; destinationVertices[vertexIndex + 1] = destinationTopLeft; destinationVertices[vertexIndex + 2] = destinationTopRight; destinationVertices[vertexIndex + 3] = destinationBottomRight; }
/// <summary> /// It turns out charInfo.index is the actual character position in the string /// If you have tags like <color> etc. it will be included in the index. /// Therefore we need to pass in the actual index from our loop here. /// </summary> /// <param name="charInfo">charInfo struct for character being modified</param> /// <param name="index">index of the character. This is excluding characters in tags.</param> private void ApplyColors(TMP_CharacterInfo charInfo, int index) { var materialIndex = charInfo.materialReferenceIndex; var vertexIndex = charInfo.vertexIndex; var effect = effectDatas[index]; var sourceColors = meshCache[materialIndex].colors32; var colorBottomLeft = sourceColors[vertexIndex + 0]; var colorTopLeft = sourceColors[vertexIndex + 1]; var colorTopRight = sourceColors[vertexIndex + 2]; var colorBottomRight = sourceColors[vertexIndex + 3]; colorBottomLeft.a = effect.color0.a; colorTopLeft.a = effect.color1.a; colorTopRight.a = effect.color2.a; colorBottomRight.a = effect.color3.a; var destinationColors = text.textInfo.meshInfo[materialIndex].colors32; destinationColors[vertexIndex + 0] = colorBottomLeft; destinationColors[vertexIndex + 1] = colorTopLeft; destinationColors[vertexIndex + 2] = colorTopRight; destinationColors[vertexIndex + 3] = colorBottomRight; }
private void ResetVertices() { if (_cachedMeshInfo == null) { return; } TMP_TextInfo textInfo = _textComponent.textInfo; for (int i = 0; i < textInfo.characterCount; i++) { TMP_CharacterInfo charInfo = textInfo.characterInfo[i]; int materialIndex = charInfo.materialReferenceIndex; Vector3[] destinationVertices = textInfo.meshInfo[materialIndex].vertices; int vertexIndex = charInfo.vertexIndex; for (int j = 0; j < 4; j++) { Vector3 original = _cachedMeshInfo[materialIndex].vertices[vertexIndex + j]; destinationVertices[vertexIndex + j] = original; } } for (int i = 0; i < textInfo.meshInfo.Length; i++) { TMP_MeshInfo meshInfo = textInfo.meshInfo[i]; meshInfo.mesh.vertices = meshInfo.vertices; _textComponent.UpdateGeometry(meshInfo.mesh, i); } }
private void split() { textObj.enableAutoSizing = false; for (int i = 0; i < textObj.textInfo.characterInfo.Length; i++) { TMP_CharacterInfo character = textObj.textInfo.characterInfo[i]; if (character.character.Equals(' ')) { continue; } TextMeshPro characterTMP = Instantiate(characterPrefab); characterTMP.text = character.character.ToString(); Vector3 topLeft = textObj.transform.TransformPoint(character.topLeft); Vector3 bottomRight = textObj.transform.TransformPoint(character.bottomRight); Rect rect = new Rect(topLeft.x, topLeft.y, Mathf.Abs(topLeft.x - bottomRight.x), Mathf.Abs(topLeft.y - bottomRight.y)); characterTMP.rectTransform.position = rect.center; characterTMP.rectTransform.sizeDelta = new Vector2(rect.width, rect.height); characterTMP.GetComponent <BoxCollider2D>().size = new Vector2(rect.width, rect.height); characterTMP.GetComponent <Rigidbody2D>().velocity = textObj.GetComponent <Rigidbody2D>().velocity; //characterTMP.gameObject.AddComponent<BoxCollider2D>(); //characterTMP.gameObject.AddComponent<Rigidbody2D>(); } launched = false; Destroy(textObj.gameObject); }
public void Update() { Mesh mesh = textMesh.mesh; Vector3[] vertices = mesh.vertices; TMP_TextInfo textInfo = textMesh.textInfo; float time = Time.unscaledTime; float charsCount = endIndex - startIndex; float cos = Mathf.Cos(time * ONE_SECOND_FREQUENCY * frequency); float angle = cos * amplitude; Matrix4x4 matrix = Matrix4x4.Rotate(Quaternion.Euler(0, 0, angle)); for (int i = 0; i < charsCount; i++) { int characterIndex = i + startIndex; TMP_CharacterInfo charInfo = textInfo.characterInfo[characterIndex]; if (!charInfo.isVisible) { continue; } int vertexIndex = charInfo.vertexIndex; TMProHelpers.ApplyMatrixToChar(vertices, vertexIndex, matrix); } mesh.vertices = vertices; textMesh.canvasRenderer.SetMesh(mesh); }
public void OnClick() { TMP_InputField field = GetComponentInChildren <TMP_InputField>(); if (field != null && OnClickAction != null) { TMP_TextInfo generatr = field.textComponent.textInfo; for (int i = 0; i < generatr.characterCount; i++) { TMP_CharacterInfo info = generatr.characterInfo[i]; #if BUILD_TYPE_DEBUG Debug.Log(i + " / " + "characterCount = " + info.pointSize); #endif if (info.pointSize == 0) { //文字幅がないものは表示できないフォントなのでエラー表示 Dialog newDialog = newDialog = Dialog.Create(DialogType.DialogOK); newDialog.SetDialogText(DialogTextType.OKText, GameTextUtil.GetText("common_button1")); newDialog.SetDialogText(DialogTextType.Title, GameTextUtil.GetText("error_response_title69")); newDialog.SetDialogTextFromTextkey(DialogTextType.MainText, "error_response_content69"); newDialog.SetDialogEvent(DialogButtonEventType.OK, new System.Action(() => { })); newDialog.DisableCancelButton(); newDialog.Show(); return; } } OnClickAction(field.text); } }
public void Update() { Mesh mesh = textMesh.mesh; Vector3[] vertices = mesh.vertices; float time = Time.unscaledTime; float charsCount = endIndex - startIndex; float cycleTime = (2 * Mathf.PI) * length; float cycleTimePerChild = cycleTime / charsCount; for (int i = 0; i < charsCount; i++) { int characterIndex = i + startIndex; TMP_CharacterInfo charInfo = textMesh.textInfo.characterInfo[characterIndex]; float childOffset = cycleTimePerChild * i; float t = (time * frequency) + childOffset; Vector2 newTranslate = new Vector2(0, amplitude * Mathf.Cos(t)); Vector3 sumTranslate = newTranslate; if (!charInfo.isVisible) { continue; } int vertexIndex = charInfo.vertexIndex; vertices[vertexIndex + 0] += sumTranslate; vertices[vertexIndex + 1] += sumTranslate; vertices[vertexIndex + 2] += sumTranslate; vertices[vertexIndex + 3] += sumTranslate; } mesh.vertices = vertices; textMesh.canvasRenderer.SetMesh(mesh); }
public void Update() { Mesh mesh = textMesh.mesh; Vector3[] vertices = mesh.vertices; float time = Time.unscaledTime; TMP_TextInfo textInfo = textMesh.textInfo; float charsCount = endIndex - startIndex; for (int i = 0; i < charsCount; i++) { int characterIndex = i + startIndex; TMP_CharacterInfo charInfo = textInfo.characterInfo[characterIndex]; if (!charInfo.isVisible) { continue; } Vector3 offset = charactersWiggleList[i].GetWiggle(amplitude, frequency, time); int vertexIndex = charInfo.vertexIndex; vertices[vertexIndex + 0] += offset; vertices[vertexIndex + 1] += offset; vertices[vertexIndex + 2] += offset; vertices[vertexIndex + 3] += offset; } mesh.vertices = vertices; textMesh.canvasRenderer.SetMesh(mesh); }
private void UpdateCharColors() { // If no color tweens have been created then the list of proxies will not exist if (proxyColorList == null) { return; } for (var i = proxyColorList.Count - 1; i >= 0; i--) { ProxyColor proxy = proxyColorList[i]; if (proxy.CharIndex >= characterCount) { continue; } TMP_CharacterInfo charInfo = Text.textInfo.characterInfo[proxy.CharIndex]; if (!charInfo.isVisible || !proxy.IsModified) { continue; } int materialIndex = charInfo.materialReferenceIndex; int vertexIndex = charInfo.vertexIndex; Color32[] destinationColors = Text.textInfo.meshInfo[materialIndex].colors32; destinationColors[vertexIndex + 1] = proxy.ColorGradient.topLeft; destinationColors[vertexIndex + 2] = proxy.ColorGradient.topRight; destinationColors[vertexIndex + 0] = proxy.ColorGradient.bottomLeft; destinationColors[vertexIndex + 3] = proxy.ColorGradient.bottomRight; } }
public bool ShouldRenderCharacter(TMP_CharacterInfo info) { return( (info.character != ' ') && (info.character != '\n') && (info.bottomLeft.x < info.topRight.x) && (info.bottomLeft.y < info.topRight.y)); }
public ProxyTransform(Transform target, Transform parent, TMP_CharacterInfo charInfo) { Tweens = new List <Tween>(); this.target = target; this.parent = parent; AssignCharInfo(charInfo); Target.localPosition = Vector3.zero; }
private void OffsetCharacter(int index, TMP_CharacterInfo info, ref Vector3[] verts) { var offset = Vector3.zero.WhereY(Mathf.Sin(Time.time * speed + index * 0.5f) * amount); verts[info.vertexIndex] += offset; verts[info.vertexIndex + 1] += offset; verts[info.vertexIndex + 2] += offset; verts[info.vertexIndex + 3] += offset; }
public void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data) { var t = Mathf.Clamp01(progress - data.index); t = EaseFunctions.Ease(easeType, t); var delta = endOffset - startOffset; data.localPosition = startOffset + delta * t; }
public override void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data) { var t = Mathf.Clamp01(progress - data.Index); t = EaseFunctions.Ease(easeType, t); var delta = endScale - startScale; data.LocalScale = startScale + delta * t; }
public void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data) { var t = Mathf.Clamp01(progress - data.index); t = EaseFunctions.Ease(easeType, t); var delta = endScale - startScale; data.localScale = startScale + delta * t; //Vector3.Lerp(startScale, endScale, t ); }
public Character(TMP_CharacterInfo characterInfo, TMP_MeshInfo meshInfo) { vertexIndex = characterInfo.vertexIndex; baseVertices = new MeshVertices( topLeft: meshInfo.vertices[vertexIndex + 1], topRight: meshInfo.vertices[vertexIndex + 2], bottomLeft: meshInfo.vertices[vertexIndex + 0], bottomRight: meshInfo.vertices[vertexIndex + 3] ); }
public void ChangeLinkColor(int startIndex, int length, Color32 color) { for (int i = startIndex; i < startIndex + length; i++) { TMP_CharacterInfo cInfo = m_TextComponent.textInfo.characterInfo[i]; ChangeLetterColor(m_TextComponent, cInfo, color); } // Update Geometry m_TextComponent.UpdateVertexData(TMP_VertexDataUpdateFlags.All); }
public void UpdateVertexEffect(TMP_CharacterInfo charInfo, ref EffectData data) { var t = Mathf.PI * time; var offset = Mathf.PI * data.index * period; Vector3 pt; pt.x = Mathf.Cos(t + offset) * amplitude.x; pt.y = Mathf.Sin(t + offset) * amplitude.y; pt.z = 0; data.localPosition = pt; }
public void ChangeLetterColor(TextMeshProUGUI textMeshPro, TMP_CharacterInfo cInfo, Color32 color) { // Get a reference to the vertex color Color32[] vertexColors = textMeshPro.textInfo.meshInfo[cInfo.materialReferenceIndex].colors32; originalColor = vertexColors[cInfo.vertexIndex + 0]; vertexColors[cInfo.vertexIndex + 0] = color; vertexColors[cInfo.vertexIndex + 1] = color; vertexColors[cInfo.vertexIndex + 2] = color; vertexColors[cInfo.vertexIndex + 3] = color; }
public void ChangeWordColor(TextMeshProUGUI textMeshPro, TMP_WordInfo wInfo, Color32 color) { for (int i = 0; i < wInfo.characterCount; i++) { int characterIndex = wInfo.firstCharacterIndex + i; TMP_CharacterInfo cInfo = textMeshPro.textInfo.characterInfo[characterIndex]; ChangeLetterColor(textMeshPro, cInfo, color); } // Update Geometry textMeshPro.UpdateVertexData(TMP_VertexDataUpdateFlags.All); }
public void ChangeWordColor(TMP_WordInfo wInfo, Color32 color) { for (int i = 0; i < wInfo.characterCount; i++) { int characterIndex = wInfo.firstCharacterIndex + i; TMP_CharacterInfo cInfo = m_TextComponent.textInfo.characterInfo[characterIndex]; ChangeLetterColor(m_TextComponent, cInfo, color); } // Update Geometry m_TextComponent.UpdateVertexData(TMP_VertexDataUpdateFlags.All); }
private List <RectTransform> ChangeWordToChars(string word) { if (!commandPrefix.text.Contains(word)) { Debug.LogError($"\"{word}\" not found in string!"); return(null); } TMP_TextInfo textInfo = commandPrefix.textInfo; Debug.Log("First 3 chars of text info are: " + textInfo.characterInfo[0].character + textInfo.characterInfo[1].character + textInfo.characterInfo[2].character); List <RectTransform> charList = new List <RectTransform>(); string commandText = commandPrefix.text; int wordIndex = commandText.IndexOf(word); int charCount = textInfo.characterCount; Debug.Log($"cText: {commandText}, wIndex: {wordIndex}, cCount: {charCount}"); //The Y of the first letter, making sure every letter is on the right height TMP_CharacterInfo tempCInfo = textInfo.characterInfo[0]; float firstY = VectorExtensions.Center(commandPrefix.transform.TransformPoint(tempCInfo.topRight), commandPrefix.transform.TransformPoint(tempCInfo.bottomLeft)).y; for (int i = wordIndex; i < charCount; i++) { TMP_CharacterInfo cInfo = textInfo.characterInfo[i]; if (!cInfo.isVisible) { continue; } //Gets the center of the letter Vector3 bottomLeft = commandPrefix.transform.TransformPoint(cInfo.bottomLeft); Vector3 topRight = commandPrefix.transform.TransformPoint(cInfo.topRight); Vector3 center = VectorExtensions.Center(topRight, bottomLeft); center.y = firstY; //Spawn the characters TextMeshProUGUI obj = Instantiate(charPrefab, center, Quaternion.identity); string c = cInfo.character.ToString(); obj.name = c; obj.text = c; obj.transform.parent = commandPrefix.transform; obj.transform.localScale = Vector3.one; charList.Add((RectTransform)obj.transform); } commandPrefix.text = commandText.Remove(wordIndex); return(charList); }
public override void WrapAroundPlanetSurface() { this.textMesh.ForceMeshUpdate(); TMP_TextInfo textInfo = this.textMesh.textInfo; int characterCount = textInfo.characterCount; if (characterCount == 0) { return; } float num = this.textMesh.bounds.extents.x * 2f; float num2 = Find.WorldGrid.DistOnSurfaceToAngle(num); Matrix4x4 localToWorldMatrix = this.textMesh.transform.localToWorldMatrix; Matrix4x4 worldToLocalMatrix = this.textMesh.transform.worldToLocalMatrix; for (int i = 0; i < characterCount; i++) { TMP_CharacterInfo tMP_CharacterInfo = textInfo.characterInfo[i]; if (tMP_CharacterInfo.isVisible) { int materialReferenceIndex = this.textMesh.textInfo.characterInfo[i].materialReferenceIndex; int vertexIndex = tMP_CharacterInfo.vertexIndex; Vector3 vector = this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] + this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] + this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] + this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3]; vector /= 4f; float num3 = vector.x / (num / 2f); bool flag = num3 >= 0f; num3 = Mathf.Abs(num3); float num4 = num2 / 2f * num3; float num5 = (180f - num4) / 2f; float num6 = 200f * Mathf.Tan(num4 / 2f * 0.0174532924f); Vector3 vector2 = new Vector3(Mathf.Sin(num5 * 0.0174532924f) * num6 * ((!flag) ? -1f : 1f), vector.y, Mathf.Cos(num5 * 0.0174532924f) * num6); Vector3 b = vector2 - vector; Vector3 vector3 = this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] + b; Vector3 vector4 = this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] + b; Vector3 vector5 = this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] + b; Vector3 vector6 = this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3] + b; Quaternion rotation = Quaternion.Euler(0f, num4 * ((!flag) ? 1f : -1f), 0f); vector3 = rotation * (vector3 - vector2) + vector2; vector4 = rotation * (vector4 - vector2) + vector2; vector5 = rotation * (vector5 - vector2) + vector2; vector6 = rotation * (vector6 - vector2) + vector2; vector3 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(vector3).normalized *(100f + WorldAltitudeOffsets.WorldText)); vector4 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(vector4).normalized *(100f + WorldAltitudeOffsets.WorldText)); vector5 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(vector5).normalized *(100f + WorldAltitudeOffsets.WorldText)); vector6 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(vector6).normalized *(100f + WorldAltitudeOffsets.WorldText)); this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] = vector3; this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] = vector4; this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] = vector5; this.textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3] = vector6; } } this.textMesh.UpdateVertexData(TMP_VertexDataUpdateFlags.All); }
public override void WrapAroundPlanetSurface() { textMesh.ForceMeshUpdate(); TMP_TextInfo textInfo = textMesh.textInfo; int characterCount = textInfo.characterCount; if (characterCount == 0) { return; } float num = textMesh.bounds.extents.x * 2f; float num2 = Find.WorldGrid.DistOnSurfaceToAngle(num); Matrix4x4 localToWorldMatrix = textMesh.transform.localToWorldMatrix; Matrix4x4 worldToLocalMatrix = textMesh.transform.worldToLocalMatrix; for (int i = 0; i < characterCount; i++) { TMP_CharacterInfo tMP_CharacterInfo = textInfo.characterInfo[i]; if (tMP_CharacterInfo.isVisible) { int materialReferenceIndex = textMesh.textInfo.characterInfo[i].materialReferenceIndex; int vertexIndex = tMP_CharacterInfo.vertexIndex; Vector3 b = textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] + textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] + textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] + textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3]; b /= 4f; float num3 = b.x / (num / 2f); bool flag = num3 >= 0f; num3 = Mathf.Abs(num3); float num4 = num2 / 2f * num3; float num5 = (180f - num4) / 2f; float num6 = 200f * Mathf.Tan(num4 / 2f * ((float)Math.PI / 180f)); Vector3 vector = new Vector3(Mathf.Sin(num5 * ((float)Math.PI / 180f)) * num6 * (flag ? 1f : (-1f)), b.y, Mathf.Cos(num5 * ((float)Math.PI / 180f)) * num6); Vector3 b2 = vector - b; Vector3 a = textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] + b2; Vector3 a2 = textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] + b2; Vector3 a3 = textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] + b2; Vector3 a4 = textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3] + b2; Quaternion rotation = Quaternion.Euler(0f, num4 * (flag ? (-1f) : 1f), 0f); a = rotation * (a - vector) + vector; a2 = rotation * (a2 - vector) + vector; a3 = rotation * (a3 - vector) + vector; a4 = rotation * (a4 - vector) + vector; a = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(a).normalized *(100f + WorldAltitudeOffsets.WorldText)); a2 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(a2).normalized *(100f + WorldAltitudeOffsets.WorldText)); a3 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(a3).normalized *(100f + WorldAltitudeOffsets.WorldText)); a4 = worldToLocalMatrix.MultiplyPoint(localToWorldMatrix.MultiplyPoint(a4).normalized *(100f + WorldAltitudeOffsets.WorldText)); textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex] = a; textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 1] = a2; textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 2] = a3; textMesh.textInfo.meshInfo[materialReferenceIndex].vertices[vertexIndex + 3] = a4; } } textMesh.UpdateVertexData(TMP_VertexDataUpdateFlags.All); }
public Vector3 GetCharCenter(TMP_CharacterInfo characterInfo) { Vector3 center = Vector3.zero; float characterWidth = (characterInfo.topRight - characterInfo.topLeft).magnitude; float characterHeight = (characterInfo.topRight - characterInfo.bottomRight).magnitude; center = new Vector3(characterInfo.bottomLeft.x + characterWidth / 2.0f, characterInfo.bottomLeft.y + characterHeight / 2.0f, 0.0f); Debug.Log(center); return(center); }
private void WrapAroundPlanetSurface(TextMeshPro textMesh) { TMP_TextInfo textInfo = textMesh.textInfo; int characterCount = textInfo.characterCount; if (characterCount == 0) { return; } textMesh.ForceMeshUpdate(); Vector3[] vertices = textMesh.mesh.vertices; float num = textMesh.bounds.extents.x * 2f; float num2 = Find.WorldGrid.DistOnSurfaceToAngle(num); for (int i = 0; i < characterCount; i++) { TMP_CharacterInfo tMP_CharacterInfo = textInfo.characterInfo[i]; if (tMP_CharacterInfo.isVisible) { int vertexIndex = tMP_CharacterInfo.vertexIndex; Vector3 vector = vertices[vertexIndex] + vertices[vertexIndex + 1] + vertices[vertexIndex + 2] + vertices[vertexIndex + 3]; vector /= 4f; float num3 = vector.x / (num / 2f); bool flag = num3 >= 0f; num3 = Mathf.Abs(num3); float num4 = num2 / 2f * num3; float num5 = (180f - num4) / 2f; float num6 = 200f * Mathf.Tan(num4 / 2f * 0.0174532924f); Vector3 vector2 = new Vector3(Mathf.Sin(num5 * 0.0174532924f) * num6 * ((!flag) ? -1f : 1f), vector.y, Mathf.Cos(num5 * 0.0174532924f) * num6); vector2 += new Vector3(Mathf.Sin(num4 * 0.0174532924f) * ((!flag) ? -1f : 1f), 0f, -Mathf.Cos(num4 * 0.0174532924f)) * 0.06f; Vector3 b = vector2 - vector; Vector3 vector3 = vertices[vertexIndex] + b; Vector3 vector4 = vertices[vertexIndex + 1] + b; Vector3 vector5 = vertices[vertexIndex + 2] + b; Vector3 vector6 = vertices[vertexIndex + 3] + b; Quaternion rotation = Quaternion.Euler(0f, num4 * ((!flag) ? 1f : -1f), 0f); vector3 = rotation * (vector3 - vector2) + vector2; vector4 = rotation * (vector4 - vector2) + vector2; vector5 = rotation * (vector5 - vector2) + vector2; vector6 = rotation * (vector6 - vector2) + vector2; vertices[vertexIndex] = vector3; vertices[vertexIndex + 1] = vector4; vertices[vertexIndex + 2] = vector5; vertices[vertexIndex + 3] = vector6; } } textMesh.mesh.vertices = vertices; }
private void IncreaseCharactersShown() { charactersShown++; int showCharacters = charactersShown + startIndex; textMesh.maxVisibleCharacters = showCharacters; TMP_TextInfo textInfo = textMesh.textInfo; int shownCharacterIndex = showCharacters - 1; TMP_CharacterInfo charInfo = textInfo.characterInfo[shownCharacterIndex]; sizeCharEffects.Add(new SizeCharEffect( index: charInfo.vertexIndex, startTime: effectTimeElapsed )); }
public void AssignCharInfo(TMP_CharacterInfo charInfo) { charIndex = charInfo.index; if (charInfo.isVisible) { localStartPosition = new Vector3( (charInfo.topLeft.x + charInfo.bottomRight.x) * 0.5f, (charInfo.topLeft.y + charInfo.bottomRight.y) * 0.5f, (charInfo.topLeft.z + charInfo.bottomRight.z) * 0.5f ); } else { localStartPosition = Vector3.zero; } }