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,8 @@
fileFormatVersion: 2
guid: db96a9bfa8f934f8f8ca1cc2c403131c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
/*******************************************************************************
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.
*******************************************************************************/
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public interface IPXR_PanelManager
{
public void Init();
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 22ec8844704ed4d4b87cb33d0962fcc4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c33f4710ca73400aa4ead29cfe05d8c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,125 @@
/*******************************************************************************
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;
using System;
// using UnityEngine.InputSystem.XR;
using UnityEngine.XR.Interaction.Toolkit;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_DeviceManager : MonoBehaviour
{
public static PXR_DeviceManager Instance { get; private set; }
private InputDevice rightHandDevice;
private InputDevice leftHandDevice;
private XRController rightHandController;
private XRController leftHandController;
public Transform RightHand => rightHandController.transform;
public Transform LeftHand => leftHandController.transform;
public Action OnAButtonPress;
public Action OnBButtonPress;
public Action OnXButtonPress;
public Action OnYButtonPress;
public Action OnAButtonRelease;
public Action OnBButtonRelease;
public Action OnXButtonRelease;
public Action OnYButtonRelease;
public Action OnLeftGripButtonPress;
public Action OnLeftTriggerButtonPress;
public Action OnRightGripButtonPress;
public Action OnRightTriggerButtonPress;
public Action OnLeftGripButtonRelease;
public Action OnLeftTriggerButtonRelease;
public Action OnRightGripButtonRelease;
public Action OnRightTriggerButtonRelease;
private bool previousRightPrimaryButtonPress;
private bool previousLeftPrimaryButtonPress;
private bool previousRightSecondaryButtonPress;
private bool previousLeftSecondaryButtonPress;
private bool previousRightGripButtonPress;
private bool previousLeftGripButtonPress;
private bool previousRightTriggerButtonPress;
private bool previousLeftTriggerButtonPress;
private void Awake()
{
if (Instance != null)
{
Debug.LogError($"The singleton has multiple instances");
}
else
{
Destroy(Instance);
}
Instance = this;
}
void Start()
{
leftHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
rightHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
XRController[] xrControllers = FindObjectsOfType<XRController>();
foreach (XRController controller in xrControllers){
if (controller.controllerNode == XRNode.LeftHand){
leftHandController = controller;
}
if (controller.controllerNode == XRNode.RightHand){
rightHandController = controller;
}
}
}
public void ToggleRightController(bool state){
rightHandController.modelParent.gameObject.SetActive(state);
}
private void ButtonHandler(bool currentState,ref bool previousState,in Action OnPressed,in Action OnReleased)
{
if (currentState && !previousState)
{
OnPressed?.Invoke();
}
if (!currentState && previousState)
{
OnReleased?.Invoke();
}
previousState = currentState;
}
void Update()
{
rightHandDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool isRightPrimaryButtonPress);
ButtonHandler(isRightPrimaryButtonPress,ref previousRightPrimaryButtonPress, OnAButtonPress, OnAButtonRelease);
rightHandDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out bool isRightSecondaryButtonPress);
ButtonHandler(isRightSecondaryButtonPress,ref previousRightSecondaryButtonPress, OnBButtonPress, OnBButtonRelease);
rightHandDevice.TryGetFeatureValue(CommonUsages.gripButton, out bool isRightGripButtonPress);
ButtonHandler(isRightGripButtonPress,ref previousRightGripButtonPress, OnRightGripButtonPress, OnRightGripButtonRelease);
rightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool isRightTriggerButtonPress);
ButtonHandler(isRightTriggerButtonPress,ref previousRightTriggerButtonPress, OnRightTriggerButtonPress, OnRightTriggerButtonRelease);
leftHandDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool isLeftPrimaryButtonPress);
ButtonHandler(isLeftPrimaryButtonPress,ref previousLeftPrimaryButtonPress, OnXButtonPress, OnXButtonRelease);
leftHandDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out bool isLeftSecondaryButtonPress);
ButtonHandler(isLeftSecondaryButtonPress,ref previousLeftSecondaryButtonPress, OnYButtonPress, OnYButtonRelease);
leftHandDevice.TryGetFeatureValue(CommonUsages.gripButton, out bool isLeftGripButtonPress);
ButtonHandler(isLeftGripButtonPress,ref previousLeftGripButtonPress, OnLeftGripButtonPress, OnLeftGripButtonRelease);
leftHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool isLeftTriggerButtonPress);
ButtonHandler(isLeftTriggerButtonPress,ref previousLeftTriggerButtonPress, OnLeftTriggerButtonPress, OnLeftTriggerButtonRelease);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,42 @@
/*******************************************************************************
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 UnityEditor;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_PicoDebuggerManager : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void OnBeforeSceneLoadRuntimeMethod()
{
var config = Resources.Load<PXR_PicoDebuggerSO>("PXR_PicoDebuggerSO");
if(config.isOpen){
AddPrefab();
}
}
private static void AddPrefab()
{
GameObject prefab = Resources.Load<GameObject>("PXR_PICODebugger");
if (prefab != null)
{
Instantiate(prefab, Vector3.zero, Quaternion.identity);
}
else
{
Debug.LogError("Prefab not found in Resources folder.");
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1ab97bca604e54c99a2273f6e8533286
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,100 @@
/*******************************************************************************
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;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
[CreateAssetMenu(fileName = "MainConfig", menuName = "ScriptableObjects / PXR_PicoDebuggerSO", order = 1)]
public class PXR_PicoDebuggerSO : ScriptableObject
{
private static PXR_PicoDebuggerSO _instance;
public static PXR_PicoDebuggerSO Instance
{
get
{
if (_instance == null)
{
GetAsset(out PXR_PicoDebuggerSO picoDebuggerSO, "PXR_PicoDebuggerSO");
_instance = picoDebuggerSO;
}
return _instance;
}
}
[Header("default")]
public bool isOpen;
public LauncherButton debuggerLauncherButton;
public StartPosiion startPosition;
[Header("console")]
[Range(500,1000)]public int maxInfoCount;
[Header("tools")]
public LauncherButton rulerClearButton;
internal static void GetAsset<T>(out T asset, string name) where T : PXR_PicoDebuggerSO
{
asset = null;
#if UNITY_EDITOR
string path = GetPath(name);
asset = AssetDatabase.LoadAssetAtPath(path, typeof(T)) as T;
if (asset == null )
{
asset = ScriptableObject.CreateInstance<T>();
AssetDatabase.CreateAsset(asset, path);
}
#else
asset = Resources.Load<T>(name);
#endif
}
#if UNITY_EDITOR
internal static string GetPath(string name)
{
string resourcesPath = Path.Combine(Application.dataPath, "Resources");
if (!Directory.Exists(resourcesPath))
{
Directory.CreateDirectory(resourcesPath);
}
string assetPath = Path.GetRelativePath(Application.dataPath, Path.GetFullPath(Path.Combine(resourcesPath, $"{name}.asset")));
// Unity's AssetDatabase path requires a slash before "Assets"
return "Assets/" + assetPath.Replace('\\', '/');
}
public void AddToPreloadedAssets()
{
var preloadedAssets = PlayerSettings.GetPreloadedAssets().ToList();
if (!preloadedAssets.Contains(this))
{
preloadedAssets.Add(this);
PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray());
}
}
#endif
#if UNITY_EDITOR
public static PXR_PicoDebuggerSO GetSerializedObject(string path)
{
var config = AssetDatabase.LoadAssetAtPath<PXR_PicoDebuggerSO>(path);
if (config == null)
{
Debug.LogError("Failed to load PXR_PicoDebuggerSO at path: " + path);
}
return config;
}
#endif
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b0b5ff6f3ba0942d79f41538d7d76c76
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
/*******************************************************************************
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.EventSystems;
using UnityEngine.Events;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_CloseButton : MonoBehaviour, IPointerDownHandler
{
public UnityEvent onButtonCLick;
// Called when the button is selected
public void OnPointerDown(PointerEventData args)
{
onButtonCLick?.Invoke();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,105 @@
/*******************************************************************************
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.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_DefaultButton : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler
{
bool isButtonPress = false;
bool isButtonHover = false;
private float hoverSpeed = 0.8f;
[SerializeField] private Color defaultColor;
[SerializeField] private Color hoverColor;
[SerializeField] private GameObject panelGO;
[SerializeField] private GameObject[] panelList;
[SerializeField] private PXR_DefaultButton[] buttonList;
[SerializeField] private MeshRenderer bg;
[SerializeField] private MeshRenderer border;
[SerializeField] private Sprite sprite;
private float borderAlpha;
private void Start()
{
Reset();
}
private void OnValidate()
{
transform.GetChild(0).GetComponent<Image>().sprite = sprite;
}
// Called when the button is selected
public void OnPointerDown(PointerEventData eventData)
{
if (!isButtonPress)
{
border.material.color = hoverColor;
bg.material.color = defaultColor;
isButtonHover = false;
isButtonPress = true;
OpenPanel();
}
}
private void Update()
{
if (isButtonHover)
{
bg.material.color = Color.Lerp(bg.material.color, hoverColor, hoverSpeed * Time.deltaTime);
var borderColor = Color.Lerp(border.material.color, hoverColor, hoverSpeed * Time.deltaTime);
borderAlpha += hoverSpeed * Time.deltaTime;
borderColor.a = borderAlpha;
border.material.color = borderColor;
}
}
private void OpenPanel(){
for (var i = 0; i < panelList.Length; i++)
{
panelList[i].SetActive(false);
}
for (var i = 0; i<buttonList.Length; i++){
buttonList[i].Reset();
}
panelGO.SetActive(true);
if(panelGO.TryGetComponent(out IPXR_PanelManager manager)){
manager.Init();
}
}
public void OnPointerEnter(PointerEventData eventData)
{
if (!isButtonPress)
{
border.material.color = new Color(0, 0, 0, 0);
borderAlpha = 0f;
isButtonHover = true;
}
}
public void OnPointerExit(PointerEventData eventData)
{
if (!isButtonPress)
{
isButtonHover = false;
border.material.color = new Color(0, 0, 0, 0);
bg.material.color = defaultColor;
}
}
public void Reset()
{
bg.material.color = defaultColor;
border.material.color = new Color(0, 0, 0, 0);
isButtonPress = false;
isButtonHover = false;
panelGO.SetActive(false);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,73 @@
/*******************************************************************************
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.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_DragButton : MonoBehaviour, IBeginDragHandler, IDragHandler,IEndDragHandler
{
private Image image;
private Transform _camera;
public PXR_UIController uiController;
private Vector3 origin; // Center of a sphere
private float radius = 5f; // Radius of a sphere
public Transform container;
[SerializeField]private Color defaultColor;
[SerializeField]private Color hoverColor;
private void Start()
{
_camera = Camera.main.transform;
image = GetComponent<Image>();
}
private void UpdateTransformPosition(PointerEventData eventData)
{
// Gets the position and direction of the controller
Vector3 controllerPosition = eventData.pointerCurrentRaycast.worldPosition;
// Calculate the point at which the ray intersects the sphere
Vector3 sphereCenterToController = controllerPosition - origin;
Vector3 intersectionPoint = origin + sphereCenterToController.normalized * radius;
Vector3 intersectionDirection = (intersectionPoint - origin).normalized;
float angle = Vector3.Angle(intersectionDirection, Vector3.up);
if (angle < 45 || angle > 135)return;
var forward = container.position - _camera.position;
forward.y = 0;
image.color = Color.Lerp(image.color,hoverColor,Time.deltaTime);
container.forward = forward;
container.position = intersectionPoint;
}
public void OnBeginDrag(PointerEventData eventData)
{
if (eventData.pointerCurrentRaycast.gameObject != gameObject) return;
origin = uiController.origin;
radius = uiController.GetDistance();
// Update the position when you start dragging
UpdateTransformPosition(eventData);
}
public void OnEndDrag(PointerEventData eventData)
{
if (eventData.pointerCurrentRaycast.gameObject != gameObject) return;
image.color = defaultColor;
}
public void OnDrag(PointerEventData eventData)
{
if (eventData.pointerCurrentRaycast.gameObject != gameObject) return;
// Update position while dragging
UpdateTransformPosition(eventData);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,57 @@
/*******************************************************************************
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.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_FolderButton : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler
{
private Image image;
public GameObject content;
private bool isShowContent = false;
private float hoverSpeed = 0.5f;
[SerializeField] private Color defaultColor = new(184, 235, 255);
bool isButtonHover = false;
private void Start()
{
image = GetComponent<Image>();
image.color = defaultColor;
}
public void OnPointerDown(PointerEventData eventData)
{
// text.color = Color.red;
isShowContent = !isShowContent;
content.SetActive(isShowContent);
image.transform.Rotate(0, 0, 180);
LayoutRebuilder.ForceRebuildLayoutImmediate(content.transform.parent.gameObject.GetComponent<RectTransform>());
}
public void OnPointerEnter(PointerEventData eventData)
{
isButtonHover = true;
}
public void OnPointerExit(PointerEventData eventData)
{
isButtonHover = false;
image.color = defaultColor;
}
private void Update()
{
if (isButtonHover)
{
image.color = Color.Lerp(image.color, Color.white, hoverSpeed * Time.deltaTime);
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,35 @@
/*******************************************************************************
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.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_LogButton : MonoBehaviour, IPointerDownHandler
{
public LogType type;
[SerializeField]private Color defaultColor;
[SerializeField]private PXR_LogManager logManager;
[SerializeField]private Image icon;
[SerializeField]private Text text;
private bool isFilter = true;
public void OnPointerDown(PointerEventData eventData)
{
isFilter = !isFilter;
logManager.FilterLogs(type,isFilter);
icon.color = isFilter?defaultColor:Color.gray;
text.color = isFilter?defaultColor:Color.gray;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
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.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_ToolButton : MonoBehaviour, IPointerDownHandler, IPointerEnterHandler, IPointerExitHandler
{
private bool isButtonPress = false;
private bool isButtonHover = false;
// private float hoverSpeed = 0.8f;
[SerializeField] private Color defaultColor;
[SerializeField] private Color hoverColor;
[SerializeField] private Image icon;
public UnityEvent onButtonPressed;
public void OnPointerDown(PointerEventData eventData)
{
if (!isButtonPress)
{
onButtonPressed?.Invoke();
icon.color = hoverColor;
isButtonHover = false;
isButtonPress = true;
}
}
public void OnPointerEnter(PointerEventData eventData)
{
if (!isButtonPress)
{
icon.color = hoverColor;
isButtonHover = true;
}
}
public void Reset(){
icon.color = defaultColor;
isButtonHover = false;
isButtonPress = false;
}
public void OnPointerExit(PointerEventData eventData)
{
if (!isButtonPress)
{
isButtonHover = false;
icon.color = defaultColor;
}
}
public void CreateTool(){
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f7b0a5fb3a9ea4428b7d1096863a9bb2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
/*******************************************************************************
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;
namespace Unity.XR.PXR.Debugger
{
public class Ball : MonoBehaviour
{
void Update()
{
transform.position = Vector3.up*Mathf.Sin(Time.time)+Vector3.forward*0.5f;
}
}
}

View File

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

View File

@@ -0,0 +1,170 @@
/*******************************************************************************
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.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEditor;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_Tool_Ruler : MonoBehaviour
{
// Start is called before the first frame update
[SerializeField] Material mal;
[SerializeField] private GameObject rulerPrefab;
[SerializeField] private Transform exitPosition;
private Vector3 startPosition;
private float size = 0.02f;
private bool isStart = false;
private GameObject ruler;
private Text text;
private Transform container;
private List<GameObject> rulers = new();
void Start()
{
PXR_DeviceManager.Instance.OnRightGripButtonPress += StartMeasure;
PXR_DeviceManager.Instance.OnRightGripButtonRelease += StopMeasure;
var config = Resources.Load<PXR_PicoDebuggerSO>("PXR_PicoDebuggerSO");
if(config.isOpen)
{
switch (config.rulerClearButton)
{
case LauncherButton.PressA:
PXR_DeviceManager.Instance.OnAButtonPress += OnClearButtonPress;
break;
case LauncherButton.PressB:
PXR_DeviceManager.Instance.OnBButtonPress += OnClearButtonPress;
break;
case LauncherButton.PressX:
PXR_DeviceManager.Instance.OnXButtonPress += OnClearButtonPress;
break;
case LauncherButton.PressY:
PXR_DeviceManager.Instance.OnYButtonPress += OnClearButtonPress;
break;
default:
break;
}
}
}
void Update()
{
if (isStart)
{
GenerateRoundedRectMesh();
}
}
void OnDestroy() {
PXR_DeviceManager.Instance.OnRightGripButtonPress -= StartMeasure;
PXR_DeviceManager.Instance.OnRightGripButtonRelease -= StopMeasure;
var config = Resources.Load<PXR_PicoDebuggerSO>("PXR_PicoDebuggerSO");
if(config.isOpen)
{
switch (config.rulerClearButton)
{
case LauncherButton.PressA:
PXR_DeviceManager.Instance.OnAButtonPress -= OnClearButtonPress;
break;
case LauncherButton.PressB:
PXR_DeviceManager.Instance.OnBButtonPress -= OnClearButtonPress;
break;
case LauncherButton.PressX:
PXR_DeviceManager.Instance.OnXButtonPress -= OnClearButtonPress;
break;
case LauncherButton.PressY:
PXR_DeviceManager.Instance.OnYButtonPress -= OnClearButtonPress;
break;
default:
break;
}
}
}
private void StartMeasure()
{
startPosition = exitPosition.position;
ruler = Instantiate(rulerPrefab);
text = ruler.GetComponentInChildren<Text>();
container = ruler.transform.Find("Container");
ruler.SetActive(true);
isStart = true;
rulers.Add(ruler);
}
private void StopMeasure()
{
isStart = false;
}
private void OnClearButtonPress(){
StopMeasure();
for (var i = 0; i < rulers.Count; i++)
{
Destroy(rulers[i]);
}
}
private void GenerateRoundedRectMesh()
{
var meshFilter = ruler.GetComponent<MeshFilter>();
meshFilter.GetComponent<MeshRenderer>().material = mal;
Mesh mesh = new();
meshFilter.mesh = mesh;
List<Vector3> vertices = new();
List<Vector2> uvs = new();
List<int> triangles = new();
var dir = exitPosition.position-startPosition;
var p0 = startPosition + exitPosition.forward * size;
var p2 = startPosition - exitPosition.forward * size;
var p1 = exitPosition.position + exitPosition.forward * size;
var p3 = exitPosition.position - exitPosition.forward * size;
vertices.Add(p0);
uvs.Add(new Vector2(0, 0));
vertices.Add(p2);
uvs.Add(new Vector2(0, 1));
triangles.Add(0);
triangles.Add(2);
triangles.Add(1);
triangles.Add(0);
triangles.Add(1);
triangles.Add(2);
vertices.Add(p1);
uvs.Add(new Vector2(1, 0));
vertices.Add(p3);
uvs.Add(new Vector2(1, 1));
triangles.Add(1);
triangles.Add(2);
triangles.Add(3);
triangles.Add(2);
triangles.Add(1);
triangles.Add(3);
text.text = string.Format("{0:0.000}", dir.magnitude);
mesh.SetVertices(vertices);
mesh.SetUVs(0,uvs);
mesh.SetIndices(triangles, MeshTopology.Triangles, 0);
mesh.RecalculateBounds();
mesh.RecalculateNormals();
var normal = Vector3.Cross(p2 - p0, p1 - p0);
container.transform.position = startPosition+ dir*0.5f +(exitPosition.forward - normal) * size;
container.transform.forward = normal;
meshFilter.GetComponent<MeshRenderer>().material.SetFloat("_MeshLength", dir.magnitude);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
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;
using System.Collections;
using UnityEngine;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_Tool_TimerController : MonoBehaviour
{
private readonly float delayTime = 0.17f;
[SerializeField] private Animator anim;
private bool isTurnOn = false;
private bool isLock = true;
void Start()
{
PXR_DeviceManager.Instance.OnRightGripButtonPress += CutDown;
StartCoroutine(Delay(Open));
}
void OnDestroy()
{
PXR_DeviceManager.Instance.OnRightGripButtonPress -= CutDown;
}
private void CutDown()
{
if (isLock) return;
isTurnOn = !isTurnOn;
anim.SetBool("TurnOn", isTurnOn);
StartCoroutine(Delay(Open));
if (isTurnOn)
{
StartCoroutine(Delay(TimePause));
}
else
{
Time.timeScale = 1f;
}
isLock = true;
}
private IEnumerator Delay(Action action)
{
yield return new WaitForSeconds(delayTime);
action();
}
private void Open()
{
isLock = false;
}
private void TimePause()
{
Time.timeScale = 0f;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10fdeff64c0134bbe95d1939a54eea37
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d08d4a0636fd64c698e3b13b89847379
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
/*******************************************************************************
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;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_UIController : MonoBehaviour
{
public static PXR_UIController Instance { get; private set; }
public PXR_PicoDebuggerSO config;
[HideInInspector] public Vector3 origin;
private Transform _camera;
private float distance;
private StartPosiion state;
public void Awake()
{
if (config == null)
{
config = Resources.Load<PXR_PicoDebuggerSO>("PXR_PicoDebuggerSO");
}
if (Instance == null)
{
Instance = this;
}
Init();
}
private void Init()
{
_camera = Camera.main.transform;
state = config.startPosition;
distance = GetDistance();
}
public float GetDistance()
{
return state switch
{
StartPosiion.Far => 3f,
StartPosiion.Medium => 2f,
StartPosiion.Near => 1f,
_ => 2f,
};
}
private void OnEnable()
{
ResetTransform();
}
// Update is called once per frame
private void ResetTransform()
{
origin = _camera.position;
transform.position = origin + distance * _camera.transform.forward ;
transform.forward = transform.position - origin;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,60 @@
/*******************************************************************************
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 UnityEditor;
using UnityEngine;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_UIManager : MonoBehaviour
{
public PXR_PicoDebuggerSO config;
public PXR_UIController uiController;
private GameObject _controller = null;
private void Start()
{
config = Resources.Load<PXR_PicoDebuggerSO>("PXR_PicoDebuggerSO");
uiController = Resources.Load<GameObject>("PXR_DebuggerPanel").GetComponent<PXR_UIController>();
if(config.isOpen)
{
switch (config.debuggerLauncherButton)
{
case LauncherButton.PressA:
PXR_DeviceManager.Instance.OnAButtonPress += OnStartButtonPress;
break;
case LauncherButton.PressB:
PXR_DeviceManager.Instance.OnBButtonPress += OnStartButtonPress;
break;
case LauncherButton.PressX:
PXR_DeviceManager.Instance.OnXButtonPress += OnStartButtonPress;
break;
case LauncherButton.PressY:
PXR_DeviceManager.Instance.OnYButtonPress += OnStartButtonPress;
break;
default:
break;
}
}
}
private void OnStartButtonPress(){
ToggleController();
}
private void ToggleController(){
if(_controller == null){
_controller = Instantiate(uiController.gameObject);
}else{
_controller.SetActive(!_controller.gameObject.activeSelf);
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8f68a863322194d27a20f7360a9deb30
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,77 @@
/*******************************************************************************
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.EventSystems;
using UnityEngine.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_InspectorItem : MonoBehaviour, IPointerDownHandler
{
public Text text;
private bool isShowChildren = false;
private bool hasChild = false;
private string icon => hasChild?(isShowChildren?"- ":"+ "):"";
private string nodeName;
private GameObject target;
public void SetTitle(){
text.text = icon + nodeName;
}
public void Init(Transform item)
{
target = item.gameObject;
nodeName = item.name;
if(item.childCount > 0){
hasChild = true;
TraverseChild(item);
}
SetTitle();
}
public void AddItem(Transform item)
{
var go = Instantiate(PXR_InspectorManager.Instance.inspectItem, transform);
if (go.TryGetComponent(out PXR_InspectorItem inspectItem))
{
inspectItem.Init(item);
inspectItem.gameObject.SetActive(false);
}
}
public void TraverseChild(Transform current)
{
for (int i = 0; i < current.childCount; i++)
{
// Debug.Log($"TraverseChild: {current.GetChild(i).name}");
AddItem(current.GetChild(i));
}
}
public void OnPointerDown(PointerEventData eventData)
{
isShowChildren = !isShowChildren;
// LayoutRebuilder.ForceRebuildLayoutImmediate(gameObject.GetComponent<RectTransform>());
for (int i = 0; i < transform.childCount; i++)
{
// Debug.Log($"TraverseChild: {transform.GetChild(i).name}");
transform.GetChild(i).gameObject.SetActive(isShowChildren);
LayoutRebuilder.ForceRebuildLayoutImmediate(transform.GetChild(i).GetComponent<RectTransform>());
}
var root = transform;
while(root.TryGetComponent(out PXR_InspectorItem _)){
LayoutRebuilder.ForceRebuildLayoutImmediate(root.GetComponent<RectTransform>());
root = root.parent;
}
SetTitle();
PXR_InspectorManager.Instance.SetTransformInfo(target);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,90 @@
/*******************************************************************************
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.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_InspectorManager : MonoBehaviour, IPXR_PanelManager
{
public static PXR_InspectorManager Instance;
private void Awake(){
if(Instance == null){
Instance = this;
}
}
public GameObject inspectItem;
public Transform content;
public Text positionText;
public Text rotationText;
public Text scaleText;
public GameObject transformInfoNode;
private Transform target;
void Update(){
ShowTransformInfo();
}
private void ClearAllChildren(){
int childCount = content.childCount;
for (int i = childCount - 1; i >= 0; i--)
{
DestroyImmediate(content.GetChild(i).gameObject);
}
}
public void CreateInspector()
{
GenerateInspectorTree();
}
public void Init(){
CreateInspector();
}
public void Reset(){
for (int i = 0; i < content.childCount; i++)
{
LayoutRebuilder.ForceRebuildLayoutImmediate(content.GetChild(i).GetComponent<RectTransform>());
}
}
public void SetTransformInfo(GameObject target){
this.target = target.transform;
transformInfoNode.SetActive(true);
ShowTransformInfo();
}
public void Refresh(){
ClearAllChildren();
GenerateInspectorTree();
}
private void GenerateInspectorTree(){
GameObject[] rootObjects = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
// 遍历所有根GameObject
foreach (GameObject obj in rootObjects)
{
if(!obj.TryGetComponent<PXR_UIController>(out _) && !obj.TryGetComponent<PXR_UIManager>(out _) && obj.activeSelf){
var go = Instantiate(inspectItem, content);
if(go.TryGetComponent(out PXR_InspectorItem item)){
item.Init(obj.transform);
}
}
}
Reset();
}
private void ShowTransformInfo(){
if(target != null){
positionText.text = $"x:{target.position.x} y:{target.position.y} z:{target.position.z}";
rotationText.text = $"x:{target.eulerAngles.x} y:{target.eulerAngles.y} z:{target.eulerAngles.z} ";
scaleText.text = $"x:{target.localScale.x} y:{target.localScale.y} z:{target.localScale.z}";
}else{
transformInfoNode.SetActive(false);
Refresh();
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4e6248719bac74cbd9b183852eea9d1b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,124 @@
/*******************************************************************************
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.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_LogManager : MonoBehaviour, IPXR_PanelManager
{
public List<GameObject> infoList = new();
public List<GameObject> warningList = new();
public List<GameObject> errorList = new();
public GameObject errorMessage;
public GameObject warningMessage;
public GameObject infoMessage;
public Text infoText;
public Text warningText;
public Text errorText;
public Transform messageContainer;
private int ListCount => infoList.Count + warningList.Count + errorList.Count;
private void AddMessage(string title, string content, LogType type)
{
switch (type)
{
case LogType.Error:
CreateMessage(title, content, type, errorList, errorMessage);
break;
case LogType.Assert:
break;
case LogType.Warning:
CreateMessage(title, content, type, warningList, warningMessage);
break;
case LogType.Log:
CreateMessage(title, content, type, infoList, infoMessage);
break;
case LogType.Exception:
break;
}
RecaculateLogCount();
}
private void CreateMessage(string title, string content, in LogType type, in List<GameObject> list, in GameObject template)
{
var msg = Instantiate(template, messageContainer).GetComponent<PXR_MessageController>();
msg.Init(title, content);
list.Add(msg.gameObject);
}
private void RecaculateLogCount()
{
infoText.text = infoList.Count.ToString();
warningText.text = warningList.Count.ToString();
errorText.text = errorList.Count.ToString();
}
public void FilterLogs(LogType type, bool isFilter)
{
switch (type)
{
case LogType.Error:
ToggleLogs(errorList, isFilter);
break;
case LogType.Assert:
break;
case LogType.Warning:
ToggleLogs(warningList, isFilter);
break;
case LogType.Log:
ToggleLogs(infoList, isFilter);
break;
case LogType.Exception:
break;
}
}
private void ToggleLogs(in List<GameObject> list, bool status)
{
foreach (var item in list)
{
item.SetActive(status);
}
}
void Start()
{
Application.logMessageReceived += OnLogMessageReceived;
}
private void OnLogMessageReceived(string logString, string stackTrace, LogType type)
{
if (PXR_UIController.Instance.config.maxInfoCount > ListCount)
{
AddMessage(logString, stackTrace, type);
}
}
void OnEnable()
{
foreach (var item in infoList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
foreach (var item in warningList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
foreach (var item in errorList)
{
item.GetComponent<PXR_MessageController>().Reset();
}
}
public void Init(){
}
void OnDestroy()
{
Application.logMessageReceived -= OnLogMessageReceived;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,59 @@
/*******************************************************************************
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.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_MessageController : MonoBehaviour
{
// Start is called before the first frame update
public Text title;
public Text content;
private readonly string widthMark = "------------------------------------------------------------------";
private readonly int maxLength = 47;
public void Init(string title, string content)
{
string timestamp = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string finalTitle = $"{timestamp}: {title}";
TextGenerator generator = new();
var settings = this.title.GetGenerationSettings(this.title.gameObject.GetComponent<RectTransform>().rect.size);
var targetWidth = generator.GetPreferredWidth(widthMark, settings);
var currentWidth = generator.GetPreferredWidth(finalTitle, settings);
if (targetWidth < currentWidth)
{
finalTitle = title[..(maxLength - 3)];
currentWidth = generator.GetPreferredWidth(finalTitle, settings);
while (targetWidth < currentWidth)
{
finalTitle = title[..(title.Length - 1)];
currentWidth = generator.GetPreferredWidth(finalTitle, settings);
}
finalTitle += "...";
}
this.title.text = finalTitle;
this.content.text = $"{title}\n{content}";
Reset();
}
public void Reset()
{
LayoutRebuilder.ForceRebuildLayoutImmediate(gameObject.GetComponent<RectTransform>());
}
public void ToggleContent()
{
content.gameObject.SetActive(!content.gameObject.activeSelf);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,57 @@
/*******************************************************************************
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.UI;
using UnityEngine.EventSystems;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_BGWithTouch : MonoBehaviour, IPointerMoveHandler, IPointerEnterHandler, IPointerExitHandler
{
private Material material;
private Vector4 v;
private void Start()
{
var rect = GetComponent<RectTransform>().rect;
material = new Material(GetComponent<Image>().material);
v.z = rect.width;
v.w = rect.height;
material.SetVector("_TouchPos",v);
GetComponent<Image>().material = material;
}
public void OnPointerDown(PointerEventData eventData)
{
}
private void Update()
{
}
public void OnPointerEnter(PointerEventData eventData)
{
}
public void OnPointerExit(PointerEventData eventData)
{
}
public void OnPointerMove(PointerEventData eventData)
{
Vector3 offset = eventData.pointerCurrentRaycast.worldPosition-transform.position;
v.x= offset.x/v.z;
v.y= offset.y/v.w;
material.SetVector("_TouchPos", v);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,33 @@
/*******************************************************************************
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.
*******************************************************************************/
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_DebuggerConst{
public static string sdkPackageName = "Packages/com.unity.xr.picoxr/";
public static string sdkRootName = "com.unity.xr.picoxr/";
}
public enum LauncherButton
{
PressA,
PressB,
PressX,
PressY,
}
public enum StartPosiion
{
Far,
Near ,
Medium,
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 680b341d8fe6a4b7582f09429fefc6ef
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,43 @@
/*******************************************************************************
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.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
public class PXR_ToolManager : MonoBehaviour
{
private GameObject currentTool;
public PXR_ToolButton[] toolButtons;
public void CreateTool(GameObject tool){
ResetButtons();
if(currentTool != null){
Destroy(currentTool);
}
currentTool = Instantiate(tool,PXR_DeviceManager.Instance.RightHand);
PXR_DeviceManager.Instance.ToggleRightController(false);
}
private void ResetButtons(){
foreach (var button in toolButtons){
button.Reset();
}
PXR_DeviceManager.Instance.ToggleRightController(true);
}
public void DeleteTool(){
ResetButtons();
Destroy(currentTool);
currentTool = null;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 992f1fd0351f3469cb00e97521173d91
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,141 @@
/*******************************************************************************
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;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
#if UNITY_EDITOR || DEVELOPMENT_BUILD
namespace Unity.XR.PXR.Debugger
{
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class RoundedRectMesh : MonoBehaviour
{
[SerializeField]public float width = 1f;
[SerializeField]public float height = 1f;
[SerializeField]public float depth = 1f;
[SerializeField]public float cornerRadius = 0.2f;
[SerializeField]public bool[] corner = { true, true, true, true };
[SerializeField]public int cornerSegments = 10; // The number of subdivisions of rounded corners
[SerializeField]public string saveName = "CustomMesh"; // Customize the save name
private MeshFilter meshFilter;
private bool isInit = false;
void OnValidate()
{
Init();
GenerateRoundedRectMesh();
}
private void Init(){
if(!isInit){
meshFilter = GetComponent<MeshFilter>();
isInit = true;
}
}
public static List<Vector3> CreateRoundedRectPath(Vector3 center, float width, float height, float radius, bool[] corners, int cornerSegments)
{
List<Vector3> path = new();
var halfWidth = width *0.5f;
var halfHeight = height *0.5f;
// Check whether the radius of the fillet is reasonable
radius = Mathf.Min(radius, width *0.5f, height *0.5f);
// Define the fillet subdivision Angle
float angleStep = 90f / (float)cornerSegments;
Vector2[] cornerCentersOffset = new Vector2[]
{
new(-1,1), // 左上 Left Top
new (1, 1), // 右上 Right Top
new (1, -1), // 右下 Right Bottom
new (-1, -1) // 左下 Left Bottom
};
// Generate the path of the rounded rectangle
for (int i = 0; i < 4; i++)
{
bool isCorner = corners[i];
var delta = isCorner ? radius : 0;
Vector3 currentCornerCenter = center + new Vector3((halfWidth - delta) * cornerCentersOffset[i].x, (halfHeight - delta) * cornerCentersOffset[i].y, 0);
if (isCorner)
{
// Add arcs
for (int j = 0; j <= cornerSegments; j++)
{
float angle = (i * 90 + angleStep * j) * Mathf.Deg2Rad;
path.Add(currentCornerCenter + new Vector3(-Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius, 0));
}
}
else
{
// Add a right Angle
path.Add(currentCornerCenter);
}
}
return path;
}
private void GenerateRoundedRectMesh()
{
Mesh mesh = new();
meshFilter.mesh = mesh;
cornerRadius = Mathf.Clamp(cornerRadius, 0, Mathf.Min(width, height) *0.5f);
List<Vector3> path = CreateRoundedRectPath(transform.position, width, height, cornerRadius, corner, cornerSegments);
List<Vector3> vertices = new();
List<int> triangles = new();
var count = path.Count;
var doubleCount = count * 2;
var firstIndex = 0;
for (var j = 0; j < count; j++)
{
vertices.Add(path[j]);
vertices.Add(path[j] + Vector3.forward * depth);
triangles.Add(firstIndex);
triangles.Add((firstIndex + 2) % doubleCount );
triangles.Add(doubleCount);
triangles.Add((firstIndex + 1) % doubleCount);
triangles.Add(doubleCount + 1);
triangles.Add((firstIndex + 3) % doubleCount );
firstIndex += 2;
}
vertices.Add(transform.position);
vertices.Add(transform.position + Vector3.forward * depth);
var currentCount = vertices.Count;
firstIndex = 0;
for (var i = 0; i < count; i++)
{
vertices.Add(path[i]);
vertices.Add(path[i] + Vector3.forward * depth);
triangles.Add(firstIndex + currentCount);
triangles.Add((firstIndex + 1) % doubleCount + currentCount);
triangles.Add((firstIndex + 3) % doubleCount + currentCount);
triangles.Add(firstIndex + currentCount);
triangles.Add((firstIndex + 3) % doubleCount + currentCount);
triangles.Add((firstIndex + 2) % doubleCount + currentCount);
firstIndex += 2;
}
mesh.SetVertices(vertices);
mesh.SetIndices(triangles, MeshTopology.Triangles, 0);
mesh.RecalculateBounds();
mesh.RecalculateNormals();
}
}
}
#endif

View File

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