How can I load the UISprite builtin resource at runtime?

Hi all,

I’ve tried to load the resource using Resources.GetBuiltinResource<Sprite>("unity_builtin_extra/UISprite") but it doesn’t work.

Has anyone had luck with this?

Thanks,

Found this post: https://forum.unity.com/threads/accessing-ui-build-in-sprites-in-c.305075/

 private const string kStandardSpritePath           = "UI/Skin/UISprite.psd";
 private const string kBackgroundSpriteResourcePath = "UI/Skin/Background.psd";
 private const string kInputFieldBackgroundPath     = "UI/Skin/InputFieldBackground.psd";
 private const string kKnobPath                     = "UI/Skin/Knob.psd";
 private const string kCheckmarkPath                = "UI/Skin/Checkmark.psd";

Then you do (example shows using background sprite):

AssetDatabase.GetBuiltinExtraResource(“UI/Skin/Background.psd”);

Additionally you might have to change the image type (that is true for background):

Image someImage = ...;
someImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>("UI/Skin/Background.psd");
someImage.type = Image.Type.Sliced;

You can see the type by simply choosing the image in the inspector.

@LW
Use Resources.Load instead of AssetDatabase.GetBuiltinExtraResource, works at runtime and you can build
Like: Resources.Load(“UI/Skin/InputFieldBackground.psd”);