You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//// The following function was initially copied from @JPLRepo's AmpYear mod, which is covered by the GPL, as is this mod//// This function will attempt to load either a PNG or a JPG from the specified path. // It first checks to see if the actual file is there, if not, it then looks for either a PNG or a JPG//// easier to specify different cases than to change case to lower. This will fail on MacOS and Linux// if a suffix has mixed case
51
+
staticstring[]imgSuffixes=newstring[]{".png",".jpg",".gif",".PNG",".JPG",".GIF"};publicstaticBooleanLoadImageFromFile(refTexture2Dtex,StringfileNamePath){BooleanblnReturn=false;try{stringpath=fileNamePath;if(!System.IO.File.Exists(fileNamePath)){// Look for the file with an appended suffix.for(inti=0;i<imgSuffixes.Length;i++)if(System.IO.File.Exists(fileNamePath+imgSuffixes[i])){path=fileNamePath+imgSuffixes[i];break;}}
78
52
//File Exists check
79
-
if(System.IO.File.Exists(path))
80
-
{
81
-
try
82
-
{
83
-
tex.LoadImage(System.IO.File.ReadAllBytes(path));
84
-
blnReturn=true;
85
-
}
86
-
catch(Exceptionex)
87
-
{
88
-
Log.Error("Failed to load the texture:"+path);
89
-
Log.Error(ex.Message);
90
-
}
91
-
}
92
-
else
93
-
{
94
-
Log.Error("Cannot find texture to load:"+fileNamePath);
95
-
}
96
-
97
-
98
-
}
99
-
catch(Exceptionex)
100
-
{
101
-
Log.Error("Failed to load (are you missing a file):"+fileNamePath);
if(System.IO.File.Exists(path)){try{tex.LoadImage(System.IO.File.ReadAllBytes(path));blnReturn=true;}catch(Exceptionex){Log.Error("Failed to load the texture:"+path);Log.Error(ex.Message);}}else{Log.Error("Cannot find texture to load:"+fileNamePath);}}catch(Exceptionex){Log.Error("Failed to load (are you missing a file):"+fileNamePath);Log.Error(ex.Message);}returnblnReturn;}
0 commit comments