Загрузка PICO Unity OpenXR Integration SDK

This commit is contained in:
2024-12-21 10:28:02 +03:00
parent b2ecc77b2a
commit a2c2504d48
628 changed files with 68895 additions and 2 deletions

View File

@ -0,0 +1,21 @@
/*******************************************************************************
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.
*******************************************************************************/
namespace Pico.Platform.Editor
{
public class EditorConf
{
public static int minSdkLevel = 29;
public static string minEditorVersion = "2020";
public static string AppIdMetaDataTag = "pvr.app.id";
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 291ce88e932c4172b3245a1f2e8381a1
timeCreated: 1684329960

View File

@ -0,0 +1,158 @@
/*******************************************************************************
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 UnityEditor;
namespace Pico.Platform.Editor
{
/// <summary>
/// Unity Setting Getter and Setter
/// </summary>
public class Gs
{
public static string productName
{
get { return PlayerSettings.productName; }
set { PlayerSettings.productName = value; }
}
public static string packageName
{
get { return PlayerSettings.GetApplicationIdentifier(EditorUserBuildSettings.selectedBuildTargetGroup); }
set { PlayerSettings.SetApplicationIdentifier(EditorUserBuildSettings.selectedBuildTargetGroup, value); }
}
public static BuildTargetGroup buildTargetGroup
{
get { return EditorUserBuildSettings.selectedBuildTargetGroup; }
set
{
EditorUserBuildSettings.selectedBuildTargetGroup = value;
if (value == BuildTargetGroup.Android)
{
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
}
}
}
public static BuildTarget buildTarget
{
get { return EditorUserBuildSettings.activeBuildTarget; }
}
public static BuildTarget selectedStandaloneTarget
{
get { return EditorUserBuildSettings.selectedStandaloneTarget; }
set
{
EditorUserBuildSettings.selectedStandaloneTarget = value;
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, value);
}
}
public static AndroidSdkVersions minimumApiLevel
{
get { return PlayerSettings.Android.minSdkVersion; }
set { PlayerSettings.Android.minSdkVersion = value; }
}
public static AndroidSdkVersions targetSdkVersion
{
get { return PlayerSettings.Android.targetSdkVersion; }
set { PlayerSettings.Android.targetSdkVersion = value; }
}
public static string bundleVersion
{
get { return PlayerSettings.bundleVersion; }
set { PlayerSettings.bundleVersion = value; }
}
public static int bundleVersionCode
{
get { return PlayerSettings.Android.bundleVersionCode; }
set { PlayerSettings.Android.bundleVersionCode = value; }
}
public static string keystoreName
{
get { return PlayerSettings.Android.keystoreName; }
set { PlayerSettings.Android.keystoreName = value; }
}
public static string keystorePass
{
get { return PlayerSettings.Android.keystorePass; }
set { PlayerSettings.Android.keystorePass = value; }
}
public static string keyaliasName
{
get { return PlayerSettings.Android.keyaliasName; }
set { PlayerSettings.Android.keyaliasName = value; }
}
public static string keyaliasPass
{
get { return PlayerSettings.Android.keyaliasPass; }
set { PlayerSettings.Android.keyaliasPass = value; }
}
public static bool useCustomKeystore
{
get { return PlayerSettings.Android.useCustomKeystore; }
set { PlayerSettings.Android.useCustomKeystore = value; }
}
public static ScriptingImplementation scriptBackend
{
get { return PlayerSettings.GetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup); }
set
{
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup, value);
if (value == ScriptingImplementation.Mono2x)
{
//mono only support armv7
targetArchitectures = AndroidArchitecture.ARMv7;
}
else if (value == ScriptingImplementation.IL2CPP)
{
//il2cpp use a reasonable default value
if (targetArchitectures != AndroidArchitecture.ARMv7 && targetArchitectures != AndroidArchitecture.ARM64)
{
targetArchitectures = AndroidArchitecture.ARM64;
}
}
}
}
public static AndroidArchitecture targetArchitectures
{
get { return PlayerSettings.Android.targetArchitectures; }
set { PlayerSettings.Android.targetArchitectures = value; }
}
public static AndroidBuildType androidBuildType
{
get { return EditorUserBuildSettings.androidBuildType; }
set { EditorUserBuildSettings.androidBuildType = value; }
}
public static UIOrientation UIOrientation
{
get { return PlayerSettings.defaultInterfaceOrientation; }
set { PlayerSettings.defaultInterfaceOrientation = value; }
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3273a382b4f040e1b701c1db754ee588
timeCreated: 1672406702

View File

@ -0,0 +1,37 @@
/*******************************************************************************
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 UnityEditor;
using UnityEngine;
namespace Pico.Platform.Editor
{
public class Menu
{
[MenuItem("PXR_SDK/Platform Settings")]
public static void ShowNewConfig()
{
PicoSettings window = ScriptableObject.CreateInstance(typeof(PicoSettings)) as PicoSettings;
window.minSize = new Vector2(400, 450);
window.maxSize = new Vector2(400, 450);
window.ShowUtility();
}
[MenuItem("PXR_SDK/PC Debug Settings")]
public static void EditPcConfig()
{
var obj = PcConfigEditor.load();
obj.name = "PC Debug Configuration";
Selection.activeObject = obj;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6dfff384357648919df83f7328a03901
timeCreated: 1666014061

View File

@ -0,0 +1,29 @@
{
"name": "PICO.Platform.Editor",
"references": [
"Unity.XR.PICO.Editor",
"Unity.XR.PICO",
"Unity.XR.Management",
"Unity.XR.Management.Editor",
"PICO.Platform",
"Unity.XR.OpenXR.Features.PICOSupport"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"versionDefines": [
{
"name": "com.unity.xr.management",
"expression": "",
"define": "USING_XR_MANAGEMENT"
},
{
"name": "com.unity.xr.pico",
"expression": "",
"define": "USING_XR_SDK_PICO"
}
]
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0714fd8cd186449494c96cfeaa72dc67
timeCreated: 1666088788

View File

@ -0,0 +1,97 @@
/*******************************************************************************
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 Unity.XR.PXR;
using UnityEditor;
using UnityEngine;
namespace Pico.Platform.Editor
{
[CustomEditor(typeof(PXR_PlatformSetting))]
public class PXR_PlatformSettingEditor : UnityEditor.Editor
{
private SerializedProperty deviceSNList;
private void OnEnable()
{
deviceSNList = serializedObject.FindProperty("deviceSN");
}
public override void OnInspectorGUI()
{
var startEntitleCheckTip = "If selected, you will need to enter the APPID that is obtained from" +
" PICO Developer Platform after uploading the app for an entitlement check upon the app launch.";
var startEntitleCheckLabel = new GUIContent("User Entitlement Check[?]", startEntitleCheckTip);
PXR_PlatformSetting.Instance.startTimeEntitlementCheck =
EditorGUILayout.Toggle(startEntitleCheckLabel, PXR_PlatformSetting.Instance.startTimeEntitlementCheck);
if (PXR_PlatformSetting.Instance.startTimeEntitlementCheck)
{
serializedObject.Update();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("App ID ", GUILayout.Width(100));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
PXR_PlatformSetting.Instance.appID =
EditorGUILayout.TextField(PXR_PlatformSetting.Instance.appID, GUILayout.Width(350.0f));
EditorGUILayout.EndHorizontal();
if (PXR_PlatformSetting.Instance.appID == "")
{
EditorGUILayout.BeginHorizontal(GUILayout.Width(300));
EditorGUILayout.HelpBox("APPID is required for Entitlement Check", UnityEditor.MessageType.Error, true);
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.BeginHorizontal();
GUILayout.Label("The APPID is required to run an Entitlement Check. Create / Find your APPID Here:", GUILayout.Width(500));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUIStyle style = new GUIStyle();
style.normal.textColor = new Color(0, 122f / 255f, 204f / 255f);
if (GUILayout.Button("" + "https://developer.pico-interactive.com/developer/overview", style,
GUILayout.Width(200)))
{
Application.OpenURL("https://developer.pico-interactive.com/developer/overview");
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("If you do not need user Entitlement Check, please uncheck it.", GUILayout.Width(500));
EditorGUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
var simulationTip = "If true,Development devices will simulate Entitlement Check," +
"you should enter a valid device SN codes list." +
"The SN code can be obtain in Settings-General-Device serial number or input \"adb devices\" in cmd";
var simulationLabel = new GUIContent("Entitlement Check Simulation [?]", simulationTip);
PXR_PlatformSetting.Instance.entitlementCheckSimulation = EditorGUILayout.Toggle(simulationLabel, PXR_PlatformSetting.Instance.entitlementCheckSimulation);
if (PXR_PlatformSetting.Instance.entitlementCheckSimulation)
{
serializedObject.Update();
EditorGUILayout.PropertyField(deviceSNList, true);
serializedObject.ApplyModifiedProperties();
}
if (GUI.changed)
{
EditorUtility.SetDirty(PXR_PlatformSetting.Instance);
GUI.changed = false;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9d0f9ccd124aeb74489816ba2b80ba94
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,122 @@
/*******************************************************************************
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;
using System.IO;
using LitJson;
using UnityEditor;
using UnityEngine;
namespace Pico.Platform.Editor
{
/// <summary>
/// Unity Setting Getter and Setter
/// </summary>
public enum Region
{
cn = 0,
i18n = 1,
}
public class PcConfig : ScriptableObject
{
public Region region = Region.cn;
public string accessToken = "";
internal bool hasError = false;
}
[CustomEditor(typeof(PcConfig))]
public class PcConfigEditor : UnityEditor.Editor
{
static string filepath = "Assets/Resources/PicoSdkPCConfig.json";
private static string i18nLink = "https://developer-global.pico-interactive.com/document/unity/pc-end-debugging-tool";
private static string cnLink = "https://developer-cn.pico-interactive.com/document/unity/pc-end-debugging-tool";
public override void OnInspectorGUI()
{
var x = Selection.activeObject as PcConfig;
if (x.hasError)
{
EditorGUILayout.LabelField("Config file error,please check the file");
return;
}
base.OnInspectorGUI();
//Read the document
{
GUILayout.Space(5);
var referenceStyle = new GUIStyle(EditorStyles.label);
referenceStyle.normal.textColor = new Color(0, 122f / 255f, 204f / 255f);
referenceStyle.focused.textColor = new Color(0, 122f / 255f, 204f / 255f);
referenceStyle.hover.textColor = new Color(0, 122f / 255f, 204f / 255f);
if (GUILayout.Button("Read the document", referenceStyle))
{
var link = i18nLink;
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{
link = cnLink;
}
Application.OpenURL(link);
}
}
this.save();
}
public static PcConfig load()
{
var obj = CreateInstance<PcConfig>();
obj.hasError = false;
try
{
if (File.Exists(filepath))
{
var jsonContent = File.ReadAllText(filepath);
var jsonConf = JsonMapper.ToObject(jsonContent);
obj.accessToken = jsonConf["account"]["access_token"].ToString();
if (!Region.TryParse(jsonConf["general"]["region"].ToString() ?? "", out obj.region))
{
obj.region = Region.cn;
}
}
}
catch (Exception e)
{
Debug.LogError(e);
obj.hasError = true;
}
return obj;
}
public void save()
{
var obj = Selection.activeObject as PcConfig;
if (obj.hasError)
{
return;
}
var conf = new JsonData();
conf["general"] = new JsonData();
conf["account"] = new JsonData();
conf["package"] = new JsonData();
conf["general"]["region"] = obj.region.ToString();
conf["account"]["access_token"] = obj.accessToken.Trim();
conf["package"]["package_name"] = Gs.packageName.Trim();
conf["package"]["package_version_code"] = Gs.bundleVersionCode;
conf["package"]["package_version_name"] = Gs.bundleVersion;
File.WriteAllText(filepath, JsonMapper.ToJson(conf));
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2de2dab76a48474c904742a232922902
timeCreated: 1665473073

View File

@ -0,0 +1,118 @@
/*******************************************************************************
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.Collections.Generic;
using Unity.XR.PXR;
using UnityEditor;
using UnityEditor.XR.Management;
using UnityEditor.XR.Management.Metadata;
using UnityEngine;
using UnityEngine.XR.Management;
namespace Pico.Platform.Editor
{
public class PicoGs
{
public static string appId
{
get { return PXR_PlatformSetting.Instance.appID; }
set
{
PXR_PlatformSetting.Instance.appID = value;
EditorUtility.SetDirty(PXR_PlatformSetting.Instance);
}
}
public static bool useHighlight
{
get { return PXR_PlatformSetting.Instance.useHighlight; }
set
{
PXR_PlatformSetting.Instance.useHighlight = value;
EditorUtility.SetDirty(PXR_PlatformSetting.Instance);
}
}
public static bool enableEntitlementCheck
{
get { return PXR_PlatformSetting.Instance.entitlementCheckSimulation; }
set
{
PXR_PlatformSetting.Instance.entitlementCheckSimulation = value;
EditorUtility.SetDirty(PXR_PlatformSetting.Instance);
}
}
public static List<string> entitlementCheckDeviceList
{
get { return PXR_PlatformSetting.Instance.deviceSN; }
set { PXR_PlatformSetting.Instance.deviceSN = value; }
}
#if USING_XR_SDK_PICO
static XRManagerSettings GetXrSettings()
{
XRGeneralSettings generalSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Android);
if (generalSettings == null) return null;
var assignedSettings = generalSettings.AssignedSettings;
return assignedSettings;
}
static PXR_Loader GetPxrLoader()
{
var x = GetXrSettings();
if (x == null) return null;
foreach (var i in x.activeLoaders)
{
if (i is PXR_Loader)
{
return i as PXR_Loader;
}
}
return null;
}
public static bool UsePicoXr
{
get { return GetPxrLoader() != null; }
set
{
var x = GetXrSettings();
if (x == null) return;
var loader = GetPxrLoader();
if (value == false)
{
if (loader == null)
{
}
else
{
x.TryRemoveLoader(loader);
}
}
else
{
if (loader == null)
{
var res = XRPackageMetadataStore.AssignLoader(x, nameof(PXR_Loader), BuildTargetGroup.Android);
Debug.Log($"设置XR{res} {value}");
}
else
{
}
}
}
}
#endif
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b67c9049a1bc4e1c90c2c7b99918f856
timeCreated: 1673612884

View File

@ -0,0 +1,381 @@
/*******************************************************************************
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;
using Unity.XR.PXR;
using UnityEditor;
using UnityEngine;
namespace Pico.Platform.Editor
{
public class PicoSettings : EditorWindow
{
enum Language
{
English = 0,
Chinese = 1,
}
private SerializedObject serObj;
private SerializedProperty gosPty;
static Language language = Language.English;
static string[] strAppIdText = {"Paste your App ID here", "请粘贴你的AppID"};
static string[] strAppIdHelpText = {"App ID is the unique identification ID of the PICO Application. Without AppID, you will not be able to use PICO platform feature.", "APP ID 是应用的唯一标识"};
static string[] strBuildSettingText = {"Recommend Settings [?]", "推荐设置"};
static string[] strBuildSettingHelpText = {"Recommended project settings for PXR SDK", "推荐项目设置"};
static string[] strPlatformBuildText = {"Set Platform To Android", "设置目标平台为Android"};
static string[] strUnityVersionLimit = {$"Unity Editor Version ≥ {EditorConf.minEditorVersion}", $"Unity Editor版本不小于{EditorConf.minEditorVersion}"};
static string[] strOrientationBuildText = {"Set Orientation To LandscapeLeft", "设置屏幕方向为水平"};
static string[] strMinApiLevel = {$"Android Min API Level ≥ {EditorConf.minSdkLevel}", $"Android最小API不低于{EditorConf.minSdkLevel}"};
static string[] strIgnoreButtonText = {"Ask me later", "稍后询问"};
static string[] strApplyButtonText = {"Apply", "应用"};
static string[] strHighlightText = {"Use Highlight", "开启高光时刻"};
private class Res
{
public readonly Texture PicoDeveloper;
public string Correct = "✔️";
public string Wrong = "×";
public GUIStyle correctStyle;
public GUIStyle wrongStyle;
public Res()
{
this.PicoDeveloper = Resources.Load<Texture>("PICODeveloper");
correctStyle = new GUIStyle(GUI.skin.label);
correctStyle.normal.textColor = Color.green;
wrongStyle = new GUIStyle();
wrongStyle.normal.textColor = Color.red;
wrongStyle.fontStyle = FontStyle.Bold;
}
}
private Res _R;
private Res R
{
get
{
if (_R != null) return _R;
_R = new Res();
return _R;
}
}
internal enum ConfigStatus
{
Correct,
Wrong,
Fix,
Hide,
}
internal abstract class ConfigField
{
public bool value = true;
public abstract string[] GetText();
public abstract ConfigStatus GetStatus();
public abstract void Fix();
}
internal class ConfigIsAndroid : ConfigField
{
public override string[] GetText()
{
return strPlatformBuildText;
}
public override ConfigStatus GetStatus()
{
return Gs.buildTargetGroup == BuildTargetGroup.Android ? ConfigStatus.Correct : ConfigStatus.Fix;
}
public override void Fix()
{
Gs.buildTargetGroup = BuildTargetGroup.Android;
}
}
internal class ConfigIsLandscapeLeft : ConfigField
{
public override string[] GetText()
{
return strOrientationBuildText;
}
public override ConfigStatus GetStatus()
{
return Gs.UIOrientation == UIOrientation.LandscapeLeft ? ConfigStatus.Correct : ConfigStatus.Fix;
}
public override void Fix()
{
Gs.UIOrientation = UIOrientation.LandscapeLeft;
}
}
internal class ConfigMinApiLevel : ConfigField
{
public override string[] GetText()
{
return strMinApiLevel;
}
public override ConfigStatus GetStatus()
{
return Gs.minimumApiLevel >= (AndroidSdkVersions) EditorConf.minSdkLevel ? ConfigStatus.Correct : ConfigStatus.Fix;
}
public override void Fix()
{
Gs.minimumApiLevel = (AndroidSdkVersions) EditorConf.minSdkLevel;
}
}
internal class ConfigUnityVersion : ConfigField
{
public override string[] GetText()
{
return strUnityVersionLimit;
}
public override ConfigStatus GetStatus()
{
return String.Compare(Application.unityVersion, EditorConf.minEditorVersion, StringComparison.Ordinal) >= 0 ? ConfigStatus.Hide : ConfigStatus.Wrong;
}
public override void Fix()
{
throw new NotImplementedException();
}
}
public static string appId
{
get { return PicoGs.appId; }
set { PicoGs.appId = value; }
}
public static bool useHighlight
{
get { return PicoGs.useHighlight; }
set { PicoGs.useHighlight = value; }
}
bool enableEC
{
get { return PicoGs.enableEntitlementCheck; }
set { PicoGs.enableEntitlementCheck = value; }
}
private ConfigField[] configFields;
private void OnEnable()
{
configFields = new ConfigField[]
{
new ConfigUnityVersion(),
new ConfigIsAndroid(),
new ConfigIsLandscapeLeft(),
new ConfigMinApiLevel(),
};
this.titleContent = new GUIContent("PICO Platform Settings");
language = Language.English;
if (Application.systemLanguage == SystemLanguage.Chinese || Application.systemLanguage == SystemLanguage.ChineseSimplified || Application.systemLanguage == SystemLanguage.ChineseTraditional)
{
language = Language.Chinese;
}
serObj = new SerializedObject(PXR_PlatformSetting.Instance);
gosPty = serObj.FindProperty(nameof(PXR_PlatformSetting.deviceSN));
}
Vector2 scrollPos;
void OnGUI()
{
var frameWidth = 380;
//顶部图片
{
GUIStyle style = new GUIStyle();
style.stretchWidth = true;
style.fixedWidth = 400;
GUILayout.Label(R.PicoDeveloper, style);
}
//顶部中英文选择
{
GUIStyle activeStyle = new GUIStyle();
activeStyle.alignment = TextAnchor.MiddleCenter;
activeStyle.normal.textColor = new Color(0, 122f / 255f, 204f / 255f);
GUIStyle normalStyle = new GUIStyle();
normalStyle.alignment = TextAnchor.MiddleCenter;
normalStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("ENGLISH", language == Language.English ? activeStyle : normalStyle, GUILayout.Width(80)))
{
language = Language.English;
}
GUILayout.Label("|", normalStyle, GUILayout.Width(5));
if (GUILayout.Button("中文", language == Language.Chinese ? activeStyle : normalStyle, GUILayout.Width(80)))
{
language = Language.Chinese;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
{
GUIStyle style = new GUIStyle();
style.margin = new RectOffset(5, 5, 5, 5);
GUILayout.BeginVertical(style, GUILayout.Width(360));
}
//AppID设置
{
GUILayout.Space(15);
GUILayout.Label(strAppIdText[(int) language]);
appId = EditorGUILayout.TextField(appId, GUILayout.Width(frameWidth));
if (string.IsNullOrWhiteSpace(appId))
{
EditorGUILayout.HelpBox(strAppIdHelpText[(int) language], UnityEditor.MessageType.Warning);
}
GUILayout.Space(20);
if (appId == "")
{
GUI.enabled = false;
enableEC = false;
}
else
{
GUI.enabled = true;
}
}
//Highlight设置
{
EditorGUILayout.BeginHorizontal();
GUILayout.Label(strHighlightText[(int) language]);
useHighlight = EditorGUILayout.Toggle(useHighlight, GUILayout.Width(frameWidth));
EditorGUILayout.EndHorizontal();
}
//Recommend Settings
{
GUILayout.Space(5);
GUILayout.Label(new GUIContent(strBuildSettingText[(int) language], strBuildSettingHelpText[(int) language]));
GUIStyle style = "frameBox";
style.fixedWidth = frameWidth;
EditorGUILayout.BeginVertical(style);
foreach (var field in configFields)
{
var txt = field.GetText()[(int) language];
switch (field.GetStatus())
{
case ConfigStatus.Correct:
{
EditorGUILayout.BeginHorizontal(GUILayout.Width(frameWidth));
EditorGUILayout.LabelField(txt);
EditorGUILayout.LabelField(R.Correct, R.correctStyle);
GUI.enabled = true;
EditorGUILayout.EndHorizontal();
break;
}
case ConfigStatus.Wrong:
{
EditorGUILayout.BeginHorizontal(GUILayout.Width(frameWidth));
EditorGUILayout.LabelField(txt);
EditorGUILayout.LabelField(R.Wrong, R.wrongStyle);
EditorGUILayout.EndHorizontal();
break;
}
case ConfigStatus.Hide:
{
break;
}
case ConfigStatus.Fix:
{
EditorGUILayout.BeginHorizontal(GUILayout.Width(frameWidth));
EditorGUILayout.LabelField(txt);
float originalValue = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = 250;
field.value = EditorGUILayout.Toggle(field.value);
EditorGUIUtility.labelWidth = originalValue;
EditorGUILayout.EndHorizontal();
break;
}
default:
{
Debug.LogWarning($"unhandled ConfigStatus {txt} {field.GetStatus()}");
break;
}
}
}
EditorGUILayout.EndVertical();
}
//按钮区域
{
var hasSomethingToFix = false;
foreach (var field in configFields)
{
if (field.GetStatus() == ConfigStatus.Fix && field.value)
{
hasSomethingToFix = true;
break;
}
}
if (hasSomethingToFix)
{
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button(strIgnoreButtonText[(int) language], GUILayout.Width(130)))
{
this.Close();
}
GUI.enabled = hasSomethingToFix;
if (GUILayout.Button(strApplyButtonText[(int) language], GUILayout.Width(130)))
{
this.ApplyRecommendConfig();
}
GUI.enabled = true;
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
GUILayout.FlexibleSpace();
}
}
GUILayout.EndVertical();
}
private void ApplyRecommendConfig()
{
foreach (var field in configFields)
{
if (field.GetStatus() == ConfigStatus.Fix && field.value)
{
field.Fix();
}
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a65a6e7ecd744ea481a2b1ba6c5c7046
timeCreated: 1673080389

View File

@ -0,0 +1,53 @@
/*******************************************************************************
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 System.Xml;
using UnityEditor.Android;
using UnityEngine;
namespace Pico.Platform.Editor
{
public class PlatformManifestRewrite : IPostGenerateGradleAndroidProject
{
public int callbackOrder => 9999;
public void OnPostGenerateGradleAndroidProject(string path)
{
var appId = PicoGs.appId;
if (string.IsNullOrWhiteSpace(appId))
{
Debug.Log("appId is ignored");
return;
}
XmlDocument doc = new XmlDocument();
const string androidUri = "http://schemas.android.com/apk/res/android";
var manifestPath = Path.Combine(path, "src/main/AndroidManifest.xml");
doc.Load(manifestPath);
var app = doc.SelectSingleNode("//application");
if (app == null) return;
var appIdNode = doc.CreateElement("meta-data");
appIdNode.SetAttribute("name", androidUri, "pvr.app.id");
appIdNode.SetAttribute("value", androidUri, appId);
app.AppendChild(appIdNode);
var highlightNode = doc.CreateElement("meta-data");
highlightNode.SetAttribute("name", androidUri, "use_record_highlight_feature");
highlightNode.SetAttribute("value", androidUri, PicoGs.useHighlight.ToString());
app.AppendChild(highlightNode);
doc.Save(manifestPath);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5e6569b4f00343d996dd6610d37068ca
timeCreated: 1684327101

View File

@ -0,0 +1,36 @@
/*******************************************************************************
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 Unity.XR.PXR;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
using UnityEngine;
namespace Pico.Platform.Editor
{
public class PlatformPreprocessor : IPreprocessBuildWithReport
{
public int callbackOrder
{
get { return 0; }
}
public void OnPreprocessBuild(BuildReport report)
{
string configAppID = PXR_PlatformSetting.Instance.appID.Trim();
if (string.IsNullOrWhiteSpace(configAppID))
{
Debug.LogWarning("appID is not configured");
}
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c7e99491577614bbbb6c60ad215598f5
timeCreated: 1674209284