2using System.Globalization;
35 if (File.Exists(
path +
".ini"))
37 IniData iniData =
new FileIniDataParser().ReadFile(
path +
".ini", Encoding.UTF8);
38 frame =
int.Parse(iniData.GetKey(
"frame") ??
"1");
39 scale =
int.Parse(iniData.GetKey(
"scale") ??
"50");
40 time =
float.Parse(iniData.GetKey(
"time") ??
"0.2", CultureInfo.InvariantCulture);
43 catch (Exception message)
46 Debug.Log(
"exception: Failed to parse:" +
path +
".ini");
70 DateTime lastWriteTime = File.GetLastWriteTime(
path +
".png");
71 bool flag = date.Year != 1 &&
date == lastWriteTime;
75 if (File.Exists(
path +
"_snow.png"))
83 public void Load(
bool dateMatched, ref Texture2D
tex, ref Sprite[]
sprites,
string suffix)
85 if (dateMatched && (
bool)
tex)
91 Texture2D texture2D = IO.LoadPNG(
path + suffix +
".png");
92 if (texture2D.width !=
tex.width || texture2D.height !=
tex.height)
94 Debug.Log(texture2D.width +
"/" + texture2D.height +
"/" +
path);
95 tex.Reinitialize(texture2D.width, texture2D.height);
97 tex.SetPixels32(texture2D.GetPixels32());
99 UnityEngine.Object.Destroy(texture2D);
103 tex = IO.LoadPNG(
path + suffix +
".png");
104 int num = tex.width /
frame;
105 int height =
tex.height;
107 for (
int i = 0; i <
frame; i++)
109 sprites[i] = Sprite.Create(
tex,
new Rect(i * num, 0f, num, height),
new Vector2(0.5f, 0.5f), 100f, 0u, SpriteMeshType.FullRect);
Sprite GetSprite(bool snow=false)
void Load(bool dateMatched, ref Texture2D tex, ref Sprite[] sprites, string suffix)