Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [3.2.12] - 2020-06-05
* Fix testing definitions to allows us to remove tests as separate packages.

## [3.2.11] - 2020-06-04
* Documentation updates for clarity and correctness.
* Block use of deprecated APIs on 2020.2 and later.
  • Loading branch information
Unity Technologies committed Jun 5, 2020
1 parent 6e669fe commit 266ba12
Show file tree
Hide file tree
Showing 75 changed files with 2,039 additions and 36 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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).

## [3.2.12] - 2020-06-05
* Fix testing definitions to allows us to remove tests as separate packages.

## [3.2.11] - 2020-06-04
* Documentation updates for clarity and correctness.
* Block use of deprecated APIs on 2020.2 and later.

## [3.2.11-preview.1] - 2020-05-15
* Fix FB 1242581 : Fix a number of issue around cache rebuilding and persistent UI display of cache rebuilding even though nothing was happening.
* Fix FB 1245181 : Fix nullderef access of settings manager instance.
Expand Down
46 changes: 41 additions & 5 deletions Documentation~/EndUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,46 @@ If you want to start XR on a per-Scene basis (for example, to start in 2D and tr

To handle pause state changes in the Editor, subscribe to the [`EditorApplication.pauseStateChanged`](https://docs.unity3d.com/ScriptReference/EditorApplication-pauseStateChanged.html) API, then stop and start the subsystems according to the new pause state that the `pauseStateChange` delegate method returns.

The following code shows an example of how to manually control XR using XR Plug-in Management:

```
using System.Collections;
using UnityEngine;
using UnityEngine.XR.Management;
public class ManualXRControl
{
public IEnumerator StartXR()
{
Debug.Log("Initializing XR...");
yield return XRGeneralSettings.Instance.Manager.InitializeLoader();
if (XRGeneralSettings.Instance.Manager.activeLoader == null)
{
Debug.LogError("Initializing XR Failed. Check Editor or Player log for details.");
}
else
{
Debug.Log("Starting XR...");
XRGeneralSettings.Instance.Manager.activeLoader.Start();
}
}
void StopXR()
{
Debug.Log("Stopping XR...");
if (XRGeneralSettings.Instance.Manager.activeLoader != null)
{
XRGeneralSettings.Instance.Manager.activeLoader.Stop();
XRGeneralSettings.Instance.Manager.activeLoader.Deinitialize();
Debug.Log("XR stopped completely.");
}
}
}
```

## Customizing build and runtime settings

Any package that needs build or runtime settings should provide a settings data type for use. This data type appears in the **Project Settings** window, underneath a top level **XR** node.
Expand Down Expand Up @@ -107,8 +147,4 @@ You would most likely place this script in a custom build script, but that isn't

## Installing the XR Plug-in Management package

Most XR Plug-in provider packages typically include XR Plug-in Management, so you shouldn't need to install it. If you do need to install it, follow the instructions in the [Package Manager documentation](https://docs.unity3d.com/Packages/com.unity.package-manager-ui@latest/index.html).

## Installing the Legacy Input Helpers package

Unity requires the Legacy Input Helpers package to operate XR devices correctly. To check if the Legacy Input Helpers package is installed, open the **Project Settings** window and navigate to **XR Plug-in Management** > **Input Helpers**. If Unity can't locate the package, click the **Install Legacy Helpers Package** button to install it.
Please see related Unity documentation for [Configuring XR](https://docs.unity3d.com/Manual/configuring-project-for-xr.html ).
2 changes: 1 addition & 1 deletion Documentation~/com.unity.xr.management.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ There are two target audiences for XR Plug-in Management: the end user and the p

This version of XR Plug-in Management is compatible with the following versions of the Unity Editor:

* 2019.1 and later (recommended)
* 2019.3 and later (recommended)

### Known limitations

Expand Down
4 changes: 3 additions & 1 deletion Editor/Legacy/XRLegacyUninstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ static XRLegacyUninstaller()
packSettings.SaveSettings();
}

#if !UNITY_2020_2_OR_NEWER
bool virtualRealityEnabled = false;
foreach (var buildTargetGroup in (BuildTargetGroup[])Enum.GetValues(typeof(BuildTargetGroup)))
{
Expand All @@ -201,7 +202,8 @@ static XRLegacyUninstaller()
}
}
}
}
#endif //!UNITY_2020_2_OR_NEWER
}
}
};

