备份CatanBuilding瘦身独立工程
This commit is contained in:
30
Assets/Scripts/Others/ImageMatPropChange.cs
Normal file
30
Assets/Scripts/Others/ImageMatPropChange.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ImageMatPropChange : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Image image;
|
||||
private Material mat;
|
||||
|
||||
[SerializeField]
|
||||
private string propName = "_Color";
|
||||
private int propID = Shader.PropertyToID("_Color");
|
||||
|
||||
void Start()
|
||||
{
|
||||
propID = Shader.PropertyToID(propName);
|
||||
mat = image?.material;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
mat?.SetFloat(propID, 1);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
mat?.SetFloat(propID, 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user