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 jtcrash · Mar 07, 2012 at 11:46 PM · transformobjectwwwdataproperties

Adding data to a set of transforms

Hello,

I have a blank gameobject that contains 70 some odd prefabs (generated at run-time). I want to be able to loop through the prefabs and add a WWW object which will be setting its texture as soon as the download completes, but I need to track which prefabs have have WWW objects that aren't isDone, so that I could dispose of the WWW object that is associated with that particular prefab. Here is an example of what I have/need (simplified):

 for(var child : Transform in transform){
     var txt = new Texture2D(tileSize, tileSize, TextureFormat.DXT1, false);
     var www = new WWW("urlgoeshere");
     yield www;
     www.LoadImageIntoTexture(txt);
     child.guiTexture.texture = txt;    
     child.newpropertynamehere = www; // THIS IS WHAT I NEED
 }

So that later I can do:

 for(var child : Transform in transform){
     if(!child.newpropertynamehere.isDone) child.newpropertynamehere.Dispose();
 }
 

Any help would be greatly appreciated!

Jake

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

1 Reply

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

Answer by FishBone · Mar 08, 2012 at 04:48 PM

Let every GameObject have a script that loads the textures and keeps the variables for isDone.

 var children : WWWLoader[] = GetComponentsInChildren<WWWLoader>();
 for (child : WWWLoader in children)
 {
    child.Load("urlgoeshere");
 }

so later you can do:

 for (child : WWWLoader in children)
 {
    if(!child.isDone) child.Dispose();
 }


the WWWLoader-class would look something like

 var isDone : boolean;
 function Load (url : string) {
     var txt = new Texture2D(tileSize, tileSize, TextureFormat.DXT1, false);
     var www = new WWW(url);
     yield www;
     www.LoadImageIntoTexture(txt);
     guiTexture.texture = txt; 
     isDone = true;
 }
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 jtcrash · Mar 08, 2012 at 07:21 PM 0
Share

Thanks for your help on this, I am new to unity and game development so I have to think a bit differently.

I figured it would involve applying a class to the tiles, should I drop this WWWLoader script on the guitexture that is inside the prefab? Or the prefab itself?

Also, does the child.Dispose(); dispose of the WWW object or does it dispose of the whole prefab?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to center prefabs' children to (0, 0, 0) without changing their position relative to each other 1 Answer

Loading a large xml file (~200 multi-level nodes) into Unity 1 Answer

How to assign Transform to prefab ? 2 Answers

downloading data in background without halting application 1 Answer

WWW and php issues 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