68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Security.Policy;
|
|
using UnityEngine;
|
|
using UnityEngine.InputSystem;
|
|
using BITKit;
|
|
using BITKit.SceneManagement;
|
|
using BITKit.UX;
|
|
using INetClient = BITKit.INetClient;
|
|
using Cysharp.Threading.Tasks;
|
|
using UnityEngine.ResourceManagement.ResourceProviders;
|
|
|
|
namespace BITFALL.UX
|
|
{
|
|
public class UXMenu : UIToolKitPanel
|
|
{
|
|
[Header(Constant.Header.Providers)]
|
|
[SerializeReference, SubclassSelector] private ISceneService SceneService;
|
|
|
|
[Header(Constant.Header.Components)]
|
|
[SerializeField] private UXButton playButton;
|
|
[SerializeField] private UXButton stopButton;
|
|
[SerializeField] private UXButton exitButton;
|
|
[SerializeField] private UXButton returnButton;
|
|
[SerializeField] private UXImage backgroundImage;
|
|
[Header(Constant.Header.Input)]
|
|
[SerializeField] private InputActionReference returnAction;
|
|
[SerializeField] private InputActionReference inventoryAction;
|
|
|
|
protected override void Start()
|
|
{
|
|
inputActionGroup.RegisterCallback(returnAction, OnReturn);
|
|
inputActionGroup.RegisterCallback(inventoryAction, OnReturn);
|
|
|
|
SceneService.OnLoadScene +=(_)=> OnConnected();
|
|
SceneService.OnUnloadScene +=(_)=>
|
|
{
|
|
Entry();
|
|
OnDisconnected();
|
|
};
|
|
OnDisconnected();
|
|
}
|
|
private void OnConnected()
|
|
{
|
|
backgroundImage.SetActive(false);
|
|
playButton.SetActive(false);
|
|
stopButton.SetActive(true);
|
|
exitButton.SetActive(false);
|
|
returnButton.SetActive(true);
|
|
}
|
|
private void OnDisconnected()
|
|
{
|
|
backgroundImage.SetActive(true);
|
|
playButton.SetActive(true);
|
|
stopButton.SetActive(false);
|
|
exitButton.SetActive(true);
|
|
returnButton.SetActive(false);
|
|
}
|
|
private void OnReturn(InputAction.CallbackContext context)
|
|
{
|
|
if (context.ReadValueAsButton())
|
|
{
|
|
UXService.Entry<UXHud>();
|
|
}
|
|
}
|
|
}
|
|
} |