/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh, Graphic graphic) { if (!isActiveAndEnabled) { return; } var normalizedIndex = paramTex.GetNormalizedIndex(this); var rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect); // rotation. var rad = m_Rotation * Mathf.Deg2Rad; var dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); dir.x *= rect.height / rect.width; dir = dir.normalized; // Calculate vertex position. var vertex = default(UIVertex); var localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix. for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); Vector2 normalizedPos; connector.GetNormalizedFactor(m_EffectArea, i, localMatrix, vertex.position, out normalizedPos); vertex.uv0 = new Vector2( Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), Packer.ToFloat(normalizedPos.y, normalizedIndex) ); vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } bool isText = isTMPro || graphic is Text; float normalizedIndex = ptex.GetNormalizedIndex(this); // rect. var tex = transitionTexture; var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1; Rect rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect, aspectRatio); // Set prameters to vertex. UIVertex vertex = default(UIVertex); float x, y; int count = vh.currentVertCount; for (int i = 0; i < count; i++) { vh.PopulateUIVertex(ref vertex, i); m_EffectArea.GetPositionFactor(i, rect, vertex.position, isText, isTMPro, out x, out y); vertex.uv0 = new Vector2( Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), Packer.ToFloat(x, y, normalizedIndex) ); vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh, Graphic graphic) { if (!isActiveAndEnabled) { return; } // bool isText = isTMPro || graphic is Text; var normalizedIndex = paramTex.GetNormalizedIndex(this); // rect. var tex = transitionTexture; var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1; var rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect, aspectRatio); // Calculate vertex position. var vertex = default(UIVertex); var count = vh.currentVertCount; for (var i = 0; i < count; i++) { vh.PopulateUIVertex(ref vertex, i); float x; float y; connector.GetPositionFactor(m_EffectArea, i, rect, vertex.position, out x, out y); vertex.uv0 = new Vector2( Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), Packer.ToFloat(x, y, normalizedIndex) ); vh.SetUIVertex(vertex, i); } }
// public void OnBeforeSerialize() // { // } // // public void OnAfterDeserialize() // { // var obj = this; // EditorApplication.delayCall += () => // { // if (Application.isPlaying || !obj) // return; // // var mat = GetMaterial(shaderName); // if (m_EffectMaterial == mat && graphic.material == mat) // return; // // graphic.material = m_EffectMaterial = mat; // EditorUtility.SetDirty(this); // EditorUtility.SetDirty(graphic); // EditorApplication.delayCall += AssetDatabase.SaveAssets; // }; // } // // public static Material GetMaterial(string shaderName) // { // string name = Path.GetFileName(shaderName); // return AssetDatabase.FindAssets("t:Material " + name) // .Select(x => AssetDatabase.GUIDToAssetPath(x)) // .SelectMany(x => AssetDatabase.LoadAllAssetsAtPath(x)) // .OfType<Material>() // .FirstOrDefault(x => x.name == name); // } #endif /// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } // rect. Rect rect = m_EffectArea.GetEffectArea(vh, graphic); // rotation. float rad = rotation * Mathf.Deg2Rad; Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); dir.x *= rect.height / rect.width; dir = dir.normalized; // Calculate vertex position. bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character; UIVertex vertex = default(UIVertex); Vector2 nomalizedPos; Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix. for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); // Normalize vertex position by local matrix. nomalizedPos = localMatrix * vertex.position; // Normalize vertex position by local matrix. if (effectEachCharacter) { // Each characters. nomalizedPos = localMatrix * splitedCharacterPosition[i % 4]; } else { nomalizedPos = localMatrix * vertex.position; } vertex.uv1 = new Vector2( Packer.ToFloat(Mathf.Clamp01(nomalizedPos.y), softness, width, brightness), Packer.ToFloat(location, highlight) ); vh.SetUIVertex(vertex, i); } }
#pragma warning restore 0612 #endif /// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } bool isText = isTMPro || graphic is Text; float normalizedIndex = ptex.GetNormalizedIndex(this); // rect. Rect rect = m_EffectArea.GetEffectArea(vh, rectTransform.rect); // rotation. float rad = m_Rotation * Mathf.Deg2Rad; Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad)); dir.x *= rect.height / rect.width; dir = dir.normalized; // Calculate vertex position. UIVertex vertex = default(UIVertex); Vector2 nomalizedPos; Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y); // Get local matrix. for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); m_EffectArea.GetNormalizedFactor(i, localMatrix, vertex.position, isText, out nomalizedPos); if (isTMPro) { vertex.uv2 = new Vector2( Packer.ToFloat(nomalizedPos.y, normalizedIndex), 0 ); } else { vertex.uv0 = new Vector2( Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), Packer.ToFloat(nomalizedPos.y, normalizedIndex) ); } vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } float normalizedIndex = ptex.GetNormalizedIndex(this); // rect. var tex = noiseTexture; var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1; Rect rect = m_EffectArea.GetEffectArea(vh, graphic, aspectRatio); // Calculate vertex position. UIVertex vertex = default(UIVertex); bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character; float x, y; int count = vh.currentVertCount; for (int i = 0; i < count; i++) { vh.PopulateUIVertex(ref vertex, i); if (effectEachCharacter) { x = splitedCharacterPosition[i % 4].x; y = splitedCharacterPosition[i % 4].y; } else { x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f); y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f); } vertex.uv0 = new Vector2( Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), Packer.ToFloat(x, y, normalizedIndex) ); vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled || m_EffectMode == EffectMode.None) { return; } // rect. var tex = transitionTexture; var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1; Rect rect = m_EffectArea.GetEffectArea(vh, graphic, aspectRatio); // Set prameters to vertex. UIVertex vertex = default(UIVertex); bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character; float x, y; for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); if (effectEachCharacter) { x = splitedCharacterPosition[i % 4].x; y = splitedCharacterPosition[i % 4].y; } else { x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f); y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f); } vertex.uv1 = new Vector2( effectFactor, Packer.ToFloat(x, y) ); vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { if (!isActiveAndEnabled) { return; } // rect. Rect rect = m_EffectArea.GetEffectArea(vh, graphic); // Calculate vertex position. UIVertex vertex = default(UIVertex); bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character; float x, y; for (int i = 0; i < vh.currentVertCount; i++) { vh.PopulateUIVertex(ref vertex, i); if (effectEachCharacter) { x = splitedCharacterPosition[i % 4].x; y = splitedCharacterPosition[i % 4].y; } else { x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f); y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f); } vertex.uv1 = new Vector2( Packer.ToFloat(x, y, location, m_Width), Packer.ToFloat(m_Color.r, m_Color.g, m_Color.b, m_Softness) ); vh.SetUIVertex(vertex, i); } }
/// <summary> /// Modifies the mesh. /// </summary> public override void ModifyMesh(VertexHelper vh) { Debug.Log("ModifyMesh"); //return; if (!isActiveAndEnabled) { return; } float normalizedIndex = ptex.GetNormalizedIndex(this); // rect. var tex = noiseTexture; var aspectRatio = m_KeepAspectRatio && tex ? ((float)tex.width) / tex.height : -1; Rect rect = m_EffectArea.GetEffectArea(vh, graphic, aspectRatio); // Calculate vertex position. UIVertex vertex = default(UIVertex); bool effectEachCharacter = graphic is Text && m_EffectArea == EffectArea.Character; float x, y; /* * int count = vh.currentVertCount; * for (int i = 0; i < count; i++) * { * vh.PopulateUIVertex(ref vertex, i); * * if (effectEachCharacter) * { * x = splitedCharacterPosition[i % 4].x; * y = splitedCharacterPosition[i % 4].y; * } * else * { * x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f); * y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f); * } * * //vertex.uv0 = new Vector2( * // Packer.ToFloat(vertex.uv0.x, vertex.uv0.y), * // Packer.ToFloat(x, y, normalizedIndex) * //); * * vertex.uv2 = new Vector2 ( * Packer.ToFloat (x, y, normalizedIndex), 0 * ); * * vh.SetUIVertex(vertex, i); * } */ var t = graphic as TMPro.TextMeshProUGUI; Mesh mesh = t.mesh; int count = mesh.vertexCount; Vector2[] uvs = mesh.uv; for (int i = 0; i < count; i++) { if (effectEachCharacter) { x = splitedCharacterPosition [i % 4].x; y = splitedCharacterPosition [i % 4].y; } else { x = Mathf.Clamp01(vertex.position.x / rect.width + 0.5f); y = Mathf.Clamp01(vertex.position.y / rect.height + 0.5f); } uvs [i] = new Vector2( Packer.ToFloat(uvs [i].x, uvs [i].y), Packer.ToFloat(x, y, normalizedIndex) ); } mesh.uv = uvs; Debug.Log(count); }