浏览器嵌入,国旗文件

This commit is contained in:
Caiyanpeng committed 2021-04-09 09:19:04 +08:00
1 parent e7a3214cb5
commit 07feba912c
552 files changed
+39279 -8128

No files matched your search

@@ -0,0 +1,43 @@
using DG.Tweening;
using System;
using UnityEngine;
using UnityEngine.UI;
[ExecuteInEditMode]
public class ImageWithRoundedCorners : MonoBehaviour {
private static readonly int Props = Shader.PropertyToID("_WidthHeightRadius");
private Material material;
public float radius;
private void Start()
{
Refresh();
}
void OnRectTransformDimensionsChange()
{
Refresh();
}
private void OnValidate()
{
Refresh();
}
private void Refresh(){
if (material == null)
{
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
}
var rect = ((RectTransform)transform).rect;
material.SetVector(Props, new Vector4(rect.width, rect.height, radius * 2, 0));
if (gameObject.GetComponent<Image>() != null)
{
gameObject.GetComponent<Image>().material = material;
gameObject.GetComponent<Image>().sprite = null;
}
else if (gameObject.GetComponent<RawImage>() != null)
{
gameObject.GetComponent<RawImage>().material = material;
}
}
}