This commit is contained in:
2025-11-13 17:40:28 +08:00
parent 962ab49609
commit 10156da245
5503 changed files with 805282 additions and 0 deletions

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 System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
namespace Unity.XR.PXR
{
public class PXR_ControllerAnimator : MonoBehaviour
{
private Animator controllerAnimator;
public Transform primary2DAxisTran;
public Transform gripTran;
public Transform triggerTran;
public PXR_Input.Controller controller;
private InputDevice currentController;
private Vector2 axis2D = Vector2.zero;
private bool primaryButton;
private bool secondaryButton;
private bool menuButton;
private float grip;
private float trigger;
private Vector3 originalGrip;
private Vector3 originalTrigger;
private Vector3 originalJoystick;
public const string primary = "IsPrimaryDown";
public const string secondary = "IsSecondaryDown";
public const string media = "IsMediaDown";
public const string menu = "IsMenuDown";
void Start()
{
controllerAnimator = GetComponent<Animator>();
currentController = InputDevices.GetDeviceAtXRNode(controller == PXR_Input.Controller.LeftController
? XRNode.LeftHand
: XRNode.RightHand);
originalGrip = gripTran.localEulerAngles;
originalJoystick = primary2DAxisTran.localEulerAngles;
originalTrigger = triggerTran.localEulerAngles;
}
void Update()
{
currentController.TryGetFeatureValue(CommonUsages.primary2DAxis, out axis2D);
currentController.TryGetFeatureValue(CommonUsages.grip, out grip);
currentController.TryGetFeatureValue(CommonUsages.trigger, out trigger);
currentController.TryGetFeatureValue(CommonUsages.primaryButton, out primaryButton);
currentController.TryGetFeatureValue(CommonUsages.secondaryButton, out secondaryButton);
currentController.TryGetFeatureValue(CommonUsages.menuButton, out menuButton);
float x = Mathf.Clamp(axis2D.x * 10f, -10f, 10f);
float z = Mathf.Clamp(axis2D.y * 10f, -10f, 10f);
if (primary2DAxisTran != null)
{
if (controller == PXR_Input.Controller.LeftController)
{
primary2DAxisTran.localEulerAngles = new Vector3(-z, 0, x) + originalJoystick;
}
else
{
primary2DAxisTran.localEulerAngles = new Vector3(-z, 0, -x) + originalJoystick;
}
}
trigger *= -15;
if (triggerTran != null)
triggerTran.localEulerAngles = new Vector3(trigger, 0f, 0f) + originalTrigger;
grip *= 12;
if (gripTran != null)
gripTran.localEulerAngles = new Vector3(0f, grip, 0f) + originalGrip;
if (controllerAnimator != null)
{
controllerAnimator.SetBool(primary, primaryButton);
controllerAnimator.SetBool(secondary, secondaryButton);
if (controller == PXR_Input.Controller.LeftController)
controllerAnimator.SetBool(menu, menuButton);
else if(controller == PXR_Input.Controller.RightController)
controllerAnimator.SetBool(media, menuButton);
}
}
}
}

View File

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

View File

