rename sliderhandler, rest rotator on modelchange, add slop
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -12,6 +12,7 @@ public class StateManager : MonoBehaviour
|
||||
{
|
||||
Resettables ??= new List<IResettable>();
|
||||
Resettables.Clear();
|
||||
//root GO = goot
|
||||
foreach (var goot in SceneManager.GetActiveScene().GetRootGameObjects())
|
||||
{
|
||||
Resettables.AddRange(goot.GetComponentsInChildren<IResettable>());
|
||||
|
||||
@@ -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<BaseModelBehaviour>();
|
||||
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<BaseModelBehaviour>().BaseModel = baseModel;
|
||||
baseModelGO.SetActive(true);
|
||||
|
||||
@@ -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;
|
||||
public float joystickSpeed = 50f;
|
||||
|
||||
private float x, y, z;
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using Util;
|
||||
|
||||
public class PortSelector : MonoBehaviour, IResettable
|
||||
{
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user