38 id = Path.GetFileNameWithoutExtension(
path);
42 catch (Exception exception)
44 Debug.LogException(exception);
45 Debug.LogError(
"#sprite failed " +
id +
"/" +
path);
52 if (File.Exists(
path +
".pref"))
60 if (!File.Exists(
path +
".ini"))
69 IniData iniData =
new FileIniDataParser().ReadFile(
path +
".ini", Encoding.UTF8);
70 frame = Mathf.Max(1, (!
int.TryParse(iniData.GetKey(
"frame"), out var result)) ? 1 : result);
71 scale = (
int.TryParse(iniData.GetKey(
"scale"), out var result2) ? result2 : 50);
72 time = (
float.TryParse(iniData.GetKey(
"time"), out var result3) ? Mathf.Max(0.016f, result3) : 0.2f);
74 catch (Exception exception)
76 Debug.LogException(exception);
82 Texture2D texture2D = IO.LoadPNG(
path +
".png");
83 Debug.Log(texture2D.width +
"/" + texture2D.height +
"/" +
path);
86 if (texture2D.width !=
tex.width || texture2D.height !=
tex.height)
88 tex.Reinitialize(texture2D.width, texture2D.height);
90 tex.SetPixels32(texture2D.GetPixels32());
92 UnityEngine.Object.Destroy(texture2D);
98 int num = tex.width /
frame;
99 int height =
tex.height;
104 Vector2 pivot =
new Vector2(0.5f, 0.5f);
105 for (
int i = 0; i <
frame; i++)
107 sprites[i] = Sprite.Create(
tex,
new Rect(i * num, 0f, num, height), pivot, 100f, 0u, SpriteMeshType.FullRect);
126 return sprites.TryGet(0, returnNull:
true);
135 bool IsDirty(
string p, ref DateTime lastChecked)
137 string text =
path + p;
138 if (!File.Exists(text))
142 DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(text);
143 if (lastWriteTimeUtc == lastChecked)
147 lastChecked = lastWriteTimeUtc;
static SourcePref ReadFromIni(string path)
bool tryFixPrefNotLoadedAtStart