Initial Commit

This commit is contained in:
2025-07-04 20:33:06 +03:00
commit 8f09347ae0
9219 changed files with 2447903 additions and 0 deletions
@@ -0,0 +1,40 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UiAxis1dInspector : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private float m_minExtent = 0;
[SerializeField] private float m_maxExtent = 1;
[Header("Components")]
[SerializeField] private TextMeshProUGUI m_nameLabel = null;
[SerializeField] private TextMeshProUGUI m_valueLabel = null;
[SerializeField] private Slider m_slider = null;
public void SetExtents(float minExtent, float maxExtent)
{
m_minExtent = minExtent;
m_maxExtent = maxExtent;
}
public void SetName(string name)
{
m_nameLabel.text = name;
}
public void SetValue(float value)
{
m_valueLabel.text = string.Format("[{0}]", value.ToString("f2"));
m_slider.minValue = Mathf.Min(value, m_minExtent);
m_slider.maxValue = Mathf.Max(value, m_maxExtent);
m_slider.value = value;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dcf3246473f1a024e8f952f2a56a10c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,53 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UiAxis2dInspector : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private Vector2 m_xExtent = new Vector2(-1, +1);
[SerializeField] private Vector2 m_yExtent = new Vector2(-1, +1);
[Header("Components")]
[SerializeField] private TextMeshProUGUI m_nameLabel = null;
[SerializeField] private TextMeshProUGUI m_valueLabel = null;
[SerializeField] private Image m_handle = null;
public void SetExtents(Vector2 xExtent, Vector2 yExtent)
{
m_xExtent = xExtent;
m_yExtent = yExtent;
}
public void SetName(string name)
{
m_nameLabel.text = name;
}
public void SetValue(bool isTouching, Vector2 value)
{
m_handle.color = isTouching ? Color.white : new Color(0.2f, 0.2f, 0.2f);
Vector2 clampedValue = new Vector2(
Mathf.Clamp(value.x, m_xExtent.x, m_xExtent.y),
Mathf.Clamp(value.y, m_yExtent.x, m_yExtent.y)
);
m_valueLabel.text = $"[{clampedValue.x.ToString("f2")}, {clampedValue.y.ToString("f2")}]";
RectTransform parentRect = m_handle.transform.parent.GetComponent<RectTransform>();
Vector2 parentSize = (parentRect != null)
? new Vector2(Mathf.Abs(parentRect.sizeDelta.x), Mathf.Abs(parentRect.sizeDelta.y))
: new Vector2(Mathf.Abs(m_xExtent.y - m_xExtent.x), Mathf.Abs(m_yExtent.y - m_yExtent.x));
m_handle.transform.localPosition = new Vector3(
clampedValue.x * parentSize.x * 0.5f,
clampedValue.y * parentSize.y * 0.5f,
0
);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1c0717b533f75054d93d184c48b4b8d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UiBoolInspector : MonoBehaviour
{
[Header("Components")]
[SerializeField] private TextMeshProUGUI m_nameLabel = null;
[SerializeField] private Toggle m_toggle = null;
public void SetName(string name)
{
m_nameLabel.text = name;
}
public void SetValue(bool value)
{
m_toggle.isOn = value;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c25d8f20d93560f47bf604ec2dfc098c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,106 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using UnityEngine;
using TMPro;
public class UiDeviceInspector : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private OVRInput.Handedness m_handedness = OVRInput.Handedness.LeftHanded;
[Header("Left Column Components")]
[SerializeField] private TextMeshProUGUI m_title;
[SerializeField] private TextMeshProUGUI m_status;
[SerializeField] private UiBoolInspector m_thumbRestTouch;
[SerializeField] private UiAxis1dInspector m_thumbRestForce;
[SerializeField] private UiAxis1dInspector m_indexTrigger;
[SerializeField] private UiAxis1dInspector m_gripTrigger;
[SerializeField] private UiAxis1dInspector m_stylusTipForce;
[SerializeField] private UiAxis1dInspector m_indexCurl1d;
[SerializeField] private UiAxis1dInspector m_indexSlider1d;
[Header("Right Column Components")]
[SerializeField] private UiBoolInspector m_ax;
[SerializeField] private UiBoolInspector m_axTouch;
[SerializeField] private UiBoolInspector m_by;
[SerializeField] private UiBoolInspector m_byTouch;
[SerializeField] private UiBoolInspector m_indexTouch;
[SerializeField] private UiAxis2dInspector m_thumbstick;
private OVRInput.Controller m_controller;
private void Start()
{
m_controller = m_handedness == OVRInput.Handedness.LeftHanded
? OVRInput.Controller.LTouch
: OVRInput.Controller.RTouch;
}
private void Update()
{
// Set device title
string deviceTitle = $"{ToDeviceModel()} [{ToHandednessString(m_handedness)}]";
m_title.SetText(deviceTitle);
// Set status flags
string connectionState = OVRInput.IsControllerConnected(m_controller)
? "<color=#66ff87>o</color>"
: "<color=#ff8991>x</color>";
bool isTracked = OVRInput.GetControllerOrientationTracked(m_controller) &&
OVRInput.GetControllerPositionTracked(m_controller);
string trackingState = isTracked ? "<color=#66ff87>o</color>" : "<color=#ff8991>x</color>";
m_status.SetText($"Connected [{connectionState}] Tracked [{trackingState}]");
// ThumbRest force and triggers
m_thumbRestTouch.SetValue(OVRInput.Get(OVRInput.Touch.PrimaryThumbRest, m_controller));
m_indexTrigger.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, m_controller));
m_gripTrigger.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryHandTrigger, m_controller));
m_thumbRestForce.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryThumbRestForce, m_controller));
// Stylus tip
m_stylusTipForce.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryStylusForce, m_controller));
// Index capsense
m_indexCurl1d.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTriggerCurl, m_controller));
m_indexSlider1d.SetValue(OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTriggerSlide, m_controller));
// Face buttons
m_ax.SetValue(OVRInput.Get(OVRInput.Button.One, m_controller));
m_axTouch.SetValue(OVRInput.Get(OVRInput.Touch.One, m_controller));
m_by.SetValue(OVRInput.Get(OVRInput.Button.Two, m_controller));
m_byTouch.SetValue(OVRInput.Get(OVRInput.Touch.Two, m_controller));
;
// Index touch
m_indexTouch.SetValue(OVRInput.Get(OVRInput.Touch.PrimaryIndexTrigger, m_controller));
// Thumbstick position & touch
m_thumbstick.SetValue(OVRInput.Get(OVRInput.Touch.PrimaryThumbstick, m_controller),
OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, m_controller));
}
private static string ToDeviceModel()
{
return "Touch";
}
private static string ToHandednessString(OVRInput.Handedness handedness)
{
switch (handedness)
{
case OVRInput.Handedness.LeftHanded:
return "L";
case OVRInput.Handedness.RightHanded:
return "R";
}
return "-";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e6c7e66b7c8ee684ab35e741ee622a32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,113 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
public class UiSceneMenu : MonoBehaviour
{
[Header("Settings")]
[SerializeField] private VerticalLayoutGroup m_layoutGroup = null;
[SerializeField] private TextMeshProUGUI m_labelPf = null;
private static Vector2 s_lastThumbstickL;
private static Vector2 s_lastThumbstickR;
private Scene m_activeScene;
private void Awake()
{
m_activeScene = SceneManager.GetActiveScene();
// Build labels
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; ++i)
{
string scenePath = SceneUtility.GetScenePathByBuildIndex(i);
CreateLabel(i, scenePath);
}
}
private void Update()
{
int sceneCount = SceneManager.sceneCountInBuildSettings;
if (InputPrevScene())
{
ChangeScene((m_activeScene.buildIndex - 1 + sceneCount) % sceneCount);
}
else if (InputNextScene())
{
ChangeScene((m_activeScene.buildIndex + 1) % sceneCount);
}
s_lastThumbstickL = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.LTouch);
s_lastThumbstickR = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.RTouch);
}
private bool InputPrevScene()
{
return KeyboardPrevScene() || ThumbstickPrevScene(OVRInput.Controller.LTouch) ||
ThumbstickPrevScene(OVRInput.Controller.RTouch);
}
private bool InputNextScene()
{
return KeyboardNextScene() || ThumbstickNextScene(OVRInput.Controller.LTouch) ||
ThumbstickNextScene(OVRInput.Controller.RTouch);
}
private bool KeyboardPrevScene()
{
return Input.GetKeyDown(KeyCode.UpArrow);
}
private bool KeyboardNextScene()
{
return Input.GetKeyDown(KeyCode.DownArrow);
}
private bool ThumbstickPrevScene(OVRInput.Controller controller)
{
return (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller).y >= 0.9f) &&
(GetLastThumbstickValue(controller).y < 0.9f);
}
private bool ThumbstickNextScene(OVRInput.Controller controller)
{
return (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, controller).y <= -0.9f) &&
(GetLastThumbstickValue(controller).y > -0.9f);
}
private Vector2 GetLastThumbstickValue(OVRInput.Controller controller)
{
return controller == OVRInput.Controller.LTouch ? s_lastThumbstickL : s_lastThumbstickR;
}
private void ChangeScene(int nextScene)
{
SceneManager.LoadScene(nextScene);
}
private void CreateLabel(int sceneIndex, string scenePath)
{
// Get the scene name
string sceneName = System.IO.Path.GetFileNameWithoutExtension(scenePath);
// Add spaces after capital letters
sceneName = Regex.Replace(sceneName, "[A-Z]", " $0").Trim();
// Call attention to the active scene
bool isActiveScene = m_activeScene.buildIndex == sceneIndex;
if (isActiveScene)
{
sceneName = $"Open: {sceneName}";
}
// Create and set the label
TextMeshProUGUI label = GameObject.Instantiate(m_labelPf);
label.SetText($"{sceneIndex + 1}. {sceneName}");
label.transform.SetParent(m_layoutGroup.transform, false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04938183eea4b0f458db0fd0a977d53a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
// (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
using TMPro;
using UnityEngine;
public class UiVectorInspector : MonoBehaviour
{
[Header("Components")]
[SerializeField] private TextMeshProUGUI m_nameLabel = null;
[SerializeField] private TextMeshProUGUI m_valueLabel = null;
public void SetName(string name)
{
m_nameLabel.text = name;
}
public void SetValue(bool value)
{
m_valueLabel.text = string.Format("[{0}]", value);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b5b953c396f406b44bfcbce884437b85
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: