game: fixed pen interaction

This commit is contained in:
shannon 3 2025-02-03 18:34:32 +08:00
parent 07fbc4da29
commit 039a6e88ed
10 changed files with 1471 additions and 30 deletions

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: d95c3a2e9a39dee4289a159646510527
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: e49446b1e5ffd3e44868005292f43190
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,23 @@
/*
* Author: Shannon Goh
* Date: 03/02/2025
* Description: Pen Interactor Handle script
*/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
public class PenInteractor : MonoBehaviour
{
private void OnCollisionEnter(Collision collision)
{
if (PenSocketInteractor.isPickedUp && collision.gameObject.CompareTag("Paper"))
{
Debug.Log("The pen is writing on the paper!");
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 515c29b766d256d47938c73d089e2c15
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,48 @@
/*
* Author: Shannon Goh
* Date: 03/02/2025
* Description: Pen Socket Interactor Handle script
*/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.XR.Interaction.Toolkit.Interactors;
public class PenSocketInteractor : MonoBehaviour
{
XRSocketInteractor penSocket;
public static bool isPickedUp = false;
private void Awake()
{
penSocket = GetComponent<XRSocketInteractor>();
}
void OnEnable()
{
penSocket.selectEntered.AddListener(OnPenPlaced);
penSocket.selectExited.AddListener(OnPenPickedUp);
}
void OnDisable()
{
penSocket.selectEntered.RemoveListener(OnPenPlaced);
penSocket.selectExited.RemoveListener(OnPenPickedUp);
}
private void OnPenPickedUp(SelectExitEventArgs args)
{
isPickedUp = true;
Debug.Log("Pen picked up");
}
private void OnPenPlaced(SelectEnterEventArgs args)
{
isPickedUp = false;
Debug.Log("Pen placed back");
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d531cc8baa946954491479f13e469a9c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 58f7e79a87c79824597746e8c1bfe400
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: f58d25b9e504a4f41ab4a71cf87c1845
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -6,6 +6,7 @@ TagManager:
tags:
- Anchor
- NPC
- Paper
layers:
- Default
- TransparentFX