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:
@@ -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