Add Hand Configs and change hand ball color
This commit is contained in:
@@ -83,6 +83,13 @@ public static class JsonConfiguration {
|
||||
|
||||
saveFile();
|
||||
}
|
||||
public static void SetFloatArray(string key, float[] numbers) {
|
||||
ensureInitialization();
|
||||
|
||||
config[key] = JArray.FromObject(numbers);
|
||||
|
||||
saveFile();
|
||||
}
|
||||
|
||||
public static bool GetBoolean(string key) {
|
||||
ensureInitialization();
|
||||
@@ -104,4 +111,9 @@ public static class JsonConfiguration {
|
||||
|
||||
return config.Value<double>(key);
|
||||
}
|
||||
public static float[] GetFloatArray(string key) {
|
||||
ensureInitialization();
|
||||
|
||||
return config.Value<float[]>(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SettingsManager : MonoBehaviour
|
||||
{
|
||||
public double DefaultPhysicFPS = 90;
|
||||
public double DefaultHandSize = 7;
|
||||
public float[] DefaultHandPosition = {2f, -2f, 7f};
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
if (!Application.isFocused)
|
||||
FocusChecked=false;
|
||||
}
|
||||
void UpdateAllConfigs()
|
||||
{
|
||||
UwcConfig.UpdateConfigs();
|
||||
UpdatePhysicFPS();
|
||||
UpdateHands();
|
||||
}
|
||||
|
||||
void UpdatePhysicFPS()
|
||||
{
|
||||
if (!JsonConfiguration.HasKey("PhysicFPS"))
|
||||
JsonConfiguration.SetDouble("PhysicFPS", DefaultPhysicFPS);
|
||||
Time.fixedDeltaTime = 1/(float)JsonConfiguration.GetDouble("PhysicFPS");
|
||||
}
|
||||
|
||||
void UpdateHands()
|
||||
{
|
||||
if (!JsonConfiguration.HasKey("HandSize"))
|
||||
JsonConfiguration.SetDouble("HandSize", DefaultHandSize);
|
||||
if (!JsonConfiguration.HasKey("HandPosition"))
|
||||
JsonConfiguration.SetFloatArray("HandPosition", DefaultHandPosition);
|
||||
float HandSize = (float)JsonConfiguration.GetDouble("HandSize");
|
||||
float[] 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,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a76604ac77e1add42b84974256adc28e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user