Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
869 B

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Creates an object and attaches it to the hand
//
//=============================================================================
using UnityEngine;
using System.Collections;
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class SpawnAndAttachToHand : MonoBehaviour
{
public Hand hand;
public GameObject prefab;
//-------------------------------------------------
public void SpawnAndAttach( Hand passedInhand )
{
Hand handToUse = passedInhand;
if ( passedInhand == null )
{
handToUse = hand;
}
if ( handToUse == null )
{
return;
}
GameObject prefabObject = Instantiate( prefab ) as GameObject;
handToUse.AttachObject( prefabObject );
}
}
}