Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 24a6df9

Browse files
committed
测试表情的集体渲染
1 parent 3cf2f2b commit 24a6df9

File tree

8 files changed

+192
-129
lines changed

8 files changed

+192
-129
lines changed

Assets/Hidden/SpriteGraphic02.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using UnityEngine;
44
using UnityEngine.UI;
55

6+
[ExecuteInEditMode]
67
public class SpriteGraphic02 : MaskableGraphic
78
{
89
#region 属性
@@ -19,13 +20,18 @@ public class SpriteGraphic02 : MaskableGraphic
1920
[SerializeField]
2021
private float _speed;
2122

22-
private MeshInfo _meshInfo=new MeshInfo();
23+
private MeshInfo _meshInfo;
2324
public MeshInfo MeshInfo
2425
{
2526
get { return _meshInfo; }
2627
set
2728
{
28-
_meshInfo = value;
29+
if (value == null&& _meshInfo!=null)
30+
{
31+
_meshInfo.Clear();
32+
}
33+
else
34+
_meshInfo = value;
2935

3036
SetAllDirty();
3137
}
@@ -54,23 +60,17 @@ public override Material material
5460
_defaultMater = new Material(Shader.Find(_defaultShader));
5561
_defaultMater.SetFloat("_CellAmount", _cellAmount);
5662
_defaultMater.SetFloat("_Speed", _speed);
57-
//_defaultMater.SetTexture("_MainTex", mainTexture);
58-
// _defaultMater.EnableKeyword("EMOJI_ANIMATION");
59-
_defaultMater.DisableKeyword("EMOJI_ANIMATION");
60-
}
63+
if(m_spriteAsset==null|| m_spriteAsset.IsStatic)
64+
_defaultMater.DisableKeyword("EMOJI_ANIMATION");
65+
else
66+
_defaultMater.EnableKeyword("EMOJI_ANIMATION");
67+
68+
}
6169
return _defaultMater;
6270
}
6371
}
6472
#endregion
65-
66-
protected InlineManager _inlineManager;
67-
68-
protected override void OnEnable()
69-
{
70-
base.OnEnable();
71-
_inlineManager = GetComponentInParent<InlineManager>();
72-
}
73-
73+
7474
protected override void OnPopulateMesh(VertexHelper vh)
7575
{
7676
if (_meshInfo != null)
@@ -79,7 +79,7 @@ protected override void OnPopulateMesh(VertexHelper vh)
7979
for (int i = 0; i < _meshInfo.Vertices.Count; i++)
8080
{
8181
int tempVertsIndex = i & 3;
82-
_tempVerts[tempVertsIndex].position = Utility.Transform2World2Point(transform,_meshInfo.Vertices[i]);
82+
_tempVerts[tempVertsIndex].position = Utility.TransformWorld2Point(transform,_meshInfo.Vertices[i]);
8383
_tempVerts[tempVertsIndex].uv0 = _meshInfo.UVs[i];
8484
_tempVerts[tempVertsIndex].color = color;
8585
if (tempVertsIndex == 3)

Assets/Hidden/Utility.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static Vector3 TransformPoint2World(Transform transform, Vector3 point)
2121
/// <param name="transform"></param>
2222
/// <param name="point"></param>
2323
/// <returns></returns>
24-
public static Vector3 Transform2World2Point(Transform transform, Vector3 point)
24+
public static Vector3 TransformWorld2Point(Transform transform, Vector3 point)
2525
{
2626
return transform.worldToLocalMatrix.MultiplyPoint(point);
2727
}

0 commit comments

Comments
 (0)