Skip to content
Snippets Groups Projects
Commit 1487f8b1 authored by eric.boise's avatar eric.boise Committed by Martins Mozeiko
Browse files

Fix resize on full screen visualization

parent 0a2e6bde
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,9 @@
*
*/
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
namespace Simulator.Sensors.UI
......@@ -46,6 +45,7 @@ namespace Simulator.Sensors.UI
private float headerAnchoredYPos = 0f;
private RectTransform rootRT;
private List<VisualizerWindowResize> windowResizers;
public WindowSizeType CurrentWindowSizeType { get; private set; } = WindowSizeType.Window;
......@@ -57,22 +57,25 @@ namespace Simulator.Sensors.UI
HeaderRT.gameObject.SetActive(false);
ContractTextGO.SetActive(false);
ExpandTextGO.SetActive(false);
windowSize = new Vector2(240f, 135f);
windowSize = new Vector2(Screen.width / 8f, Screen.height / 8f);
fullSize = new Vector2(Screen.width, Screen.height);
rt = GetComponent<RectTransform>();
rt.sizeDelta = windowSize;
headerAnchoredYPos = HeaderRT.anchoredPosition.y;
CurrentWindowSizeType = WindowSizeType.Window;
UpdateWindowSize((int)CurrentWindowSizeType);
CameraRawImage = CameraVisualGO.GetComponentInChildren<RawImage>();
cameraRT = CameraVisualGO.GetComponent<RectTransform>();
ValuesText = ValuesVisualGO.GetComponent<Text>();
fitter = CameraVisualGO.GetComponentInChildren<AspectRatioFitter>();
windowResizers = GetComponentsInChildren<VisualizerWindowResize>(true).ToList();
windowResizers.ForEach(win => win.gameObject.SetActive(true));
CameraVisualGO.SetActive(false);
ValuesVisualGO.SetActive(false);
UpdateWindowSize((int)CurrentWindowSizeType);
}
private void OnEnable()
{
ExitButton.onClick.AddListener(ExitButtonOnClick);
......@@ -161,6 +164,7 @@ namespace Simulator.Sensors.UI
HeaderRT.anchoredPosition = new Vector2(0f, headerAnchoredYPos);
ContractTextGO.SetActive(false);
ExpandTextGO.SetActive(true);
windowResizers.ForEach(win => win.gameObject.SetActive(true));
break;
case WindowSizeType.Full:
rt.sizeDelta = fullSize;
......@@ -168,6 +172,7 @@ namespace Simulator.Sensors.UI
HeaderRT.anchoredPosition = new Vector2(0f, -headerAnchoredYPos);
ContractTextGO.SetActive(true);
ExpandTextGO.SetActive(false);
windowResizers.ForEach(win => win.gameObject.SetActive(false));
break;
}
}
......
......@@ -6,25 +6,25 @@
*/
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using Simulator.Sensors.UI;
public class VisualizerWindowResize : MonoBehaviour, IPointerDownHandler, IDragHandler
{
public Vector2 minSize;
public Vector2 maxSize;
public RectTransform ParentRT;
private Vector3 currentPointerPosition;
private Vector3 previousPointerPosition;
public RectTransform headerRT;
private RectTransform rootRT;
public RectTransform headerRT;
private Vector3 currentPointerPosition;
private Vector3 previousPointerPosition;
private Vector2 minSize;
private Vector2 maxSize;
private void Awake()
{
minSize = new Vector2(Screen.width / 8f, Screen.height / 8f);
maxSize = new Vector2(Screen.width, Screen.height - headerRT.rect.max.y * 2f);
rootRT = SimulatorManager.Instance.UIManager.VisualizerCanvasGO.GetComponent<RectTransform>();
maxSize = new Vector2(Screen.width, Screen.height - headerRT.rect.max.y * 2);
}
public void OnPointerDown(PointerEventData data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment