- Home /
Resource load default unity sprite?
Is it possible to use a default unity sprite via scripting? I'm trying to build a simple UI element via scripting, I'm now trying to assign the default background sprite to an image component. How ever, I can't seem to think of any way of grabbing/finding said sprite via scripting.
Are you trying to make a Sprite out of an Image? Can you explain more clearly please?
When you create a Panel, Image, etc., the default one will already be there so you don't need to go grab it.
Or, are you trying to assign the default image for Panel to something else, like a Button?
Answer by Niks4Linux · Apr 27, 2018 at 11:12 AM
Hi, Here's the link where you can get the default unity resources paths and their values. If you see as you are trying to access default unity sprite you can access it using AssetDatabase class like this -
GetComponent<Image> ().sprite = AssetDatabase.GetBuiltinExtraResource<Sprite> ("UI/Skin/UISprite.psd");
As you can see the path for default UI sprite im above link. But it'll run only in Unity Editor. You can't access it run-time, because as I think that default unity resources are available in editor only.
Your answer
Follow this Question
Related Questions
Sprite image not changing 0 Answers
Sprite dots spawn and have their own color, but they only show as wireframes? 0 Answers
Make images fit in UI 0 Answers
How to pack a sprite with transparent areas 2 Answers
Color blending in UI sprite 1 Answer