playMaker

Author Topic: Selecting textures logically - and Resources Load [SOLVED]  (Read 2828 times)

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Selecting textures logically - and Resources Load [SOLVED]
« on: February 11, 2014, 04:40:19 PM »
Hi,

I have a string variable that should help me assign the right texture to an object. I'd want to do something like

texStringVar = "ABCD"
texTexVar = \Assets\Texture_[texStringVar]
renderer.material.mainTexture = texTexVar;

=> which (I wish!) would set my texture to "Texture_ABCD"

I'm trying to use the "Resources Load", but it seems I can only assign a predefined texture ... which I have no way of referencing logically.

Also, I've failed trying to figure out what I am to put in the required "Asset Path" field. There is no help as to how the path is supposed to look in the description, only that it is a relative path to my Assets\Resources folder. I mean, even if I've pointed directly to my texture, selecting it in a Texture variable, it still fails trying to locate it.

Please help :)
/Bad





« Last Edit: February 12, 2014, 10:25:00 AM by TheBadFeeling »
The Force is with you, young Playmaker – but you are not a C# senpai yet.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Selecting textures logically - and Resources Load
« Reply #1 on: February 12, 2014, 03:59:13 AM »
Hi,

 indeed, Resources are totally not harcoded, since you have to reference the "file" itself.

 http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html

this page has examples, I am not sure what's not clear there. If you have a "glass" texture in a "Resources" folder, then putting "glass" in load resource action will work.

Can you give me more info about your exaczt folder structure to reach your textures? Lots of stuff on this topic on UA actually:

http://answers.unity3d.com/questions/14748/c-resourcesload-problem.html
http://answers.unity3d.com/questions/199313/resourcesload-folders-path.html

Bye,

 Jean

TheBadFeeling

  • Junior Playmaker
  • **
  • Posts: 66
Re: Selecting textures logically - and Resources Load
« Reply #2 on: February 12, 2014, 10:24:12 AM »
Thanks for the reply! Yeah, I guess I should look it up in the Unity-reference, when the Playmaker description doesn't explain things.

So -- from your links I found my mistake:

I thought the texture I wanted to load should go into the "Variable" option and the relative path should go into the "Asset Path" field. :-[ Duh.

Now I can both reference a texture using a variable AND load it.  ;D

Thanks a lot for your help and pointers!
/Bad
The Force is with you, young Playmaker – but you are not a C# senpai yet.