• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SupriyaRaul · Jul 03, 2018 at 07:44 PM · developmenttaptomove

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; // --------------
     }
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

88 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

taptomove controls, plane boundary?? 0 Answers

Build Error for Iphone Developer 2 Answers

what should I take note when making a game character? 0 Answers

MonoDevelop Opening New Window 1 Answer

How do I make that when I hover the mouse over GUI Texture it changes color? 4 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges