Skip to content

Commit

Permalink
[BSL] Use UriRx OnPointerEnterAsObservable
Browse files Browse the repository at this point in the history
  • Loading branch information
Keelhauled committed Jul 22, 2024
1 parent 0e8b4d9 commit e565754
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/BetterSceneLoader.Core/ImageGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
using KeelPlugins.Utils;
using UnityEngine.Networking;
using KKAPI.Utilities;
using UnityEngine.EventSystems;
using UniRx.Triggers;
using UniRx;

namespace BetterSceneLoader
{
Expand Down Expand Up @@ -367,9 +368,7 @@ private IEnumerator LoadButtonsAsync(Transform parent, List<FileInfo> scenefiles
private Button CreateSceneButton(Transform parent, Texture2D texture, FileInfo fileInfo)
{
var button = UIUtility.CreateButton("ImageButton", parent, "");
var pointerEnterEvent = new EventTrigger.Entry{ eventID = EventTriggerType.PointerEnter };
button.gameObject.AddComponent<EventTrigger>().triggers.Add(pointerEnterEvent);
pointerEnterEvent.callback.AddListener(e =>
button.OnPointerEnterAsObservable().Subscribe(e =>
{
currentButton = button;
currentPath = fileInfo.FullName;
Expand All @@ -392,11 +391,6 @@ private Button CreateSceneButton(Transform parent, Texture2D texture, FileInfo f
confirmpanel.gameObject.SetActive(false);
});

// Pass scroll event through
var scrollEvent = new EventTrigger.Entry{ eventID = EventTriggerType.Scroll };
button.gameObject.AddComponent<EventTrigger>().triggers.Add(scrollEvent);
scrollEvent.callback.AddListener(e => imagelist.SendMessage("OnScroll", e));

var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
button.gameObject.GetComponent<Image>().sprite = sprite;

Expand Down

0 comments on commit e565754

Please sign in to comment.