@@ -0,0 +1,78 @@
/*******************************************************************************
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 UnityEngine;
using UnityEngine.XR;
namespace Unity.XR.PXR
{
public class PXR_ControllerG3Animator : MonoBehaviour
{
public Transform triggerTran;
public Transform menuTran;
public Transform touchPadTran;
public PXR_ControllerPower controllerPower;
private bool primaryAxisState = false;
private bool menuButtonState;
private float trigger;
private Vector3 menu;
private Vector3 originTrigger;
private Vector3 touchPadPos;
private InputDevice currentController;
private int handness;
void Start()
{
PXR_Plugin.Controller.UPxr_GetControllerHandness(ref handness);
XRNode hand = handness == 0? XRNode.RightHand : XRNode.LeftHand;
if (controllerPower != null)
{
controllerPower.hand = handness == 0 ? PXR_Input.Controller.RightController : PXR_Input.Controller.LeftController;
}
currentController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
menu = menuTran.localPosition;
originTrigger = triggerTran.localEulerAngles;
touchPadPos = touchPadTran.localPosition;
}
void Update()
{
currentController.TryGetFeatureValue(CommonUsages.primary2DAxisClick, out primaryAxisState);
currentController.TryGetFeatureValue(CommonUsages.menuButton, out menuButtonState);
currentController.TryGetFeatureValue(CommonUsages.trigger, out trigger);
if (triggerTran != null)
{
trigger *= -9.0f;
triggerTran.localEulerAngles = new Vector3(0f, 0f, Mathf.Clamp(trigger, -9f, 0f)) + originTrigger;
}
if (touchPadTran != null)
{
if (primaryAxisState)
touchPadTran.localPosition = touchPadPos + new Vector3(0f, -0.0005f, 0f);
else
touchPadTran.localPosition = touchPadPos;
}
if (menuButtonState)
menuTran.localPosition = new Vector3(0f, -0.00021f, 0f) + menu;
else
menuTran.localPosition = menu;
}
}
}

View File

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

View File

@@ -0,0 +1,339 @@
/*******************************************************************************
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;
using System.IO;
using LitJson;
using UnityEngine;
using UnityEngine.Rendering;
namespace Unity.XR.PXR
{
public class PXR_ControllerLoader : MonoBehaviour
{
[SerializeField]
private PXR_Input.Controller hand;
public GameObject neo3L;
public GameObject neo3R;
public GameObject PICO_4L;
public GameObject PICO_4R;
public GameObject G3;
public GameObject PICO_4U_L;
public GameObject PICO_4U_R;
public Material legacyMaterial;
private Texture2D modelTexture2D;
private int controllerType = -1;
private JsonData curControllerData = null;
private int systemOrLocal = 0;
private bool loadModelSuccess = false;
private string modelName = "";
private string texFormat = "";
private string prePath = "";
private string modelFilePath = "/system/media/pxrRes/controller/";
private bool leftControllerState = false;
private bool rightControllerState = false;
private enum ControllerSimulationType
{
None,
Neo3,
PICO4,
G3,
PICO4U
}
#if UNITY_EDITOR
[SerializeField]
private ControllerSimulationType controllerSimulation = ControllerSimulationType.None;
#endif
public PXR_ControllerLoader(PXR_Input.Controller controller)
{
hand = controller;
}
void Awake()
{
#if UNITY_EDITOR
switch (controllerSimulation)
{
case ControllerSimulationType.Neo3:
{
Instantiate(hand == PXR_Input.Controller.LeftController ? neo3L : neo3R, transform, false);
break;
}
case ControllerSimulationType.PICO4:
{
Instantiate(hand == PXR_Input.Controller.LeftController ? PICO_4L : PICO_4R, transform, false);
break;
}
case ControllerSimulationType.G3:
{
Instantiate(G3, transform, false);
break;
}
case ControllerSimulationType.PICO4U:
{
Instantiate(hand == PXR_Input.Controller.LeftController ? PICO_4U_L : PICO_4U_R, transform, false);
break;
}
}
#endif
}
void Start()
{
controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
#if UNITY_ANDROID && !UNITY_EDITOR
LoadResFromJson();
#endif
leftControllerState = PXR_Plugin.Controller.UPxr_IsControllerConnected(PXR_Input.Controller.LeftController);
rightControllerState = PXR_Plugin.Controller.UPxr_IsControllerConnected(PXR_Input.Controller.RightController);
if (hand == PXR_Input.Controller.LeftController)
RefreshController(PXR_Input.Controller.LeftController);
if (hand == PXR_Input.Controller.RightController)
RefreshController(PXR_Input.Controller.RightController);
}
void Update()
{
if (hand == PXR_Input.Controller.LeftController)
{
if (PXR_Plugin.Controller.UPxr_IsControllerConnected(PXR_Input.Controller.LeftController))
{
if (!leftControllerState)
{
controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
RefreshController(PXR_Input.Controller.LeftController);
leftControllerState = true;
}
}
else
{
if (leftControllerState)
{
DestroyLocalController();
leftControllerState = false;
}
}
}
if (hand == PXR_Input.Controller.RightController)
{
if (PXR_Plugin.Controller.UPxr_IsControllerConnected(PXR_Input.Controller.RightController))
{
if (!rightControllerState)
{
controllerType = PXR_Plugin.Controller.UPxr_GetControllerType();
RefreshController(PXR_Input.Controller.RightController);
rightControllerState = true;
}
}
else
{
if (rightControllerState)
{
DestroyLocalController();
rightControllerState = false;
}
}
}
}
private void RefreshController(PXR_Input.Controller hand)
{
if (PXR_Plugin.Controller.UPxr_IsControllerConnected(hand))
{
if (systemOrLocal == 0)
{
LoadControllerFromPrefab(hand);
if (!loadModelSuccess)
{
LoadControllerFromSystem((int)hand);
}
}
else
{
var isControllerExist = false;
foreach (Transform t in transform)
{
if (t.name == modelName)
{
isControllerExist = true;
}
}
if (!isControllerExist)
{
LoadControllerFromSystem((int)hand);
if (!loadModelSuccess)
{
LoadControllerFromPrefab(hand);
}
}
else
{
var currentController = transform.Find(modelName);
currentController.gameObject.SetActive(true);
}
}
}
}
private void LoadResFromJson()
{
string json = PXR_Plugin.System.UPxr_GetObjectOrArray("config.controller", (int)ResUtilsType.TypeObjectArray);
if (json != null)
{
JsonData jdata = JsonMapper.ToObject(json);
if (controllerType > 0)
{
if (jdata.Count >= controllerType)
{
curControllerData = jdata[controllerType - 1];
if (curControllerData != null)
{
modelFilePath = (string)curControllerData["base_path"];
modelName = (string)curControllerData["model_name"] + "_sys";
}
}
}
}
else
{
Debug.LogError("PXRLog LoadJsonFromSystem Error");
}
}
private void DestroyLocalController()
{
foreach (Transform t in transform)
{
Destroy(modelTexture2D);
Destroy(t.gameObject);
Resources.UnloadUnusedAssets();
loadModelSuccess = false;
}
}
private void LoadControllerFromPrefab(PXR_Input.Controller hand)
{
#if UNITY_6000_0_OR_NEWER && !URP
if (GraphicsDeviceType.OpenGLES3 == SystemInfo.graphicsDeviceType && QualitySettings.activeColorSpace == ColorSpace.Linear
&& PXR_Settings.GetSettings().stereoRenderingModeAndroid == PXR_Settings.StereoRenderingModeAndroid.Multiview)
{
loadModelSuccess = false;
return;
}
#endif
switch (controllerType)
{
case 5:
Instantiate(hand == PXR_Input.Controller.LeftController ? neo3L : neo3R, transform, false);
loadModelSuccess = true;
break;
case 6:
Instantiate(hand == PXR_Input.Controller.LeftController ? PICO_4L : PICO_4R, transform, false);
loadModelSuccess = true;
break;
case 7:
Instantiate(G3, transform, false);
loadModelSuccess = true;
break;
case 8:
Instantiate(hand == PXR_Input.Controller.LeftController ? PICO_4U_L : PICO_4U_R, transform, false);
loadModelSuccess = true;
break;
default:
loadModelSuccess = false;
break;
}
}
private void LoadControllerFromSystem(int id)
{
var sysControllerName = controllerType.ToString() + id.ToString() + ".obj";
var fullFilePath = modelFilePath + sysControllerName;
if (!File.Exists(fullFilePath))
{
Debug.Log("PXRLog Load Obj From Prefab");
}
else
{
GameObject go = new GameObject
{
name = modelName
};
MeshFilter meshFilter = go.AddComponent<MeshFilter>();
meshFilter.mesh = PXR_ObjImporter.Instance.ImportFile(fullFilePath);
go.transform.SetParent(transform);
go.transform.localPosition = Vector3.zero;
MeshRenderer meshRenderer = go.AddComponent<MeshRenderer>();
meshRenderer.material = legacyMaterial;
LoadTexture(meshRenderer, controllerType.ToString() + id.ToString(), false);
go.transform.localRotation = Quaternion.Euler(new Vector3(0, 180, 0));
go.transform.localScale = new Vector3(-0.01f, 0.01f, 0.01f);
loadModelSuccess = true;
}
}
private void LoadTexture(MeshRenderer mr,string controllerName, bool fromRes)
{
if (fromRes)
{
texFormat = "";
prePath = controllerName;
}
else
{
texFormat = "." + (string)curControllerData["tex_format"];
prePath = modelFilePath + controllerName;
}
var texturePath = prePath + "_idle" + texFormat;
mr.material.SetTexture("_MainTex", LoadOneTexture(texturePath, fromRes));
}
private Texture2D LoadOneTexture(string filepath, bool fromRes)
{
if (fromRes)
{
return Resources.Load<Texture2D>(filepath);
}
else
{
int tW = (int)curControllerData["tex_width"];
int tH = (int)curControllerData["tex_height"];
modelTexture2D = new Texture2D(tW, tH);
modelTexture2D.LoadImage(ReadPNG(filepath));
return modelTexture2D;
}
}
private byte[] ReadPNG(string path)
{
FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
fileStream.Seek(0, SeekOrigin.Begin);
byte[] binary = new byte[fileStream.Length];
fileStream.Read(binary, 0, (int)fileStream.Length);
fileStream.Close();
fileStream.Dispose();
return binary;
}
}
}

View File

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

View File

@@ -0,0 +1,128 @@
/*******************************************************************************
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;
using System.Collections.Generic;
using Unity.XR.PXR;
using UnityEngine;
using UnityEngine.XR;
public class PXR_ControllerPower : MonoBehaviour
{
[SerializeField]
private Texture power1;
[SerializeField]
private Texture power2;
[SerializeField]
private Texture power3;
[SerializeField]
private Texture power4;
[SerializeField]
private Texture power5;
private Material powerMaterial;
private float interval = 2f;
public PXR_Input.Controller hand;
// Start is called before the first frame update
void Awake()
{
if (GetComponent<MeshRenderer>() != null)
{
powerMaterial = GetComponent<MeshRenderer>().material;
}
else
{
powerMaterial = GetComponent<SkinnedMeshRenderer>().material;
}
}
void OnEnable()
{
RefreshPower();
}
private void RefreshPower()
{
var curBattery = 0f;
switch (hand)
{
case PXR_Input.Controller.LeftController:
{
InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).TryGetFeatureValue(CommonUsages.batteryLevel, out curBattery);
}
break;
case PXR_Input.Controller.RightController:
{
InputDevices.GetDeviceAtXRNode(XRNode.RightHand).TryGetFeatureValue(CommonUsages.batteryLevel, out curBattery);
}
break;
}
switch ((int)curBattery)
{
case 1:
{
powerMaterial.SetTexture("_MainTex", power1);
powerMaterial.SetTexture("_EmissionMap", power1);
}
break;
case 2:
{
powerMaterial.SetTexture("_MainTex", power2);
powerMaterial.SetTexture("_EmissionMap", power2);
}
break;
case 3:
{
powerMaterial.SetTexture("_MainTex", power3);
powerMaterial.SetTexture("_EmissionMap", power3);
}
break;
case 4:
{
powerMaterial.SetTexture("_MainTex", power4);
powerMaterial.SetTexture("_EmissionMap", power4);
}
break;
case 5:
{
powerMaterial.SetTexture("_MainTex", power5);
powerMaterial.SetTexture("_EmissionMap", power5);
}
break;
default:
{
powerMaterial.SetTexture("_MainTex", power1);
powerMaterial.SetTexture("_EmissionMap", power1);
}
break;
}
}
// Update is called once per frame
void Update()
{
interval -= Time.deltaTime;
if (interval > 0)
return;
interval = 2f;
RefreshPower();
}
}

View File

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

View File

@@ -0,0 +1,307 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR;
using Unity.XR.PXR.Input;
namespace Unity.XR.PXR
{
public class PXR_ControllerWithHandAnimator : MonoBehaviour
{
public PXR_Input.Controller controller;
private Animator mAnimator;
private InputDevice mInputDevice;
private PXR_Controller mXRController;
private readonly float animation_time = 0.05f;
private float per_animation_step = 0.1f;
//trigger;
private readonly string trigger_Touch_LayerName = "trigger_touch";
private int trigger_Touch_LayerIndex;
private readonly string trigger_Value_LayerName = "trigger_press";
private int trigger_Value_LayerIndex;
private bool trigger_Touch;
private float trigger_Value;
private float trigger_Touch_Weight = 0f;
// A/X;
private readonly string X_A_Touch_LayerName = "X_A_touch";
private int X_A_Touch_LayerIndex;
private readonly string X_A_Press_LayerName = "X_A_press";
private int X_A_Press_LayerIndex;
private bool X_A_Press;
private bool X_A_Touch;
private float X_A_Touch_Weight = 0f;
// B/Y;
private readonly string Y_B_Touch_LayerName = "Y_B_touch";
private int Y_B_Touch_LayerIndex;
private readonly string Y_B_Press_LayerName = "Y_B_press";
private int Y_B_Press_LayerIndex;
private bool Y_B_Press;
private bool Y_B_Touch;
private float Y_B_Touch_Weight = 0f;
//Y/B or X/A
private readonly string X_A_Y_B_Press_LayerName = "X_A_Y_B_press";
private int X_A_Y_B_Press_LayerIndex;
//Y/B or X/A
private readonly string X_A_Y_B_Touch_LayerName = "X_A_Y_B_touch";
private int X_A_Y_B_Touch_LayerIndex;
private float X_A_Y_B_Touch_Weight = 0f;
//grip;
private readonly string grip_Value_LayerName = "grip_press";
private int grip_Value_LayerIndex;
private float grip_Value;
//rocker
private readonly string primary2DAxis_Touch_LayerName = "axis_touch";
private int primary2DAxis_Touch_LayerIndex;
private readonly string primary2DAxis_Vertical = "axis_vertical";
private int primary2DAxis_Vertical_Index;
private readonly string primary2DAxis_Horizontal = "axis_horizontal";
private int primary2DAxis_Horizontal_Index;
private Vector2 primary2DAxisVec2;
private bool primary2DAxis_Touch;
private float primary2DAxis_Touch_Weight = 0f;
//print screen
private readonly string menu_Press_LayerName = "thumbMenu";
private int menu_Press_LayerIndex;
private bool menu_Press;
private float menu_Press_Weight;
//home
private readonly string pico_Press_LayerName = "thumbPico";
private int pico_Press_LayerIndex;
private bool pico_Press;
private float pico_Press_Weight;
//thumb rest
private readonly string thumbstick_Touch_LayerName = "thumbstick_touch";
private int thumbstick_Touch_LayerIndex;
private bool thumbstick_Touch;
private float thumbstick_Touch_Weight;
// Start is called before the first frame update
void Start()
{
per_animation_step = 1.0f / animation_time;
mAnimator = GetComponent<Animator>();
mInputDevice = InputDevices.GetDeviceAtXRNode(controller == PXR_Input.Controller.LeftController ? XRNode.LeftHand : XRNode.RightHand);
mXRController = (controller == PXR_Input.Controller.LeftController ? PXR_Controller.leftHand : PXR_Controller.rightHand) as PXR_Controller;
if (mAnimator != null)
{
trigger_Touch_LayerIndex = mAnimator.GetLayerIndex(trigger_Touch_LayerName);
trigger_Value_LayerIndex = mAnimator.GetLayerIndex(trigger_Value_LayerName);
grip_Value_LayerIndex = mAnimator.GetLayerIndex(grip_Value_LayerName);
X_A_Touch_LayerIndex = mAnimator.GetLayerIndex(X_A_Touch_LayerName);
X_A_Press_LayerIndex = mAnimator.GetLayerIndex(X_A_Press_LayerName);
Y_B_Touch_LayerIndex = mAnimator.GetLayerIndex(Y_B_Touch_LayerName);
Y_B_Press_LayerIndex = mAnimator.GetLayerIndex(Y_B_Press_LayerName);
X_A_Y_B_Press_LayerIndex = mAnimator.GetLayerIndex(X_A_Y_B_Press_LayerName);
X_A_Y_B_Touch_LayerIndex = mAnimator.GetLayerIndex(X_A_Y_B_Touch_LayerName);
primary2DAxis_Touch_LayerIndex = mAnimator.GetLayerIndex(primary2DAxis_Touch_LayerName);
thumbstick_Touch_LayerIndex = mAnimator.GetLayerIndex(thumbstick_Touch_LayerName);
primary2DAxis_Vertical_Index = Animator.StringToHash(primary2DAxis_Vertical);
primary2DAxis_Horizontal_Index = Animator.StringToHash(primary2DAxis_Horizontal);
}
else
{
Debug.Log("Animator is null");
}
}
// Update is called once per frame
void Update()
{
mInputDevice.TryGetFeatureValue(CommonUsages.primaryButton, out X_A_Press);
mInputDevice.TryGetFeatureValue(CommonUsages.primaryTouch, out X_A_Touch);
mInputDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out Y_B_Press);
mInputDevice.TryGetFeatureValue(CommonUsages.secondaryTouch, out Y_B_Touch);
mInputDevice.TryGetFeatureValue(CommonUsages.trigger, out trigger_Value);
mInputDevice.TryGetFeatureValue(PXR_Usages.triggerTouch, out trigger_Touch);
mInputDevice.TryGetFeatureValue(CommonUsages.grip, out grip_Value);
mInputDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out primary2DAxisVec2);
mInputDevice.TryGetFeatureValue(CommonUsages.primary2DAxisTouch, out primary2DAxis_Touch);
if (!primary2DAxis_Touch)
{
if (primary2DAxisVec2 != Vector2.zero)
primary2DAxis_Touch = true;
}
mInputDevice.TryGetFeatureValue(CommonUsages.menuButton, out menu_Press);
if (Y_B_Touch && primary2DAxisVec2 == Vector2.zero)
{
if (Y_B_Press)
{
Y_B_Touch_Weight = 1.0f;
mAnimator.SetLayerWeight(Y_B_Touch_LayerIndex, Y_B_Touch_Weight);
mAnimator.SetLayerWeight(Y_B_Press_LayerIndex, 1.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Press_LayerIndex, X_A_Press ? 1.0f : 0.0f);
}
else
{
if (X_A_Touch)
{
if (X_A_Press)
{
X_A_Touch_Weight = 1.0f;
mAnimator.SetLayerWeight(X_A_Touch_LayerIndex, X_A_Touch_Weight);
}
else
{
if (X_A_Y_B_Touch_Weight < 0.9999f)
{
X_A_Y_B_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(X_A_Y_B_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Touch_LayerIndex, X_A_Y_B_Touch_Weight);
}
}
mAnimator.SetLayerWeight(X_A_Press_LayerIndex, X_A_Press ? 1.0f : 0f);
}
else
{
if (Y_B_Touch_Weight < 0.9999f)
{
Y_B_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(Y_B_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(Y_B_Touch_LayerIndex, Y_B_Touch_Weight);
}
if (X_A_Y_B_Touch_Weight > 0.0001f)
{
X_A_Y_B_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(X_A_Y_B_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Touch_LayerIndex, X_A_Y_B_Touch_Weight);
}
if (X_A_Touch_Weight > 0.0001f)
{
X_A_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(X_A_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(X_A_Touch_LayerIndex, X_A_Touch_Weight);
}
}
mAnimator.SetLayerWeight(Y_B_Press_LayerIndex, 0.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Press_LayerIndex, 0.0f);
}
}
else
{
if (Y_B_Touch_Weight > 0.0001f)
{
Y_B_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(Y_B_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(Y_B_Touch_LayerIndex, Y_B_Touch_Weight);
mAnimator.SetLayerWeight(Y_B_Press_LayerIndex, 0.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Press_LayerIndex, 0.0f);
}
if (X_A_Y_B_Touch_Weight > 0.0001f)
{
X_A_Y_B_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(X_A_Y_B_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Touch_LayerIndex, X_A_Y_B_Touch_Weight);
mAnimator.SetLayerWeight(Y_B_Press_LayerIndex, 0.0f);
mAnimator.SetLayerWeight(X_A_Y_B_Press_LayerIndex, 0.0f);
}
if (X_A_Touch && primary2DAxisVec2 == Vector2.zero)
{
if (X_A_Press)
{
X_A_Touch_Weight = 1.0f;
mAnimator.SetLayerWeight(X_A_Touch_LayerIndex, X_A_Touch_Weight);
}
else
{
if (X_A_Touch_Weight < 0.9999f)
{
X_A_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(X_A_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(X_A_Touch_LayerIndex, X_A_Touch_Weight);
}
}
mAnimator.SetLayerWeight(X_A_Press_LayerIndex, X_A_Press ? 1.0f : 0f);
mAnimator.SetFloat(primary2DAxis_Vertical_Index, 0f);
mAnimator.SetFloat(primary2DAxis_Horizontal_Index, 0f);
}
else
{
if (X_A_Touch_Weight > 0.0001f)
{
X_A_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(X_A_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(X_A_Touch_LayerIndex, X_A_Touch_Weight);
mAnimator.SetLayerWeight(X_A_Press_LayerIndex, 0f);
}
if (primary2DAxis_Touch)
{
if (primary2DAxis_Touch_Weight < 0.9999f)
{
primary2DAxis_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(primary2DAxis_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(primary2DAxis_Touch_LayerIndex, primary2DAxis_Touch_Weight);
}
mAnimator.SetFloat(primary2DAxis_Vertical_Index, primary2DAxisVec2.y);
mAnimator.SetFloat(primary2DAxis_Horizontal_Index, primary2DAxisVec2.x);
}
else
{
if (primary2DAxis_Touch_Weight > 0.0001f)
{
primary2DAxis_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(primary2DAxis_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(primary2DAxis_Touch_LayerIndex, primary2DAxis_Touch_Weight);
mAnimator.SetFloat(primary2DAxis_Vertical_Index, 0f);
mAnimator.SetFloat(primary2DAxis_Horizontal_Index, 0f);
}
if (thumbstick_Touch)
{
if (thumbstick_Touch_Weight < 0.9999f)
{
thumbstick_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(thumbstick_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(thumbstick_Touch_LayerIndex, thumbstick_Touch_Weight);
}
}
else
{
if (thumbstick_Touch_Weight > 0.0001f)
{
thumbstick_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(thumbstick_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(thumbstick_Touch_LayerIndex, thumbstick_Touch_Weight);
}
}
}
}
}
if (trigger_Touch)
{
if (trigger_Touch_Weight < 0.9999f)
{
trigger_Touch_Weight = Mathf.Min(mAnimator.GetLayerWeight(trigger_Touch_LayerIndex) + Time.deltaTime * per_animation_step, 1.0f);
mAnimator.SetLayerWeight(trigger_Touch_LayerIndex, trigger_Touch_Weight);
}
mAnimator.SetLayerWeight(trigger_Value_LayerIndex, trigger_Value);
}
else
{
if (trigger_Touch_Weight > 0.0001f)
{
trigger_Touch_Weight = Mathf.Max(mAnimator.GetLayerWeight(trigger_Touch_LayerIndex) - Time.deltaTime * per_animation_step, 0.0f);
mAnimator.SetLayerWeight(trigger_Touch_LayerIndex, trigger_Touch_Weight);
}
}
mAnimator.SetLayerWeight(grip_Value_LayerIndex, grip_Value);
}
}
}

View File

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