Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Golnahali · Feb 16, 2019 at 02:33 PM · script.vuforia

Disable Game object, Enable other Game objects after 5 seconds to show progress

Hi I want to disable game object and enable other object and do this for all object in 5 second for each one to show progress, i did this by adding a script to ImageTarget with this code:

 public class cv : MonoBehaviour
 {
     
     void Start()
     {
         StartCoroutine(LateCall());
     }
 
     IEnumerator LateCall()
     {
 
         Obj1.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj1.SetActive(false);
         Obj2.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj2.SetActive(false);
         Obj3.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj3.SetActive(false);
         Obj4.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj4.SetActive(false);
         Obj5.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj5.SetActive(false);
         Obj6.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj6.SetActive(false);
         Obj7.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj7.SetActive(false);
         Obj8.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj8.SetActive(false);
         Obj9.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj9.SetActive(false);
         Obj10.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj10.SetActive(false);
         Obj11.SetActive(true);
         yield return new WaitForSeconds(5f);
         Obj11.SetActive(false);
         Obj12.SetActive(true);
     }
 
 
     [SerializeField] private GameObject Obj1;
     [SerializeField] private GameObject Obj2;
     [SerializeField] private GameObject Obj3;
     [SerializeField] private GameObject Obj4;
     [SerializeField] private GameObject Obj5;
     [SerializeField] private GameObject Obj6;
     [SerializeField] private GameObject Obj7;
     [SerializeField] private GameObject Obj8;
     [SerializeField] private GameObject Obj9;
     [SerializeField] private GameObject Obj10;
     [SerializeField] private GameObject Obj11;
     [SerializeField] private GameObject Obj12;
    
 }

What is the problem?

@Bieere @fafase Thanks!

Comment
Add comment · Show 3
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 RobAnthem · Feb 16, 2019 at 03:30 PM 0
Share

First of all, this is not how you should be handling any of this. Something more like this...

      IEnumerator LateCall()
      {
           for (int i = 0; i < objectArray.Length; i++)
          {
                objectArray[i].SetActive(true);
                yield return new WaitForSeconds(5f);
                objectArray[i].SetActive(false);
          }
      }
 
      public GameObject[] objectArray;
avatar image zereda-games · Feb 16, 2019 at 03:45 PM 0
Share

what outcome are you looking to get? have you tried to do : {Edit to use @RobAnthem 's method}

      bool check;
      public GameObject[] objectArray;

      IEnumerator $$anonymous$$yEnumerator(){
    for (int i = 0; i < objectArray.Length; i++)
       {
             check=Equals( objectArray[i].enabled, true);
             objectArray[i].SetActive(true);
             while (Equals(check,true)){
         yield return WaitForSeccond(5.0f);
         objectArray[i+1].SetActive(true);
     }
             yield return new WaitForSeconds(5f);
             objectArray[i-1].SetActive(false);
       }
avatar image Golnahali zereda-games · Feb 17, 2019 at 08:03 AM 0
Share

i should put this is Start() ?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by SharkoFR · Feb 16, 2019 at 03:36 PM

First of all, try to put the GameObject variables before the IEnumerator (i suggest you to place it at the top (before the start). Then are you sure your GameObjects are assigned? and Do you get any errors?

Comment
Add comment · Show 6 · 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 Golnahali · Feb 16, 2019 at 03:44 PM 0
Share

Thanks, i didnt get any error and i assigned all objects

avatar image SharkoFR Golnahali · Feb 16, 2019 at 03:47 PM 0
Share

so it works now ?

avatar image Golnahali SharkoFR · Feb 17, 2019 at 08:00 AM 0
Share

dont work!

avatar image zereda-games · Feb 17, 2019 at 10:28 AM 0
Share

didn't i answer this same question yesterday?

avatar image Golnahali zereda-games · Feb 17, 2019 at 11:30 AM 0
Share

you added comment

avatar image zereda-games Golnahali · Feb 17, 2019 at 11:31 AM 0
Share

maybe i removed it myself LOL appologies.

avatar image
0

Answer by Uios-Theou · Feb 17, 2019 at 02:50 PM

There has got to be an easier way than this.

That code is hard to look at.

Have you tried using a list, maybe a queue, to achieve your goal?

Add the objects to a list. Start a Coroutine like,

  IEnumerator FlashObjects
 {
     I = 0;
     while(I < list.count)
     {
      list[I].setActive(true);
           if(I - 1 >= 0 && I - 1 <= list.count)
          {
           list[I-1].setactive(false);
          }
      I++;
     yield return new wait for seconds (5);
     }
 }

This should work and looks a lot nicer and cleaner , in my humble opinion, but im a rookie coder.

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

116 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Vuforia Database Load Behavior 1 Answer

How to make object showing depend on target? 1 Answer

Cloud recognition in Vuforia 0 Answers

Vuforia tracks without showing objects 0 Answers

AR Camera zoomed in on iPad Air 2 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