36 id = Path.GetFileNameWithoutExtension(
path);
40 catch (Exception exception)
42 Debug.LogException(exception);
43 Debug.LogError(
"#sprite failed to init '" +
id +
"' at " +
path);
50 if (File.Exists(
path +
".pref"))
58 if (!File.Exists(
path +
".ini"))
67 IniData iniData =
new FileIniDataParser().ReadFile(
path +
".ini", Encoding.UTF8);
68 frame = Mathf.Max(1, (!
int.TryParse(iniData.GetKey(
"frame"), out var result)) ? 1 : result);
69 scale = (
int.TryParse(iniData.GetKey(
"scale"), out var result2) ? result2 : 50);
70 time = (
float.TryParse(iniData.GetKey(
"time"), out var result3) ? Mathf.Max(0.016f, result3) : 0.2f);
72 catch (Exception exception)
74 Debug.LogException(exception);
80 Texture2D texture2D = IO.LoadPNG(
path +
".png");
81 Debug.Log(texture2D.width +
"/" + texture2D.height +
"/" +
path);
84 if (texture2D.width !=
tex.width || texture2D.height !=
tex.height)
86 tex.Reinitialize(texture2D.width, texture2D.height);
88 tex.SetPixels32(texture2D.GetPixels32());
90 UnityEngine.Object.Destroy(texture2D);
96 int num = tex.width /
frame;
97 int height =
tex.height;
102 Vector2 pivot =
new Vector2(0.5f, 0.5f);
103 for (
int i = 0; i <
frame; i++)
105 sprites[i] = Sprite.Create(
tex,
new Rect(i * num, 0f, num, height), pivot, 100f, 0u, SpriteMeshType.FullRect);
124 return sprites.TryGet(0, returnNull:
true);
133 bool IsDirty(
string p, ref DateTime lastChecked)
135 string text =
path + p;
136 if (!File.Exists(text))
140 DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(text);
141 if (lastWriteTimeUtc == lastChecked)
145 lastChecked = lastWriteTimeUtc;
static SourcePref ReadFromIni(string path)