Hey there!
I’m working with the HoloLens right now and I’m trying to instantiate an object on button press (floating UI) in front of the player. If I press the corresponding button, the 3 Objects appear instead of one. Also, when I try to instantiate an onther object, 3 new Objects appear in the place of the last object placed. Had anybody had a similar problem? Or maybe has the Idea how to fix this?
Here is my Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MenueEvents : MonoBehaviour {
public GameObject objectA;
public GameObject objectB;
public void spawnObjectA()
{
Instantiate(objectA, Camera.main.transform.position + (Camera.main.transform.forward * 2.0f), objectA.transform.rotation, GameObject.Find("HoloCollection").transform);
}
public void spawnObjectB()
{
Instantiate(objectB, Camera.main.transform.position + (Camera.main.transform.forward * 2.0f), objectB.transform.rotation, GameObject.Find("HoloCollection").transform);
}
}