initial commit
This commit is contained in:
parent
6715289efe
commit
788c3389af
37645 changed files with 2526849 additions and 80 deletions
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7a4a436f8d8c5c341958531231759e0d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"name": "UnityEditor.XR.LegacyInputHelpers.Tests",
|
||||
"references": [
|
||||
"UnityEditor.XR.LegacyInputHelpers"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 559bcbd55c770ea4d959cfdb857c39a5
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f55c8aa2f418fae4693a0db0739d4b7a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor.XR.LegacyInputHelpers;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityEditor.XR.LegacyInputHelpers.Tests
|
||||
{
|
||||
|
||||
[TestFixture]
|
||||
internal class TestSeededInput
|
||||
{
|
||||
|
||||
const int kNumOverlaps = 4; // we know there are four overlaps between the input asset, and the seeded assets.
|
||||
const int kNumDupesToKeep = 2;
|
||||
|
||||
[Test]
|
||||
public void SeededInput_FillsOutCompleteData()
|
||||
{
|
||||
|
||||
// load the input asset
|
||||
var inputManagerAsset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
var serializedObject = new SerializedObject(inputManagerAsset);
|
||||
var inputManagerCurrentData = serializedObject.FindProperty("m_Axes");
|
||||
|
||||
// cache the number of items so we can reset.
|
||||
int prevInputManagerSize = inputManagerCurrentData.arraySize;
|
||||
|
||||
SeedXRInputBindings tsxib = new SeedXRInputBindings();
|
||||
|
||||
Dictionary<string, SeedXRInputBindings.BindingData> axisMap = new Dictionary<string, SeedXRInputBindings.BindingData>();
|
||||
for (int i = 0; i < tsxib.axisList.Count; ++i)
|
||||
{
|
||||
axisMap.Add(tsxib.axisList[i].name, new SeedXRInputBindings.BindingData() { newDataIndex = i, exists = false, inputManagerIndex = -1 });
|
||||
}
|
||||
|
||||
tsxib.GenerateXRBindings();
|
||||
|
||||
inputManagerAsset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
serializedObject = new SerializedObject(inputManagerAsset);
|
||||
inputManagerCurrentData = serializedObject.FindProperty("m_Axes");
|
||||
|
||||
// did we create the right number of things?
|
||||
Assert.That(inputManagerCurrentData.arraySize == (prevInputManagerSize + tsxib.axisList.Count) - kNumOverlaps); // we subtract kNumOverlaps because we know there are 4 things duplicated and they shouldnt be included.
|
||||
|
||||
List<SeedXRInputBindings.InputAxis> currentInputData = new List<SeedXRInputBindings.InputAxis>();
|
||||
|
||||
tsxib.LoadExistingDataAndCheckAgainstNewData(inputManagerCurrentData, ref axisMap, ref currentInputData);
|
||||
|
||||
// the axis map should now be true for every element.
|
||||
foreach(var item in axisMap)
|
||||
{
|
||||
Assert.That(item.Value.exists == true);
|
||||
}
|
||||
|
||||
inputManagerCurrentData.arraySize = prevInputManagerSize;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SeededInput_DoesntAddDuplicates()
|
||||
{
|
||||
// load the input asset
|
||||
var inputManagerAsset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
var serializedObject = new SerializedObject(inputManagerAsset);
|
||||
var inputManagerCurrentData = serializedObject.FindProperty("m_Axes");
|
||||
|
||||
// cache the number of items so we can reset.
|
||||
int prevInputManagerSize = inputManagerCurrentData.arraySize;
|
||||
inputManagerCurrentData.arraySize = 0;
|
||||
|
||||
SeedXRInputBindings tsxib = new SeedXRInputBindings();
|
||||
|
||||
Dictionary<string, SeedXRInputBindings.BindingData> axisMap = new Dictionary<string, SeedXRInputBindings.BindingData>();
|
||||
for (int i = 0; i < tsxib.axisList.Count; ++i)
|
||||
{
|
||||
axisMap.Add(tsxib.axisList[i].name, new SeedXRInputBindings.BindingData() { newDataIndex = i, exists = false, inputManagerIndex = -1 });
|
||||
}
|
||||
|
||||
tsxib.GenerateXRBindings();
|
||||
|
||||
// slam back the value to a smaller number
|
||||
inputManagerAsset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
serializedObject = new SerializedObject(inputManagerAsset);
|
||||
inputManagerCurrentData = serializedObject.FindProperty("m_Axes");
|
||||
// we want to maintain a few records to ensure that we dont add duplicates.
|
||||
inputManagerCurrentData.arraySize = kNumDupesToKeep;
|
||||
|
||||
List<SeedXRInputBindings.InputAxis> currentInputData = new List<SeedXRInputBindings.InputAxis>();
|
||||
|
||||
tsxib.LoadExistingDataAndCheckAgainstNewData(inputManagerCurrentData, ref axisMap, ref currentInputData);
|
||||
|
||||
// now, we should only have two elements that match, seeing as we only left two items in the asset.
|
||||
int trueCount = 0;
|
||||
foreach (var item in axisMap)
|
||||
{
|
||||
if (item.Value.exists)
|
||||
trueCount++;
|
||||
}
|
||||
Assert.That(trueCount == kNumDupesToKeep);
|
||||
|
||||
tsxib.GenerateXRBindings();
|
||||
|
||||
inputManagerAsset = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0];
|
||||
serializedObject = new SerializedObject(inputManagerAsset);
|
||||
inputManagerCurrentData = serializedObject.FindProperty("m_Axes");
|
||||
Assert.That(inputManagerCurrentData.arraySize == (prevInputManagerSize + tsxib.axisList.Count) - kNumOverlaps); // we subtract kNumOverlaps because we know there are 4 things duplicated and they shouldnt be included.
|
||||
tsxib.LoadExistingDataAndCheckAgainstNewData(inputManagerCurrentData, ref axisMap, ref currentInputData);
|
||||
|
||||
// the axis map should now be true for every element.
|
||||
foreach (var item in axisMap)
|
||||
{
|
||||
Assert.That(item.Value.exists == true);
|
||||
}
|
||||
|
||||
inputManagerCurrentData.arraySize = prevInputManagerSize;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0bcb0a0c70d1bbe419964a5935a83745
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 11a5cf454eec528428e2df5463d6a0ee
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b515c4e6a4ca71643b0e830024fe733f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
using NUnit.Framework;
|
||||
using UnityEngine.Experimental.XR.Interaction;
|
||||
|
||||
namespace UnityEngine.SpatialTracking
|
||||
{
|
||||
[TestFixture]
|
||||
internal class TrackedPoseDriverTests
|
||||
{
|
||||
internal class TestTrackedPoseDriverWrapper : TrackedPoseDriver
|
||||
{
|
||||
public void FakeUpdate()
|
||||
{
|
||||
Update();
|
||||
}
|
||||
|
||||
public void FakeOnBeforeRender()
|
||||
{
|
||||
OnBeforeRender();
|
||||
}
|
||||
}
|
||||
|
||||
static Vector3 testpos = new Vector3(1.0f, 2.0f, 3.0f);
|
||||
static Quaternion testrot = new Quaternion(0.09853293f, 0.09853293f, 0.09853293f, 0.9853293f);
|
||||
|
||||
|
||||
internal class TestPoseProvider : BasePoseProvider
|
||||
{
|
||||
public PoseDataFlags flags = PoseDataFlags.Position | PoseDataFlags.Rotation;
|
||||
|
||||
public override PoseDataFlags GetPoseFromProvider(out Pose output)
|
||||
{
|
||||
Pose tmp = new Pose();
|
||||
tmp.position = testpos;
|
||||
tmp.rotation = testrot;
|
||||
output = tmp;
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
|
||||
internal static TestTrackedPoseDriverWrapper CreateGameObjectWithTPD()
|
||||
{
|
||||
GameObject go = new GameObject();
|
||||
TestTrackedPoseDriverWrapper tpd = go.AddComponent<TestTrackedPoseDriverWrapper>();
|
||||
return tpd;
|
||||
}
|
||||
|
||||
internal static BasePoseProvider CreatePoseProviderOnTPD(TestTrackedPoseDriverWrapper tpd)
|
||||
{
|
||||
TestPoseProvider tpp = tpd.gameObject.AddComponent<TestPoseProvider>();
|
||||
tpd.poseProviderComponent = tpp;
|
||||
return tpp;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TPDApiSetTest()
|
||||
{
|
||||
TestTrackedPoseDriverWrapper tpd = CreateGameObjectWithTPD();
|
||||
|
||||
bool ret = tpd.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.Head);
|
||||
Assert.That(ret, Is.EqualTo(true));
|
||||
Assert.That(tpd.poseSource, Is.EqualTo(TrackedPoseDriver.TrackedPose.Head));
|
||||
|
||||
ret = tpd.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRDevice, TrackedPoseDriver.TrackedPose.LeftPose);
|
||||
Assert.That(ret, Is.EqualTo(false));
|
||||
Assert.That(tpd.poseSource, Is.EqualTo(TrackedPoseDriver.TrackedPose.Head));
|
||||
|
||||
ret = tpd.SetPoseSource(TrackedPoseDriver.DeviceType.GenericXRController, TrackedPoseDriver.TrackedPose.RightPose);
|
||||
Assert.That(ret, Is.EqualTo(true));
|
||||
Assert.That(tpd.poseSource, Is.EqualTo(TrackedPoseDriver.TrackedPose.RightPose));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TPDPoseProviderTest()
|
||||
{
|
||||
TestTrackedPoseDriverWrapper tpd = CreateGameObjectWithTPD();
|
||||
BasePoseProvider pp = CreatePoseProviderOnTPD(tpd);
|
||||
|
||||
Assert.That(tpd.poseProviderComponent, Is.EqualTo(pp));
|
||||
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
}
|
||||
|
||||
public void Reset(GameObject go)
|
||||
{
|
||||
go.transform.position = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
go.transform.rotation = new Quaternion(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TPDUpdateOptionTest()
|
||||
{
|
||||
TestTrackedPoseDriverWrapper tpd = CreateGameObjectWithTPD();
|
||||
BasePoseProvider pp = CreatePoseProviderOnTPD(tpd);
|
||||
|
||||
Assert.That(tpd.poseProviderComponent, Is.EqualTo(pp));
|
||||
|
||||
// check the update/before render case
|
||||
tpd.updateType = TrackedPoseDriver.UpdateType.BeforeRender;
|
||||
tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition;
|
||||
Reset(tpd.gameObject);
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(testpos));
|
||||
Assert.That(!tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
tpd.FakeOnBeforeRender();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
Reset(tpd.gameObject);
|
||||
|
||||
tpd.updateType = TrackedPoseDriver.UpdateType.Update;
|
||||
tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition;
|
||||
tpd.FakeOnBeforeRender();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(testpos));
|
||||
Assert.That(!tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
// check the rot/pos case
|
||||
tpd.updateType = TrackedPoseDriver.UpdateType.UpdateAndBeforeRender;
|
||||
|
||||
tpd.trackingType = TrackedPoseDriver.TrackingType.PositionOnly;
|
||||
Reset(tpd.gameObject);
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(!tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
tpd.trackingType = TrackedPoseDriver.TrackingType.RotationOnly;
|
||||
Reset(tpd.gameObject);
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TPDPartialUpdateDataTest()
|
||||
{
|
||||
TestTrackedPoseDriverWrapper tpd = CreateGameObjectWithTPD();
|
||||
BasePoseProvider pp = CreatePoseProviderOnTPD(tpd);
|
||||
TestPoseProvider tpp = pp as TestPoseProvider;
|
||||
|
||||
Assert.That(tpd.poseProviderComponent, Is.EqualTo(pp));
|
||||
|
||||
tpp.flags = PoseDataFlags.Position;
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(!tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
Reset(tpd.gameObject);
|
||||
tpp.flags = PoseDataFlags.Rotation;
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.Not.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
|
||||
Reset(tpd.gameObject);
|
||||
tpp.flags = PoseDataFlags.Position | PoseDataFlags.Rotation;
|
||||
tpd.FakeUpdate();
|
||||
Assert.That(tpd.gameObject.transform.position, Is.EqualTo(testpos));
|
||||
Assert.That(tpd.gameObject.transform.rotation.Equals(testrot));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0cb5ab924d5b50c498ffc64879877e86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"name": "UnityEngine.SpatialTracking.Tests",
|
||||
"references": [
|
||||
"UnityEngine.SpatialTracking"
|
||||
],
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ed2122ec3d57864e862de5fb40f7eae
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue