Browse Source

Fixed SFX firing on non interactive button

jamesperet 2 years ago
parent
commit
eda6d4430d
3 changed files with 8 additions and 2 deletions
  1. 1 1
      Readme.md
  2. 6 0
      Runtime/SFX/ButtonSFX.cs
  3. 1 1
      package.json

+ 1 - 1
Readme.md

@@ -1,4 +1,4 @@
-# 📦 KairoEngine.UI.v0.1.6
+# 📦 KairoEngine.UI.v0.1.7
 
 The **UI** package contains the ``UiSystem`` component and the ``UiSystemModule``. The module loads the Ui System in place which manages canvases with UI data. The system now which canvases are enabled and has a global toggle for all the game UI.
 

+ 6 - 0
Runtime/SFX/ButtonSFX.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.UI;
 using Sirenix.OdinInspector;
 using KairoEngine.SFX;
 using UnityEngine.EventSystems;
@@ -10,6 +11,7 @@ namespace KairoEngine.UI.SFX
     [HideMonoScript]
     public class ButtonSFX : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
     {
+        public Button button;
         public SFXClip onPointerEnterSFX;
         public SFXClip onPointerExitSFX;
         public SFXClip onPointerDownSFX;
@@ -71,6 +73,10 @@ namespace KairoEngine.UI.SFX
         {
             if(clip == null) return;
             if(this.gameObject.activeInHierarchy == false) return;
+            if(button != null)
+            {
+                if(button.interactable == false) return;
+            }
             SoundController.EmmitSound(clip, new Vector3());
             
         }

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
     "name": "at.kairoscope.kairoengine.ui",
     "displayName" : "KairoEngine UI",
-    "version": "0.1.6",
+    "version": "0.1.7",
     "unity": "2020.3",
     "description": "User Interface library for kairoEngine",
     "repository": {