38 return s.rect.width * 100f / s.pixelsPerUnit;
43 return s.rect.height * 100f / s.pixelsPerUnit;
50 id = Path.GetFileNameWithoutExtension(
path);
54 catch (Exception exception)
56 Debug.LogException(exception);
57 Debug.LogError(
"#sprite failed " +
id +
"/" +
path);
64 if (File.Exists(
path +
".pref"))
82 if (!File.Exists(
path +
".ini"))
91 IniData iniData =
new FileIniDataParser().ReadFile(
path +
".ini", Encoding.UTF8);
92 frame = Mathf.Max(1, (!
int.TryParse(iniData.GetKey(
"frame"), out var result)) ? 1 : result);
93 scale = (
int.TryParse(iniData.GetKey(
"scale"), out var result2) ? result2 : 50);
94 time = (
float.TryParse(iniData.GetKey(
"time"), out var result3) ? Mathf.Max(0.016f, result3) : 0.2f);
96 catch (Exception exception)
98 Debug.LogException(exception);
104 Texture2D texture2D = IO.LoadPNG(
path +
".png");
105 Debug.Log(texture2D.width +
"/" + texture2D.height +
"/" +
path);
108 if (texture2D.width !=
tex.width || texture2D.height !=
tex.height)
110 tex.Reinitialize(texture2D.width, texture2D.height);
112 tex.SetPixels32(texture2D.GetPixels32());
114 UnityEngine.Object.Destroy(texture2D);
120 int num = tex.width /
frame;
121 int height =
tex.height;
126 Vector2 pivot =
new Vector2(0.5f, 0.5f);
127 for (
int i = 0; i <
frame; i++)
129 sprites[i] = Sprite.Create(
tex,
new Rect(i * num, 0f, num, height), pivot, num2, 0u, SpriteMeshType.FullRect);
149 return sprites.TryGet(0, returnNull:
true);
158 bool IsDirty(
string p, ref DateTime lastChecked)
160 string text =
path + p;
161 if (!File.Exists(text))
165 DateTime lastWriteTimeUtc = File.GetLastWriteTimeUtc(text);
166 if (lastWriteTimeUtc == lastChecked)
170 lastChecked = lastWriteTimeUtc;
static SourcePref ReadFromIni(string path)
bool tryFixPrefNotLoadedAtStart
static float BaseHeight(Sprite s)
void LoadPrefAndFixDensity()
static float BaseWidth(Sprite s)