IMHOTEP Framework
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
SpawnAndAttachToHand.cs
1 //======= Copyright (c) Valve Corporation, All rights reserved. ===============
2 //
3 // Purpose: Creates an object and attaches it to the hand
4 //
5 //=============================================================================
6 
7 using UnityEngine;
8 using System.Collections;
9 
10 namespace Valve.VR.InteractionSystem
11 {
12  //-------------------------------------------------------------------------
13  public class SpawnAndAttachToHand : MonoBehaviour
14  {
15  public Hand hand;
16  public GameObject prefab;
17 
18 
19  //-------------------------------------------------
20  public void SpawnAndAttach( Hand passedInhand )
21  {
22  Hand handToUse = passedInhand;
23  if ( passedInhand == null )
24  {
25  handToUse = hand;
26  }
27 
28  if ( handToUse == null )
29  {
30  return;
31  }
32 
33  GameObject prefabObject = Instantiate( prefab ) as GameObject;
34  handToUse.AttachObject( prefabObject );
35  }
36  }
37 }