Skip to content

Commit

Permalink
add export tools
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-ivashenko committed Oct 15, 2023
1 parent 4ff2202 commit a5c8e43
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 1 deletion.
8 changes: 8 additions & 0 deletions Assets/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/Scripts/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Assets/Scripts/Editor/ExportPackageWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using UnityEditor;
using UnityEngine;

public class ExportPackageWindow : EditorWindow
{
int majorVersion = 1;
int minorVersion = 0;
int patchVersion = 0;

[MenuItem("Export/Export StatefulUI Package With Version")]
public static void ShowWindow()
{
// Открытие окна и установка начального размера
var window = GetWindow<ExportPackageWindow>("Export Package");
window.minSize = new Vector2(250, 120);
}

private void OnEnable()
{
// Разбор текущей версии на составляющие
var versionParts = PlayerSettings.bundleVersion.Split('.');
if (versionParts.Length == 3)
{
int.TryParse(versionParts[0], out majorVersion);
int.TryParse(versionParts[1], out minorVersion);
int.TryParse(versionParts[2], out patchVersion);
}
}

void OnGUI()
{
GUILayout.Label("Enter the version number:", EditorStyles.boldLabel);
majorVersion = EditorGUILayout.IntField("Major Version", majorVersion);
minorVersion = EditorGUILayout.IntField("Minor Version", minorVersion);
patchVersion = EditorGUILayout.IntField("Patch Version", patchVersion);

if (GUILayout.Button("Export"))
{
var version = $"{majorVersion}.{minorVersion}.{patchVersion}";
ExportUnityPackage.ExportPackageWithVersion(version);
Close();
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Editor/ExportPackageWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions Assets/Scripts/Editor/ExportUnityPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using UnityEditor;
using UnityEngine;

public class ExportUnityPackage
{
public static void ExportPackageWithVersion(string version)
{
PlayerSettings.bundleVersion = version;

string[] folders = { "Assets/Plugins/StatefulUI" };

var exportDir = "Releases";
if (!System.IO.Directory.Exists(exportDir))
{
System.IO.Directory.CreateDirectory(exportDir);
}

var packageName = $"{exportDir}/stateful_ui_{version}.unitypackage";

AssetDatabase.ExportPackage(folders, packageName, ExportPackageOptions.Recurse);

Debug.Log($"Exported to: {packageName}");
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Editor/ExportUnityPackage.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.0
bundleVersion: 1.0.2
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit a5c8e43

Please sign in to comment.