﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Button : MonoBehaviour{
    
    public Webcam webcamInstance;
    Image img;

    void Start(){
        img = GetComponent<Image>();
    }

    void Update(){
        // int x = (int) (100*webcamInstance.scale),
        //     y = (int) (190*webcamInstance.scale),
        //     s = (int) (100*webcamInstance.scale);
        
        RectTransform rt = GetComponent<RectTransform>();
        int x = (int) (Mathf.Abs(rt.anchoredPosition.x)*webcamInstance.scale),
            y = (int) (Mathf.Abs(rt.anchoredPosition.y)*webcamInstance.scale),
            s = (int) (100*webcamInstance.scale);

        if( webcamInstance.checkArea( x, y, s, s ) ){
            img.color = new Color32( 163, 255, 96, 255 );
        }
        else{
            img.color = new Color32( 255, 106, 96, 255 );
        }
    }

}