Expand Down
25 changes: 5 additions & 20 deletions Editor/XRSettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ static class Styles
struct Content
{
public static readonly GUIContent k_InitializeOnStart = new GUIContent("Initialize XR on Startup");
public static readonly GUIContent k_DocText = new GUIContent("View documentation");
public static readonly Uri k_DocUri = new Uri("https://docs.unity3d.com/Manual/XRPluginArchitecture.html");
public static readonly GUIContent k_ExplanatoryText = new GUIContent("Selecting an XR plug-in provider below enables that provider for the corresponding build target. The appropriate plug-in package will be installed if it is not already present. Disabling plug-ins will not automatically uninstall already installed packages. To uninstall a provider plug-in use the Package Manager.");
public static readonly GUIContent k_XRTrackingText = new GUIContent("To set up tracking in your XR project, please follow the steps outlined using the link below.");
public static readonly GUIContent k_XRTrackingDocsText = new GUIContent("View XR Tracking Migration Guide");
public static readonly Uri k_XRTrackingDocsUri = new Uri("https://docs.unity3d.com/Packages/com.unity.xr.legacyinputhelpers@latest");
public static readonly GUIContent k_XRConfigurationText = new GUIContent("Information about configuration, tracking and migration can be found below.");
public static readonly GUIContent k_XRConfigurationDocUriText = new GUIContent("View Documentation");
public static readonly Uri k_XRConfigurationUri = new Uri(" https://docs.unity3d.com/Manual/configuring-project-for-xr.html");

}

Expand Down Expand Up @@ -272,30 +269,19 @@ private void DisplayLink(GUIContent text, Uri link, int leftMargin, int width)
EditorGUI.DrawRect(new Rect(uriRect.x, uriRect.y + uriRect.height - 1, uriRect.width, 1), labelStyle.normal.textColor);
}

private void DisplayDocumentationLink()
{
DisplayLink(Content.k_DocText, Content.k_DocUri, 5, 120);
EditorGUILayout.Space();
}

private void DisplayXRTrackingDocumentationLink()
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
EditorGUILayout.LabelField(Content.k_XRTrackingText, Styles.k_LabelWordWrap);
DisplayLink(Content.k_XRTrackingDocsText, Content.k_XRTrackingDocsUri, 2, 200);
EditorGUILayout.LabelField(Content.k_XRConfigurationText, Styles.k_LabelWordWrap);
DisplayLink(Content.k_XRConfigurationDocUriText, Content.k_XRConfigurationUri, 2, 200);
}
GUILayout.EndVertical();
EditorGUILayout.Space();
}

