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 /
avatar image
0
Question by lklqlk · Dec 09, 2016 at 06:19 AM · c#eventsmethodgameobject.find

very funny problems,a function doesn't excute to the end

alt text

alt text

so,the problem is this function didn't get excuted to the end,it just break at the GameObject.Find function call.and the excution flow goes to another script.so what happened?it's very funny that this function somehow breaked before it's done,the rest of the Debug.Log didn't even get excuted.i'll post another image to show the next step the excution goes to another script directly. if i comment out the code in that if scope,the rest of the code gets excuted as normal.strange? isn't it?

this function should be called when SceneManager set my game scene to be active.as you see, this is an event callback.sorry for my english,i'm not a native english speaker.so maybe we can discuss about this funny problem.what happened behind this

and there's an error below i don't quite understand 'fillTime The identifier fillTime is not in the scope' what is this errror?

step1.png (187.0 kB)
step2.png (186.4 kB)
Comment
Add comment · Show 3
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 lklqlk · Dec 09, 2016 at 02:18 AM 0
Share

it seems i can't post that image,maybe because the limitation.

avatar image NoseKills · Dec 09, 2016 at 07:26 AM 0
Share

If you look into Unity's console window after running this, do you see an error. $$anonymous$$ethods do break if they encounter an unhandled exception.

The message about fillTime is not really an error. You just have set a watch to a variable called fillTime, but the class/method you are stepping through doesn't contain such a variable.

avatar image lklqlk NoseKills · Dec 09, 2016 at 11:38 AM 0
Share

thank you,unity didn't log any error in console window.and the extra if statement didn't get called,otherwise i would see the message to notify me it is null.i used to think in program$$anonymous$$g world method should execute to the end,no matter what.i don't know if this is unity thing,or other computer program could run the same problem.some code didn't get a chance to execute,and no error message.

2 Replies

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

Answer by clyburnw · Dec 09, 2016 at 10:50 AM

That is a giant red flag that there's an exception. I'll bet you 5 American dollars that GameObject.Find() is returning null, causing the GetComponent() call to throw. Wrap the whole thing in a try/catch and log the exception text.

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 lklqlk · Dec 09, 2016 at 11:29 AM 0
Share

you're absolutely right.you know what i found later.there's actually a problem with that GameObject.Find() call.but unity console didn't log an error. below that call i added extra check to see if 'GameCamera' is null.if it can't be found,unity should log that message.however,unity shows nothing in console.now i see that if some code or function runs into some problem,it could actually break the method execution,without any error message,and the code after the breaked point won't get executed,even though they're in the same function.if someone runs into the same strange problem,be sure to check your code carefully.there may be a potential error. and thank you for the help.

avatar image
0

Answer by Denzil · Dec 09, 2016 at 05:07 PM

I'll bet your problem is that the "Game Camera" object is not found. Are you sure that you have an active Game Object in the scene with that name?

Do note it must be active!

If it doesn't find anything, it will return a null reference, and calling GetComponent on this null reference will will cause an exception to be thrown, which will stop execution of the script.

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

10 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Invoke/Coroutine problems with events 2 Answers

Unity Events, Listeners, Delegates, etc. 1 Answer

How would I go about creating a custom Unity Event in a Custom Unity Editor/Inspector? 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