/// <summary>
/// Start is called before the first frame update
/// </summary>
/// <remarks>
/// This is a pretty dirty solution to the problem of attaching the object to the desk. Do not use in production.
/// </remarks>
/// <returns></returns>
IEnumerator Start()
{
OVRSemanticClassification deskElement = null;
//loop until we find the desk element
while (deskElement == null)
{
yield return null;
// find all the objects with semantic classifications in the scene
var classifications = FindObjectsByType<OVRSemanticClassification>(FindObjectsInactive.Exclude, FindObjectsSortMode.None);
foreach (var classification in classifications)
{
// if the object is a table, set it as the desk element
// and break the loop
if (classification.Labels.Contains("TABLE"))
{
deskElement = classification;
break;
}
}
}
// wait for a bit before attaching the object to the desk, so it initializes properly
yield return new WaitForSeconds(0.33f);
//now parent the object to the desk
transform.SetParent(deskElement.transform, false);
}