Can unity ignore file formats such as png, jpg, or gif?
I'm working on a code that needs to display lots of different images. Right now I have a simple code that just checks to make sure an image file exists in the assets section the problem is that I need to specify the file format beforehand.
public class FileTester : MonoBehaviour
{
string folderName = "Assets/Images/sunset.png";
// Start is called before the first frame update
void Start()
{
string fullPath = Path.GetFullPath(folderName);
Debug.Log(fullPath);
bool success = File.Exists(fullPath);
Debug.Log(success);
}
As you can see the code looks for a file called sunset.png and when it finds the file it returns true to the console. If, however, I were to change the path to "Assets/Images/sunset" and refer to the image as sunset not sunset.png the code returns false. The problem that arises is that I need the code to work the same for pngs, jpgs, jpegs, gifs, etc.
Does anyone have any suggestions?
Comment