111
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using Sirenix.OdinInspector;
|
using Sirenix.OdinInspector;
|
||||||
using Sirenix.OdinInspector.Editor;
|
using Sirenix.OdinInspector.Editor;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
@@ -10,7 +11,7 @@ namespace Stary.Evo.Editor
|
|||||||
{
|
{
|
||||||
public static OdinEditorWindow window;
|
public static OdinEditorWindow window;
|
||||||
|
|
||||||
[MenuItem("Evo/Dev/Apk打包工具",false, 4)]
|
[MenuItem("Evo/Dev/Apk打包工具", false, 4)]
|
||||||
static void ShowWindows()
|
static void ShowWindows()
|
||||||
{
|
{
|
||||||
window = (BuildApkWindow)EditorWindow.GetWindow(typeof(BuildApkWindow));
|
window = (BuildApkWindow)EditorWindow.GetWindow(typeof(BuildApkWindow));
|
||||||
@@ -28,6 +29,11 @@ namespace Stary.Evo.Editor
|
|||||||
|
|
||||||
[EnumToggleButtons, HideLabel] public DeviceType deviceType;
|
[EnumToggleButtons, HideLabel] public DeviceType deviceType;
|
||||||
|
|
||||||
|
|
||||||
|
[HideLabel] [Title("包裹列表", titleAlignment: TitleAlignments.Centered)] [ValueDropdown("GetBuildPackageNames")]
|
||||||
|
public string selectedPackageNames;
|
||||||
|
|
||||||
|
|
||||||
[BoxGroup("Build(清空打包缓存)", centerLabel: true, order: 1)]
|
[BoxGroup("Build(清空打包缓存)", centerLabel: true, order: 1)]
|
||||||
[Button("清空打包缓存")]
|
[Button("清空打包缓存")]
|
||||||
void OnClearCache()
|
void OnClearCache()
|
||||||
@@ -84,9 +90,26 @@ namespace Stary.Evo.Editor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置包名和项目名
|
string packageName = "";
|
||||||
PlayerSettings.productName = hotfixMainResDomain.projectInfo.projectName;
|
// 检测包名格式
|
||||||
PlayerSettings.applicationIdentifier = hotfixMainResDomain.projectInfo.projectPackageName;
|
if (!IsValidPackageName(selectedPackageNames))
|
||||||
|
{
|
||||||
|
// 不是有效包名格式,添加前缀 com.xosmo.
|
||||||
|
packageName = "com.xosmo." + selectedPackageNames;
|
||||||
|
// 设置包名和项目名
|
||||||
|
PlayerSettings.productName = selectedPackageNames;
|
||||||
|
PlayerSettings.applicationIdentifier = packageName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 分割包名字符串
|
||||||
|
string[] segments = selectedPackageNames.Split('.');
|
||||||
|
// 返回最后一个部分
|
||||||
|
packageName = segments[segments.Length - 1];
|
||||||
|
PlayerSettings.productName = packageName;
|
||||||
|
PlayerSettings.applicationIdentifier = selectedPackageNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
string[] scenelist = default;
|
string[] scenelist = default;
|
||||||
if (isWatermark)
|
if (isWatermark)
|
||||||
@@ -96,7 +119,15 @@ namespace Stary.Evo.Editor
|
|||||||
hotfixMainResDomain.projectInfo.loadingScenePath,
|
hotfixMainResDomain.projectInfo.loadingScenePath,
|
||||||
$"Assets/Main/main_{deviceType.ToString()}.unity"
|
$"Assets/Main/main_{deviceType.ToString()}.unity"
|
||||||
};
|
};
|
||||||
|
PlayerSettings.productName += "_watermark";
|
||||||
PlayerSettings.applicationIdentifier += "_watermark";
|
PlayerSettings.applicationIdentifier += "_watermark";
|
||||||
|
Sprite xosmo = Resources.Load<Sprite>("logo");
|
||||||
|
PlayerSettings.virtualRealitySplashScreen = xosmo.texture;
|
||||||
|
PlayerSettings.SplashScreen.showUnityLogo = false;
|
||||||
|
PlayerSettings.SplashScreen.logos = new[]
|
||||||
|
{
|
||||||
|
PlayerSettings.SplashScreenLogo.Create(3f, xosmo),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -104,13 +135,16 @@ namespace Stary.Evo.Editor
|
|||||||
{
|
{
|
||||||
$"Assets/Main/main_{deviceType.ToString()}.unity"
|
$"Assets/Main/main_{deviceType.ToString()}.unity"
|
||||||
};
|
};
|
||||||
|
PlayerSettings.virtualRealitySplashScreen = null;
|
||||||
|
PlayerSettings.SplashScreen.showUnityLogo = false;
|
||||||
|
PlayerSettings.SplashScreen.logos = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置构建选项
|
// 配置构建选项
|
||||||
BuildPlayerOptions buildOptions = new BuildPlayerOptions
|
BuildPlayerOptions buildOptions = new BuildPlayerOptions
|
||||||
{
|
{
|
||||||
scenes = scenelist,
|
scenes = scenelist,
|
||||||
locationPathName = $"Builds/Android/{PlayerSettings.applicationIdentifier}.apk",
|
locationPathName = $"Builds/Android/{PlayerSettings.productName}.apk",
|
||||||
target = BuildTarget.Android,
|
target = BuildTarget.Android,
|
||||||
options = BuildOptions.None
|
options = BuildOptions.None
|
||||||
};
|
};
|
||||||
@@ -136,5 +170,65 @@ namespace Stary.Evo.Editor
|
|||||||
Xreal,
|
Xreal,
|
||||||
Rokid
|
Rokid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测当前所有包裹
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<string> GetBuildPackageNames()
|
||||||
|
{
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
foreach (var name in CreatAssetWindow.GetCreatDomainAllName())
|
||||||
|
{
|
||||||
|
result.Add(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedPackageNames.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if (result.Count > 0)
|
||||||
|
{
|
||||||
|
selectedPackageNames = result[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
selectedPackageNames = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测字符串是否是有效的包名格式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="packageName">要检测的字符串</param>
|
||||||
|
/// <returns>是否是有效的包名格式</returns>
|
||||||
|
private bool IsValidPackageName(string packageName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(packageName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 包名只能包含小写字母、数字和点
|
||||||
|
foreach (char c in packageName)
|
||||||
|
{
|
||||||
|
if (!char.IsLower(c) && !char.IsDigit(c) && c != '.')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不能以点开头或结尾
|
||||||
|
if (packageName.StartsWith(".") || packageName.EndsWith("."))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 不能包含连续的点
|
||||||
|
if (packageName.Contains(".."))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 至少包含一个点
|
||||||
|
if (!packageName.Contains("."))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "com.staryevo.tools",
|
"name": "com.staryevo.tools",
|
||||||
"version": "1.3.9",
|
"version": "1.3.10",
|
||||||
"displayName": "00.StaryEvo.Tools",
|
"displayName": "00.StaryEvo.Tools",
|
||||||
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
"description": "This is an Framework package(后台服务器版本,端口9527)",
|
||||||
"unity": "2021.3",
|
"unity": "2021.3",
|
||||||
|
|||||||
Reference in New Issue
Block a user