rabidus-test/Assets/MaterialTransparency.cs

21 lines
476 B
C#
Raw Normal View History

2023-10-12 15:05:48 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MaterialTransparency : MonoBehaviour
{
private Renderer _renderer;
private void Awake()
{
_renderer = GetComponent<Renderer>();
}
public void SetValue(float value)
{
Color oldColor = _renderer.material.color;
Color newColor = new Color(oldColor.r, oldColor.g, oldColor.b, value);
_renderer.material.color = newColor;
}
}