- Home /
HoloLens airtap and instantiate object and then tap to move it around with Gaze and tap to place it on real world surface
I am trying to tap and instantiate a box then move it with my gaze on another tap place it at a place with spatial mapping. I am able to do it but the problem is that when I place the object with the final tap, one more box is getting created in front of me due to tapping. I have instantiated the Box in IInputClickHandler.OnInputClicked function. Any suggestions?
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// using System.Collections; using System.Collections.Generic; using UnityEngine; using HoloToolkit.Unity.InputModule; using HoloToolkit.Unity; using System;
public class Place_Holder : MonoBehaviour, IInputClickHandler { public Transform prefab; private int count; private bool loaded;
// Use this for initialization
void Start () {
InputManager.Instance.PushFallbackInputHandler(this.gameObject);
}
void IInputClickHandler.OnInputClicked(InputClickedEventData eventData)
{
var instance = Instantiate(prefab);
instance.gameObject.transform.position = GazeManager.Instance.GazeOrigin + GazeManager.Instance.GazeNormal * 1.5f;
var tapToPlace = instance.gameObject.AddComponent<TapToPlace>(); //----------
tapToPlace.SavedAnchorFriendlyName = (++this.count).ToString(); //-----------
}
private void Update()
{
if(!this.loaded && (WorldAnchorManager.Instance.AnchorStore != null))
{
var ids = WorldAnchorManager.Instance.AnchorStore.GetAllIds();
foreach(var id in ids)
{
var instance = Instantiate(this.prefab);
WorldAnchorManager.Instance.AttachAnchor(instance.gameObject, id);
}
this.loaded = true;
this.count = ids.Length; // --------------
}
}
}
Your answer
Follow this Question
Related Questions
Poll which line of code app is stuck at? 1 Answer
creating a game? 3 Answers
Programatically creating entire Unity games 2 Answers
Apps crash in development build 0 Answers
Can i create a virtual globe in unity? 0 Answers