- Home /
load/have asset on a static script
Hey, I was wondering: how would you load/have a reference to an asset within a static class/script? The reason I'm asking is because I have a static script that can be called from anywhere, and it is not attached to any GameObject. I want the static script to, for example, apply a GUISkin. How would I get the reference to the GUI SKin?
For example, usually you would attach a script to a game object, and set the reference in inspector. Because this static script isn't attached to anything, I can't do that. Anyway for me to do that? Thanks.
Answer by Mike 3 · Mar 28, 2011 at 08:59 PM
You can use
Resources.Load("Moo");
This will load an asset called Moo with the path (relative to assets) Resources/Moo.jpg
You need to skip on the extension, and the file HAS to be in the Resources folder (which you should add if it doesn't exist), or one of its subdirectories. The path you use in the Resources.Load call needs to be relative to Resources
ahh i see, so you can specify resources that can be accessed by code, pretty cool, this should work perfectly. Thanks!!
Small note - everything in that directory gets added into the build (which is why it's the only appropriate place to put runtime loaded stuff that doesn't go into a variable slot)
Your answer
![](https://koobas.hobune.stream/wayback/20220613115356im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Export asset also includes static dependencies 0 Answers
Static problems 0 Answers
No solution in Monodevelop 5 Answers
Updating assets changes .meta files and breaks dependencies. 1 Answer