73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
#if UNITY_EDITOR
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Pipeline / 菜单:创建 Boot 场景并写入 Build Settings。
|
|
/// </summary>
|
|
public static class SetupBootScene
|
|
{
|
|
const string ScenePath = "Assets/Scenes/Boot.unity";
|
|
|
|
[MenuItem("AIGame/Boot/Setup Boot Scene")]
|
|
public static string Setup()
|
|
{
|
|
var scene = UnityEditor.SceneManagement.EditorSceneManager.NewScene(
|
|
UnityEditor.SceneManagement.NewSceneSetup.DefaultGameObjects,
|
|
UnityEditor.SceneManagement.NewSceneMode.Single);
|
|
|
|
// 竖屏参考:调整主相机背景
|
|
var cam = Camera.main;
|
|
if (cam != null)
|
|
{
|
|
cam.backgroundColor = new Color(0.08f, 0.09f, 0.12f, 1f);
|
|
cam.clearFlags = CameraClearFlags.SolidColor;
|
|
}
|
|
|
|
var bootGo = new GameObject("Boot");
|
|
var driver = bootGo.AddComponent<AOT.Boot.BootDriver>();
|
|
var loading = AssetDatabase.LoadAssetAtPath<GameObject>(AIGame.EditorTools.BuildBootLoading.PrefabPath);
|
|
if (loading != null)
|
|
{
|
|
var so = new SerializedObject(driver);
|
|
so.FindProperty("loadingPrefab").objectReferenceValue = loading.GetComponent<AOT.UI.BootPatchView>();
|
|
so.ApplyModifiedPropertiesWithoutUndo();
|
|
}
|
|
|
|
Directory.CreateDirectory("Assets/Scenes");
|
|
UnityEditor.SceneManagement.EditorSceneManager.SaveScene(scene, ScenePath);
|
|
|
|
var scenes = new[]
|
|
{
|
|
new EditorBuildSettingsScene(ScenePath, true),
|
|
};
|
|
// 保留其它场景但 Boot 置顶
|
|
var existing = EditorBuildSettings.scenes;
|
|
var list = new System.Collections.Generic.List<EditorBuildSettingsScene> { scenes[0] };
|
|
foreach (var s in existing)
|
|
{
|
|
if (s.path != ScenePath)
|
|
list.Add(s);
|
|
}
|
|
EditorBuildSettings.scenes = list.ToArray();
|
|
|
|
AssetDatabase.SaveAssets();
|
|
return $"ok scene={ScenePath} buildScenes={EditorBuildSettings.scenes.Length}";
|
|
}
|
|
|
|
public static string EnsurePortrait()
|
|
{
|
|
PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
|
|
PlayerSettings.allowedAutorotateToPortrait = true;
|
|
PlayerSettings.allowedAutorotateToPortraitUpsideDown = false;
|
|
PlayerSettings.allowedAutorotateToLandscapeLeft = false;
|
|
PlayerSettings.allowedAutorotateToLandscapeRight = false;
|
|
PlayerSettings.companyName = "XWorld";
|
|
PlayerSettings.productName = "AIGame";
|
|
PlayerSettings.bundleVersion = "1.0.0";
|
|
return $"orientation={PlayerSettings.defaultInterfaceOrientation} product={PlayerSettings.productName} ver={PlayerSettings.bundleVersion}";
|
|
}
|
|
}
|
|
#endif
|