using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SetOpactity : MonoBehaviour { public Material mat; public float opactity = 1f; public Toggle myToggle; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { mat.color = new Color(0.3804f, 0.6f, 0.23137f, opactity); } public void SetOpcaity() { if (myToggle.isOn) { opactity = 0.1f; } else { opactity = 255f; } } }