i want to assign a picture from a folder in my computer to a texture2d, but not in the inspector! i want to do it in script. but it gives me an error like this:
"NullReferenceException: Object reference not set to an instance of an object"
i want to assign a picture from a folder in my computer to a texture2d, but not in the inspector! i want to do it in script. but it gives me an error like this:
"NullReferenceException: Object reference not set to an instance of an object"
You can use Resources.Load or asset bundles to load textures on the fly without referencing them first. Just make sure to read the docs for its' limitations, especially if you're developing a streamed web player.
The Resources folder isn't exposed to the end user. It's used by you, and you alone when you develop your application. If you want your end user to add/change assets, you'll need to use other tools, such as the WWW class with the file:// syntax or the System.IO namespace of Mono (like this, for example). There are plenty of examples for it in the forum, and maybe even in the WIKI. Try searching for System.IO for example.
but looks like this is just for editor mode! how if I want to do this when the game is built? then I won't have any folder called asset :(
– kingrexthanx for the help bro
– kingrexNo probs dude :)
– anon23753345sorry I built the game but there was no folder called Resources! how should the user put some extra images in that folder? only I can put images in the folder before building the game, but end user can't.
– kingrex