Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 sam_sundar · Nov 01, 2018 at 03:34 AM · vuforiagameobjectsaugmented-reality

Hide and Show Multiple Gameobjects upon button click .

I'm trying to develop an augmented reality application using Vuforia . I have to show specific Gameobject for an Image Target , say cube for Image Target 1 and Rectangle for Image target 2 , triangle for target 3 and so on for 10 targets. Both the targets will be tracked simultaneously . All i want to do is show cube first and when button is clicked it should hide the rectangle . and Again when button is clicked , it should show triangle hiding both cube and rectangle . All these with a single button and on multiple clicks . All i know is things are to be changed at Defaukttrackableeventhandler.cs script .

Whats i'm doing right now is each scene has a image target and a button for each scene , so when button is clicked , load next scene . I know this is not the right way to do . I'm new and i'm learning.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Vega4Life · Nov 01, 2018 at 03:17 PM

I think I understand what you are saying, so here is me just messing around.


Create a script like this and add it to an empty GameObject in your scene. Add your target objects to the array, preferably in order you wish to see them display after each click.

Also add a UI Button (via GameObject -> UI -> Button). On the button is an OnClick event. Drag the script onto this event. You can now select a function from the script in that box (click on the button that probably says No Function). You should see a list of scripts, find yours and then click on the function you want to call. In the example I made, it's called OnClickButton.


It should default show the first one, then cycle through the rest. You should also disable the objects you are trying to show to be off. You can do this by default in the scene, clicking the checkbox at the top of each object, or cycle through the array OnStart() and do Setactive(false) to all of them.


 public class Changer : MonoBehaviour
 {
     [SerializeField] GameObject[] targets;
 
     GameObject currentTarget;
     int targetIndex;
 
 
     void Start()
     {
         ChangeTarget();
     }
 
 
     void ChangeTarget()
     {
         if (targets.Length > targetIndex)
         {
             if (currentTarget != null)
             {
                 currentTarget.SetActive(false);
             }
 
             currentTarget = targets[targetIndex];
             currentTarget.SetActive(true);
             targetIndex++;
         }
     }
 
 
     public void OnClickButton()
     {
         ChangeTarget();
     }
 }




Comment
Add comment · Show 3 · Share
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
avatar image icanCsharp · Oct 08, 2019 at 03:06 PM 0
Share

Hi, how can I reverse this? I have 2 buttons next and prev. I also have 4 images. It's working on next button the images works from 1 - 4 but I dont know what to do for previous button. Can you help me?

avatar image GubaLord icanCsharp · Oct 08, 2019 at 03:54 PM 0
Share

You just have to decrease the index ins$$anonymous$$d of increase it. So change the targetIndex++; line to targetIndex--; and that's it.

avatar image icanCsharp GubaLord · Oct 08, 2019 at 04:37 PM 0
Share

It's not working :(

avatar image
0

Answer by harimukulsagar · Jul 20, 2021 at 11:39 AM

Hi, @Vega4Life Thanks for your brilliant suggestion for this, I am a newbie to unity and tried some things. I used your script and nothing is happening. I guess because I don't know how to add targets "Create a script like this and add it to an empty GameObject in your scene. Add your target objects to the array, preferably in order you wish to see them display after each click."

I will be really thankful if you can drop a comment and teach me master /m\ ;),Hi, @Vega4Life Thanks for your brilliant suggestion for this, I am a newbie to unity and tried some things. I used your script and nothing is happening. I guess because i don't know how to add targets "Create a script like this and add it to an empty GameObject in your scene. Add your target objects to the array, preferably in order you wish to see them display after each click."

I will be really thankful if you can drop a comment on teach me master /m\ ;)

Comment
Add comment · Share
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

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.

Follow this Question

Answers Answers and Comments

109 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 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

Cloud recognition in Vuforia 0 Answers

Augmented Reality Tracker 1 Answer

How do ı acces dji matrice100 camera in my augmented reality application?(Using vuforia sdk) 0 Answers

Access vuforia ARCamera and put it on a sphere? 0 Answers

VUFORIA MULTI-TARGETS: SCRIPTING & CHILD HOLOGRAM VISUALIZATION 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges