Files
VR-WuKong/Packages/PICO Unity Integration SDK-3.3.2-20251111/Editor/PXR_SDKBuildCheck.cs
2025-11-13 17:40:28 +08:00

72 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;
using Debug = UnityEngine.Debug;
namespace Unity.XR.PXR.Editor
{
[InitializeOnLoad]
public static class PXR_SDKBuildCheck
{
private static bool doNotShowAgain = false;
static PXR_SDKBuildCheck()
{
ObjectFactory.componentWasAdded += ComponentWasAdded;
BuildPlayerWindow.RegisterBuildPlayerHandler(OnBuild);
doNotShowAgain = GetDoNotShowBuildWarning();
Debug.Log("PXRLog [Build Check]RegisterBuildPlayerHandler,Already Do not show: " + doNotShowAgain);
}
static void ComponentWasAdded(Component com)
{
if (com.name == "XR Rig")
{
if (!com.GetComponent<PXR_Manager>() && com.GetType() != typeof(Transform))
{
com.gameObject.AddComponent<PXR_Manager>();
}
}
}
static bool GetDoNotShowBuildWarning()
{
string path = PXR_SDKSettingEditor.assetPath + typeof(PXR_SDKSettingAsset).ToString() + ".asset";
if (File.Exists(path))
{
PXR_SDKSettingAsset asset = AssetDatabase.LoadAssetAtPath<PXR_SDKSettingAsset>(path);
if (asset != null)
{
return asset.doNotShowBuildWarning;
}
}
return false;
}
public static void OnBuild(BuildPlayerOptions options)
{
#if UNITY_2021_2_OR_NEWER
NamedBuildTarget recommendedBuildTarget = NamedBuildTarget.Android;
#else
BuildTargetGroup recommendedBuildTarget = BuildTargetGroup.Android;
#endif
PlayerSettings.SetScriptingBackend(recommendedBuildTarget, ScriptingImplementation.IL2CPP);
PlayerSettings.Android.targetArchitectures = AndroidArchitecture.ARM64;
BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(options);
}
}
}