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 piottej · Feb 09, 2015 at 03:49 PM · onbecamevisible

Crash - OnBecameVisible OnBecameInvisible & Mesh distorsion

Hi guys, I have a Crash issue.

I'm twisting meshes at runtime in my application so it fits to a curve that I drew in the editor. Here's an image of what's happening with a few comments :

On the top-left side, you got a prototype (a railroad in this example). On the top-right side, there is some piece of network I drew. And at runtime, you got the result from the bottom of the image.

alt text

I used to have those objects drawn in a Manager that looped over them every few frames to check if it had to delete/draw something. But I wanted to optimize my code using the 'OneBecameVisible' & 'OnBecameInvisible' methods because I'm starting to have huge number of objects to draw and I spend more time wondering which I should draw/delete than actualy drawing/deleting anything.

So the idea is that each prototype that must be drawn and twisted along the network, there is a box (an invisible stretched cube) that bounds the space in which the prototype is gonna be placed. Also I'm using a "IsBusy" bool to avoid concurrent drawing/deletion, etc.


So how this is drawn at runtime :

  • Everytime the box triggers the OnBecameVisible :

While(IsBusy), wait. Set IsBusy to true, instantiated prototype (or get it from a pool if any), compute the vertices distorsion, place the mesh, set back IsBusy to false.

  • Everytime the box triggers the OnBecameInvisible :

While(IsBusy), wait. Set IsBusy to true, deleted the object (or release it in a pool for further usage), set back IsBusy to false.


Everything works fine as long as you don't try to turn back several times or move forward and backward "too" fast. But when you do, it seems that the OnBecameVisible & OnBecameInvisible triggers in a way that makes my editor crash. I made some tests using only one prototype and I can make my editor crash nearly every time I turn back several times quickly. I added logs everywhere to track down if I didn't messed up my logic with my IsBusy boolean, everything looks cool... I also tried adding logs to track down a potential null ref (even though I don't think this could have lead to a crash), still nothing...

I'm out of options in my code. I'm suspecting the OnBecame(In)Visible methods to be the cause of my crashes. Does anyone have a lead ?

Sorry for that wall of text, I wanted to be clear and I find it quite hard to be clear and concise. Sorry for my english as well.

EDIT : Okay, I never had this before, it seems the editor crashes even when I turn back slowly... I'm even more confused...

EDIT 2 : I migrated my code to the Update function so that the OnBecame(In)Visible methods are not used anymore. Same result. I'm starting to think this is scene/cache related as I never had those troubles before...

EDIT 3 : Ok, fixed it. My code was working perfectly fine. The bug I wanted to correct appeared when an intern of ours added some "fix" in my code. Somehow, he managed to destroy my whole test scene & test prototypes. Even when I reverted his modifications, I could not make anything work again. I'm gonna break his both hands tomorrow, this won't happen again.

drawersbasics.png (87.5 kB)
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 VesuvianPrime · Feb 09, 2015 at 03:50 PM 0
Share

Is it a viable solution to loop over your pieces of geometry and perform an AABB test with the camera frustum ins$$anonymous$$d?

avatar image piottej · Feb 09, 2015 at 03:52 PM 0
Share

Sadly, no. This is the option i'm trying to replace. I used to do this but in the end I was spending my time looping over like 10000 objects just to know "should I draw or delete this object".

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by piottej · Feb 10, 2015 at 08:58 AM

Fixed (see EDIT 3 in first post)

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to use isVisible or OnBecameInvisible() to detect player offscreen 1 Answer

Is there a way that I can control the maximum number of Visable Skinned Mesh? 0 Answers

OnBecameVisible() called out of nowhere... 1 Answer

Onbecomevisable, straight up dosnt work. activates but gameobject is not in camera view? 0 Answers

My Enemy isn't moving! 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