SwitchButtonCollor.cs
644 Bytes
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SwitchButtonCollor : MonoBehaviour {
public Button thisButton;
private Graphic thisButtonGraphic;
public bool isEnabled;
private Color enabledAlpha = new Color(0.356F, 0.78F, 0.815F, 1F);
private Color disabledAlpha = new Color(1F, 1F, 1F, 1F);
void Start () {
thisButtonGraphic = thisButton.GetComponent<Graphic>();
thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha;
}
public void switchCollor(){
isEnabled = !isEnabled;
thisButtonGraphic.color = isEnabled ? enabledAlpha : disabledAlpha;
}
}