Setting textures in code

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Corran

Danger Mouse
Mar 10, 2003
168
0
0
37
Portsmouth, England
planetunreal.com
Hey, I'm having a problem with setting textures in my code. I'm setting the texture of a model according to the choice of the user. The user chooses the texture in the menu before the game and the texture is applied at the very start of the game, or should be. The line that's causing problems is this one:
Code:
BodyMaterial = Shader'UR-Nas_tex.Body.N_DrkBlu';
The compiler complains that it "Can't find Shader UR". I would assume that the comiler can't open the file or something if it wasn't for the fact that I do a very similar thing in the defaultproperties:
Code:
BodyMaterial=Shader'UR-Nas_tex.Body.N_DrkBlu'
And this one works fine.

Is there some kind of crazy thing you can't do in the code or is it something deeper? Any help would be appreciated.
 

Corran

Danger Mouse
Mar 10, 2003
168
0
0
37
Portsmouth, England
planetunreal.com
Yeah I've loaded the package and it works because if I remove the code and just use the defaultproperties setting, it compiles fine and the texture is applied. But as soon as I try to set it in the main body of the code, it says it cant find the package at compile time.
 

ceej

New Member
Nov 5, 2003
3
0
0
58
Silicon Valley
www.ceejbot.com
We encountered a similar problem and just ended up putting all our choosable textures into data structures that we set up in default properties. E.g.,

Code:
defaultproperties
{
   mNASBodySkins[0]=Shader'UR-Nas_tex.Body.N_DrkBlu'
   mNASBodySkins[1]=Shader'UR-Nas_tex.Body.N_LtRed'
}

then

Code:
if (choice == kDarkBlue)
   BodyMaterial = mNASBodySkins[0];
else
   BodyMaterial = mNASBodySkins[1];

etc etc. I'd like to know how to make this work 'right', but the workaround is clean enough.
 

chip

New Member
Nov 14, 2002
524
0
0
Visit site
is the hyphen in the package name causing the compile error? granted it works OK in the defaultproperties block, but perhaps that uses somewhat different rules. the error message from your original post seems to indicate that the compiler is looking only for a Shader called UR. maybe try renaming the package sans hyphen, or use ceej's method of referencing a variable that points to your package.
 
Last edited: