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: a76604ac77e1add42b84974256adc28e
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0559825455822d48a37fc54c6dfd318
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class LocomotionStatus : MonoBehaviour
|
||||
{
|
||||
private TextMeshPro text;
|
||||
void Start()
|
||||
{
|
||||
text = GetComponent<TextMeshPro>();
|
||||
UpdateText(LocomotionToggle.IsEnabled);
|
||||
}
|
||||
|
||||
public void UpdateText(bool status)
|
||||
{
|
||||
text.text = "Locomotion: " + (status ? "Enabled" : "Disabled");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 351fc1d968d436d44b431f42a0570812
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class LocomotionToggle : MonoBehaviour
|
||||
{
|
||||
[System.Serializable]
|
||||
public class LocomotionToggleEvent : UnityEvent<bool> { }
|
||||
|
||||
public static bool IsEnabled
|
||||
{
|
||||
get { return _state; }
|
||||
}
|
||||
private static bool _state = true;
|
||||
|
||||
private float timer = 0;
|
||||
private bool actionDone = false;
|
||||
|
||||
private bool leftHeld = false;
|
||||
private bool rightHeld = false;
|
||||
|
||||
public LocomotionToggleEvent locoEvent;
|
||||
|
||||
private AudioClip soundOn;
|
||||
private AudioClip soundOff;
|
||||
private AudioSource audioSrc;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField]
|
||||
private float holdTime;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField]
|
||||
private GameObject locomotionController;
|
||||
[SerializeField]
|
||||
private InputActionProperty leftHandAction;
|
||||
[SerializeField]
|
||||
private InputActionProperty rightHandAction;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if (locoEvent == null)
|
||||
locoEvent = new LocomotionToggleEvent();
|
||||
|
||||
audioSrc = GetComponent<AudioSource>();
|
||||
soundOn = Resources.Load<AudioClip>("Audio/loco on");
|
||||
soundOff = Resources.Load<AudioClip>("Audio/loco off");
|
||||
|
||||
leftHandAction.action.Enable();
|
||||
rightHandAction.action.Enable();
|
||||
|
||||
leftHandAction.action.started +=
|
||||
(InputAction.CallbackContext _) => leftHeld = true;
|
||||
leftHandAction.action.canceled +=
|
||||
(InputAction.CallbackContext _) => leftHeld = false;
|
||||
rightHandAction.action.started +=
|
||||
(InputAction.CallbackContext _) => rightHeld = true;
|
||||
rightHandAction.action.canceled +=
|
||||
(InputAction.CallbackContext _) => rightHeld = false;
|
||||
|
||||
locomotionController.SetActive(_state);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (leftHeld && rightHeld)
|
||||
{
|
||||
timer += Time.unscaledDeltaTime;
|
||||
if (timer >= holdTime && !actionDone)
|
||||
{
|
||||
_state = !_state;
|
||||
locoEvent.Invoke(_state);
|
||||
locomotionController.SetActive(_state);
|
||||
actionDone = true;
|
||||
|
||||
audioSrc.clip = _state ? soundOn : soundOff;
|
||||
audioSrc.Play();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timer = 0;
|
||||
actionDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e28739818e0aced4fbf1afd49f82dcff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,91 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[RequireComponent(typeof(AudioSource))]
|
||||
public class PanelHiderButton : MonoBehaviour
|
||||
{
|
||||
private int colliderCount = 0;
|
||||
private bool isLocked = false;
|
||||
private float timer = 0f;
|
||||
private bool actionTaken = false;
|
||||
private Renderer r;
|
||||
|
||||
[Header("Settings")]
|
||||
[SerializeField]
|
||||
private float holdTime = 1f;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField]
|
||||
private RawImage statusImg;
|
||||
[SerializeField]
|
||||
private Image timerRing;
|
||||
[SerializeField]
|
||||
private List<GameObject> panelButtons;
|
||||
|
||||
[Header("Assets")]
|
||||
[SerializeField]
|
||||
private Texture lockImg;
|
||||
[SerializeField]
|
||||
private Texture unlockImg;
|
||||
[SerializeField]
|
||||
private AudioClip lockSound;
|
||||
[SerializeField]
|
||||
private AudioClip unlockSound;
|
||||
|
||||
private AudioSource audioSrc;
|
||||
private void Start()
|
||||
{
|
||||
audioSrc = GetComponent<AudioSource>();
|
||||
r = GetComponent<Renderer>();
|
||||
statusImg.texture = isLocked ? lockImg : unlockImg;
|
||||
audioSrc.clip = lockSound;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider _)
|
||||
{
|
||||
r.material.color = Color.white;
|
||||
++colliderCount;
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider _)
|
||||
{
|
||||
r.material.color = Color.gray;
|
||||
colliderCount = Mathf.Clamp(colliderCount - 1, 0, colliderCount);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (colliderCount >= 1)
|
||||
{
|
||||
timer += Time.unscaledDeltaTime;
|
||||
float ratio = Mathf.Clamp(timer, 0, holdTime) / holdTime;
|
||||
|
||||
timerRing.fillAmount = Mathf.Pow(ratio, 3f);
|
||||
|
||||
if (ratio >= 1 && !actionTaken)
|
||||
{
|
||||
isLocked = !isLocked;
|
||||
|
||||
foreach (var btn in panelButtons)
|
||||
{
|
||||
btn.SetActive(!isLocked);
|
||||
}
|
||||
actionTaken = true;
|
||||
|
||||
timerRing.color = Color.cyan;
|
||||
statusImg.texture = isLocked ? lockImg : unlockImg;
|
||||
|
||||
audioSrc.clip = isLocked ? lockSound : unlockSound;
|
||||
audioSrc.Play();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
timer = 0;
|
||||
timerRing.fillAmount = 0;
|
||||
timerRing.color = Color.white;
|
||||
actionTaken = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5ce728dbf8b0e54e880d703d5c18eba
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
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 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;
|
||||
public GameObject Room;
|
||||
|
||||
[SerializeField]
|
||||
private List<Material> skyboxes;
|
||||
[SerializeField]
|
||||
private int currentSkyboxIndex = 0;
|
||||
|
||||
void Start()
|
||||
{
|
||||
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);
|
||||
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.png"));
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.jpg"));
|
||||
imageFiles.AddRange(skyboxDir.GetFiles("*.jpeg"));
|
||||
//List<FileInfo> hdrFiles = new List<FileInfo>();
|
||||
//hdrFiles.AddRange(skyboxDir.GetFiles("*.hdr"));
|
||||
//hdrFiles.AddRange(skyboxDir.GetFiles("*.hdri"));
|
||||
//hdrFiles.AddRange(skyboxDir.GetFiles("*.exr"));
|
||||
|
||||
foreach (var file in imageFiles) // Typical image files
|
||||
{
|
||||
var uwr = UnityWebRequestTexture.GetTexture(file.ToString());
|
||||
yield return uwr.SendWebRequest();
|
||||
if (uwr.result == UnityWebRequest.Result.ConnectionError)
|
||||
{
|
||||
Debug.LogWarning($"Couldn't load skybox texture at {uwr.uri}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var skyboxMat = new Material(Shader.Find("Skybox/Panoramic"));
|
||||
skyboxMat.SetFloat("_Rotation", 45f);
|
||||
var texture = DownloadHandlerTexture.GetContent(uwr);
|
||||
if (texture != null)
|
||||
{
|
||||
skyboxMat.SetTexture("_MainTex", texture);
|
||||
skyboxes.Add(skyboxMat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetSkybox();
|
||||
//foreach (var file in hdrFiles) // HDR files -- no way to use by scripting?
|
||||
//{
|
||||
// var uwr = UnityWebRequest.Get(file.ToString());
|
||||
// yield return uwr.SendWebRequest();
|
||||
// if (uwr.result == UnityWebRequest.Result.ConnectionError)
|
||||
// {
|
||||
// Debug.Log($"Had trouble loading file {uwr.uri}.");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// byte[] data = uwr.downloadHandler.data;
|
||||
// if (data != null)
|
||||
// {
|
||||
// GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
// IntPtr pointer = pinnedArray.AddrOfPinnedObject();
|
||||
|
||||
// var cubemap = Cubemap.CreateExternalTexture(2200, TextureFormat.DXT5, false, pointer);
|
||||
// var skyboxMat = new Material(Shader.Find("Skybox/Panoramic"));
|
||||
// skyboxMat.SetTexture("_Tex", cubemap);
|
||||
// skyboxes.Add(skyboxMat);
|
||||
|
||||
// pinnedArray.Free();
|
||||
// }
|
||||
// // FIXME: convert Texture2D to Cubemap
|
||||
// //textures.Add(texture);
|
||||
// //ptrs.Add(texture.GetNativeTexturePtr());
|
||||
// //texture = textures[textures.Count - 1];
|
||||
// //var cubemap = Cubemap.CreateExternalTexture(texture.width, texture.format, false, texture.GetNativeTexturePtr());
|
||||
// //skyboxMat.SetTexture("_Tex", cubemap);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void SetSkybox()
|
||||
{
|
||||
if (currentSkyboxIndex < skyboxes.Count && skyboxes[currentSkyboxIndex] != null)
|
||||
RenderSettings.skybox = skyboxes[currentSkyboxIndex];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9d7372274e9214429d55ed4ef283584
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
Reference in New Issue
Block a user