Initialer Upload neues Unity-Projekt
This commit is contained in:
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
public class Controller :
|
||||
DataModifier<ControllerDataAsset>,
|
||||
IController
|
||||
{
|
||||
public Handedness Handedness => GetData().Config.Handedness;
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
var currentData = GetData();
|
||||
return currentData.IsDataValid && currentData.IsConnected;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPoseValid
|
||||
{
|
||||
get
|
||||
{
|
||||
var currentData = GetData();
|
||||
return currentData.IsDataValid &&
|
||||
currentData.RootPoseOrigin != PoseOrigin.None;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPointerPoseValid
|
||||
{
|
||||
get
|
||||
{
|
||||
var currentData = GetData();
|
||||
return currentData.IsDataValid &&
|
||||
currentData.PointerPoseOrigin != PoseOrigin.None;
|
||||
}
|
||||
}
|
||||
|
||||
public event Action WhenUpdated = delegate { };
|
||||
|
||||
private ITrackingToWorldTransformer TrackingToWorldTransformer =>
|
||||
GetData().Config.TrackingToWorldTransformer;
|
||||
|
||||
public float Scale => TrackingToWorldTransformer != null
|
||||
? TrackingToWorldTransformer.Transform.lossyScale.x
|
||||
: 1;
|
||||
|
||||
public bool IsButtonUsageAnyActive(ControllerButtonUsage buttonUsage)
|
||||
{
|
||||
var currentData = GetData();
|
||||
return
|
||||
currentData.IsDataValid &&
|
||||
(buttonUsage & currentData.ButtonUsageMask) != 0;
|
||||
}
|
||||
|
||||
public bool IsButtonUsageAllActive(ControllerButtonUsage buttonUsage)
|
||||
{
|
||||
var currentData = GetData();
|
||||
return currentData.IsDataValid &&
|
||||
(buttonUsage & currentData.ButtonUsageMask) == buttonUsage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the current controller pose, in world space.
|
||||
/// </summary>
|
||||
/// <param name="pose">Set to current pose if `IsPoseValid`; Pose.identity otherwise</param>
|
||||
/// <returns>Value of `IsPoseValid`</returns>
|
||||
public bool TryGetPose(out Pose pose)
|
||||
{
|
||||
if (!IsPoseValid)
|
||||
{
|
||||
pose = Pose.identity;
|
||||
return false;
|
||||
}
|
||||
|
||||
pose = GetData().Config.TrackingToWorldTransformer.ToWorldPose(GetData().RootPose);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the current controller pointer pose, in world space.
|
||||
/// </summary>
|
||||
/// <param name="pose">Set to current pose if `IsPoseValid`; Pose.identity otherwise</param>
|
||||
/// <returns>Value of `IsPoseValid`</returns>
|
||||
public bool TryGetPointerPose(out Pose pose)
|
||||
{
|
||||
if (!IsPointerPoseValid)
|
||||
{
|
||||
pose = Pose.identity;
|
||||
return false;
|
||||
}
|
||||
|
||||
pose = GetData().Config.TrackingToWorldTransformer.ToWorldPose(GetData().PointerPose);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void MarkInputDataRequiresUpdate()
|
||||
{
|
||||
base.MarkInputDataRequiresUpdate();
|
||||
|
||||
if (Started)
|
||||
{
|
||||
WhenUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Apply(ControllerDataAsset data)
|
||||
{
|
||||
// Default implementation does nothing, to allow instantiation of this modifier directly
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ae60cfa43388e449a7518f36418f81c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Interaction.Input {
|
||||
public class ControllerButtonUsageActiveState : MonoBehaviour, IActiveState
|
||||
{
|
||||
[SerializeField, Interface(typeof(IController))]
|
||||
UnityEngine.Object _controller;
|
||||
|
||||
private IController Controller;
|
||||
|
||||
[SerializeField]
|
||||
private ControllerButtonUsage _controllerButtonUsage;
|
||||
|
||||
public bool Active => Controller.IsButtonUsageAnyActive(_controllerButtonUsage);
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Controller = _controller as IController;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.AssertField(Controller, nameof(Controller));
|
||||
}
|
||||
|
||||
#region Inject
|
||||
|
||||
public void InjectAllControllerButtonUsageActiveState(IController controller,
|
||||
ControllerButtonUsage controllerButtonUsage)
|
||||
{
|
||||
InjectController(controller);
|
||||
InjectControllerButtonUsage(controllerButtonUsage);
|
||||
}
|
||||
|
||||
public void InjectController(IController controller)
|
||||
{
|
||||
_controller = controller as UnityEngine.Object;
|
||||
Controller = controller;
|
||||
}
|
||||
|
||||
public void InjectControllerButtonUsage(ControllerButtonUsage controllerButtonUsage)
|
||||
{
|
||||
_controllerButtonUsage = controllerButtonUsage;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad374a43a946e7d4496818c6b194809f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
[Serializable]
|
||||
public class ControllerDataAsset : ICopyFrom<ControllerDataAsset>
|
||||
{
|
||||
public bool IsDataValid;
|
||||
public bool IsConnected;
|
||||
public bool IsTracked;
|
||||
public ControllerButtonUsage ButtonUsageMask;
|
||||
public Pose RootPose;
|
||||
public PoseOrigin RootPoseOrigin;
|
||||
public Pose PointerPose;
|
||||
public PoseOrigin PointerPoseOrigin;
|
||||
public ControllerDataSourceConfig Config;
|
||||
|
||||
public void CopyFrom(ControllerDataAsset source)
|
||||
{
|
||||
IsDataValid = source.IsDataValid;
|
||||
IsConnected = source.IsConnected;
|
||||
IsTracked = source.IsTracked;
|
||||
Config = source.Config;
|
||||
CopyPosesAndStateFrom(source);
|
||||
}
|
||||
|
||||
public void CopyPosesAndStateFrom(ControllerDataAsset source)
|
||||
{
|
||||
ButtonUsageMask = source.ButtonUsageMask;
|
||||
RootPose = source.RootPose;
|
||||
RootPoseOrigin = source.RootPoseOrigin;
|
||||
PointerPose = source.PointerPose;
|
||||
PointerPoseOrigin = source.PointerPoseOrigin;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe4ca944e80140841985b0f273793641
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// A set of constants that are passed to each child of a Controller modifier tree from the root DataSource.
|
||||
/// </summary>
|
||||
public class ControllerDataSourceConfig
|
||||
{
|
||||
public Handedness Handedness { get; set; }
|
||||
public ITrackingToWorldTransformer TrackingToWorldTransformer { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1675de914d203a4a910d701ade05ce3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
// Enum containing all values of Unity.XR.CommonUsage.
|
||||
[Flags]
|
||||
public enum ControllerButtonUsage
|
||||
{
|
||||
None = 0,
|
||||
PrimaryButton = 1 << 0,
|
||||
PrimaryTouch = 1 << 1,
|
||||
SecondaryButton = 1 << 2,
|
||||
SecondaryTouch = 1 << 3,
|
||||
GripButton = 1 << 4,
|
||||
TriggerButton = 1 << 5,
|
||||
MenuButton = 1 << 6,
|
||||
Primary2DAxisClick = 1 << 7,
|
||||
Primary2DAxisTouch = 1 << 8,
|
||||
Thumbrest = 1 << 9,
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8489868b0a7582e43890f869877224e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
/// <summary>
|
||||
/// ControllerRef is a utility component that delegates all of its IController implementation
|
||||
/// to the provided Controller object.
|
||||
/// </summary>
|
||||
public class ControllerRef : MonoBehaviour, IController, IActiveState
|
||||
{
|
||||
[SerializeField, Interface(typeof(IController))]
|
||||
private UnityEngine.Object _controller;
|
||||
private IController Controller;
|
||||
|
||||
protected virtual void Awake()
|
||||
{
|
||||
Controller = _controller as IController;
|
||||
}
|
||||
|
||||
protected virtual void Start()
|
||||
{
|
||||
this.AssertField(Controller, nameof(Controller));
|
||||
}
|
||||
|
||||
public Handedness Handedness => Controller.Handedness;
|
||||
|
||||
public bool IsConnected => Controller.IsConnected;
|
||||
|
||||
public bool IsPoseValid => Controller.IsPoseValid;
|
||||
|
||||
public event Action WhenUpdated
|
||||
{
|
||||
add => Controller.WhenUpdated += value;
|
||||
remove => Controller.WhenUpdated -= value;
|
||||
}
|
||||
|
||||
public bool Active => IsConnected;
|
||||
|
||||
public bool TryGetPose(out Pose pose)
|
||||
{
|
||||
return Controller.TryGetPose(out pose);
|
||||
}
|
||||
|
||||
public bool TryGetPointerPose(out Pose pose)
|
||||
{
|
||||
return Controller.TryGetPointerPose(out pose);
|
||||
}
|
||||
|
||||
public float Scale => Controller.Scale;
|
||||
|
||||
public bool IsButtonUsageAnyActive(ControllerButtonUsage buttonUsage)
|
||||
{
|
||||
return Controller.IsButtonUsageAnyActive(buttonUsage);
|
||||
}
|
||||
|
||||
public bool IsButtonUsageAllActive(ControllerButtonUsage buttonUsage)
|
||||
{
|
||||
return Controller.IsButtonUsageAllActive(buttonUsage);
|
||||
}
|
||||
|
||||
#region Inject
|
||||
public void InjectAllControllerRef(IController controller)
|
||||
{
|
||||
InjectController(controller);
|
||||
}
|
||||
|
||||
public void InjectController(IController controller)
|
||||
{
|
||||
_controller = controller as UnityEngine.Object;
|
||||
Controller = controller;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3673df66324d8f34d9433049c54de631
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
public interface IController
|
||||
{
|
||||
Handedness Handedness { get; }
|
||||
bool IsConnected { get; }
|
||||
bool IsPoseValid { get; }
|
||||
bool TryGetPose(out Pose pose);
|
||||
bool TryGetPointerPose(out Pose pose);
|
||||
float Scale { get; }
|
||||
bool IsButtonUsageAnyActive(ControllerButtonUsage buttonUsage);
|
||||
bool IsButtonUsageAllActive(ControllerButtonUsage buttonUsage);
|
||||
event Action WhenUpdated;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77db11dffd48abd4cb96a6076a2a2545
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Licensed under the Oculus SDK License Agreement (the "License");
|
||||
* you may not use the Oculus SDK except in compliance with the License,
|
||||
* which is provided at the time of installation or download, or which
|
||||
* otherwise accompanies this software in either electronic or hard copy form.
|
||||
*
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://developer.oculus.com/licenses/oculussdk/
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, the Oculus SDK
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Oculus.Interaction.Input
|
||||
{
|
||||
public interface IControllerDataModifier
|
||||
{
|
||||
void Apply(ControllerDataAsset controllerDataAsset, Handedness handedness);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b392af6b92984f2887f80975b07141ba
|
||||
timeCreated: 1629344165
|
||||
Reference in New Issue
Block a user