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 /
avatar image
0
Question by Michael 17 · Feb 23, 2011 at 02:06 AM · editorbuildqueue

Queue> not working?

Hi !

Using : C#

I ran onto a strange bug this week... in my code, I'm using a Queue<KeyValuePair<string,int>> to store a type of ennemy(string) and how many I need to spawn(int).

If I'm trying to something like :


list<string> aList = new list<string>();

aList[0] = aQueue.Dequeue().Key;


This code works in the editor, but not in the build.(Building for PC) In fact, the line where I dequeue and everything after is not executed in the build. The wierd thing is that everything before this line is executed...

I placed a GUIText that changes his text to debug this in the build....so I know that it is this exact line.

No errors, no warnings in the console.

Very weird.

Is there any complex data structure that Unity can't handle ?

Thank you

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

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Ianson · Feb 10, 2014 at 02:35 PM

I know this is a very old thread but I had this problem too.

if you go into monodevelop and go to Run >> Exceptions you can add exception types to the list of exceptions. this will catch the exception in the editor and make it easier to debug...

But, in a nut shell you need to check the queue count before accessing it. Even .Peek() will throw an exception if your queue is empty- which makes very little sense in my opinion. If it returned null at least you would get a null exception when you tried to dequeue which is far more useful...

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

Answer by tertle · Feb 23, 2011 at 03:33 AM

I don't really understand why it'd work in the editor, but not when you actually build it.

Out of interest, what type of List are you using? Is it the standard System.Collections.Generic.List?

Have you tried

List<string> aList = new List<string>();
aList.Add(aQueue.Dequeue().Key);
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 yoyo · Feb 23, 2011 at 04:11 AM 0
Share

Good point -- even trying to set element 0 should throw an ArgumentOutOfRange exception if the list is empty. Add is the way to go.

avatar image
0

Answer by Michael 17 · Feb 23, 2011 at 04:45 PM

I tried changing the data structure and the same thing is happening.

This line is not working in the build but do works in the editor :

string strEnnemyType = EnnemyType.Dequeue();

I'm running out of ideas... this is really annoying. I'm tried the script on a new project, and it's doing the same thing.

I'm using the System.Collections.Generic

Next step: I'm gonna try it on another computer...

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

Answer by Blr. · Sep 28, 2012 at 08:54 PM

I have the same problem too, inside the editor everything works fine but inside Xcode I got the this message:


InvalidOperationException: Operation is not valid due to the current state of the object at System.Collections.Generic.Queue`1[System.Single].Peek () [0x0000b] in /Applications/buildAgent/work/51c26656ff47b7e8/mcs/class/System/System.Collections.Generic/Queue.cs:154 at System.Collections.Generic.Queue`1[System.Single].Dequeue () [0x00000] in /Applications/buildAgent/work/51c26656ff47b7e8/mcs/class/System/System.Collections.Generic/Queue.cs:138

(Filename: /Applications/buildAgent/work/51c26656ff47b7e8/mcs/class/System/System.Collections.Generic/Queue.cs Line: 154)


 private Queue<float> m_que = new Queue<float>();
 
 void Awake(){
                 for(int i=0; i<m_sample; ++i){
             m_que.Enqueue(0);
         }
 }
 
 void Update (){
         m_que.Dequeue();
         m_que.Enqueue(vAcc.x);
 }
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

2 People are following this question.

avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

Create custom warning dialog on build, if a script or gameobject exists in the scene 2 Answers

OnServerStart not being called in standalone build. Works in editor. 1 Answer

MouseLook doesn't work! 1 Answer

Network View and Networking script crash 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