- Home /
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?
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
Not in a web build, no. It's disallowed from web builds for privacy and security reasons