huge change, new desig wip
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using uWindowCapture;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
public class CaptureSettingManager : MonoBehaviour
|
||||
{
|
||||
public UwcWindowTexture windowTexture;
|
||||
private void Start()
|
||||
{
|
||||
windowTexture = GetComponent<UwcWindowTexture>();
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
private void ApplyConfig()
|
||||
{
|
||||
windowTexture.captureMode = (CaptureMode)ConfigManager.config.CaptureMode - 1;
|
||||
|
||||
var fps = Enum.GetName(typeof(Config.captureFPS), ConfigManager.config.CaptureFPS);
|
||||
windowTexture.captureFrameRate = int.Parse(fps.Remove(0, 3));
|
||||
|
||||
if (ConfigManager.config.CaptureDesktop)
|
||||
{
|
||||
windowTexture.type = WindowTextureType.Desktop;
|
||||
windowTexture.desktopIndex = ConfigManager.config.CaptureDesktopNumber;
|
||||
}
|
||||
else
|
||||
windowTexture.type = WindowTextureType.Window;
|
||||
|
||||
windowTexture.desktopIndex = ConfigManager.config.CaptureDesktopNumber;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ca064e37a912ac49a2b617a99d67189
|
||||
guid: aab0706a705f478439bdde244717e9f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,90 @@
|
||||
using System.Collections;
|
||||
using WindowsInput.Native;
|
||||
using UnityEngine;
|
||||
|
||||
public class Config
|
||||
{
|
||||
public captureMode CaptureMode = captureMode.BitBlt;
|
||||
public enum captureMode
|
||||
{
|
||||
None = 0,
|
||||
PrintWindow = 1,
|
||||
BitBlt = 2,
|
||||
WindowsGraphicCapture = 3,
|
||||
Auto = 4
|
||||
}
|
||||
public captureFPS CaptureFPS = captureFPS.FPS72;
|
||||
public enum captureFPS
|
||||
{
|
||||
FPS30 = 0,
|
||||
FPS60 = 1,
|
||||
FPS72 = 2,
|
||||
FPS90 = 3,
|
||||
FPS120 = 4,
|
||||
FPS144 = 5
|
||||
}
|
||||
public bool CaptureDesktop = false;
|
||||
public int CaptureDesktopNumber = 0;
|
||||
public spectatorMode SpectatorMode = spectatorMode.ThirdPerson;
|
||||
public enum spectatorMode
|
||||
{
|
||||
FirstPerson = 0,
|
||||
FirstPersonSmooth = 1,
|
||||
ThirdPerson = 2,
|
||||
}
|
||||
public spectatorFPS SpectatorFPS = spectatorFPS.FPS60;
|
||||
public enum spectatorFPS
|
||||
{
|
||||
FPS15 = 0,
|
||||
FPS30 = 1,
|
||||
FPS45 = 2,
|
||||
FPS60 = 3,
|
||||
FPS72 = 4,
|
||||
FPS90 = 5,
|
||||
FPS120 = 6,
|
||||
FPS144 = 7
|
||||
}
|
||||
public float SpectatorFOV = 40;
|
||||
public float SpectatorSmooth = 0.125f;
|
||||
public float[] TPCamPosition = new float[3] { -0.6f, 1.8f, -1.2f };
|
||||
public float[] TPCamRotation = new float[3] { 23, 35, 0 };
|
||||
public float HandSize = 8f;
|
||||
public float[] HandPosition = new float[3] { 0, 0, 0 };
|
||||
public int Skybox = 0;
|
||||
public float PlayerHeight = 0;
|
||||
public float HapticDuration = 0.1f;
|
||||
public float HapticAmplitude = 0.75f;
|
||||
public touchSampleRate TouchSampleRate = touchSampleRate.FPS90;
|
||||
public enum touchSampleRate
|
||||
{
|
||||
FPS60 = 0,
|
||||
FPS72 = 1,
|
||||
FPS90 = 2,
|
||||
FPS120 = 3,
|
||||
FPS144 = 4,
|
||||
FPS160 = 5,
|
||||
FPS180 = 6,
|
||||
FPS200 = 7,
|
||||
FPS240 = 8,
|
||||
FPS280 = 9,
|
||||
FPS320 = 10,
|
||||
}
|
||||
public handStabilization HandStabilizationMode = handStabilization.None;
|
||||
public enum handStabilization
|
||||
{
|
||||
None = 0,
|
||||
Velocity = 1,
|
||||
Distance = 2,
|
||||
Smooth = 3,
|
||||
}
|
||||
public float HandStabilVelocity = 0.1f;
|
||||
public float HandStabilDistance = 0.1f;
|
||||
public float HandStabilSmooth = 0.1f;
|
||||
public bool useLight = true;
|
||||
public bool useIPCLighting = true;
|
||||
public bool useIPCTouch = true;
|
||||
public VirtualKeyCode TestKey = VirtualKeyCode.INSERT;
|
||||
public VirtualKeyCode ServiceKey = VirtualKeyCode.DELETE;
|
||||
public VirtualKeyCode CoinKey = VirtualKeyCode.HOME;
|
||||
public VirtualKeyCode CustomKey = VirtualKeyCode.NONAME;
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ac3a0e2569fb414f987646d98807ef9
|
||||
guid: 6698a2fb3ec8a144bb82ba10ec7fe7cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfigBehavior : MonoBehaviour
|
||||
{
|
||||
public static ConfigBehavior instance;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
public static void SaveFile()
|
||||
{
|
||||
instance.StopCoroutine(ConfigManager.SaveFileWait());
|
||||
instance.StartCoroutine(ConfigManager.SaveFileWait());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46aeec2d43d72c84a808e47673b6177f
|
||||
guid: 1f08f3c86e1b0ac4090e2ae9c18b8201
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,226 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using WindowsInput.Native;
|
||||
using TMPro;
|
||||
using UnityEngine.UI;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
public class ConfigManager : MonoBehaviour
|
||||
{
|
||||
public static Config config;
|
||||
private static bool hasInitialized = false;
|
||||
Config oldConfig;
|
||||
public static event Action onConfigChanged;
|
||||
void Awake()
|
||||
{
|
||||
onConfigChanged += EnsureInitialization;
|
||||
onConfigChanged += SaveFile;
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
EnsureInitialization();
|
||||
FindConfigPanelWidget();
|
||||
UpdateConfigPanel();
|
||||
AddListenerToWidget();
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public static void EnsureInitialization()
|
||||
{
|
||||
if (hasInitialized)
|
||||
return;
|
||||
LoadFile();
|
||||
hasInitialized = true;
|
||||
}
|
||||
private static void LoadFile()
|
||||
{
|
||||
Debug.Log("Loading config file");
|
||||
if (File.Exists(GetFileName()))
|
||||
{
|
||||
Debug.Log("Config file exists");
|
||||
config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(GetFileName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Config file does not exist");
|
||||
config = new Config();
|
||||
SaveFile();
|
||||
Debug.Log("Config file created");
|
||||
}
|
||||
}
|
||||
public static string GetFileName()
|
||||
{
|
||||
return Application.dataPath + "/../config.json";
|
||||
}
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (ConfigBehavior.instance != null)
|
||||
ConfigBehavior.SaveFile();
|
||||
}
|
||||
public static IEnumerator SaveFileWait()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
File.WriteAllText(GetFileName(), JsonConvert.SerializeObject(config, Formatting.Indented));
|
||||
Debug.Log("Config file saved");
|
||||
}
|
||||
|
||||
private TMP_Dropdown CaptureModeDropdown;
|
||||
private TMP_Dropdown CaptureFPSDropdown;
|
||||
private Toggle CaptureDesktopToggle;
|
||||
private TMP_Dropdown SpectatorModeDropdown;
|
||||
private TMP_Dropdown SpectatorFPSDropdown;
|
||||
private Slider SpectatorFOVSlider;
|
||||
private Slider HandSizeSlider;
|
||||
private Slider HandXSlider;
|
||||
private Slider HandYSlider;
|
||||
private Slider HandZSlider;
|
||||
private TMP_Dropdown SkyboxDropdown;
|
||||
private ValueManager PlayerHeightManager;
|
||||
private Slider HapticDurationSlider;
|
||||
private Slider HapticAmplitudeSlider;
|
||||
private TMP_Dropdown TouchSampleRateDropdown;
|
||||
private TMP_Dropdown HandStabilizationModeDropdown;
|
||||
private Slider HandStabilVelocitySlider;
|
||||
private Slider HandStabilDistanceSlider;
|
||||
private Slider HandStabilSmoothSlider;
|
||||
private Toggle isIPCLightingToggle;
|
||||
private Toggle isIPCTouchToggle;
|
||||
private TMP_Dropdown TestKeyDropdown;
|
||||
private TMP_Dropdown ServiceKeyDropdown;
|
||||
private TMP_Dropdown CoinKeyDropdown;
|
||||
private TMP_Dropdown CustomKeyDropdown;
|
||||
|
||||
void FindConfigPanelWidget()
|
||||
{
|
||||
CaptureModeDropdown = transform.Find("Tab1").Find("CaptureMode").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
CaptureFPSDropdown = transform.Find("Tab1").Find("CaptureFPS").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
CaptureDesktopToggle = transform.Find("Tab1").Find("CaptureDesktop").Find("Toggle").GetComponent<Toggle>();
|
||||
SpectatorModeDropdown = transform.Find("Tab1").Find("SpectatorMode").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
SpectatorFPSDropdown = transform.Find("Tab1").Find("SpectatorFPS").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
SpectatorFOVSlider = transform.Find("Tab1").Find("SpectatorFOV").Find("Slider").GetComponent<Slider>();
|
||||
HandSizeSlider = transform.Find("Tab1").Find("HandSize").Find("Slider").GetComponent<Slider>();
|
||||
HandXSlider = transform.Find("Tab1").Find("HandX").Find("Slider").GetComponent<Slider>();
|
||||
HandYSlider = transform.Find("Tab1").Find("HandY").Find("Slider").GetComponent<Slider>();
|
||||
HandZSlider = transform.Find("Tab1").Find("HandZ").Find("Slider").GetComponent<Slider>();
|
||||
SkyboxDropdown = transform.Find("Tab1").Find("Skybox").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
PlayerHeightManager = transform.Find("Tab1").Find("PlayerHeight").Find("Value").GetComponent<ValueManager>();
|
||||
HapticDurationSlider = transform.Find("Tab2").Find("HapticDuration").Find("Slider").GetComponent<Slider>();
|
||||
HapticAmplitudeSlider = transform.Find("Tab2").Find("HapticAmplitude").Find("Slider").GetComponent<Slider>();
|
||||
TouchSampleRateDropdown = transform.Find("Tab2").Find("TouchSampleRate").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
HandStabilizationModeDropdown = transform.Find("Tab2").Find("HandStabilization").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
//HandStabilVelocitySlider = transform.Find("Tab2").Find("HandStabilVelocity").Find("Slider").GetComponent<Slider>();
|
||||
//HandStabilDistanceSlider = transform.Find("Tab2").Find("HandStabilDistance").Find("Slider").GetComponent<Slider>();
|
||||
//HandStabilSmoothSlider = transform.Find("Tab2").Find("HandStabilSmooth").Find("Slider").GetComponent<Slider>();
|
||||
isIPCLightingToggle = transform.Find("Tab2").Find("UseIPCLighting").Find("Toggle").GetComponent<Toggle>();
|
||||
isIPCTouchToggle = transform.Find("Tab2").Find("UseIPCTouch").Find("Toggle").GetComponent<Toggle>();
|
||||
TestKeyDropdown = transform.Find("Tab2").Find("TestKeyBind").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
ServiceKeyDropdown = transform.Find("Tab2").Find("ServiceKeyBind").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
CoinKeyDropdown = transform.Find("Tab2").Find("CoinKeyBind").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
CustomKeyDropdown = transform.Find("Tab2").Find("CustomKeyBind").Find("Dropdown").GetComponent<TMP_Dropdown>();
|
||||
}
|
||||
void AddListenerToWidget()
|
||||
{
|
||||
CaptureModeDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
CaptureFPSDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
CaptureDesktopToggle.onValueChanged.AddListener(onBoolChanged);
|
||||
SpectatorModeDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
SpectatorFPSDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
SpectatorFOVSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
HandSizeSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
HandXSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
HandYSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
HandZSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
SkyboxDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
PlayerHeightManager.onValueChanged.AddListener(onValueChanged);
|
||||
HapticDurationSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
HapticAmplitudeSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
TouchSampleRateDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
HandStabilizationModeDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
//HandStabilVelocitySlider.onValueChanged.AddListener(onFloatChanged);
|
||||
//HandStabilDistanceSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
//HandStabilSmoothSlider.onValueChanged.AddListener(onFloatChanged);
|
||||
isIPCLightingToggle.onValueChanged.AddListener(onBoolChanged);
|
||||
isIPCTouchToggle.onValueChanged.AddListener(onBoolChanged);
|
||||
TestKeyDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
ServiceKeyDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
CoinKeyDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
CustomKeyDropdown.onValueChanged.AddListener(onIntChanged);
|
||||
}
|
||||
void onValueChanged()
|
||||
{
|
||||
config.PlayerHeight = PlayerHeightManager.Value;
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
void onIntChanged(int value)
|
||||
{
|
||||
config.CaptureMode = (Config.captureMode)CaptureModeDropdown.value;
|
||||
config.CaptureFPS = (Config.captureFPS)CaptureFPSDropdown.value;
|
||||
config.SpectatorMode = (Config.spectatorMode)SpectatorModeDropdown.value;
|
||||
config.SpectatorFPS = (Config.spectatorFPS)SpectatorFPSDropdown.value;
|
||||
config.Skybox = SkyboxDropdown.value;
|
||||
config.TouchSampleRate = (Config.touchSampleRate)TouchSampleRateDropdown.value;
|
||||
config.HandStabilizationMode = (Config.handStabilization)HandStabilizationModeDropdown.value;
|
||||
config.TestKey = (VirtualKeyCode)TestKeyDropdown.value;
|
||||
config.ServiceKey = (VirtualKeyCode)ServiceKeyDropdown.value;
|
||||
config.CoinKey = (VirtualKeyCode)CoinKeyDropdown.value;
|
||||
config.CustomKey = (VirtualKeyCode)CustomKeyDropdown.value;
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
|
||||
void onFloatChanged(float value)
|
||||
{
|
||||
config.SpectatorFOV = SpectatorFOVSlider.value;
|
||||
config.HandSize = HandSizeSlider.value;
|
||||
config.HandPosition[0] = HandXSlider.value;
|
||||
config.HandPosition[1] = HandYSlider.value;
|
||||
config.HandPosition[2] = HandZSlider.value;
|
||||
config.HapticDuration = HapticDurationSlider.value;
|
||||
config.HapticAmplitude = HapticAmplitudeSlider.value;
|
||||
//config.HandStabilVelocity = HandStabilVelocitySlider.value;
|
||||
//config.HandStabilDistance = HandStabilDistanceSlider.value;
|
||||
//config.HandStabilSmooth = HandStabilSmoothSlider.value;
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
|
||||
void onBoolChanged(bool value)
|
||||
{
|
||||
config.useIPCLighting = isIPCLightingToggle.isOn;
|
||||
config.useIPCTouch = isIPCTouchToggle.isOn;
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
|
||||
void UpdateConfigPanel()
|
||||
{
|
||||
CaptureModeDropdown.value = (int)config.CaptureMode;
|
||||
CaptureFPSDropdown.value = (int)config.CaptureFPS;
|
||||
CaptureDesktopToggle.isOn = config.CaptureDesktop;
|
||||
SpectatorModeDropdown.value = (int)config.SpectatorMode;
|
||||
SpectatorFPSDropdown.value = (int)config.SpectatorFPS;
|
||||
SpectatorFOVSlider.value = config.SpectatorFOV;
|
||||
HandSizeSlider.value = config.HandSize;
|
||||
HandXSlider.value = config.HandPosition[0];
|
||||
HandYSlider.value = config.HandPosition[1];
|
||||
HandZSlider.value = config.HandPosition[2];
|
||||
SkyboxDropdown.value = config.Skybox;
|
||||
PlayerHeightManager.Value = config.PlayerHeight;
|
||||
HapticDurationSlider.value = config.HapticDuration;
|
||||
HapticAmplitudeSlider.value = config.HapticAmplitude;
|
||||
TouchSampleRateDropdown.value = (int)config.TouchSampleRate;
|
||||
HandStabilizationModeDropdown.value = (int)config.HandStabilizationMode;
|
||||
//HandStabilVelocitySlider.value = HandStabilVelocity;
|
||||
//HandStabilDistanceSlider.value = HandStabilDistance;
|
||||
//HandStabilSmoothSlider.value = HandStabilSmooth;
|
||||
isIPCLightingToggle.isOn = config.useIPCLighting;
|
||||
isIPCTouchToggle.isOn = config.useIPCTouch;
|
||||
TestKeyDropdown.value = (int)config.TestKey;
|
||||
ServiceKeyDropdown.value = (int)config.ServiceKey;
|
||||
CoinKeyDropdown.value = (int)config.CoinKey;
|
||||
CustomKeyDropdown.value = (int)config.CustomKey;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a76604ac77e1add42b84974256adc28e
|
||||
guid: f0559825455822d48a37fc54c6dfd318
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -2,7 +2,11 @@
|
||||
"name": "Configuration",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:56dd35f9b6f21364494ed8365264cbf6"
|
||||
"GUID:56dd35f9b6f21364494ed8365264cbf6",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:2dcfcfc00d4ac7749bb60698b85f1dc2",
|
||||
"GUID:fe685ec1767f73d42b749ea8045bfe43",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public static class JsonConfiguration {
|
||||
public static bool hasInitialized = false;
|
||||
private static JObject config;
|
||||
|
||||
private static void ensureInitialization() {
|
||||
if (hasInitialized) return;
|
||||
|
||||
loadFile();
|
||||
|
||||
hasInitialized = true;
|
||||
}
|
||||
|
||||
private static string getFileName() {
|
||||
return Application.dataPath + "/../config.json";
|
||||
}
|
||||
|
||||
private static void saveFile() {
|
||||
File.WriteAllText(getFileName(), config.ToString());
|
||||
}
|
||||
|
||||
private static void loadFile() {
|
||||
if (File.Exists(getFileName()))
|
||||
config = JObject.Parse(File.ReadAllText(getFileName()));
|
||||
else {
|
||||
config = new JObject();
|
||||
saveFile();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteAll() {
|
||||
ensureInitialization();
|
||||
|
||||
config.RemoveAll();
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void DeleteKey(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
config.Remove(key);
|
||||
|
||||
saveFile();
|
||||
}
|
||||
|
||||
public static bool HasKey(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.ContainsKey(key);
|
||||
}
|
||||
|
||||
public static void SetBoolean(string key, bool boolean) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = boolean;
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void SetString(string key, string text) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = text;
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void SetInt(string key, int number) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = number;
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void SetDouble(string key, double number) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = number;
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void SetFloatArray(string key, float[] numbers) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = JArray.FromObject(numbers);
|
||||
|
||||
saveFile();
|
||||
}
|
||||
|
||||
public static bool GetBoolean(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.Value<bool>(key);
|
||||
}
|
||||
public static string GetString(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.Value<string>(key);
|
||||
}
|
||||
public static int GetInt(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.Value<int>(key);
|
||||
}
|
||||
public static double GetDouble(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.Value<double>(key);
|
||||
}
|
||||
public static float[] GetFloatArray(string key) {
|
||||
ensureInitialization();
|
||||
//convert JArray to float[]
|
||||
return config.Value<JArray>(key).ToObject<float[]>();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LightSettingManager : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> Lights;
|
||||
void Start()
|
||||
{
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
void ApplyConfig()
|
||||
{
|
||||
foreach (var light in Lights)
|
||||
{
|
||||
light.SetActive(ConfigManager.config.useLight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 785dd3d2a9b58f24d9e6ecf071fb1304
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+1
-3
@@ -6,8 +6,6 @@ using UnityEngine;
|
||||
public class LocomotionStatus : MonoBehaviour
|
||||
{
|
||||
private TextMeshPro text;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
text = GetComponent<TextMeshPro>();
|
||||
@@ -16,6 +14,6 @@ public class LocomotionStatus : MonoBehaviour
|
||||
|
||||
public void UpdateText(bool status)
|
||||
{
|
||||
text.text = "LOCOMOTION: " + (status ? "ENABLED" : "DISABLED");
|
||||
text.text = "Locomotion: " + (status ? "Enabled" : "Disabled");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
public class PlayerSettingManager : MonoBehaviour
|
||||
{
|
||||
private Transform LHandTransform = null;
|
||||
private Transform RHandTransform = null;
|
||||
private double height = 0; // meters
|
||||
[SerializeField]
|
||||
private double upperLimit = 10; // meters
|
||||
[SerializeField]
|
||||
private double lowerLimit = -10; // meters
|
||||
void Start()
|
||||
{
|
||||
LHandTransform = transform.Find("Camera Offset").Find("LeftHand Controller").Find("LHand");
|
||||
RHandTransform = transform.Find("Camera Offset").Find("RightHand Controller").Find("RHand");
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
void ApplyConfig()
|
||||
{
|
||||
LHandTransform.localPosition = new Vector3(ConfigManager.config.HandPosition[0]/100,
|
||||
ConfigManager.config.HandPosition[1]/100,
|
||||
ConfigManager.config.HandPosition[2]/100);
|
||||
RHandTransform.localPosition = new Vector3(-ConfigManager.config.HandPosition[0]/100,
|
||||
ConfigManager.config.HandPosition[1]/100,
|
||||
ConfigManager.config.HandPosition[2]/100);
|
||||
|
||||
var value = ConfigManager.config.HandSize;
|
||||
LHandTransform.localScale = new Vector3(value/100, value/100, value/100);
|
||||
RHandTransform.localScale = new Vector3(value/100, value/100, value/100);
|
||||
|
||||
height = ConfigManager.config.PlayerHeight;
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (height > upperLimit) height = upperLimit;
|
||||
if (height < lowerLimit) height = lowerLimit;
|
||||
transform.position = new Vector3(transform.position.x, (float)height, transform.position.z);
|
||||
}
|
||||
private void ResetHeight()
|
||||
{
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f4b84873f4a3b447a498596e8ce2421
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,68 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SettingsManager : MonoBehaviour
|
||||
{
|
||||
public double DefaultPhysicFPS = 90;
|
||||
public double DefaultHandSize = 7;
|
||||
public float[] DefaultHandPosition = {1f, 1f, -3f};
|
||||
|
||||
private bool FocusChecked;
|
||||
public GameObject Display;
|
||||
public GameObject LHand;
|
||||
public GameObject RHand;
|
||||
UwcConfigurator UwcConfig;
|
||||
|
||||
void Start()
|
||||
{
|
||||
UwcConfig = Display.GetComponent<UwcConfigurator>();
|
||||
UpdateAllConfigs();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.F5) | !FocusChecked) //Update ConfigFile
|
||||
{
|
||||
if (Application.isFocused)
|
||||
{
|
||||
FocusChecked=true;
|
||||
UpdateAllConfigs();
|
||||
Debug.Log("Configs Updated");
|
||||
}
|
||||
}
|
||||
if (!Application.isFocused)
|
||||
FocusChecked=false;
|
||||
}
|
||||
void UpdateAllConfigs()
|
||||
{
|
||||
JsonConfiguration.hasInitialized = false;
|
||||
UwcConfig.UpdateConfigs();
|
||||
UpdatePhysicFPS();
|
||||
UpdateHands();
|
||||
|
||||
}
|
||||
|
||||
void UpdatePhysicFPS()
|
||||
{
|
||||
if (!JsonConfiguration.HasKey("PhysicFPS"))
|
||||
JsonConfiguration.SetDouble("PhysicFPS", DefaultPhysicFPS);
|
||||
Time.fixedDeltaTime = 1/(float)JsonConfiguration.GetDouble("PhysicFPS");
|
||||
}
|
||||
|
||||
static float HandSize;
|
||||
static float[] HandPosition;
|
||||
|
||||
void UpdateHands()
|
||||
{
|
||||
if (!JsonConfiguration.HasKey("HandSize"))
|
||||
JsonConfiguration.SetDouble("HandSize", DefaultHandSize);
|
||||
if (!JsonConfiguration.HasKey("HandPosition"))
|
||||
JsonConfiguration.SetFloatArray("HandPosition", DefaultHandPosition);
|
||||
HandSize = (float)JsonConfiguration.GetDouble("HandSize");
|
||||
HandPosition = JsonConfiguration.GetFloatArray("HandPosition");
|
||||
LHand.transform.localScale = new Vector3(HandSize/100,HandSize/100,HandSize/100);
|
||||
RHand.transform.localScale = new Vector3(HandSize/100,HandSize/100,HandSize/100);
|
||||
LHand.transform.localPosition = new Vector3(HandPosition[0]/100,HandPosition[1]/100,HandPosition[2]/100);
|
||||
RHand.transform.localPosition = new Vector3(HandPosition[0]/-100,HandPosition[1]/100,HandPosition[2]/100);
|
||||
}
|
||||
}
|
||||
+16
-43
@@ -10,6 +10,7 @@ using System;
|
||||
public class SkyboxSwitcher : MonoBehaviour
|
||||
{
|
||||
private string skyboxPath;
|
||||
public List<FileInfo> imageFiles = new List<FileInfo>();
|
||||
public List<Texture2D> textures = new List<Texture2D>();
|
||||
public List<System.IntPtr> ptrs = new List<System.IntPtr>();
|
||||
public static bool useSkybox = false;
|
||||
@@ -20,38 +21,33 @@ public class SkyboxSwitcher : MonoBehaviour
|
||||
[SerializeField]
|
||||
private int currentSkyboxIndex = 0;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField]
|
||||
private PanelButton incrementBtn;
|
||||
[SerializeField]
|
||||
private PanelButton decrementBtn;
|
||||
[SerializeField]
|
||||
private TextMeshPro counterTxt;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (JsonConfiguration.HasKey("useSkybox")) useSkybox = JsonConfiguration.GetBoolean("useSkybox");
|
||||
else SaveSkyboxState();
|
||||
Room.SetActive(!useSkybox);
|
||||
|
||||
if (JsonConfiguration.HasKey("Skybox")) currentSkyboxIndex = JsonConfiguration.GetInt("Skybox");
|
||||
else SaveSkyboxIndex();
|
||||
|
||||
incrementBtn.ButtonPressed += IncrementEvent;
|
||||
decrementBtn.ButtonPressed += DecrementEvent;
|
||||
|
||||
{
|
||||
skyboxes.Insert(0, RenderSettings.skybox); // add ubiquitous default skybox (should be current)
|
||||
|
||||
// check StreamingAssets folder for additional skybox textures
|
||||
skyboxPath = Path.Combine(Application.streamingAssetsPath, "SkyboxTextures");
|
||||
StartCoroutine(AddSkyboxes());
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
void ApplyConfig()
|
||||
{
|
||||
if (ConfigManager.config.Skybox == 0)
|
||||
useSkybox = false;
|
||||
else
|
||||
useSkybox = true;
|
||||
Room.SetActive(!useSkybox);
|
||||
|
||||
currentSkyboxIndex = ConfigManager.config.Skybox-1;
|
||||
SetSkybox();
|
||||
}
|
||||
|
||||
IEnumerator AddSkyboxes()
|
||||
{
|
||||
var skyboxDir = new DirectoryInfo(skyboxPath);
|
||||
List<FileInfo> imageFiles = new List<FileInfo>();
|
||||
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.png"));
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.jpg"));
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.jpeg"));
|
||||
@@ -115,32 +111,9 @@ public class SkyboxSwitcher : MonoBehaviour
|
||||
//}
|
||||
}
|
||||
|
||||
private void IncrementEvent()
|
||||
{
|
||||
currentSkyboxIndex = (currentSkyboxIndex + 1) % skyboxes.Count;
|
||||
SetSkybox();
|
||||
}
|
||||
private void DecrementEvent()
|
||||
{
|
||||
if (--currentSkyboxIndex < 0)
|
||||
currentSkyboxIndex = skyboxes.Count - 1;
|
||||
SetSkybox();
|
||||
}
|
||||
|
||||
private void SetSkybox()
|
||||
{
|
||||
counterTxt.text = (currentSkyboxIndex + 1).ToString();
|
||||
if (currentSkyboxIndex < skyboxes.Count && skyboxes[currentSkyboxIndex] != null)
|
||||
RenderSettings.skybox = skyboxes[currentSkyboxIndex];
|
||||
SaveSkyboxIndex();
|
||||
}
|
||||
|
||||
private void SaveSkyboxIndex()
|
||||
{
|
||||
JsonConfiguration.SetInt("Skybox", currentSkyboxIndex);
|
||||
}
|
||||
private void SaveSkyboxState()
|
||||
{
|
||||
JsonConfiguration.SetBoolean("useSkybox", useSkybox);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class SpectatorManager : MonoBehaviour
|
||||
{
|
||||
CameraSmooth cameraSmooth;
|
||||
Camera SpectatorCam;
|
||||
public Transform SpectatorFPTarget;
|
||||
public Transform SpectatorTPTarget;
|
||||
|
||||
void Start()
|
||||
{
|
||||
cameraSmooth = GetComponent<CameraSmooth>();
|
||||
SpectatorCam = GetComponent<Camera>();
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
ApplyTPCamTransform();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void ApplyConfig()
|
||||
{
|
||||
if (SpectatorCam == null || cameraSmooth == null || SpectatorFPTarget == null || SpectatorTPTarget == null)
|
||||
return;
|
||||
switch ((int)ConfigManager.config.SpectatorMode)
|
||||
{
|
||||
case 0:
|
||||
if (gameObject.activeSelf)
|
||||
gameObject.SetActive(false);
|
||||
break;
|
||||
case 1:
|
||||
if (!gameObject.activeSelf)
|
||||
gameObject.SetActive(true);
|
||||
cameraSmooth.target = SpectatorFPTarget;
|
||||
cameraSmooth.smoothSpeed = (float)ConfigManager.config.SpectatorSmooth;
|
||||
SpectatorCam.cullingMask |= 1 << LayerMask.NameToLayer("TPBlock"); // Enable TPBlock Layer Mask
|
||||
SpectatorCam.cullingMask &= ~(1 << LayerMask.NameToLayer("FPBlock")); // Disable FPBlock Layer Mask
|
||||
break;
|
||||
case 2:
|
||||
if (!gameObject.activeSelf)
|
||||
gameObject.SetActive(true);
|
||||
cameraSmooth.target = SpectatorTPTarget;
|
||||
cameraSmooth.smoothSpeed = 1;
|
||||
SpectatorCam.cullingMask &= ~(1 << LayerMask.NameToLayer("TPBlock")); // Disable TPBlock Layer Mask
|
||||
SpectatorCam.cullingMask |= 1 << LayerMask.NameToLayer("FPBlock"); // Enable FPBlock Layer Mask
|
||||
break;
|
||||
}
|
||||
|
||||
SpectatorCam.fieldOfView = (float)ConfigManager.config.SpectatorFOV;
|
||||
|
||||
string fpsString = Enum.GetName(typeof(Config.captureFPS), ConfigManager.config.CaptureFPS);
|
||||
Application.targetFrameRate = int.Parse(fpsString.Remove(0, 3));
|
||||
}
|
||||
void ApplyTPCamTransform()
|
||||
{
|
||||
if (SpectatorTPTarget == null)
|
||||
return;
|
||||
SpectatorTPTarget.position = new Vector3(ConfigManager.config.TPCamPosition[0],
|
||||
ConfigManager.config.TPCamPosition[1],
|
||||
ConfigManager.config.TPCamPosition[2]);
|
||||
SpectatorTPTarget.rotation = Quaternion.Euler(ConfigManager.config.TPCamRotation[0],
|
||||
ConfigManager.config.TPCamRotation[1],
|
||||
ConfigManager.config.TPCamRotation[2]);
|
||||
}
|
||||
public void SaveTransform()
|
||||
{
|
||||
if (SpectatorTPTarget == null)
|
||||
return;
|
||||
ConfigManager.config.TPCamPosition[0] = SpectatorTPTarget.position.x;
|
||||
ConfigManager.config.TPCamPosition[1] = SpectatorTPTarget.position.y;
|
||||
ConfigManager.config.TPCamPosition[2] = SpectatorTPTarget.position.z;
|
||||
ConfigManager.config.TPCamRotation[0] = SpectatorTPTarget.rotation.eulerAngles.x;
|
||||
ConfigManager.config.TPCamRotation[1] = SpectatorTPTarget.rotation.eulerAngles.y;
|
||||
ConfigManager.config.TPCamRotation[2] = SpectatorTPTarget.rotation.eulerAngles.z;
|
||||
ConfigManager.SaveFile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5cf4893867dcdb458ecc6e169503821
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System;
|
||||
|
||||
public class TouchSettingManager : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
public void ApplyConfig()
|
||||
{
|
||||
string fpsString = Enum.GetName(typeof(Config.captureFPS), ConfigManager.config.CaptureFPS);
|
||||
Time.fixedDeltaTime = 1 / int.Parse(fpsString.Remove(0, 3));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c61eae81376a85408cd633220ade758
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,41 +0,0 @@
|
||||
using UnityEngine;
|
||||
using uWindowCapture;
|
||||
|
||||
public class UwcConfigurator : MonoBehaviour {
|
||||
private UwcWindowTexture uwcWindowTexture;
|
||||
|
||||
void Start() {
|
||||
uwcWindowTexture = GetComponent<UwcWindowTexture>();
|
||||
UpdateConfigs();
|
||||
}
|
||||
|
||||
void SwitchToDesktopCapture() {
|
||||
uwcWindowTexture.type = WindowTextureType.Desktop;
|
||||
uwcWindowTexture.desktopIndex = JsonConfiguration.GetInt("CaptureDesktopNumber");
|
||||
}
|
||||
public void UpdateConfigs()
|
||||
{
|
||||
if (JsonConfiguration.HasKey("CaptureMode")) {
|
||||
int rawCaptureMode = JsonConfiguration.GetInt("CaptureMode");
|
||||
|
||||
if (rawCaptureMode > 3 || rawCaptureMode < 0) {
|
||||
JsonConfiguration.SetInt("CaptureMode", (int) uwcWindowTexture.captureMode);
|
||||
} else
|
||||
uwcWindowTexture.captureMode = (CaptureMode) JsonConfiguration.GetInt("CaptureMode");
|
||||
} else
|
||||
JsonConfiguration.SetInt("CaptureMode", (int) uwcWindowTexture.captureMode);
|
||||
|
||||
if (JsonConfiguration.HasKey("CaptureFramerate"))
|
||||
uwcWindowTexture.captureFrameRate = JsonConfiguration.GetInt("CaptureFramerate");
|
||||
else
|
||||
JsonConfiguration.SetInt("CaptureFramerate", uwcWindowTexture.captureFrameRate);
|
||||
|
||||
if (!JsonConfiguration.HasKey("CaptureDesktopNumber"))
|
||||
JsonConfiguration.SetInt("CaptureDesktopNumber", 0);
|
||||
|
||||
if (JsonConfiguration.HasKey("CaptureDesktop") && JsonConfiguration.GetBoolean("CaptureDesktop"))
|
||||
SwitchToDesktopCapture();
|
||||
else
|
||||
JsonConfiguration.SetBoolean("CaptureDesktop", false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Events;
|
||||
using TMPro;
|
||||
|
||||
public class ValueManager : MonoBehaviour
|
||||
{
|
||||
TMP_Text tmp;
|
||||
public float Value;
|
||||
float tempValue;
|
||||
public bool isPointerDown = false;
|
||||
public UnityEvent onValueChanged = new UnityEvent();
|
||||
void Start()
|
||||
{
|
||||
tmp = GetComponent<TMP_Text>();
|
||||
ConfigManager.EnsureInitialization();
|
||||
onValueChanged.AddListener(UpdateText);
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
if (isPointerDown)
|
||||
{
|
||||
ChangeValueContinue(tempValue);
|
||||
}
|
||||
}
|
||||
public void ChangeValueContinue(float _value)
|
||||
{
|
||||
tempValue = _value;
|
||||
Value += Time.deltaTime * _value;
|
||||
isPointerDown = true;
|
||||
onValueChanged?.Invoke();
|
||||
}
|
||||
public void PointerState(bool state)
|
||||
{
|
||||
isPointerDown = state;
|
||||
}
|
||||
public void ResetValue()
|
||||
{
|
||||
Value = 0;
|
||||
onValueChanged?.Invoke();
|
||||
}
|
||||
public void UpdateText()
|
||||
{
|
||||
tmp.text = String.Format("{0:F2}", Value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2741c97e96d043044b88f783f1f16738
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"name": "ControlPanel",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:75469ad4d38634e559750d17036d5f7c",
|
||||
"GUID:2dcfcfc00d4ac7749bb60698b85f1dc2",
|
||||
"GUID:80de51a1f88203a4cb129a5922de311f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5436500ab54595849b4b0dda68b4f629
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,87 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.IO;
|
||||
using UnityEngine.Networking;
|
||||
using System.Runtime.InteropServices;
|
||||
using System;
|
||||
|
||||
public class HeightAdjuster : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private double height = 0; // meters
|
||||
[SerializeField]
|
||||
private double upperLimit = 10; // meters
|
||||
[SerializeField]
|
||||
private double lowerLimit = -10; // meters
|
||||
|
||||
[Space]
|
||||
[SerializeField]
|
||||
private double adjustSpeed = 0.1; // meters per second
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField]
|
||||
private PanelButton incrementButton;
|
||||
[SerializeField]
|
||||
private PanelButton decrementButton;
|
||||
[SerializeField]
|
||||
private PanelButton resetButton;
|
||||
[SerializeField]
|
||||
private TextMeshPro counterTxt;
|
||||
[SerializeField]
|
||||
private Transform XROrigin;
|
||||
|
||||
private bool incrementing = false;
|
||||
private bool decrementing = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (JsonConfiguration.HasKey("Height")) height = JsonConfiguration.GetDouble("Height");
|
||||
else SaveHeight();
|
||||
|
||||
incrementButton.ButtonPressed += StartIncrementing;
|
||||
incrementButton.ButtonReleased += StopIncrementing;
|
||||
|
||||
decrementButton.ButtonPressed += StartDecrementing;
|
||||
decrementButton.ButtonReleased += StopDecrementing;
|
||||
|
||||
resetButton.ButtonPressed += ResetHeight;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (incrementing) height += Time.deltaTime * adjustSpeed;
|
||||
if (decrementing) height -= Time.deltaTime * adjustSpeed;
|
||||
|
||||
if (height > upperLimit) height = upperLimit;
|
||||
if (height < lowerLimit) height = lowerLimit;
|
||||
|
||||
counterTxt.text = String.Format("{0:F2}m", height);
|
||||
XROrigin.position = new Vector3(XROrigin.position.x, (float) -height, XROrigin.position.z);
|
||||
}
|
||||
|
||||
private void StartIncrementing() { incrementing = true; }
|
||||
private void StartDecrementing() { decrementing = true; }
|
||||
|
||||
private void StopIncrementing()
|
||||
{
|
||||
incrementing = false;
|
||||
SaveHeight();
|
||||
}
|
||||
private void StopDecrementing()
|
||||
{
|
||||
decrementing = false;
|
||||
SaveHeight();
|
||||
}
|
||||
|
||||
private void ResetHeight()
|
||||
{
|
||||
height = 0;
|
||||
SaveHeight();
|
||||
}
|
||||
|
||||
private void SaveHeight() {
|
||||
JsonConfiguration.SetDouble("Height", height);
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
using WindowsInput.Native;
|
||||
|
||||
public class PanelThirdPersonButton : MonoBehaviour
|
||||
{
|
||||
public bool isTP;
|
||||
|
||||
private Renderer cr;
|
||||
public GameObject tpCamera;
|
||||
public GameObject fpsCamera;
|
||||
public AudioSource audioSrc;
|
||||
|
||||
void Start()
|
||||
{
|
||||
cr = GetComponent<Renderer>();
|
||||
|
||||
if (JsonConfiguration.HasKey("ThirdPerson")) SetTP(JsonConfiguration.GetBoolean("ThirdPerson"));
|
||||
else SetTP(isTP);
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
audioSrc.Play();
|
||||
isTP = !isTP;
|
||||
SetTP(isTP);
|
||||
}
|
||||
|
||||
private void SetTP(bool state)
|
||||
{
|
||||
isTP = state;
|
||||
cr.material.color = state ? Color.green : Color.red;
|
||||
tpCamera?.SetActive(state);
|
||||
fpsCamera?.SetActive(!state);
|
||||
|
||||
JsonConfiguration.SetBoolean("ThirdPerson", state);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 447b0e47a465da145b212861d2c70c27
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,7 +1,10 @@
|
||||
{
|
||||
"name": "Controller",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"references": [
|
||||
"GUID:80de51a1f88203a4cb129a5922de311f",
|
||||
"GUID:fe685ec1767f73d42b749ea8045bfe43"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b827d6b92c85ea44b8376851b155786b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+14
-3
@@ -2,12 +2,18 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
public class Controller : MonoBehaviour
|
||||
public class ControllerHapticManager : MonoBehaviour
|
||||
{
|
||||
public XRNode Hand;
|
||||
InputDevice device;
|
||||
public float duration;
|
||||
public float amplitude;
|
||||
public float duration = 0.1f;
|
||||
public float amplitude = 1f;
|
||||
void Start()
|
||||
{
|
||||
ConfigManager.onConfigChanged += ApplyConfig;
|
||||
ConfigManager.EnsureInitialization();
|
||||
ApplyConfig();
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
device = InputDevices.GetDeviceAtXRNode(Hand);
|
||||
@@ -18,4 +24,9 @@ public class Controller : MonoBehaviour
|
||||
device = InputDevices.GetDeviceAtXRNode(Hand);
|
||||
device.StopHaptics();
|
||||
}
|
||||
void ApplyConfig()
|
||||
{
|
||||
duration = ConfigManager.config.HapticDuration;
|
||||
amplitude = ConfigManager.config.HapticAmplitude;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 901c50071db1c3f4fb9f655e0daeb979
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
public class RayManager : MonoBehaviour
|
||||
{
|
||||
public bool RaySwitch = true;
|
||||
public float Distance = -0.45f;
|
||||
XRRayInteractor interactor;
|
||||
XRInteractorLineVisual lineVisual;
|
||||
LineRenderer lineRenderer;
|
||||
void Start()
|
||||
{
|
||||
interactor = GetComponent<XRRayInteractor>();
|
||||
lineVisual = GetComponent<XRInteractorLineVisual>();
|
||||
lineRenderer = lineVisual.GetComponent<LineRenderer>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (gameObject.transform.position.z > Distance || !RaySwitch)
|
||||
{
|
||||
interactor.enabled = false;
|
||||
lineRenderer.enabled = false;
|
||||
lineVisual.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
interactor.enabled = true;
|
||||
lineRenderer.enabled = true;
|
||||
lineVisual.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83408e1317bdfaa48b49a1e9e7c0cc13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f09d9fc74e7b7874cbb1324e30a08097
|
||||
guid: 8c5547a91ba32b040a67c4c2955ac3e7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using WindowsInput.Native;
|
||||
|
||||
public class KeyDropdownManager : MonoBehaviour
|
||||
{
|
||||
TMP_Dropdown Dropdown;
|
||||
void Start()
|
||||
{
|
||||
Dropdown = GetComponent<TMP_Dropdown>();
|
||||
PopulateList();
|
||||
}
|
||||
void PopulateList()
|
||||
{
|
||||
string[] enumNames = Enum.GetNames(typeof(VirtualKeyCode));
|
||||
List<string> keyNames = new List<string>(enumNames);
|
||||
Dropdown.AddOptions(keyNames);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5dc3809278e8e6344b8891c35a1896ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TabManager : MonoBehaviour
|
||||
{
|
||||
public GameObject Tab1Object;
|
||||
public GameObject Tab2Object;
|
||||
void Start()
|
||||
{
|
||||
OnFirstTabClick();
|
||||
}
|
||||
public void OnFirstTabClick()
|
||||
{
|
||||
Tab1Object.SetActive(true);
|
||||
Tab2Object.SetActive(false);
|
||||
}
|
||||
public void OnSecondTabClick()
|
||||
{
|
||||
Tab1Object.SetActive(false);
|
||||
Tab2Object.SetActive(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0be7d3822381814d8b27523d4f9a550
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,8 +8,8 @@ public class LightManager : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> Lights = new List<GameObject>();
|
||||
List<Material> Materials = new List<Material>();
|
||||
public static bool useIPC = false;
|
||||
public static bool useIPC_Config = true;
|
||||
public static bool isIPCIdle = false;
|
||||
public static bool IsUseIPC = true;
|
||||
static Texture2D RGBColor2D;
|
||||
|
||||
public static MemoryMappedFile sharedBuffer;
|
||||
@@ -20,15 +20,14 @@ public class LightManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (JsonConfiguration.HasKey("useIPC"))
|
||||
useIPC_Config = JsonConfiguration.GetBoolean("useIPC");
|
||||
else
|
||||
JsonConfiguration.SetBoolean("useIPC", useIPC_Config);
|
||||
ConfigManager.EnsureInitialization();
|
||||
ConfigManager.onConfigChanged += UpdateConfig;
|
||||
UpdateConfig();
|
||||
|
||||
for (int i = 0; i < Lights.Count; i++)
|
||||
Materials.Add(Lights[i].GetComponent<Renderer>().material);
|
||||
|
||||
if (useIPC_Config)
|
||||
if (IsUseIPC)
|
||||
{
|
||||
InitializeIPC("Local\\WACVR_SHARED_BUFFER", 2164);
|
||||
RGBColor2D = new Texture2D(480, 1, TextureFormat.RGBA32, false);
|
||||
@@ -38,18 +37,25 @@ public class LightManager : MonoBehaviour
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
GetTextureFromBytes(GetBytesFromMemory());
|
||||
if (useIPC_Config)
|
||||
if (sharedBuffer != null)
|
||||
GetTextureFromBytes(GetBytesFromMemory());
|
||||
else
|
||||
return;
|
||||
if (IsUseIPC)
|
||||
CheckIPCState();
|
||||
if (useIPC)
|
||||
if (!isIPCIdle)
|
||||
UpdateLED();
|
||||
}
|
||||
void UpdateConfig()
|
||||
{
|
||||
IsUseIPC = ConfigManager.config.useIPCLighting;
|
||||
}
|
||||
private void CheckIPCState()
|
||||
{
|
||||
if (RGBColor2D.GetPixel(0 , 0).a == 0)
|
||||
useIPC = false;
|
||||
if (RGBColor2D.GetPixel(0 , 0).a == 1)
|
||||
isIPCIdle = false;
|
||||
else
|
||||
useIPC = true;
|
||||
isIPCIdle = true;
|
||||
}
|
||||
private void InitializeIPC(string sharedMemoryName, int sharedMemorySize)
|
||||
{
|
||||
@@ -88,7 +94,7 @@ public class LightManager : MonoBehaviour
|
||||
}
|
||||
public void UpdateLightFade(int Area, bool State)
|
||||
{
|
||||
if(useIPC)
|
||||
if(!isIPCIdle)
|
||||
return;
|
||||
|
||||
Area -= 1;
|
||||
|
||||
@@ -7,22 +7,20 @@ using System.Collections;
|
||||
|
||||
public class ColliderToSerial : MonoBehaviour
|
||||
{
|
||||
public GameObject LightManager;
|
||||
private LightManager lightManager;
|
||||
public LightManager LightManager;
|
||||
private int _insideColliderCount = 0;
|
||||
public static event Action touchDidChange;
|
||||
private int Area;
|
||||
private void Start()
|
||||
{
|
||||
Area = Convert.ToInt32(gameObject.name);
|
||||
lightManager = LightManager.GetComponent<LightManager>();
|
||||
}
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
_insideColliderCount += 1;
|
||||
Serial.SetTouch(Area, true);
|
||||
touchDidChange?.Invoke();
|
||||
lightManager.UpdateLightFade(Area, true);
|
||||
LightManager.UpdateLightFade(Area, true);
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
@@ -33,7 +31,7 @@ public class ColliderToSerial : MonoBehaviour
|
||||
{
|
||||
Serial.SetTouch(Area, false);
|
||||
touchDidChange?.Invoke();
|
||||
lightManager.UpdateLightFade(Area, false);
|
||||
LightManager.UpdateLightFade(Area, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user