2using System.Globalization;
33 if (File.Exists(
path +
".ini"))
35 IniData iniData =
new FileIniDataParser().ReadFile(
path +
".ini", Encoding.UTF8);
36 frame =
int.Parse(iniData.GetKey(
"frame") ??
"1");
37 scale =
int.Parse(iniData.GetKey(
"scale") ??
"50");
38 time =
float.Parse(iniData.GetKey(
"time") ??
"0.2", CultureInfo.InvariantCulture);
41 catch (Exception message)
44 Debug.Log(
"exception: Failed to parse:" +
path +
".ini");
68 DateTime lastWriteTime = File.GetLastWriteTime(
path +
".png");
69 bool flag = date.Year != 1 &&
date == lastWriteTime;
73 if (File.Exists(
path +
"_snow.png"))
81 public void Load(
bool dateMatched, ref Texture2D
tex, ref Sprite[]
sprites,
string suffix)
83 if (dateMatched && (
bool)
tex)
89 Texture2D texture2D = IO.LoadPNG(
path + suffix +
".png");
90 if (texture2D.width !=
tex.width || texture2D.height !=
tex.height)
92 Debug.Log(texture2D.width +
"/" + texture2D.height +
"/" +
path);
93 tex.Reinitialize(texture2D.width, texture2D.height);
95 tex.SetPixels32(texture2D.GetPixels32());
97 UnityEngine.Object.Destroy(texture2D);
101 tex = IO.LoadPNG(
path + suffix +
".png");
102 int num = tex.width /
frame;
103 int height =
tex.height;
105 for (
int i = 0; i <
frame; i++)
107 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)