先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
168 lines
5.7 KiB
C#
168 lines
5.7 KiB
C#
/*
|
|
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using addressables.helper;
|
|
using GameCore;
|
|
using UnityEditor;
|
|
using UnityEditor.AddressableAssets;
|
|
using UnityEngine;
|
|
|
|
public class BuildHandler
|
|
{
|
|
#if UNITY_ANDROID || UNITY_EDITOR
|
|
static BuildTarget _buildTarget = BuildTarget.Android;
|
|
#elif UNITY_IOS
|
|
static BuildTarget _buildTarget = BuildTarget.iOS;
|
|
#endif
|
|
private static string BUILD_NUMBER = "1";
|
|
private static string APKNAME = "Fishing";
|
|
|
|
[MenuItem("Tools/Build/Build ABAndPlayer Android")]
|
|
public static void BuildABAndPlayerAndroid()
|
|
{
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
foreach (var s in args)
|
|
{
|
|
if (s.Contains("--productName:"))
|
|
{
|
|
APKNAME = s.Split(':')[1];
|
|
// 设置app名字
|
|
//PlayerSettings.productName = productName;
|
|
}
|
|
|
|
if (s.Contains("--version:"))
|
|
{
|
|
string version = s.Split(':')[1];
|
|
// 设置版本号
|
|
PlayerSettings.bundleVersion = version;
|
|
}
|
|
|
|
if (s.Contains("BUILD_NUMBER"))
|
|
{
|
|
BUILD_NUMBER = s.Split(':')[1];
|
|
}
|
|
if (s.Contains("--profile"))
|
|
{
|
|
SetActiveProfile(s.Split(':')[1]);
|
|
}
|
|
}
|
|
_buildTarget = BuildTarget.Android;
|
|
BuildPlayerAndroid();
|
|
}
|
|
[MenuItem("Tools/Build/SetActiveProfile")]
|
|
public static void SetActiveProfile(string context)
|
|
{
|
|
AddressableAssetSettingsDefaultObject.Settings.activeProfileId = AddressableAssetSettingsDefaultObject.Settings.profileSettings.GetProfileId(context);
|
|
}
|
|
[MenuItem("Tools/Build/Build ABAndPlayer IOS")]
|
|
public static void BuildABAndPlayerIOS()
|
|
{
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
foreach (var s in args)
|
|
{
|
|
if (s.Contains("--productName:"))
|
|
{
|
|
APKNAME = s.Split(':')[1];
|
|
// 设置app名字
|
|
//PlayerSettings.productName = productName;
|
|
|
|
}
|
|
|
|
if (s.Contains("--version:"))
|
|
{
|
|
string version = s.Split(':')[1];
|
|
// 设置版本号
|
|
PlayerSettings.bundleVersion = version;
|
|
}
|
|
if (s.Contains("BUILD_NUMBER"))
|
|
{
|
|
BUILD_NUMBER = s.Split(':')[1];
|
|
}
|
|
if (s.Contains("--profile"))
|
|
{
|
|
SetActiveProfile(s.Split(':')[1]);
|
|
}
|
|
}
|
|
AddressableHelper.SyncGroups();
|
|
_buildTarget = BuildTarget.iOS;
|
|
BuildPlayerIOS();
|
|
}
|
|
|
|
[MenuItem("Tools/Build/Build Android")]
|
|
public static void BuildPlayerAndroid()
|
|
{
|
|
//MAC 获取shell传来的参数
|
|
int index = Application.dataPath.LastIndexOf('/');
|
|
var parent_dir = $"{Application.dataPath[..index]}/AssetBundles";
|
|
//var manifest_filename = $"{parent_dir}/{_buildTarget}/{AssetManager.ASSET_BUNDLE_STREAMING_FOLDER_NAME}/{AssetManager.ASSET_BUNDLE_STREAMING_FOLDER_NAME}.manifest";
|
|
string output_path = $"{Application.dataPath[..index]}/{APKNAME}.apk";
|
|
if (Application.platform == RuntimePlatform.OSXEditor)
|
|
output_path = $"/Users/zhuzi/workspace/jenkins/Workspace/n3_Android/{BUILD_NUMBER}/{APKNAME}.apk";
|
|
|
|
var buildPlayerOptions = new BuildPlayerOptions
|
|
{
|
|
scenes = EditorBuildSettings.scenes.Select(x => x.path).ToArray(),
|
|
locationPathName = output_path,
|
|
|
|
//assetBundleManifestPath = manifest_filename,
|
|
target = _buildTarget,
|
|
options = BuildOptions.None,
|
|
};
|
|
|
|
var build_report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
|
|
|
if (build_report?.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
|
{
|
|
Debug.Log("--== Build Player Success ==--");
|
|
AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"Build Player Failed: {build_report?.summary}");
|
|
}
|
|
}
|
|
|
|
[MenuItem("Tools/Build/Build IOS")]
|
|
public static void BuildPlayerIOS()
|
|
{
|
|
//MAC 获取shell传来的参数
|
|
int index = Application.dataPath.LastIndexOf('/');
|
|
var parent_dir = $"{Application.dataPath[..index]}/AssetBundles";
|
|
var manifest_filename =
|
|
$"{parent_dir}/{_buildTarget}/{AssetManager.ASSET_BUNDLE_STREAMING_FOLDER_NAME}/{AssetManager.ASSET_BUNDLE_STREAMING_FOLDER_NAME}.manifest";
|
|
string output_path =
|
|
$"{Application.dataPath[..index]}/XcodeProject";
|
|
if (Application.platform == RuntimePlatform.OSXEditor)
|
|
output_path = $"/Users/zhuzi/workspace/jenkins/XcodeProject/n3/{BUILD_NUMBER}";
|
|
|
|
var buildPlayerOptions = new BuildPlayerOptions
|
|
{
|
|
scenes = EditorBuildSettings.scenes.Select(x => x.path).ToArray(),
|
|
locationPathName = output_path,
|
|
|
|
assetBundleManifestPath = manifest_filename,
|
|
target = _buildTarget,
|
|
options = BuildOptions.None,
|
|
};
|
|
//打包覆盖源文件
|
|
if (Directory.Exists(output_path))
|
|
{
|
|
EditorTools.DeleteAllFiles(output_path);
|
|
}
|
|
|
|
var build_report = BuildPipeline.BuildPlayer(buildPlayerOptions);
|
|
|
|
if (build_report?.summary.result == UnityEditor.Build.Reporting.BuildResult.Succeeded)
|
|
{
|
|
Debug.Log("--== Build Player Success ==--");
|
|
AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError($"Build Player Failed: {build_report?.summary}");
|
|
}
|
|
}
|
|
}
|
|
*/
|