109 lines
2.1 KiB
C#
109 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace DebuggingEssentials
|
|
{
|
|
[Serializable]
|
|
public class WindowSettings
|
|
{
|
|
public List<Search> searchList;
|
|
|
|
public bool showSearchNonFound = true;
|
|
|
|
public bool search;
|
|
|
|
public Vector2 position;
|
|
|
|
public Rect rect;
|
|
|
|
public GUIChangeBool isDocked = new GUIChangeBool(value: false);
|
|
|
|
public bool isMinimized;
|
|
|
|
[NonSerialized]
|
|
public float newScrollViewY = -1f;
|
|
|
|
[NonSerialized]
|
|
public Vector2 scrollView;
|
|
|
|
[NonSerialized]
|
|
public Vector2 updatedScrollView;
|
|
|
|
[NonSerialized]
|
|
public int drag;
|
|
|
|
[NonSerialized]
|
|
public Rect rectStartScroll;
|
|
|
|
[NonSerialized]
|
|
public float scrollWindowPosY;
|
|
|
|
[NonSerialized]
|
|
public float culledSpaceY;
|
|
|
|
public void Update(float minWidth, float minHeight)
|
|
{
|
|
CheckMinMaxSize(minWidth, minHeight);
|
|
CalcRectPosition();
|
|
}
|
|
|
|
public void UpdateScrollView()
|
|
{
|
|
if (newScrollViewY != 0f)
|
|
{
|
|
scrollView.y = newScrollViewY;
|
|
newScrollViewY = 0f;
|
|
}
|
|
updatedScrollView = scrollView;
|
|
}
|
|
|
|
public void SetScrollViewToEnd(ScrollViewCullData cull)
|
|
{
|
|
scrollView.y = cull.scrollWindowPosY;
|
|
}
|
|
|
|
public bool IsScrollViewAtEnd(ScrollViewCullData cull)
|
|
{
|
|
return scrollView.y == cull.scrollWindowPosY;
|
|
}
|
|
|
|
public void CheckMinMaxSize(float minWidth, float minHeight)
|
|
{
|
|
if (rect.width < minWidth)
|
|
{
|
|
rect.width = minWidth;
|
|
}
|
|
else if (rect.width > (float)Screen.width)
|
|
{
|
|
rect.width = Screen.width;
|
|
}
|
|
if (rect.height < minHeight)
|
|
{
|
|
rect.height = minHeight;
|
|
}
|
|
else if (rect.height > (float)Screen.height)
|
|
{
|
|
rect.height = Screen.height;
|
|
}
|
|
position.x = Mathf.Clamp(position.x, 0.035f - rect.width / (float)Screen.width, 0.995f);
|
|
position.y = Mathf.Clamp(position.y, 0f, 0.995f);
|
|
}
|
|
|
|
public void CalcRectPosition()
|
|
{
|
|
rect.x = position.x * (float)Screen.width;
|
|
rect.y = position.y * (float)Screen.height;
|
|
}
|
|
|
|
public bool ContainsMousePos(Vector2 mousePos)
|
|
{
|
|
if (isMinimized)
|
|
{
|
|
return new Rect(rect.x, rect.y, rect.width, 30f).Contains(mousePos);
|
|
}
|
|
return rect.Contains(mousePos);
|
|
}
|
|
}
|
|
}
|