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 pickledzebra · Jul 01, 2010 at 05:18 PM · instantiateprefabtextwebplayerasset

Prefabs not visible in webplayer? (read from .txt file)

I've got a script in my scene that reads a .txt file in the project directory.

It reads in 3D coordinates and places simple prefabs into the scene according to those coordinates.

This all works fine and dandy in the editor and a standalone windows.

However, in the web-player, these prefabs are never instantiated. The problem appears to be that the script isn't reading the .txt. asset.

Is there a solution to this?

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
3
Best Answer

Answer by Mike 3 · Jul 01, 2010 at 05:35 PM

Put the txt file in the /Assets/Resources folder (or a subdirectory of it). That'll let you use it as a Resource and TextAsset

Code to get it working after that:

var textAsset : TextAsset = Resources.Load("MyTextFile"); if (textAsset == null) return;

var text = textAsset.text; //this is the text as a string var bytes = textAsset.bytes; //this is the text as bytes

You can use text or bytes as you wish, depending on which is more useful

Comment
Add comment · Show 3 · 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 pickledzebra · Jul 01, 2010 at 05:41 PM 0
Share

Great, thanks! So, I can't use he streamreader?

avatar image Mike 3 · Jul 01, 2010 at 05:43 PM 0
Share

Not in a web build, no. It's disallowed from web builds for privacy and security reasons

avatar image pickledzebra · Jul 01, 2010 at 05:56 PM 0
Share

Ok, thanks for the info.

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

No one has followed this question yet.

Related Questions

Prefab instantiating at wrong position in mobile 1 Answer

Make Mesh & Text disappear 2 Answers

How do I instantiate a textObject prefab? 0 Answers

Create an AssetBundle with prefabs containing imported models 0 Answers

Help making a damage number system 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