查找 rayResList 是否存在你所点击的按钮 存在则不是透明的 不存在则是透明的

  • eventData 为鼠标点击的位置 使用UI事件传递下去的数据即可
1
2
3
List<RaycastResult> rayResList = new List<RaycastResult>();
EventSystem.current.RaycastAll(eventData, rayResList);
//

参考链接Unity3d Ugui 24 EventSystem事件机制
“Texture2d 缩略图” “### 制作Texture2d 的缩略图

更改Texture的尺寸,并返回新尺寸的 texture

用法:var newText = texture.NewSize(128, 128);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
     
/// <summary>
/// Texture 扩展
/// </summary>
public static class TextureExtent
{

/// <summary>
/// 创建新尺寸的 Texture
/// </summary>
/// <param name="tex"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public static Texture NewSize(this Texture tex, int width, int height)
{
if (null == tex)
return null;

tex.filterMode = FilterMode.Point;
RenderTexture rt = RenderTexture.GetTemporary(width, height);
rt.filterMode = FilterMode.Point;
RenderTexture.active = rt;
Graphics.Blit(tex, rt);
var nTex = new Texture2D(width, height);
nTex.ReadPixels(new Rect(0, 0, width, height), 0, 0);
nTex.Apply();
RenderTexture.active = null;
return nTex;
}

}