Skip to content

Commit 99ba117

Browse files
committed
unity
1 parent 77e26d0 commit 99ba117

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,5 @@ src/ZString.Unity/Assembly-CSharp.csproj
121121
src/ZString.Unity/Assembly-CSharp-Editor.csproj
122122
src/ZString.Unity/ZString.csproj
123123
src/ZString.Unity/ZString.Unity.sln
124+
125+
src/ZString.Unity/ZString.Unity.unitypackage

src/ZString.Unity/Assets/Scripts/Editor/PackageExporter.cs

+39-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ public static class PackageExporter
99
[MenuItem("Tools/Export Unitypackage")]
1010
public static void Export()
1111
{
12-
var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION");
13-
14-
// configure
1512
var root = "Scripts/ZString";
13+
var version = GetVersion(root);
14+
1615
var fileName = string.IsNullOrEmpty(version) ? "ZString.Unity.unitypackage" : $"ZString.Unity.{version}.unitypackage";
1716
var exportPath = "./" + fileName;
1817

@@ -40,4 +39,41 @@ public static void Export()
4039

4140
UnityEngine.Debug.Log("Export complete: " + Path.GetFullPath(exportPath));
4241
}
42+
43+
static string GetVersion(string root)
44+
{
45+
var version = Environment.GetEnvironmentVariable("UNITY_PACKAGE_VERSION");
46+
var versionJson = Path.Combine(Application.dataPath, root, "package.json");
47+
48+
if (File.Exists(versionJson))
49+
{
50+
var v = JsonUtility.FromJson<Version>(File.ReadAllText(versionJson));
51+
52+
if (!string.IsNullOrEmpty(version))
53+
{
54+
if (v.version != version)
55+
{
56+
var msg = $"package.json and env version are mismatched. UNITY_PACKAGE_VERSION:{version}, package.json:{v.version}";
57+
58+
if (Application.isBatchMode)
59+
{
60+
Console.WriteLine(msg);
61+
Application.Quit(1);
62+
}
63+
64+
throw new Exception("package.json and env version are mismatched.");
65+
}
66+
}
67+
68+
version = v.version;
69+
}
70+
71+
return version;
72+
}
73+
74+
public class Version
75+
{
76+
public string version;
77+
}
78+
4379
}

src/ZString.Unity/Assets/Scripts/ZString/IResettableBufferWriter.cs.meta

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-179 KB
Binary file not shown.

0 commit comments

Comments
 (0)