2022-06-09 21:36:15 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class SettingsManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
public double DefaultPhysicFPS = 90;
|
|
|
|
public double DefaultHandSize = 7;
|
2022-06-10 00:16:34 +02:00
|
|
|
public float[] DefaultHandPosition = {1f, 1f, -3f};
|
2022-06-09 21:36:15 +02:00
|
|
|
|
|
|
|
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();
|
2022-07-29 18:49:56 +02:00
|
|
|
Debug.Log("Configs Updated");
|
2022-06-09 21:36:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!Application.isFocused)
|
|
|
|
FocusChecked=false;
|
|
|
|
}
|
|
|
|
void UpdateAllConfigs()
|
|
|
|
{
|
2022-06-09 22:55:37 +02:00
|
|
|
JsonConfiguration.hasInitialized = false;
|
2022-06-09 21:36:15 +02:00
|
|
|
UwcConfig.UpdateConfigs();
|
|
|
|
UpdatePhysicFPS();
|
|
|
|
UpdateHands();
|
2022-07-29 18:49:56 +02:00
|
|
|
|
2022-06-09 21:36:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdatePhysicFPS()
|
|
|
|
{
|
|
|
|
if (!JsonConfiguration.HasKey("PhysicFPS"))
|
|
|
|
JsonConfiguration.SetDouble("PhysicFPS", DefaultPhysicFPS);
|
|
|
|
Time.fixedDeltaTime = 1/(float)JsonConfiguration.GetDouble("PhysicFPS");
|
|
|
|
}
|
|
|
|
|
2022-06-09 22:55:37 +02:00
|
|
|
static float HandSize;
|
|
|
|
static float[] HandPosition;
|
|
|
|
|
2022-06-09 21:36:15 +02:00
|
|
|
void UpdateHands()
|
|
|
|
{
|
|
|
|
if (!JsonConfiguration.HasKey("HandSize"))
|
|
|
|
JsonConfiguration.SetDouble("HandSize", DefaultHandSize);
|
|
|
|
if (!JsonConfiguration.HasKey("HandPosition"))
|
|
|
|
JsonConfiguration.SetFloatArray("HandPosition", DefaultHandPosition);
|
2022-06-09 22:55:37 +02:00
|
|
|
HandSize = (float)JsonConfiguration.GetDouble("HandSize");
|
|
|
|
HandPosition = JsonConfiguration.GetFloatArray("HandPosition");
|
2022-06-09 21:36:15 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|