forked from cgvr/DeltaVR
shape scanner improvements: add handle, destroy scannable object on completion, correctly detect when new object is generated
This commit is contained in:
@@ -36,7 +36,10 @@ public class MicrophoneStand : MonoBehaviour
|
||||
microphoneOffStatus.SetActive(false);
|
||||
microphoneOnStatus.SetActive(true);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
npcController.SpeakVoiceLine(1);
|
||||
if (npcController != null)
|
||||
{
|
||||
npcController.SpeakVoiceLine(1);
|
||||
}
|
||||
fmodWhisperBridge.ActivateRecording();
|
||||
}
|
||||
}
|
||||
@@ -49,7 +52,10 @@ public class MicrophoneStand : MonoBehaviour
|
||||
microphoneOffStatus.SetActive(true);
|
||||
microphoneOnStatus.SetActive(false);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.RadioButton, gameObject);
|
||||
npcController.SpeakVoiceLine(2);
|
||||
if (npcController != null)
|
||||
{
|
||||
npcController.SpeakVoiceLine(2);
|
||||
}
|
||||
fmodWhisperBridge.DeactivateRecording();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,12 @@ public class ShapeDetectionMinigameController : MonoBehaviour
|
||||
GameObject spawnedObject = await ModelGenerationUtils.Instance.SpawnModel(encodedModel);
|
||||
InitializeSpawnedObject(spawnedObject);
|
||||
|
||||
// Destroy previous generated object
|
||||
Destroy(GeneratedModel);
|
||||
if (GeneratedModel != null)
|
||||
{
|
||||
// Destroy previous generated object (first move out of ShapeScanner to trigger OnTriggerExit
|
||||
GeneratedModel.transform.position = Vector3.zero;
|
||||
//Destroy(GeneratedModel);
|
||||
}
|
||||
GeneratedModel = spawnedObject;
|
||||
|
||||
modelGenerationButton.Deactivate();
|
||||
|
||||
@@ -42,6 +42,8 @@ public class ShapeScanner : MonoBehaviour
|
||||
private int rayCount;
|
||||
private int correctRayStates;
|
||||
|
||||
private GameObject currentlyScannableObject;
|
||||
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
@@ -60,6 +62,22 @@ public class ShapeScanner : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == rayPrefab.scannableTag)
|
||||
{
|
||||
currentlyScannableObject = other.gameObject;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
{
|
||||
if (other.tag == rayPrefab.scannableTag)
|
||||
{
|
||||
currentlyScannableObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeConfiguration()
|
||||
{
|
||||
// Delete all existing rays first
|
||||
@@ -67,6 +85,11 @@ public class ShapeScanner : MonoBehaviour
|
||||
{
|
||||
Destroy(ray);
|
||||
}
|
||||
if (currentlyScannableObject != null)
|
||||
{
|
||||
currentlyScannableObject.transform.position = Vector3.zero;
|
||||
Destroy(currentlyScannableObject);
|
||||
}
|
||||
|
||||
ShapeScannerConfiguration configuration = configurations[currentConfiguration];
|
||||
int rayRowCount = configuration.rows.Count;
|
||||
@@ -97,8 +120,6 @@ public class ShapeScanner : MonoBehaviour
|
||||
rayCount = configuration.rows.SelectMany(row => row.cells).Count();
|
||||
correctRayStates = configuration.rows.SelectMany(row => row.cells).Count(cell => !cell);
|
||||
UpdateDisplay(calculateCorrectPercentage());
|
||||
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.ShapeScannerSuccess, gameObject);
|
||||
}
|
||||
|
||||
private float calculateCorrectPercentage()
|
||||
@@ -117,9 +138,11 @@ public class ShapeScanner : MonoBehaviour
|
||||
{
|
||||
currentConfiguration++;
|
||||
InitializeConfiguration();
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.ShapeScannerSuccess, gameObject);
|
||||
} else
|
||||
{
|
||||
Debug.Log("Shape checker completed");
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.ShapeScannerSuccess, gameObject);
|
||||
}
|
||||
}
|
||||
UpdateDisplay(correctPercentage);
|
||||
|
||||
Reference in New Issue
Block a user