diff --git a/Assets/Scenes/Main Scene.unity b/Assets/Scenes/Main Scene.unity index 554711a..e0322fe 100644 --- a/Assets/Scenes/Main Scene.unity +++ b/Assets/Scenes/Main Scene.unity @@ -455,7 +455,7 @@ Camera: m_FocalLength: 12 m_NormalizedViewPortRect: serializedVersion: 2 - x: 0.1 + x: 0 y: 0 width: 1 height: 1 @@ -464,7 +464,7 @@ Camera: field of view: 90 orthographic: 0 orthographic size: 5 - m_Depth: 0 + m_Depth: 1 m_CullingMask: serializedVersion: 2 m_Bits: 4294967295 @@ -707,7 +707,7 @@ Camera: m_TargetDisplay: 0 m_TargetEye: 3 m_HDR: 1 - m_AllowMSAA: 1 + m_AllowMSAA: 0 m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 @@ -2726,11 +2726,11 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 949242374} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -1.8799009, y: 0.5712118, z: 0.14460258} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &995594085 GameObject: @@ -3209,6 +3209,54 @@ Transform: m_Father: {fileID: 747929426} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!1 &1419342721 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1419342723} + - component: {fileID: 1419342722} + m_Layer: 0 + m_Name: Settings Manager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1419342722 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1419342721} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5826d7e028a40364c9d0e2514ceeee6b, type: 3} + m_Name: + m_EditorClassIdentifier: + LHandObj: {fileID: 1213452594} + RHandObj: {fileID: 995594085} + ScreenObj: {fileID: 856927129} + SmoothCameraObj: {fileID: 366364277} + XROriginObj: {fileID: 1647048262} +--- !u!4 &1419342723 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1419342721} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1522911141 stripped GameObject: m_CorrespondingSourceObject: {fileID: 7675345320277832881, guid: ea6463ca199d52046962b69f2ab654ef, type: 3} @@ -3292,50 +3340,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0} ---- !u!1 &1759784305 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1759784307} - - component: {fileID: 1759784306} - m_Layer: 0 - m_Name: JsonManager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1759784306 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1759784305} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 516380dd8af0ccd45940ea4a1bb8c942, type: 3} - m_Name: - m_EditorClassIdentifier: - JsonPath: ---- !u!4 &1759784307 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1759784305} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -12.495436, y: -1.1547682, z: -2.1243403} - m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] - m_Father: {fileID: 0} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1900118868 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/CameraFollow.cs b/Assets/Scripts/CameraSmooth.cs similarity index 88% rename from Assets/Scripts/CameraFollow.cs rename to Assets/Scripts/CameraSmooth.cs index f793583..d72cb27 100644 --- a/Assets/Scripts/CameraFollow.cs +++ b/Assets/Scripts/CameraSmooth.cs @@ -1,6 +1,6 @@ using UnityEngine; -public class CameraFollow : MonoBehaviour { +public class CameraSmooth : MonoBehaviour { public Transform target; public float smoothSpeed = 0.125f; diff --git a/Assets/Scripts/CameraFollow.cs.meta b/Assets/Scripts/CameraSmooth.cs.meta similarity index 100% rename from Assets/Scripts/CameraFollow.cs.meta rename to Assets/Scripts/CameraSmooth.cs.meta diff --git a/Assets/Scripts/SettingsManager.cs b/Assets/Scripts/SettingsManager.cs index b5bb4db..1baa42e 100644 --- a/Assets/Scripts/SettingsManager.cs +++ b/Assets/Scripts/SettingsManager.cs @@ -1,12 +1,13 @@ using System.IO; using UnityEngine; using Newtonsoft.Json; - +using Unity.XR.CoreUtils; +using uWindowCapture; public class SettingsManager : MonoBehaviour { - public string JsonPath; - public string JsonStr; - public Settings Setting = new Settings(); + string JsonPath; + string JsonStr; + Settings Setting = new Settings(); void Start() { JsonPath = Path.GetDirectoryName(Application.dataPath) + "/Settings.json"; @@ -16,8 +17,10 @@ public class SettingsManager : MonoBehaviour Settings Setting = new Settings() { HandSize = 8.5f, - //HandPosition = new Vector3(0.01f, -0.02f, 0.06f), - PlayerHigh = 1.7f, + HandPositionX = 1f, + HandPositionY = -2f, + HandPositionZ = 6f, + PlayerHigh = 170f, CaptureFrameRate = 90, TouchRefreshRate = 120, CameraSmooth = 0.1f, @@ -34,20 +37,62 @@ public class SettingsManager : MonoBehaviour Setting = JsonConvert.DeserializeObject(JsonStr); } } + bool FocusChecked = true; void Update() { - + if (Input.GetKeyDown(KeyCode.F5) | !FocusChecked) + { + if (Application.isFocused) + { + FocusChecked=true; + JsonStr = File.ReadAllText(JsonPath); + Setting = JsonConvert.DeserializeObject(JsonStr); + UpdateFromFile(); + Debug.Log("Setting Updated"); + } + } + if (!Application.isFocused) + FocusChecked=false; } + public GameObject LHandObj; + public GameObject RHandObj; + public GameObject ScreenObj; + public GameObject SmoothCameraObj; + public GameObject XROriginObj; + + void UpdateFromFile() + { + LHandObj.transform.localScale = new Vector3(Setting.HandSize/100,Setting.HandSize/100,Setting.HandSize/100); + RHandObj.transform.localScale = new Vector3(Setting.HandSize/100,Setting.HandSize/100,Setting.HandSize/100); + LHandObj.transform.localPosition = new Vector3(Setting.HandPositionX/100,Setting.HandPositionY/100,Setting.HandPositionZ/100); + RHandObj.transform.localPosition = new Vector3(Setting.HandPositionX/-100,Setting.HandPositionY/100,Setting.HandPositionZ/100); + XROrigin XROriginScp = XROriginObj.GetComponent(); + XROriginScp.CameraYOffset = Setting.PlayerHigh; + UwcWindowTexture ScreenScp = ScreenObj.GetComponent(); + ScreenScp.captureFrameRate = Setting.CaptureFrameRate; + CameraSmooth CameraSmoothScp = SmoothCameraObj.GetComponent(); + CameraSmoothScp.smoothSpeed = Setting.CameraSmooth; + Controller LHandScp = LHandObj.GetComponent(); + LHandScp.amplitude = Setting.HapticAmplitude; + Controller RHandScp = RHandObj.GetComponent(); + RHandScp.amplitude = Setting.HapticAmplitude; + XROriginScp.CameraYOffset = Setting.PlayerHigh/100; + Time.fixedDeltaTime = 1/Setting.TouchRefreshRate; + } + + } public class Settings { public float HandSize { get; set; } - //public Vector3 HandPosition { get; set; } + public float HandPositionX { get; set; } + public float HandPositionY { get; set; } + public float HandPositionZ { get; set; } public float PlayerHigh { get; set; } public int CaptureFrameRate { get; set; } public float TouchRefreshRate { get; set; } public float CameraSmooth { get; set; } public float HapticDuration { get; set; } public float HapticAmplitude { get; set; } -} +} \ No newline at end of file diff --git a/Settings.json b/Settings.json index 5dddc7e..c2bc386 100644 --- a/Settings.json +++ b/Settings.json @@ -1,6 +1,9 @@ { "HandSize": 8.5, - "PlayerHigh": 1.7, + "HandPositionX": 1, + "HandPositionY": -2, + "HandPositionZ": 6, + "PlayerHigh": 170, "CaptureFrameRate": 90, "TouchRefreshRate": 120.0, "CameraSmooth": 0.1,