Author Topic: how to load an image form disk resource and put it on an UITexture?  (Read 4414 times)

pcutile

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 81
    • View Profile
this not work
   category_image.mainTexture= Resources.Load(path) as Texture;
   category_image.MakePixelPerfect ();

where categoryi_image is declared as UITexture and path is like this
C:\Users\root\Documents\Unity Projects\myprj\Assets\Resources\fotopiatto1.jpg

i don't see any error in console but after this i don't see any texture ..

another.if i put an image in texture field of my UITexture via editor i see it but after my code it disappear and its value become null. so i think error is in load but no error i see.
« Last Edit: August 26, 2014, 06:07:20 PM by pcutile »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: how to load an image form disk resource and put it on an UITexture?
« Reply #1 on: August 27, 2014, 04:22:26 AM »
Resources.Load is only capable of pulling things from the Resources folder, and it doesn't take a path. It takes an asset name, such as "fotopiatto1". Check Unity's documentation.

pcutile

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 81
    • View Profile
Re: how to load an image form disk resource and put it on an UITexture?
« Reply #2 on: August 27, 2014, 05:53:12 AM »
thank i will read documentation better,  but since I consider your already give optimal response to my question, at this point you wonder if you can help me in this brief analysis of things. Since I have to give a chance to my user to upload a file via an image browser and put it in his program and that is, the 'user loads the program, open the file browser and search his briefcase for get image. Should I decide for a single folder (different from resources) that user can use or leave user with full use of all folders via filebrowser?