rename sliderhandler, rest rotator on modelchange, add slop
This commit is contained in:
@@ -11417,7 +11417,7 @@ MonoBehaviour:
|
|||||||
modelManager: {fileID: 1519836175}
|
modelManager: {fileID: 1519836175}
|
||||||
uiButtonsCanvas: {fileID: 525196400}
|
uiButtonsCanvas: {fileID: 525196400}
|
||||||
cmsCanvas: {fileID: 1509914124}
|
cmsCanvas: {fileID: 1509914124}
|
||||||
sliderHandler: {fileID: 2108164463}
|
rotator: {fileID: 2108164463}
|
||||||
--- !u!1 &628967020
|
--- !u!1 &628967020
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -37131,7 +37131,7 @@ GameObject:
|
|||||||
- component: {fileID: 2108164464}
|
- component: {fileID: 2108164464}
|
||||||
- component: {fileID: 2108164463}
|
- component: {fileID: 2108164463}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: Slider
|
m_Name: RotatorSlider
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@@ -37171,7 +37171,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: a28b3692aca31b141907b971599c1e61, type: 3}
|
m_Script: {fileID: 11500000, guid: a28b3692aca31b141907b971599c1e61, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
basemodel: {fileID: 1272917964}
|
baseModel: {fileID: 1272917964}
|
||||||
rotationSlider: {fileID: 2108164464}
|
rotationSlider: {fileID: 2108164464}
|
||||||
joystickSpeed: 50
|
joystickSpeed: 50
|
||||||
--- !u!114 &2108164464
|
--- !u!114 &2108164464
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class StateManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Resettables ??= new List<IResettable>();
|
Resettables ??= new List<IResettable>();
|
||||||
Resettables.Clear();
|
Resettables.Clear();
|
||||||
|
//root GO = goot
|
||||||
foreach (var goot in SceneManager.GetActiveScene().GetRootGameObjects())
|
foreach (var goot in SceneManager.GetActiveScene().GetRootGameObjects())
|
||||||
{
|
{
|
||||||
Resettables.AddRange(goot.GetComponentsInChildren<IResettable>());
|
Resettables.AddRange(goot.GetComponentsInChildren<IResettable>());
|
||||||
|
|||||||
@@ -111,13 +111,13 @@ public class ModelManager : MonoBehaviour, IResettable
|
|||||||
//create if doesn't exist
|
//create if doesn't exist
|
||||||
if (baseModelGO == null)
|
if (baseModelGO == null)
|
||||||
{
|
{
|
||||||
Debug.Log($"Spawning BaseModelGO.");
|
Debug.LogError("Respawning BaseModelGO. Who destroyed it?");
|
||||||
baseModelGO = new GameObject(baseModel.NameId);
|
baseModelGO = new GameObject(baseModel.NameId);
|
||||||
baseModelGO.AddComponent<BaseModelBehaviour>();
|
baseModelGO.AddComponent<BaseModelBehaviour>();
|
||||||
baseModelGO.transform.position = new Vector3(0, 0, 1);
|
baseModelGO.transform.position = new Vector3(0, 0, 1);
|
||||||
baseModelGO.transform.localRotation = Quaternion.Euler(0, 90, 0);
|
baseModelGO.transform.localRotation = Quaternion.Euler(0, 90, 0);
|
||||||
baseModelGO.SetActive(true);
|
baseModelGO.SetActive(true);
|
||||||
Debug.Log($"Spawned BaseModelGO.");
|
Debug.LogWarning("Spawned BaseModelGO, this will break most likely");
|
||||||
}
|
}
|
||||||
baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
|
baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
|
||||||
baseModelGO.SetActive(true);
|
baseModelGO.SetActive(true);
|
||||||
|
|||||||
@@ -1,20 +1,18 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class SilderHandler : MonoBehaviour
|
//rotates y axis
|
||||||
|
public class Rotator : MonoBehaviour
|
||||||
{
|
{
|
||||||
public GameObject basemodel;
|
public GameObject baseModel;
|
||||||
public Slider rotationSlider;
|
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;
|
SetMinMaxRotation(model.Rotation);
|
||||||
if (basemodel == null)
|
|
||||||
Debug.LogError("SetBaseModel: Übergebenes Modell ist null!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
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;
|
Debug.LogError("Basemodel missing!");
|
||||||
z = basemodel.transform.eulerAngles.z;
|
return;
|
||||||
basemodel.transform.rotation = Quaternion.Euler(x, value, z);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("Basemodel ist nicht zugewiesen!");
|
|
||||||
}
|
}
|
||||||
|
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;
|
Vector3 euler = modelRotation.eulerAngles;
|
||||||
rotationSlider.minValue = eulerRotation.y;
|
rotationSlider.minValue = euler.y;
|
||||||
rotationSlider.maxValue = eulerRotation.y + 360f;
|
rotationSlider.maxValue = euler.y + 360f;
|
||||||
|
rotationSlider.value = rotationSlider.minValue; //reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
public ModelManager modelManager;
|
public ModelManager modelManager;
|
||||||
public GameObject uiButtonsCanvas;
|
public GameObject uiButtonsCanvas;
|
||||||
public GameObject cmsCanvas;
|
public GameObject cmsCanvas;
|
||||||
public SilderHandler sliderHandler;
|
public Rotator rotator;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -48,15 +48,11 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
}
|
}
|
||||||
modelManager.LoadSelectedModel(model);
|
modelManager.LoadSelectedModel(model);
|
||||||
|
|
||||||
if (sliderHandler != null && modelManager.baseModelGO != null)
|
if (rotator == null)
|
||||||
{
|
{
|
||||||
Debug.LogWarning("Setting BaseModel for SliderHandler");
|
Debug.LogWarning("Setting BaseModel for SliderHandler impossible; Handler: " + rotator);
|
||||||
sliderHandler.SetBaseModel(modelManager.baseModelGO);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogWarning("Setting BaseModel for SliderHandler geht nit: SliderHandler: " + sliderHandler + ", BaseModelGO: " + modelManager.baseModelGO);
|
|
||||||
}
|
}
|
||||||
|
rotator.LoadBaseModelConfig(model);
|
||||||
|
|
||||||
if (portSelector == null)
|
if (portSelector == null)
|
||||||
{
|
{
|
||||||
@@ -84,7 +80,6 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
Debug.LogError("CMS Canvas is null!");
|
Debug.LogError("CMS Canvas is null!");
|
||||||
}
|
}
|
||||||
cmsCanvas.SetActive(true);
|
cmsCanvas.SetActive(true);
|
||||||
sliderHandler.getRotation(model.Rotation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public void Activate()
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine.UI;
|
|
||||||
using Util;
|
|
||||||
|
|
||||||
public class PortSelector : MonoBehaviour, IResettable
|
public class PortSelector : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
public class Marker : MonoBehaviour
|
||||||
namespace Util
|
|
||||||
{
|
{
|
||||||
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