diff --git a/vr-configurator/Assets/Scenes/SampleScene.unity b/vr-configurator/Assets/Scenes/SampleScene.unity index aadc17a..e3b07dc 100644 --- a/vr-configurator/Assets/Scenes/SampleScene.unity +++ b/vr-configurator/Assets/Scenes/SampleScene.unity @@ -11417,7 +11417,7 @@ MonoBehaviour: modelManager: {fileID: 1519836175} uiButtonsCanvas: {fileID: 525196400} cmsCanvas: {fileID: 1509914124} - sliderHandler: {fileID: 2108164463} + rotator: {fileID: 2108164463} --- !u!1 &628967020 GameObject: m_ObjectHideFlags: 0 @@ -37131,7 +37131,7 @@ GameObject: - component: {fileID: 2108164464} - component: {fileID: 2108164463} m_Layer: 0 - m_Name: Slider + m_Name: RotatorSlider m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -37171,7 +37171,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a28b3692aca31b141907b971599c1e61, type: 3} m_Name: m_EditorClassIdentifier: - basemodel: {fileID: 1272917964} + baseModel: {fileID: 1272917964} rotationSlider: {fileID: 2108164464} joystickSpeed: 50 --- !u!114 &2108164464 diff --git a/vr-configurator/Assets/Scripts/Managing/StateManager.cs b/vr-configurator/Assets/Scripts/Managing/StateManager.cs index 341ca2f..262fbf2 100644 --- a/vr-configurator/Assets/Scripts/Managing/StateManager.cs +++ b/vr-configurator/Assets/Scripts/Managing/StateManager.cs @@ -12,6 +12,7 @@ public class StateManager : MonoBehaviour { Resettables ??= new List(); Resettables.Clear(); + //root GO = goot foreach (var goot in SceneManager.GetActiveScene().GetRootGameObjects()) { Resettables.AddRange(goot.GetComponentsInChildren()); diff --git a/vr-configurator/Assets/Scripts/Models/ModelManager.cs b/vr-configurator/Assets/Scripts/Models/ModelManager.cs index 4ac3c33..5e86b50 100644 --- a/vr-configurator/Assets/Scripts/Models/ModelManager.cs +++ b/vr-configurator/Assets/Scripts/Models/ModelManager.cs @@ -111,13 +111,13 @@ public class ModelManager : MonoBehaviour, IResettable //create if doesn't exist if (baseModelGO == null) { - Debug.Log($"Spawning BaseModelGO."); + Debug.LogError("Respawning BaseModelGO. Who destroyed it?"); baseModelGO = new GameObject(baseModel.NameId); baseModelGO.AddComponent(); baseModelGO.transform.position = new Vector3(0, 0, 1); baseModelGO.transform.localRotation = Quaternion.Euler(0, 90, 0); baseModelGO.SetActive(true); - Debug.Log($"Spawned BaseModelGO."); + Debug.LogWarning("Spawned BaseModelGO, this will break most likely"); } baseModelGO.GetComponent().BaseModel = baseModel; baseModelGO.SetActive(true); diff --git a/vr-configurator/Assets/Scripts/UI/SilderHandler.cs b/vr-configurator/Assets/Scripts/Transform/Rotator.cs similarity index 57% rename from vr-configurator/Assets/Scripts/UI/SilderHandler.cs rename to vr-configurator/Assets/Scripts/Transform/Rotator.cs index 6940b9c..6c0ad77 100644 --- a/vr-configurator/Assets/Scripts/UI/SilderHandler.cs +++ b/vr-configurator/Assets/Scripts/Transform/Rotator.cs @@ -1,20 +1,18 @@ using UnityEngine; using UnityEngine.InputSystem; +using UnityEngine.Serialization; using UnityEngine.UI; -public class SilderHandler : MonoBehaviour +//rotates y axis +public class Rotator : MonoBehaviour { - public GameObject basemodel; + public GameObject baseModel; public Slider rotationSlider; - public float joystickSpeed = 400f; - - private float x, y, z; + public float joystickSpeed = 50f; - public void SetBaseModel(GameObject model) + public void LoadBaseModelConfig(BaseModel model) { - basemodel = model; - if (basemodel == null) - Debug.LogError("SetBaseModel: Übergebenes Modell ist null!"); + SetMinMaxRotation(model.Rotation); } void Start() @@ -50,24 +48,21 @@ public class SilderHandler : MonoBehaviour } } - private void OnSliderValueChanged(float value) + void OnSliderValueChanged(float value) { - if (basemodel != null) + if (baseModel == null) { - x = basemodel.transform.eulerAngles.x; - z = basemodel.transform.eulerAngles.z; - basemodel.transform.rotation = Quaternion.Euler(x, value, z); - } - else - { - Debug.LogError("Basemodel ist nicht zugewiesen!"); + Debug.LogError("Basemodel missing!"); + return; } + baseModel.transform.rotation = Quaternion.Euler(baseModel.transform.eulerAngles.x, value, baseModel.transform.eulerAngles.z); } - public void getRotation(Quaternion modelRotation) + void SetMinMaxRotation(Quaternion modelRotation) { - Vector3 eulerRotation = modelRotation.eulerAngles; - rotationSlider.minValue = eulerRotation.y; - rotationSlider.maxValue = eulerRotation.y + 360f; + Vector3 euler = modelRotation.eulerAngles; + rotationSlider.minValue = euler.y; + rotationSlider.maxValue = euler.y + 360f; + rotationSlider.value = rotationSlider.minValue; //reset } } \ No newline at end of file diff --git a/vr-configurator/Assets/Scripts/UI/SilderHandler.cs.meta b/vr-configurator/Assets/Scripts/Transform/Rotator.cs.meta similarity index 100% rename from vr-configurator/Assets/Scripts/UI/SilderHandler.cs.meta rename to vr-configurator/Assets/Scripts/Transform/Rotator.cs.meta diff --git a/vr-configurator/Assets/Scripts/UI/BaseModelSelector.cs b/vr-configurator/Assets/Scripts/UI/BaseModelSelector.cs index 36535a5..0c98d8e 100644 --- a/vr-configurator/Assets/Scripts/UI/BaseModelSelector.cs +++ b/vr-configurator/Assets/Scripts/UI/BaseModelSelector.cs @@ -12,7 +12,7 @@ public class BaseModelSelector : MonoBehaviour public ModelManager modelManager; public GameObject uiButtonsCanvas; public GameObject cmsCanvas; - public SilderHandler sliderHandler; + public Rotator rotator; void Start() { @@ -48,15 +48,11 @@ public class BaseModelSelector : MonoBehaviour } modelManager.LoadSelectedModel(model); - if (sliderHandler != null && modelManager.baseModelGO != null) + if (rotator == null) { - Debug.LogWarning("Setting BaseModel for SliderHandler"); - sliderHandler.SetBaseModel(modelManager.baseModelGO); - } - else - { - Debug.LogWarning("Setting BaseModel for SliderHandler geht nit: SliderHandler: " + sliderHandler + ", BaseModelGO: " + modelManager.baseModelGO); + Debug.LogWarning("Setting BaseModel for SliderHandler impossible; Handler: " + rotator); } + rotator.LoadBaseModelConfig(model); if (portSelector == null) { @@ -84,7 +80,6 @@ public class BaseModelSelector : MonoBehaviour Debug.LogError("CMS Canvas is null!"); } cmsCanvas.SetActive(true); - sliderHandler.getRotation(model.Rotation); } public void Activate() diff --git a/vr-configurator/Assets/Scripts/UI/PortSelector.cs b/vr-configurator/Assets/Scripts/UI/PortSelector.cs index a9546a3..c7a9a00 100644 --- a/vr-configurator/Assets/Scripts/UI/PortSelector.cs +++ b/vr-configurator/Assets/Scripts/UI/PortSelector.cs @@ -1,7 +1,5 @@ using UnityEngine; using System.Collections.Generic; -using UnityEngine.UI; -using Util; public class PortSelector : MonoBehaviour, IResettable { diff --git a/vr-configurator/Assets/Scripts/Util/Marker.cs b/vr-configurator/Assets/Scripts/Util/Marker.cs index f8ba759..189f805 100644 --- a/vr-configurator/Assets/Scripts/Util/Marker.cs +++ b/vr-configurator/Assets/Scripts/Util/Marker.cs @@ -1,9 +1,5 @@ using UnityEngine; - -namespace Util +public class Marker : MonoBehaviour { - public class Marker : MonoBehaviour - { - //this script doesn't do anything else than allow for getcomponentsinchildren to find a targeted feature - } + //this script doesn't do anything else than allow for getcomponentsinchildren to find a targeted feature } \ No newline at end of file