OneClickInteractable
This commit is contained in:
@@ -68,4 +68,9 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
}
|
||||
return anySuccess;
|
||||
}
|
||||
|
||||
public void CompleteInteraction(bool success)
|
||||
{
|
||||
InteractionComplete?.Invoke(success);
|
||||
}
|
||||
}
|
||||
|
||||
35
Assets/Scripts/Interactions/OneClickInteraction.cs
Normal file
35
Assets/Scripts/Interactions/OneClickInteraction.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// MonoBehaviour that immediately completes an interaction when started.
|
||||
/// </summary>
|
||||
public class OneClickInteraction : MonoBehaviour
|
||||
{
|
||||
private Interactable interactable;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
interactable = GetComponent<Interactable>();
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.StartedInteraction += OnStartedInteraction;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.StartedInteraction -= OnStartedInteraction;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStartedInteraction()
|
||||
{
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.CompleteInteraction(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Interactions/OneClickInteraction.cs.meta
Normal file
3
Assets/Scripts/Interactions/OneClickInteraction.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 833a4ccef651449e973e623d9107bef5
|
||||
timeCreated: 1757417586
|
||||
Reference in New Issue
Block a user