private void DisplayLoadOrderUi()
{
GUILayout.BeginVertical(EditorStyles.helpBox);
{
EditorGUILayout.LabelField(Content.k_ExplanatoryText, Styles.k_LabelWordWrap);
}
GUILayout.EndVertical();
EditorGUILayout.Space();

EditorGUI.BeginDisabledGroup(XRPackageMetadataStore.isDoingQueueProcessing || EditorApplication.isPlaying || EditorApplication.isPaused);
Expand All @@ -319,7 +305,6 @@ public override void OnGUI(string searchContext)
{
EditorGUILayout.Space();

DisplayDocumentationLink();
DisplayLoadOrderUi();
DisplayXRTrackingDocumentationLink();

Expand Down
3 changes: 1 addition & 2 deletions Samples~/Unity.XR.Management.Samples.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"Unity.XR.Management.Editor",
"Unity.XR.Management"
],
"optionalUnityReferences": [
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
Expand Down
8 changes: 8 additions & 0 deletions Tests.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Tests/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions Tests/Editor/BuildTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEditor.Build;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.XR.Management;
using UnityEngine.XR.Management.Tests;
using Object = UnityEngine.Object;

#if UNITY_EDITOR_WIN || UNITY_EDITOR_OSX

namespace UnityEditor.XR.Management.Tests.BuildTests
{
#if UNITY_EDITOR_WIN
[TestFixture(GraphicsDeviceType.Direct3D11, false, new [] { GraphicsDeviceType.Direct3D11})]
[TestFixture(GraphicsDeviceType.Direct3D11, false, new [] { GraphicsDeviceType.Direct3D12, GraphicsDeviceType.Direct3D11})]
[TestFixture(GraphicsDeviceType.Direct3D11, true, new [] { GraphicsDeviceType.Direct3D12, GraphicsDeviceType.Vulkan})]
[TestFixture(GraphicsDeviceType.Direct3D11, false, new [] { GraphicsDeviceType.Null, GraphicsDeviceType.Vulkan})]
[TestFixture(GraphicsDeviceType.Direct3D11, false, new [] { GraphicsDeviceType.Vulkan, GraphicsDeviceType.Null})]
#elif UNITY_EDITOR_OSX
[TestFixture(GraphicsDeviceType.Metal, false, new [] { GraphicsDeviceType.Metal})]
[TestFixture(GraphicsDeviceType.Metal, false, new [] { GraphicsDeviceType.Direct3D12, GraphicsDeviceType.Metal})]
[TestFixture(GraphicsDeviceType.Metal, true, new [] { GraphicsDeviceType.OpenGLES3, GraphicsDeviceType.Vulkan})]
[TestFixture(GraphicsDeviceType.Metal, false, new [] { GraphicsDeviceType.Null, GraphicsDeviceType.Vulkan})]
[TestFixture(GraphicsDeviceType.Metal, false, new [] { GraphicsDeviceType.Vulkan, GraphicsDeviceType.Null})]
#endif
class GraphicsAPICompatibilityTests
{
XRManagerSettings m_Manager;
List<XRLoader> m_Loaders = new List<XRLoader>();

private GraphicsDeviceType m_PlayerSettingsDeviceType;
private GraphicsDeviceType[] m_LoadersSupporteDeviceTypes;
bool m_BuildFails;

public GraphicsAPICompatibilityTests(GraphicsDeviceType playerSettingsDeviceType, bool fails, GraphicsDeviceType[] loaders)
{
m_BuildFails = fails;
m_PlayerSettingsDeviceType = playerSettingsDeviceType;
m_LoadersSupporteDeviceTypes = loaders;
}

[SetUp]
public void SetupPlayerSettings()
{
#if UNITY_EDITOR_WIN
PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneWindows64, new[] { m_PlayerSettingsDeviceType });
#elif UNITY_EDITOR_OSX
PlayerSettings.SetGraphicsAPIs(BuildTarget.StandaloneOSX, new[] { m_PlayerSettingsDeviceType });
#endif
m_Manager = ScriptableObject.CreateInstance<XRManagerSettings>();
m_Manager.automaticLoading = false;

m_Loaders = new List<XRLoader>();

for (int i = 0; i < m_LoadersSupporteDeviceTypes.Length; i++)
{
DummyLoader dl = ScriptableObject.CreateInstance(typeof(DummyLoader)) as DummyLoader;
dl.id = i;
dl.supportedDeviceType = m_LoadersSupporteDeviceTypes[i];
m_Loaders.Add(dl);
m_Manager.loaders.Add(dl);
}
}

[TearDown]
public void TeadDown()
{
Object.DestroyImmediate(m_Manager);
m_Manager = null;

}

[Test]
public void CheckGraphicsAPICompatibilityOnBuild()
{
try
{
XRGeneralBuildProcessor.VerifyGraphicsAPICompatibility(m_Manager, m_PlayerSettingsDeviceType);
}
catch (BuildFailedException)
{
Assert.True(m_BuildFails);
return;
}

Assert.False(m_BuildFails);
}
}
}
#endif //UNITY_EDITOR_WIN || UNITY_EDITOR_OSX
11 changes: 11 additions & 0 deletions Tests/Editor/BuildTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions Tests/Editor/EditorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using NUnit.Framework;

using System;
using System.IO;

using UnityEngine;
using UnityEngine.XR.Management;

using Unity.XR.TestTooling;

namespace UnityEditor.XR.Management.Tests
{

class XRGeneralSettingsTests : ManagementTestSetup
{
protected override bool TestManagerUpgradePath => true;
BuildTargetGroup previousBuildTargetSelection { get; set; }

[SetUp]
public override void SetupTest()
{

base.SetupTest();

previousBuildTargetSelection = EditorUserBuildSettings.selectedBuildTargetGroup;
EditorUserBuildSettings.selectedBuildTargetGroup = BuildTargetGroup.Standalone;
}

[TearDown]
public override void TearDownTest()
{
EditorUserBuildSettings.selectedBuildTargetGroup = previousBuildTargetSelection;
base.TearDownTest();
}


[Test]
public void UpdateGeneralSettings_ToPerBuildTargetSettings()
{
bool success = XRGeneralSettingsUpgrade.UpgradeSettingsToPerBuildTarget(testPathToSettings);
Assert.IsTrue(success);

XRGeneralSettingsPerBuildTarget pbtgs = null;

pbtgs = AssetDatabase.LoadAssetAtPath(testPathToSettings, typeof(XRGeneralSettingsPerBuildTarget)) as XRGeneralSettingsPerBuildTarget;
Assert.IsNotNull(pbtgs);

var settings = pbtgs.SettingsForBuildTarget(EditorUserBuildSettings.selectedBuildTargetGroup);
Assert.IsNotNull(settings);
Assert.IsNotNull(settings.Manager);
Assert.AreEqual(testManager, settings.Manager);
}
}
}
11 changes: 11 additions & 0 deletions Tests/Editor/EditorTests.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 266ba12

Please sign in to comment.