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 post has been wikified, any user with enough reputation can edit it.
avatar image
2
Question by devPhil · Feb 18, 2013 at 12:48 AM · loadingresourcesdelaywait

How do I wait for an object to load before accessing it's information?

Hi,

I'm building an iOS game that requires items to be generated dynamically, it then looks in a folder hierarchy after a corresponding file which has the item's name and icon.

Since in some cases I need to access the item's information straight away I'm getting null pointers because the item I'm trying to access hasn't loaded / generated all it's information yet (loading from resource folder). For example: Loading items to Inventory at start and having labels with it's name, where I get an error because the name isn't available yet.

This is a problem I've stumbled upon a few times before in other project but somehow found a way around it. In this case I'd like some help figuring out what the proper way of doing this is. Unfortunately loading all items at the start isn't really an option.

Apologies if this has been answered before, my search skills must be lacking :)

Grateful for any help, thanks!

Phil

Comment
Add comment · Show 1
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 $$anonymous$$ · Feb 18, 2013 at 01:12 AM 0
Share

$$anonymous$$aybe check to see if the object is null before accessing it?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Starkid225 · Feb 18, 2013 at 02:31 AM

Maybe perform a yield/coroutine and have it run a function to gather all the information first. Then it will continue and shouldn't have any null pointers. Just my thoughts...

This page may also be of help

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 devPhil · Feb 18, 2013 at 05:23 AM 0
Share

I've been thinking about using coroutines but was curious to what other solutions there were. For now I'm going with coroutines. I load the resources, I then pass the information to it's label or whatever it is. Not the best solution but it works :)

Thanks

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

Using yield wait for seconds in my script, correctly 2 Answers

Loading a mesh? 1 Answer

Unity IAP InitializePurchasing taking too long. 1 Answer

2D Infinite Runner questions 3 Answers

Slowing down the speed of my bullets whilst holding in the key. 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