1
0
mirror of synced 2024-11-27 23:50:50 +01:00

added a height adjuster

This commit is contained in:
FizzyApple12 2022-06-03 00:15:11 -04:00
parent 85d858c313
commit 287248c0b8
6 changed files with 1420 additions and 40 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,87 @@
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 (PlayerPrefs.HasKey("Height")) height = PlayerPrefs.GetFloat("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() {
PlayerPrefs.SetFloat("Height", (float) height);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 46aeec2d43d72c84a808e47673b6177f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,6 @@
{
"dependencies": {
"com.hecomi.uwindowcapture": "https://github.com/hecomi/uWindowCapture.git#upm",
"com.unity.collab-proxy": "1.15.17",
"com.unity.ide.rider": "3.0.13",
"com.unity.ide.visualstudio": "2.0.15",

View File

@ -1,5 +1,12 @@
{
"dependencies": {
"com.hecomi.uwindowcapture": {
"version": "https://github.com/hecomi/uWindowCapture.git#upm",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "0412fe09e11d3720197707a935f8114cc2454639"
},
"com.unity.burst": {
"version": "1.6.5",
"depth": 1,

View File

@ -19,7 +19,7 @@ MonoBehaviour:
width: 1536
height: 772.8
m_ShowMode: 4
m_Title: Project
m_Title: Inspector
m_RootView: {fileID: 4}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@ -74,7 +74,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 945
controlID: 106
--- !u!114 &4
MonoBehaviour:
m_ObjectHideFlags: 52
@ -124,7 +124,7 @@ MonoBehaviour:
height: 30
m_MinSize: {x: 0, y: 0}
m_MaxSize: {x: 0, y: 0}
m_LastLoadedLayoutName: 2 by 3
m_LastLoadedLayoutName:
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@ -150,7 +150,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 913
controlID: 323
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
@ -196,7 +196,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 940
controlID: 151
--- !u!114 &9
MonoBehaviour:
m_ObjectHideFlags: 52
@ -269,8 +269,8 @@ MonoBehaviour:
y: 0
width: 725.6
height: 371.2
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 18}
m_Panes:
- {fileID: 18}
@ -295,8 +295,8 @@ MonoBehaviour:
y: 371.2
width: 725.6
height: 351.59998
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 17}
m_Panes:
- {fileID: 17}
@ -365,23 +365,23 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 6423ffff6824ffff2c27ffff7898ffffc2e00000d8e40000fee60000
m_ExpandedIDs: aaa6ffffaea7ffff82aaffff90efffff30fbffffea7300001a750000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
m_OriginalName:
m_Name: Reset
m_OriginalName: Reset
m_EditFieldRect:
serializedVersion: 2
x: 0
y: 0
width: 0
height: 0
m_UserData: 0
m_UserData: -4208
m_IsWaitingForDelay: 0
m_IsRenaming: 0
m_OriginalEventType: 11
m_OriginalEventType: 0
m_IsRenamingFilename: 0
m_ClientGUIView: {fileID: 0}
m_ClientGUIView: {fileID: 9}
m_SearchString:
m_ExpandedScenes: []
m_CurrenRootInstanceID: 0
@ -473,22 +473,22 @@ MonoBehaviour:
m_SkipHidden: 0
m_SearchArea: 1
m_Folders:
- Assets/uWindowCapture
- Assets/Script
m_Globs: []
m_OriginalText:
m_ViewMode: 1
m_StartGridSize: 64
m_LastFolders:
- Assets/uWindowCapture
- Assets/Script
m_LastFoldersGridSize: -1
m_LastProjectPath: C:\Users\FizzyApple12\Desktop\WACVR
m_LockTracker:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 138.20001}
m_SelectedIDs: 2ee00000
m_LastClickedID: 57390
m_ExpandedIDs: 0000000016e000002ee00000ceed000000ca9a3b
scrollPos: {x: 0, y: 82.20001}
m_SelectedIDs: 18810000
m_LastClickedID: 33048
m_ExpandedIDs: 00000000fe80000000810000028100000481000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -516,7 +516,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000016e0000000ca9a3b
m_ExpandedIDs: 00000000fe800000008100000281000004810000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -543,7 +543,7 @@ MonoBehaviour:
m_ListAreaState:
m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1
m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs:
m_RenameOverlay:
m_UserAcceptedRename: 0
@ -568,10 +568,10 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_NewAssetIndexInList: -1
m_ScrollPosition: {x: 0, y: 13.200012}
m_ScrollPosition: {x: 0, y: 0}
m_GridSize: 64
m_SkipHiddenPackages: 0
m_DirectoriesAreaWidth: 115
m_DirectoriesAreaWidth: 161
--- !u!114 &17
MonoBehaviour:
m_ObjectHideFlags: 52
@ -663,7 +663,7 @@ MonoBehaviour:
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 00000000000000000000
m_XRRenderMode: 0
m_XRRenderMode: -1
m_RenderTexture: {fileID: 0}
--- !u!114 &18
MonoBehaviour:
@ -891,9 +891,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 0.9642745, y: 0.58841795, z: 2.890922}
m_Target: {x: 4.9885635, y: 0.65081775, z: 1.799812}
speed: 2
m_Value: {x: 0.9642745, y: 0.58841795, z: 2.890922}
m_Value: {x: 4.9885635, y: 0.65081775, z: 1.799812}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@ -940,13 +940,13 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: 0.10625741, y: 0.18266892, z: -0.019862695, w: 0.97721505}
m_Target: {x: 0.02845645, y: 0.5192402, z: -0.017302273, w: 0.8539866}
speed: 2
m_Value: {x: 0.10479134, y: 0.1826983, z: -0.019588644, w: 0.97737217}
m_Value: {x: 0.028456269, y: 0.5192369, z: -0.017302163, w: 0.8539812}
m_Size:
m_Target: 1.9749055
m_Target: 2.6252074
speed: 2
m_Value: 1.9749055
m_Value: 2.6252074
m_Ortho:
m_Target: 0
speed: 2