SwitchButtonCollor.cs 652 Bytes
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class SwitchButtonCollor : MonoBehaviour {

    public Button thisButton;
    private Graphic thisButtonGraphic;

    public bool enabled;
    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 = enabled ? enabledAlpha : disabledAlpha;
	}

    public void switchCollor(){
        enabled = !enabled;
        thisButtonGraphic.color = enabled ? enabledAlpha : disabledAlpha;
    }

}