quickoutline
This commit is contained in:
@@ -3,9 +3,13 @@ using Cysharp.Threading.Tasks;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootReality.jelycho {
|
||||
public class ButtonActor : Actor, IInteractable {
|
||||
static readonly Logger s_Logger = new Logger(nameof(ButtonActor));
|
||||
|
||||
[SerializeField] Outline m_Outline;
|
||||
[SerializeField] Transform m_Graphics;
|
||||
[SerializeField] float m_CooldownDuration = 0.5f;
|
||||
|
||||
@@ -13,6 +17,17 @@ namespace RebootReality.jelycho {
|
||||
|
||||
public UnityEvent pressed = new UnityEvent();
|
||||
|
||||
//
|
||||
// @MARK: Unity callbacks
|
||||
//
|
||||
void Awake() {
|
||||
SetHighlight(false);
|
||||
m_LastPressTime = DateTime.MinValue;
|
||||
}
|
||||
|
||||
//
|
||||
// @MARK: Actor
|
||||
//
|
||||
protected override IActorData CreateActorData() {
|
||||
return new NoActorData();
|
||||
}
|
||||
@@ -42,10 +57,22 @@ namespace RebootReality.jelycho {
|
||||
|
||||
async UniTask PressAsync() {
|
||||
m_Graphics.localScale = new Vector3(1, 0.1f, 1);
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(1.0f));
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(m_CooldownDuration), cancellationToken: destroyCancellationToken);
|
||||
m_Graphics.localScale = new Vector3(1, 1, 1);
|
||||
}
|
||||
|
||||
//
|
||||
// @MARK: IInteractable
|
||||
//
|
||||
public void SetHighlight(bool highlight) {
|
||||
if (m_Outline == null) {
|
||||
Debug.LogError("ButtonActor does not have an Outline component.");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Outline.enabled = highlight;
|
||||
}
|
||||
|
||||
public void Interact() {
|
||||
SendActorCommand((ushort) ButtonActorCommands.Press);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user