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 Anxo · Mar 03, 2016 at 11:04 PM · c#methods

Arbitrary line in one method prevents another for working?

This is blowing my mind....

I have a loop.

 IEnumerator Start()
 {
      while(true) {
           if(collectedFloatList.Count > 0){
                OverallLatencyReport(collectedFloatList.Avarage); // < Call Method 1;
                CheckForEvent (collectedFloatList);   // Call Method 2; 
           }
       yield return new WaitForSeconds(1f);
      }
 }

The problem is, this works perfectly fine if I comment out Method 2, "CheckForEvent" but with the method in there, it will not execute method 1 "OverallLatencyReport". So I started commenting out some lines, in Method 2 and found the line that makes method 1 stop working but that line has nothing to do with Method 1. What is worse is that if I swap the "guilty" line with another line that also has nothing to do with Method 1, and comment out the guilty line, the new random line becomes the "guilty" line and stops method one for working.

I do not understand what I am missing.

Here is Method 1 and 2.

 void OverallLatencyReport(float lag) // This method does not do the job when "guilty" line is active
 {
      GameObject lagBarClone = Instantiate (latencyHitPrefab) as GameObject;
      lagBarClone.transform.SetParent(graphParent);
      activeGraphHits.Enqueue(lagBarClone);
      lagBarClone.GetComponent<Slider>().value = lag;
      if(activeGraphHits.Count > maxGraphHit)
           Destroy(activeGraphHits.Dequeue());
      overallLatencyInfo.text = (lag).ToString() + " ms";
 }

And this is the method with the "guilty" line?

 void CheckForEvent(List<float> ALPS)
 {
      float minLatency = ALPS.Min();
      float.maxLatency = ALPS.Max();
      bool spike = (minLatency *2 < maxLatency);
      bool drop = (maxLatency / 2 > minLatency);
      if(spike){
           GameObject textClone = Instantiate (eventTextPrefab) as GameObject) as GameObject;
           Text newEvent = textClone.GetComponent<Text>();
           newEvent.transform.SetParent(eventParent); // This is the guilty line if not commented out
 
           // BUT!!! if I comment it out, and I uncomment the next line like so. 
           // newEvent.transform.SetParent(eventParent); 
           newEvent.text = "Spike at " + (Time.time -autoToggleTime).ToString(); // Now this is the guilty line and stops the first method for performing. 
     }
 }

No error, just stops working. Any ideas?

Comment
Add comment · Show 2
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 Anxo · Mar 04, 2016 at 07:51 PM 0
Share

Sorry to bump and tag but its been a while @Bunny83 @Eric5h5

avatar image Eric5h5 Anxo · Mar 04, 2016 at 08:12 PM 0
Share

Don't tag people who have nothing to do with this question, and it hasn't "been a while", it's less than a day.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by phil_me_up · Mar 04, 2016 at 01:25 AM

Are you getting any errors in the console?

My guess is that as both "guilty" lines are using 'newEvent', the problem is that newEvent is null, which causes an exception and halt the coroutine (assuming Start is a coroutine. If so you might want to rename for clarity).

If the above is correct, you need to look at how newEvent is set and that your GetConponent call is successful (will fail if the Text component can't be found).

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 Anxo · Mar 04, 2016 at 06:17 PM 0
Share

I wish it was this simple, I can replace the "guilty" line with "Debug.Log("write something"); and it will break the system. It appears not to be the content of the line but the count? There is no error and the item is not null. It appears to be deeper than that.

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

113 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

Related Questions

re historic GUI system 1 Answer

I can't seem to have access to Tilemap methods, what am I doing wrong ? 0 Answers

Method not being called on Unity Event 0 Answers

Can I store a value computed in one method outside of that method? 2 Answers

Random.Range method "left-hand side" error 2 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