42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FloorButtonVisualizer : MonoBehaviour
|
|
{
|
|
public Sprite InactiveSprite;
|
|
public Sprite ActiveSprite;
|
|
public float FloorUpperCoordiantes;
|
|
public float FloorLowerCoordiantes;
|
|
private bool activeState = true;
|
|
private Image buttonImage;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
buttonImage = gameObject.GetComponent<Image>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
float height = gameObject.transform.position.y;
|
|
if (height < FloorUpperCoordiantes && height > FloorLowerCoordiantes)
|
|
{
|
|
if (!activeState) {
|
|
activeState = true;
|
|
buttonImage.sprite = ActiveSprite;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if (activeState)
|
|
{
|
|
activeState = false;
|
|
buttonImage.sprite = InactiveSprite;
|
|
}
|
|
}
|
|
}
|
|
}
|