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 /
  • Help Room /
avatar image
0
Question by Rodolinc · May 12, 2016 at 04:50 PM · c#scripting problemcoroutinesevents

Same script working yesterday not working today

Hello, I made a script that makes a list of the childs of an object and then sets them active one at a time using a coroutine. The script is suscribed to an event on another script's Start function for testing reasons. It worked perfectly yesterday, but today after opening the project again and pressing play, it didn't work :S could be something to do with the event? or the coroutine?

 public class FootPrintManager : MonoBehaviour {
 
     public delegate void FootstepsShot();
     public static event FootstepsShot FootstepsEnd;
 
     public float delayTime = 1.0f;
 
     public List<GameObject> footsteps;
 
     void OnEnable(){
         AnimController.ShotLight += StartSteps;
     }
     void OnDisable(){
         AnimController.ShotLight -= StartSteps;
     }
 
     public void StartSteps(){
         foreach(GameObject step in footsteps){
             StartCoroutine("Walking");
         }
     }
 
 
     void Start () {
         footsteps = new List<GameObject>();
         foreach(Transform steps in transform){
             footsteps.Add(steps.gameObject);
         }
     }
     
 
     IEnumerator Walking(){
         
         foreach(GameObject step in footsteps){
             yield return new WaitForSeconds(delayTime);
             step.SetActive(true);
         }
     }
 }
 

Thanks!

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
1

Answer by $$anonymous$$ · May 13, 2016 at 07:09 AM

The order of the two scripts is important in your case. The Start function in one script must start before the other one starts. Unfortunately the order can be random and can be different on different platforms and devices. You can however define an order to specific scripts with Edit-->Project settings --> Script execution order. Add your script that has to be executed first and give it a negative number to be sure it starts first.

Comment
Add comment · Show 1 · 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 Rodolinc · May 13, 2016 at 02:25 PM 0
Share

unfortunately this didn't work, but thanks a lot for that info I didn't know. I'll keep finding what may be the problem. A difficult thing to do because I tested the game just before closing the project and going out of work, and it worked good, then the next day it didn't, I moved nothing in between...

avatar image
0

Answer by Rodolinc · May 13, 2016 at 02:41 PM

I just found out what it was, maybe I was lucky the first time I ran the script it filled the list of gameobjects "before" I was reading it in the StartSteps function. The solution was to change my Start() function to an Awake() function and now the List gets filled before trying to access it.

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

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

Performance of event vs static method call 0 Answers

Coroutines not running one after another 1 Answer

Error with calling events from other scripts 3 Answers

Continuously monitor childrens properties 1 Answer

How would i modify my current script to remove these UI buttons without killing my pause menu? 1 Answer


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