Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Jan 20, 2012 at 01:26 AM by digitalConundrum for the following reason:

Question was wrong, simple mistake, no answers submitted before problem found...comments reflect this.

avatar image
0
Question by digitalConundrum · Jan 20, 2012 at 12:33 AM · c#crashlistbroadcastmessage

Unity crashing with BroadcastMessage (possibly not thread safe?)

I have a random number of nodes which are connected via a structure I call the transfer manager. It allows items to be transferred from one node to another. As far as my testing has gone, everything seemed to work perfectly until I implemented BroadcastMessage to call a function on every transfer manager, followed by a call to every node.

very simply this starts the call:

 if(GUI.Button(new Rect(Screen.width-101,0, 100, 100), "End Turn"))
         {
             allParent.BroadcastMessage("ResolveTransfers");
         }

followed by this script running on all transferManagers simultaneously.

 void ResolveTransfers()
     {
         
         if (tempOne.fleetShips > 0 && tempTwo.fleetShips > 0 && tempOne != tempTwo)
         {
             List<Fleet> tempList=new List<Fleet>();
             tempList.Add(tempOne);
             tempList.Add(tempTwo);
             Fleet.Battle(tempList);
         }
 
         if (tempOne != null)
         {
             two.AddFleet(tempOne);
         }
 
         if (tempTwo != null)
         {
             two.AddFleet(tempTwo);
         }
 
 
         tracker++;
 
 
         if (tracker== count)
         {
             print(count);            
             GUIWindows.instance.allParent.BroadcastMessage("OnEndOfTurn");
             tracker = 0;
         }
     }

The part that concerns me is the last part, Its designed so that the message is sent only once: when the last running instance of the script (count is static and incremented in start, so it should be the number of instances) hits that point, but I'm starting to think that it might not be thread safe and is causing the crash? The next broadcastMessage is only calling an empty function at the moment, so its not the problem.

I'm really at a loss here and I've wasted 6 hours today trying to get this working. I would really appreciate any help with this.

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 Tyler 10 · Jan 20, 2012 at 01:16 AM 1
Share

Its tough to say what you are experiencing, but make sure that by broadcasting GUIWindows.instance.allParent.Broadcast$$anonymous$$essage("OnEndOfTurn");

your code doesn't call: Broadcast$$anonymous$$essage("ResolveTransfers"); again. This would throw unity into a infinite loop, you would get no error messages, it would just lock up, sit there for a few seconds and quit.

avatar image digitalConundrum · Jan 20, 2012 at 01:25 AM 0
Share

I actually just found the problem, I overloaded the equality operator and then inside the operator checked if it was == null, causing infinite recursion. Thanks for the time though, closing question.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Procedural generated mesh problem 1 Answer

adding items to my list 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