OneClickInteractable

This commit is contained in:
Michal Pikulski
2025-09-09 13:38:03 +02:00
parent aa127bf6d5
commit 07e88a88fe
4 changed files with 59 additions and 1 deletions

View File

@@ -433017,7 +433017,7 @@ PrefabInstance:
objectReference: {fileID: 11400000, guid: 5861b0a3b22b57f43a00cab7c7faafaa, type: 2}
- target: {fileID: 1498439134679474750, guid: 93ab59741ddc4e045a61cd8e05b65578, type: 3}
propertyPath: m_Name
value: Diving for Pictures
value: DivingForPictures
objectReference: {fileID: 0}
- target: {fileID: 4428217320659622763, guid: 93ab59741ddc4e045a61cd8e05b65578, type: 3}
propertyPath: m_LocalScale.x
@@ -434378,6 +434378,18 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
stepData: {fileID: 11400000, guid: 8ac614a698631554ab8ac39aed04a189, type: 2}
--- !u!114 &1182494941
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1182494929}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 833a4ccef651449e973e623d9107bef5, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1192177492
PrefabInstance:
m_ObjectHideFlags: 0
@@ -441399,6 +441411,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3}
insertIndex: -1
addedObject: {fileID: 1182494937}
- targetCorrespondingSourceObject: {fileID: 7379304988657006554, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3}
insertIndex: -1
addedObject: {fileID: 1182494941}
m_SourcePrefab: {fileID: 100100000, guid: c36b48a324dcaef4cb5ee0f8ca57f0d6, type: 3}
--- !u!1001 &7535757761066548300
PrefabInstance:

View File

@@ -68,4 +68,9 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
}
return anySuccess;
}
public void CompleteInteraction(bool success)
{
InteractionComplete?.Invoke(success);
}
}

View 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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 833a4ccef651449e973e623d9107bef5
timeCreated: 1757417586