Fix Slider
This commit is contained in:
@@ -26849,7 +26849,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1591058970}
|
||||
m_Enabled: 0
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||
m_Name:
|
||||
@@ -26910,7 +26910,7 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1591058970}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 2518c50cb3fc6a6458d4b743c2f69c7d, type: 3}
|
||||
m_Name:
|
||||
@@ -36785,8 +36785,9 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: a28b3692aca31b141907b971599c1e61, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
basemodel: {fileID: 645201570}
|
||||
basemodel: {fileID: 0}
|
||||
rotationSlider: {fileID: 2108164464}
|
||||
joystickSpeed: 50
|
||||
--- !u!114 &2108164464
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -48,6 +48,16 @@ public class BaseModelSelector : MonoBehaviour
|
||||
}
|
||||
modelManager.LoadSelectedModel(model);
|
||||
|
||||
if (sliderHandler != null && modelManager.baseModelGO != 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);
|
||||
}
|
||||
|
||||
if (portSelector == null)
|
||||
{
|
||||
Debug.LogError("PortSelector is null!");
|
||||
|
||||
@@ -1,43 +1,66 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SilderHandler : MonoBehaviour
|
||||
{
|
||||
public GameObject basemodel;
|
||||
public GameObject basemodel;
|
||||
public Slider rotationSlider;
|
||||
private float x;
|
||||
private float z;
|
||||
private float y;
|
||||
public float joystickSpeed = 50f;
|
||||
|
||||
private float x, y, z;
|
||||
|
||||
public void SetBaseModel(GameObject model)
|
||||
{
|
||||
basemodel = model;
|
||||
if (basemodel == null)
|
||||
Debug.LogError("SetBaseModel: Übergebenes Modell ist null!");
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (rotationSlider != null)
|
||||
{
|
||||
|
||||
rotationSlider.onValueChanged.AddListener(OnSliderValueChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("RotationSlider ist nicht zugewiesen!");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
float joystickInput = 0f;
|
||||
try
|
||||
{
|
||||
joystickInput = Input.GetAxis("Oculus_CrossPlatform_SecondaryThumbstickHorizontal");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Keine Achse vorhanden oder kein Controller angeschlossen
|
||||
joystickInput = 0f;
|
||||
}
|
||||
|
||||
if (Mathf.Abs(joystickInput) > 0.1f)
|
||||
{
|
||||
rotationSlider.value += joystickInput * joystickSpeed * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSliderValueChanged(float value)
|
||||
{
|
||||
if (basemodel != null)
|
||||
{
|
||||
x = basemodel.transform.eulerAngles.x;
|
||||
z = basemodel.transform.eulerAngles.z;
|
||||
basemodel.transform.rotation = Quaternion.Euler(x, value, z);
|
||||
basemodel.transform.rotation = Quaternion.Euler(x, value, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Basemodel ist nicht zugewiesen!");
|
||||
}
|
||||
}
|
||||
|
||||
public void getRotation(Quaternion modelRotation)
|
||||
{
|
||||
Vector3 eulerRotation = modelRotation.eulerAngles;
|
||||
rotationSlider.minValue = eulerRotation.y;
|
||||
rotationSlider.maxValue = eulerRotation.y + 360f;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user