Revert change to remove xr setup (#32)
Revert change to remove xr setup; this code is already being used by URP. From original PR https://github.cds.internal.unity3d.com/unity/com.unity.cli-project-setup/pull/22
This commit is contained in:
Родитель
5ca3ce9d92
Коммит
f5857cf611
|
@ -4,13 +4,16 @@ All notable changes to this package will be documented in this file.
|
|||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.1.0-preview] - 2023-05-08
|
||||
Revert breaking removal of XR setups; URP relies on these.
|
||||
|
||||
## [0.5.0-preview] - 2023-04-06
|
||||
* Add cmd line option for enabling foveated rendering setting
|
||||
|
||||
## [0.4.1-preview] - 2022-12-09
|
||||
* Remove XR specific API and create ConfigManager
|
||||
|
||||
## [0.4.0-preview] - 2022-08-17s
|
||||
## [0.4.0-preview] - 2022-08-17
|
||||
* Update to use newest version of com.unity.test.metadata-manager
|
||||
|
||||
## [0.3.18-preview] - 2022-08-11
|
||||
|
@ -91,3 +94,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
## [0.1.0-preview] - 2019-06-18
|
||||
|
||||
### This is the first release of *Unity Package \com.unity.cli-config-manager*.
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eec7c59ea3458ef4f958be85926d3e23
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"name": "ConfigureProject",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d383fd71d93730846836e8544e2bfa3d
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace ConfigureProject
|
||||
{
|
||||
public abstract class XRPlatformSettings<T>
|
||||
{
|
||||
protected abstract void ConfigureXr(T platformSettings);
|
||||
|
||||
public static void Configure(T platformSettings)
|
||||
{
|
||||
var settingsList = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => typeof(XRPlatformSettings<T>).IsAssignableFrom(p) && !p.IsAbstract).ToList();
|
||||
|
||||
foreach (var obj in settingsList.Select(type => Activator.CreateInstance(type) as XRPlatformSettings<T>)
|
||||
.Where(obj => obj != null))
|
||||
{
|
||||
obj.ConfigureXr(platformSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1dd4a0e851cb5764b879404144c38748
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
{
|
||||
"name": "ConfigureXRProject",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"ConfigureProject",
|
||||
"com.unity.cliprojectsetup",
|
||||
"Unity.XR.Oculus",
|
||||
"Unity.XR.Management",
|
||||
"Unity.XR.Management.Editor",
|
||||
"Unity.XR.MockHMD",
|
||||
"Unity.XR.OpenXR",
|
||||
"Unity.XR.OpenXR.Editor",
|
||||
"Unity.XR.WindowsMixedReality",
|
||||
"Unity.XR.PSVR2"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [
|
||||
{
|
||||
"name": "com.unity.xr.oculus",
|
||||
"expression": "0.0.1",
|
||||
"define": "XR_SDK;OCULUS_SDK"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.mock-hmd",
|
||||
"expression": "0.0.1",
|
||||
"define": "XR_SDK;MOCKHMD_SDK"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.openxr",
|
||||
"expression": "0.0.1",
|
||||
"define": "XR_SDK;OPENXR_SDK"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.windowsmr",
|
||||
"expression": "0.0.1",
|
||||
"define": "XR_SDK;WMR_SDK"
|
||||
},
|
||||
{
|
||||
"name": "com.unity.xr.psvr2",
|
||||
"expression": "0.0.1",
|
||||
"define": "XR_SDK;PSVR2_SDK"
|
||||
}
|
||||
],
|
||||
"noEngineReferences": false
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c6f1f3ea402309d41b516f9602a96583
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
using ConfigureProject;
|
||||
#if ENABLE_VR && !XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class LegacyVrPlatformSettings : XRPlatformSettings<PlatformSettings>
|
||||
{
|
||||
protected override void ConfigureXr(PlatformSettings platformSettings)
|
||||
{
|
||||
if (string.IsNullOrEmpty(platformSettings.XrTarget))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerSettings.virtualRealitySupported = true;
|
||||
|
||||
UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup
|
||||
(platformSettings.BuildTargetGroup, new string[] { platformSettings.XrTarget });
|
||||
|
||||
try
|
||||
{
|
||||
PlayerSettings.stereoRenderingPath = (StereoRenderingPath)Enum.Parse(
|
||||
typeof(StereoRenderingPath), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"Error trying to cast stereo rendering mode cmdline parameter to UnityEditor.StereoRenderingPath type.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0a790ad55d56a584d863cdc2bed435d5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
#if MOCKHMD_SDK
|
||||
using Unity.XR.MockHMD;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class MockHMDSdkPlatformSettings : XrSdkPlatformSettings<MockHMDBuildSettings, MockHMDLoader>
|
||||
{
|
||||
protected override string xrConfigName => "Unity.XR.MockHMD.Settings";
|
||||
protected override string CmdlineParam => "MockHMDXRSDK";
|
||||
|
||||
public override void SetRenderMode(PlatformSettings platformSettings)
|
||||
{
|
||||
try
|
||||
{
|
||||
xrSettings.renderMode = (MockHMDBuildSettings.RenderMode)Enum.Parse(
|
||||
typeof(MockHMDBuildSettings.RenderMode), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ArgumentException("Failed to parse stereo rendering mode for Mock HMD XR SDK", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // MOCKHMD_SDK
|
||||
#endif // XR_SDK
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 72271071a7368a14ebe9c256b00fea80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
#if OCULUS_SDK
|
||||
using Unity.XR.Oculus;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class OculusSdkPlatformSettings : XrSdkPlatformSettings<OculusSettings, OculusLoader>
|
||||
{
|
||||
protected override string xrConfigName => "Unity.XR.Oculus.Settings";
|
||||
protected override string CmdlineParam => "OculusXRSDK";
|
||||
|
||||
public override void SetRenderMode(PlatformSettings platformSettings)
|
||||
{
|
||||
if (platformSettings.BuildTarget == BuildTarget.Android)
|
||||
{
|
||||
try
|
||||
{
|
||||
xrSettings.m_StereoRenderingModeAndroid = (OculusSettings.StereoRenderingModeAndroid)Enum.Parse(
|
||||
typeof(OculusSettings.StereoRenderingModeAndroid), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ArgumentException("Failed to parse stereo rendering mode for Android Oculus XR SDK", e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
xrSettings.m_StereoRenderingModeDesktop = (OculusSettings.StereoRenderingModeDesktop)Enum.Parse(
|
||||
typeof(OculusSettings.StereoRenderingModeDesktop), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
throw new ArgumentException("Failed to parse stereo rendering mode for Desktop Oculus XR SDK.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b5f5f9395cd3066449e2c5750d707b60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,84 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
#if OPENXR_SDK
|
||||
using UnityEngine.XR.OpenXR;
|
||||
using UnityEditor.XR.OpenXR.Features;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class OpenXRPlatformSettings : XrSdkPlatformSettings<OpenXRSettings, OpenXRLoader>
|
||||
{
|
||||
protected override string xrConfigName => UnityEngine.XR.OpenXR.Constants.k_SettingsKey;
|
||||
protected override string CmdlineParam => "OpenXR";
|
||||
|
||||
private List<string> OpenXrFeatures;
|
||||
|
||||
protected override void CreateXRSettingsInstance()
|
||||
{
|
||||
FeatureHelpers.RefreshFeatures(EditorUserBuildSettings.selectedBuildTargetGroup);
|
||||
xrSettings = OpenXRSettings.ActiveBuildTargetInstance;
|
||||
}
|
||||
|
||||
protected override bool IsXrTarget(string xrTarget)
|
||||
{
|
||||
if (xrTarget.StartsWith(CmdlineParam, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
OpenXrFeatures = xrTarget.Split(new char[]{'.'}, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void SetRenderMode(PlatformSettings platformSettings)
|
||||
{
|
||||
try
|
||||
{
|
||||
xrSettings.renderMode = (OpenXRSettings.RenderMode)Enum.Parse(
|
||||
typeof(OpenXRSettings.RenderMode), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ArgumentException("Failed to parse stereo rendering mode for OpenXR", e);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ApplyLoaderSettings(XRGeneralSettingsPerBuildTarget buildTargetSettings)
|
||||
{
|
||||
FeatureHelpers.RefreshFeatures(BuildTargetGroup.Standalone);
|
||||
var msController = OpenXRSettings.ActiveBuildTargetInstance
|
||||
.GetFeature<UnityEngine.XR.OpenXR.Features.Interactions.MicrosoftMotionControllerProfile>();
|
||||
|
||||
if (OpenXrFeatures.Contains("MockRT"))
|
||||
{
|
||||
Debug.Log("Enabling Mock Runtime Feature");
|
||||
|
||||
var feature = OpenXRSettings.Instance.GetFeatures().Where(f => f.GetType().Name == "MockRuntime").FirstOrDefault();
|
||||
feature.enabled = true;
|
||||
feature.GetType().GetField("ignoreValidationErrors").SetValue(feature, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (msController)
|
||||
{
|
||||
msController.enabled = true;
|
||||
EditorUtility.SetDirty(OpenXRSettings.ActiveBuildTargetInstance);
|
||||
}
|
||||
}
|
||||
EditorUtility.SetDirty(OpenXRSettings.ActiveBuildTargetInstance);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7318be4db7ef0c04296ccd0dc2147b92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
#if PSVR2_SDK
|
||||
using UnityEngine.XR.PSVR2;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class PSVR2PlatformSettings : XrSdkPlatformSettings<PSVR2Settings, PSVR2Loader>
|
||||
{
|
||||
protected override string xrConfigName => "UnityEngine.XR.PSVR2.PSVR2Settings";
|
||||
protected override string CmdlineParam => "PSVR2";
|
||||
|
||||
public override void SetRenderMode(PlatformSettings platformSettings)
|
||||
{
|
||||
try
|
||||
{
|
||||
xrSettings.StereoRenderingMode = (StereoRenderingMode)Enum.Parse(
|
||||
typeof(StereoRenderingMode), platformSettings.StereoRenderingMode);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
throw new ArgumentException("Failed to parse stereo rendering mode for PSVR2.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4b1b22d6056d6d142b5aef41d8835d95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
#if WMR_SDK
|
||||
using UnityEngine.XR.WindowsMR;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
class WMRSdkPlatformSettings : XrSdkPlatformSettings<WindowsMRSettings, WindowsMRLoader>
|
||||
{
|
||||
protected override string xrConfigName => "Unity.XR.WindowsMR.Settings";
|
||||
protected override string CmdlineParam => "WMRXRSDK";
|
||||
|
||||
public override void SetRenderMode(PlatformSettings platformSettings)
|
||||
{
|
||||
// No Implementation
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // WMR_SDK
|
||||
#endif // XR_SDK
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee839f4e493e1964185b162d82e31b22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,148 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using com.unity.cliprojectsetup;
|
||||
using ConfigureProject;
|
||||
#if XR_SDK
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor.XR.Management;
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Management;
|
||||
|
||||
namespace ConfigureXRProject
|
||||
{
|
||||
public abstract class XrSdkPlatformSettings<T, U> : XRPlatformSettings<PlatformSettings>
|
||||
where T : ScriptableObject
|
||||
where U : XRLoader
|
||||
{
|
||||
private static readonly string xrsdkTestXrSettingsPath = "Assets/XR/Settings/Test Settings.asset";
|
||||
|
||||
protected T xrSettings;
|
||||
protected abstract string xrConfigName { get; }
|
||||
protected abstract string CmdlineParam { get; }
|
||||
|
||||
protected virtual void CreateXRSettingsInstance()
|
||||
{
|
||||
xrSettings = ScriptableObject.CreateInstance<T>();
|
||||
}
|
||||
|
||||
protected virtual bool IsXrTarget(string xrTarget)
|
||||
{
|
||||
return xrTarget.Equals(CmdlineParam, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
protected override void ConfigureXr(PlatformSettings platformSettings)
|
||||
{
|
||||
if (!IsXrTarget(platformSettings.XrTarget))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create our own test version of xr general settings.
|
||||
var xrGeneralSettings = ScriptableObject.CreateInstance<XRGeneralSettings>();
|
||||
var managerSettings = ScriptableObject.CreateInstance<XRManagerSettings>();
|
||||
var buildTargetSettings = ScriptableObject.CreateInstance<XRGeneralSettingsPerBuildTarget>();
|
||||
|
||||
EnsureArgumentsNotNull(xrGeneralSettings, buildTargetSettings, managerSettings);
|
||||
|
||||
|
||||
xrGeneralSettings.Manager = managerSettings;
|
||||
|
||||
SetupLoader(xrGeneralSettings, buildTargetSettings, managerSettings);
|
||||
|
||||
CreateXRSettingsInstance();
|
||||
|
||||
if (xrSettings == null)
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
$"Tried to instantiate an instance of {typeof(T).Name} but it is null.");
|
||||
}
|
||||
|
||||
SetRenderMode(platformSettings);
|
||||
|
||||
ApplyLoaderSettings(buildTargetSettings);
|
||||
|
||||
// Add xrSettings to Preloaded assets so XR Mgmt can see it.
|
||||
EditorBuildSettings.AddConfigObject(XRGeneralSettings.k_SettingsKey, buildTargetSettings, true);
|
||||
}
|
||||
|
||||
public virtual void ApplyLoaderSettings(XRGeneralSettingsPerBuildTarget buildTargetSettings)
|
||||
{
|
||||
AssetDatabase.AddObjectToAsset(xrSettings, xrsdkTestXrSettingsPath);
|
||||
AssetDatabase.SaveAssets();
|
||||
EditorBuildSettings.AddConfigObject(xrConfigName, xrSettings, true);
|
||||
}
|
||||
|
||||
public abstract void SetRenderMode(PlatformSettings platformSettings);
|
||||
|
||||
private static void SetupLoader(XRGeneralSettings xrGeneralSettings,
|
||||
XRGeneralSettingsPerBuildTarget buildTargetSettings,
|
||||
XRManagerSettings managerSettings)
|
||||
{
|
||||
var loader = ScriptableObject.CreateInstance<U>();
|
||||
|
||||
if (loader == null)
|
||||
{
|
||||
throw new ArgumentNullException(
|
||||
$"Tried to instantiate an instance of {typeof(U).Name}, but it is null.");
|
||||
}
|
||||
|
||||
loader.name = loader.GetType().Name;
|
||||
|
||||
xrGeneralSettings.Manager.TryAddLoader(loader);
|
||||
|
||||
buildTargetSettings.SetSettingsForBuildTarget(EditorUserBuildSettings.selectedBuildTargetGroup,
|
||||
xrGeneralSettings);
|
||||
|
||||
EnsureXrGeneralSettingsPathExists(xrsdkTestXrSettingsPath);
|
||||
|
||||
AssetDatabase.CreateAsset(buildTargetSettings, xrsdkTestXrSettingsPath);
|
||||
|
||||
AssetDatabase.AddObjectToAsset(xrGeneralSettings, xrsdkTestXrSettingsPath);
|
||||
AssetDatabase.AddObjectToAsset(managerSettings, xrsdkTestXrSettingsPath);
|
||||
AssetDatabase.AddObjectToAsset(loader, xrsdkTestXrSettingsPath);
|
||||
}
|
||||
|
||||
private static void EnsureXrGeneralSettingsPathExists(string testXrGeneralSettingsPath)
|
||||
{
|
||||
var settingsPath = Path.GetDirectoryName(testXrGeneralSettingsPath);
|
||||
if (!AssetDatabase.IsValidFolder(settingsPath))
|
||||
{
|
||||
// The parent folder must already exist before creating the folder
|
||||
// Thus itereate through each folder in the hierarchy and create each individually
|
||||
// Ref: https://docs.unity3d.com/2021.2/Documentation/ScriptReference/AssetDatabase.CreateFolder.html
|
||||
var folders = settingsPath.Split(Path.DirectorySeparatorChar);
|
||||
for (int i=0; i < folders.Length; i++)
|
||||
{
|
||||
if (!AssetDatabase.IsValidFolder(folders[i]))
|
||||
{
|
||||
var parentFolder = string.Join(Path.DirectorySeparatorChar.ToString(), folders, 0, i);
|
||||
if ( string.IsNullOrEmpty(AssetDatabase.CreateFolder(parentFolder, folders[i])) )
|
||||
{
|
||||
throw new Exception(string.Format("Failed to create folder {0}/{1}", parentFolder, folders[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureArgumentsNotNull(XRGeneralSettings xrGeneralSettings,
|
||||
XRGeneralSettingsPerBuildTarget buildTargetSettings, XRManagerSettings managerSettings)
|
||||
{
|
||||
EnsureArgumentNotNull(xrGeneralSettings);
|
||||
EnsureArgumentNotNull(buildTargetSettings);
|
||||
EnsureArgumentNotNull(managerSettings);
|
||||
}
|
||||
|
||||
private static void EnsureArgumentNotNull(object arg)
|
||||
{
|
||||
if (arg == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // XR_SDK
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a4275d8e196a0c4294105dbf61b4235
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -11,6 +11,8 @@ using Unity.Burst;
|
|||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEditor;
|
||||
using ConfigureProject;
|
||||
using UnityEditor.Build;
|
||||
|
||||
namespace com.unity.cliprojectsetup
|
||||
{
|
||||
|
@ -82,13 +84,13 @@ namespace com.unity.cliprojectsetup
|
|||
|
||||
if (!string.IsNullOrEmpty(platformSettings.XrTarget))
|
||||
{
|
||||
ConfigManager<PlatformSettings>.Instance.Configure(platformSettings);
|
||||
XRPlatformSettings<PlatformSettings>.Configure(platformSettings);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureIosSettings()
|
||||
{
|
||||
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, string.Format("com.unity3d.{0}", PlayerSettings.productName));
|
||||
PlayerSettings.SetApplicationIdentifier(NamedBuildTarget.iOS, string.Format("com.unity3d.{0}", PlayerSettings.productName));
|
||||
PlayerSettings.iOS.appleEnableAutomaticSigning = false;
|
||||
PlayerSettings.iOS.iOSManualProvisioningProfileType = ProvisioningProfileType.Development;
|
||||
}
|
||||
|
@ -101,8 +103,7 @@ namespace com.unity.cliprojectsetup
|
|||
platformSettings.ScriptingImplementation != ScriptingImplementation.Mono2x)
|
||||
{
|
||||
platformSettings.ScriptingImplementation = ScriptingImplementation.Mono2x;
|
||||
PlayerSettings.SetScriptingBackend(EditorUserBuildSettings.selectedBuildTargetGroup,
|
||||
(ScriptingImplementation) platformSettings.ScriptingImplementation);
|
||||
PlayerSettings.SetScriptingBackend(NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup), (ScriptingImplementation) platformSettings.ScriptingImplementation);
|
||||
}
|
||||
|
||||
// If the user has specified mono scripting backend, but not specified AndroidArchitecture.ARMv7, or has incorrectly specified AndroidArchitecture.ARM64 (not supported
|
||||
|
@ -132,24 +133,23 @@ namespace com.unity.cliprojectsetup
|
|||
QualitySettings.vSyncCount = !string.IsNullOrEmpty(platformSettings.Vsync) ? Convert.ToInt32(platformSettings.Vsync) : 0;
|
||||
}
|
||||
|
||||
//QualitySettings.vSyncCount = !string.IsNullOrEmpty(platformSettings.Vsync) ? Convert.ToInt32(platformSettings.Vsync) : 0;
|
||||
PlayerSettings.graphicsJobs = platformSettings.GraphicsJobs;
|
||||
PlayerSettings.MTRendering = platformSettings.MtRendering;
|
||||
PlayerSettings.colorSpace = platformSettings.ColorSpace;
|
||||
if (platformSettings.ScriptingImplementation != null)
|
||||
{
|
||||
PlayerSettings.SetScriptingBackend(
|
||||
EditorUserBuildSettings.selectedBuildTargetGroup,
|
||||
NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup),
|
||||
(ScriptingImplementation)platformSettings.ScriptingImplementation);
|
||||
}
|
||||
|
||||
if (platformSettings.ApiCompatibilityLevel != null)
|
||||
{
|
||||
PlayerSettings.SetApiCompatibilityLevel(EditorUserBuildSettings.selectedBuildTargetGroup, (ApiCompatibilityLevel) platformSettings.ApiCompatibilityLevel);
|
||||
PlayerSettings.SetApiCompatibilityLevel(NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup), (ApiCompatibilityLevel) platformSettings.ApiCompatibilityLevel);
|
||||
}
|
||||
|
||||
PlayerSettings.stripEngineCode = platformSettings.StringEngineCode;
|
||||
PlayerSettings.SetManagedStrippingLevel(EditorUserBuildSettings.selectedBuildTargetGroup, platformSettings.ManagedStrippingLevel);
|
||||
PlayerSettings.SetManagedStrippingLevel(NamedBuildTarget.FromBuildTargetGroup(EditorUserBuildSettings.selectedBuildTargetGroup), platformSettings.ManagedStrippingLevel);
|
||||
EditorUserBuildSettings.allowDebugging = platformSettings.ScriptDebugging;
|
||||
/* TODO: Revisit burst logic when we're using it
|
||||
#if ENABLE_BURST_AOT
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace com.unity.cliprojectsetup
|
||||
{
|
||||
public abstract class PlatformConfig<T>
|
||||
{
|
||||
public PlatformConfig() => ConfigManager<T>.Instance.AddConfig(this);
|
||||
|
||||
public abstract void Configure(T platformSettings);
|
||||
}
|
||||
|
||||
public class ConfigManager<T>
|
||||
{
|
||||
List<PlatformConfig<T>> platformConfigs;
|
||||
|
||||
public static ConfigManager<T> Instance = new ConfigManager<T>();
|
||||
|
||||
private ConfigManager() => platformConfigs = new List<PlatformConfig<T>>();
|
||||
|
||||
public void Configure(T platformSettings)
|
||||
{
|
||||
// Remove any empty configs
|
||||
platformConfigs.RemoveAll(config => config == null);
|
||||
|
||||
// Loop through all the knock configs
|
||||
foreach (var config in platformConfigs)
|
||||
{
|
||||
config.Configure(platformSettings);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddConfig(PlatformConfig<T> platformConfig) => platformConfigs.Add(platformConfig);
|
||||
}
|
||||
}
|
|
@ -12,9 +12,6 @@ using UnityEngine.Rendering.Universal;
|
|||
#endif
|
||||
#if ENABLE_VR
|
||||
using UnityEngine.XR;
|
||||
#if OCULUS_SDK_PERF
|
||||
using Unity.XR.Oculus;
|
||||
#endif // OCULUS_SDK_PERF
|
||||
#endif
|
||||
|
||||
namespace com.unity.cliprojectsetup
|
||||
|
@ -135,8 +132,8 @@ namespace com.unity.cliprojectsetup
|
|||
}
|
||||
|
||||
#if OCULUS_SDK_PERF
|
||||
settings.PluginVersion = string.Format("OculusPluginVersion|{0}", Stats.PluginVersion);
|
||||
#endif // OCulus_SDK_PERF
|
||||
settings.PluginVersion = string.Format("OculusPluginVersion|{0}", OculusStats.PluginVersion);
|
||||
#endif
|
||||
#endif
|
||||
#if XR_SDK
|
||||
settings.StereoRenderingMode = StereoRenderingMode;
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
"name": "com.unity.cliprojectsetup",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"ConfigureProject",
|
||||
"com.unity.test.metadata-manager",
|
||||
"Unity.XR.Oculus",
|
||||
"Unity.RenderPipelines.Universal.Runtime",
|
||||
"Unity.Burst"
|
||||
],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "com.unity.cli-project-setup",
|
||||
"displayName": "Unity CLI Project Setup",
|
||||
"version": "0.5.0-preview",
|
||||
"version": "1.1.0-preview",
|
||||
"unity": "2020.3",
|
||||
"description": "Provides a command line parser and options to set build, player, and other Unity settings when running Unity from the command line.",
|
||||
"dependencies": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче