Why can Unity's UISprite not be found when searching through Unity's sprites?
In the start of my game, I run a simple loop that searches for Unity's UISprite graphic and stores it as a reference (since I don't have any graphics for my game yet). This allows me to use the sprite both in the editor and in a complete build of the game. The snippet looks like this:
using UnityEngine;
public class Database : Monobehavior
{
public static Sprite defaultBox;
void Start()
{
foreach (Sprite sprite in Resources.FindObjectsOfTypeAll<Sprite>())
if (sprite.name == "UISprite") { defaultBox = sprite; break; }
}
}
This is attached to an object that persists throughout the game, so it's bound to run. This has worked for the past several months, yet for some reason it no longer loads in the sprite. I ran a Debug.Log() in the loop as well, but to no avail. Did something change with how Unity loads in its sprites now?
Your answer

Follow this Question
Related Questions
World Space UI and Sprite Renderer doesn't render correctly,World Space UI doesn't render correctly 0 Answers
How to change a button image with script? 1 Answer
Trouble with UI elements on Sprites 0 Answers
How do you change pressed sprite (C#) 1 Answer
Will the Sprite Packer ignore 'Max Size' set in a Sprites' import settings? 1 Answer