forked from cgvr/DeltaVR
some sound bug fixes
This commit is contained in:
@@ -9,7 +9,11 @@ public class FloorButtonVisualizer : MonoBehaviour
|
||||
public Sprite ActiveSprite;
|
||||
public bool ActiveState;
|
||||
private Image buttonImage;
|
||||
// Start is called before the first frame update
|
||||
|
||||
// --- Static tracking for selection change ---
|
||||
private static FloorButtonVisualizer lastActiveButton = null;
|
||||
private static bool initialized = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
buttonImage = gameObject.GetComponent<Image>();
|
||||
@@ -19,12 +23,20 @@ public class FloorButtonVisualizer : MonoBehaviour
|
||||
{
|
||||
this.ActiveState = true;
|
||||
buttonImage.sprite = ActiveSprite;
|
||||
//Debug.Log("Floorbutton of " + gameObject.name + " activated");
|
||||
|
||||
// --- Only play hover if selection actually changed ---
|
||||
if (initialized && lastActiveButton != this)
|
||||
{
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
|
||||
}
|
||||
|
||||
lastActiveButton = this;
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
this.ActiveState = false;
|
||||
buttonImage.sprite = InactiveSprite;
|
||||
//Debug.Log("Floorbutton of " + gameObject.name + " deactivated");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user