2020-10-23 01:50:33 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.Core.Input;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
using System.IO;
|
2021-03-26 19:49:53 +11:00
|
|
|
|
using System.Diagnostics;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
namespace UnityExplorer.UI.Utility
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
public class PanelDragger
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
internal static List<PanelDragger> Instances = new List<PanelDragger>();
|
|
|
|
|
|
|
|
|
|
public static void UpdateInstances()
|
|
|
|
|
{
|
|
|
|
|
foreach (var instance in Instances)
|
|
|
|
|
instance.Update();
|
|
|
|
|
}
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
|
|
|
|
public RectTransform Panel { get; set; }
|
2021-04-15 20:18:03 +10:00
|
|
|
|
public event Action<RectTransform> OnFinishResize;
|
|
|
|
|
public event Action<RectTransform> OnFinishDrag;
|
|
|
|
|
|
|
|
|
|
private readonly RectTransform refCanvasTransform;
|
|
|
|
|
|
|
|
|
|
// Dragging
|
|
|
|
|
public RectTransform DragableArea { get; set; }
|
|
|
|
|
public bool WasDragging { get; set; }
|
|
|
|
|
private Vector3 m_lastDragPosition;
|
|
|
|
|
|
|
|
|
|
// Resizing
|
|
|
|
|
private const int RESIZE_THICKNESS = 10;
|
|
|
|
|
|
|
|
|
|
public GameObject m_resizeCursorObj;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2021-04-16 23:59:41 +10:00
|
|
|
|
internal readonly Vector2 minResize = new Vector2(200, 50);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
|
|
|
|
|
private bool WasResizing { get; set; }
|
|
|
|
|
private ResizeTypes m_currentResizeType = ResizeTypes.NONE;
|
|
|
|
|
private Vector2 m_lastResizePos;
|
|
|
|
|
|
|
|
|
|
private bool WasHoveringResize { get; set; }
|
|
|
|
|
private ResizeTypes m_lastResizeHoverType;
|
|
|
|
|
|
|
|
|
|
private Rect m_totalResizeRect;
|
2020-11-12 16:15:41 +11:00
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
public PanelDragger(RectTransform dragArea, RectTransform panelToDrag)
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
Instances.Add(this);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
DragableArea = dragArea;
|
|
|
|
|
Panel = panelToDrag;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
refCanvasTransform = Panel.GetComponentInParent<Canvas>().GetComponent<RectTransform>();
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
|
|
|
|
UpdateResizeCache();
|
2021-04-15 20:18:03 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Destroy()
|
|
|
|
|
{
|
|
|
|
|
if (m_resizeCursorObj)
|
|
|
|
|
GameObject.Destroy(m_resizeCursorObj);
|
2020-11-14 19:51:16 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
if (Instances.Contains(this))
|
|
|
|
|
Instances.Remove(this);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
if (!m_resizeCursorObj)
|
|
|
|
|
this.CreateCursorUI();
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 rawMousePos = InputManager.MousePosition;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-10-23 19:55:02 +11:00
|
|
|
|
ResizeTypes type;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 resizePos = Panel.InverseTransformPoint(rawMousePos);
|
2020-11-14 00:46:26 +11:00
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 dragPos = DragableArea.InverseTransformPoint(rawMousePos);
|
2020-11-14 00:46:26 +11:00
|
|
|
|
bool inDragPos = DragableArea.rect.Contains(dragPos);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
if (WasHoveringResize && m_resizeCursorObj)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
UpdateHoverImagePos();
|
|
|
|
|
|
|
|
|
|
// If Mouse pressed this frame
|
|
|
|
|
if (InputManager.GetMouseButtonDown(0))
|
|
|
|
|
{
|
2020-11-14 00:46:26 +11:00
|
|
|
|
if (inDragPos)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
OnBeginDrag();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (MouseInResizeArea(resizePos))
|
|
|
|
|
{
|
2020-10-23 19:55:02 +11:00
|
|
|
|
type = GetResizeType(resizePos);
|
|
|
|
|
if (type != ResizeTypes.NONE)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2020-10-23 19:55:02 +11:00
|
|
|
|
OnBeginResize(type);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If mouse still pressed from last frame
|
|
|
|
|
else if (InputManager.GetMouseButton(0))
|
|
|
|
|
{
|
|
|
|
|
if (WasDragging)
|
|
|
|
|
{
|
|
|
|
|
OnDrag();
|
|
|
|
|
}
|
|
|
|
|
else if (WasResizing)
|
|
|
|
|
{
|
|
|
|
|
OnResize();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// If mouse not pressed
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (WasDragging)
|
|
|
|
|
{
|
|
|
|
|
OnEndDrag();
|
|
|
|
|
}
|
|
|
|
|
else if (WasResizing)
|
|
|
|
|
{
|
|
|
|
|
OnEndResize();
|
|
|
|
|
}
|
2020-11-14 00:46:26 +11:00
|
|
|
|
else if (!inDragPos && MouseInResizeArea(resizePos) && (type = GetResizeType(resizePos)) != ResizeTypes.NONE)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
OnHoverResize(type);
|
|
|
|
|
}
|
2020-10-23 02:56:22 +11:00
|
|
|
|
else if (WasHoveringResize)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
OnHoverResizeEnd();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
#region DRAGGING
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
|
|
|
|
public void OnBeginDrag()
|
|
|
|
|
{
|
|
|
|
|
WasDragging = true;
|
|
|
|
|
m_lastDragPosition = InputManager.MousePosition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnDrag()
|
|
|
|
|
{
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 diff = InputManager.MousePosition - m_lastDragPosition;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
m_lastDragPosition = InputManager.MousePosition;
|
|
|
|
|
|
2021-03-31 01:42:32 +11:00
|
|
|
|
// update position while preserving the z value
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 pos = Panel.localPosition;
|
|
|
|
|
float z = pos.z;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
pos += diff;
|
|
|
|
|
pos.z = z;
|
|
|
|
|
Panel.localPosition = pos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnEndDrag()
|
|
|
|
|
{
|
|
|
|
|
WasDragging = false;
|
2021-03-31 01:42:32 +11:00
|
|
|
|
|
|
|
|
|
OnFinishDrag?.Invoke(Panel);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
#endregion
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
#region RESIZE
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-10-23 02:56:22 +11:00
|
|
|
|
private readonly Dictionary<ResizeTypes, Rect> m_resizeMask = new Dictionary<ResizeTypes, Rect>
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
2021-03-26 19:49:53 +11:00
|
|
|
|
{ ResizeTypes.Top, default },
|
|
|
|
|
{ ResizeTypes.Left, default },
|
|
|
|
|
{ ResizeTypes.Right, default },
|
|
|
|
|
{ ResizeTypes.Bottom, default },
|
2020-10-23 01:50:33 +11:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
public enum ResizeTypes
|
|
|
|
|
{
|
2020-10-28 06:39:26 +11:00
|
|
|
|
NONE = 0,
|
|
|
|
|
Top = 1,
|
|
|
|
|
Left = 2,
|
|
|
|
|
Right = 4,
|
|
|
|
|
Bottom = 8,
|
|
|
|
|
TopLeft = Top | Left,
|
|
|
|
|
TopRight = Top | Right,
|
|
|
|
|
BottomLeft = Bottom | Left,
|
2020-10-23 01:50:33 +11:00
|
|
|
|
BottomRight = Bottom | Right,
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-26 19:49:53 +11:00
|
|
|
|
private const int HALF_THICKESS = RESIZE_THICKNESS / 2;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
private const int DBL_THICKESS = RESIZE_THICKNESS * 2;
|
2021-03-26 19:49:53 +11:00
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
private void UpdateResizeCache()
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_totalResizeRect = new Rect(Panel.rect.x - RESIZE_THICKNESS + 1,
|
|
|
|
|
Panel.rect.y - RESIZE_THICKNESS + 1,
|
|
|
|
|
Panel.rect.width + DBL_THICKESS - 2,
|
|
|
|
|
Panel.rect.height + DBL_THICKESS - 2);
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
|
|
|
|
// calculate the four cross sections to use as flags
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeMask[ResizeTypes.Bottom] = new Rect(
|
|
|
|
|
m_totalResizeRect.x,
|
|
|
|
|
m_totalResizeRect.y,
|
|
|
|
|
m_totalResizeRect.width,
|
|
|
|
|
RESIZE_THICKNESS);
|
|
|
|
|
|
|
|
|
|
m_resizeMask[ResizeTypes.Left] = new Rect(
|
|
|
|
|
m_totalResizeRect.x,
|
|
|
|
|
m_totalResizeRect.y,
|
|
|
|
|
RESIZE_THICKNESS,
|
|
|
|
|
m_totalResizeRect.height);
|
|
|
|
|
|
|
|
|
|
m_resizeMask[ResizeTypes.Top] = new Rect(
|
|
|
|
|
m_totalResizeRect.x,
|
|
|
|
|
Panel.rect.y + Panel.rect.height - 2,
|
|
|
|
|
m_totalResizeRect.width,
|
|
|
|
|
RESIZE_THICKNESS);
|
|
|
|
|
|
|
|
|
|
m_resizeMask[ResizeTypes.Right] = new Rect(
|
|
|
|
|
m_totalResizeRect.x + Panel.rect.width + RESIZE_THICKNESS - 2,
|
|
|
|
|
m_totalResizeRect.y,
|
|
|
|
|
RESIZE_THICKNESS,
|
|
|
|
|
m_totalResizeRect.height);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool MouseInResizeArea(Vector2 mousePos)
|
2020-10-23 02:56:22 +11:00
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
return m_totalResizeRect.Contains(mousePos);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ResizeTypes GetResizeType(Vector2 mousePos)
|
|
|
|
|
{
|
2020-10-23 02:56:22 +11:00
|
|
|
|
// Calculate which part of the resize area we're in, if any.
|
2021-03-26 19:49:53 +11:00
|
|
|
|
// More readable method commented out below.
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-03-26 19:49:53 +11:00
|
|
|
|
int mask = 0;
|
|
|
|
|
mask |= (int)ResizeTypes.Top * (m_resizeMask[ResizeTypes.Top].Contains(mousePos) ? 1 : 0);
|
|
|
|
|
mask |= (int)ResizeTypes.Bottom * (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos) ? 1 : 0);
|
|
|
|
|
mask |= (int)ResizeTypes.Left * (m_resizeMask[ResizeTypes.Left].Contains(mousePos) ? 1 : 0);
|
|
|
|
|
mask |= (int)ResizeTypes.Right * (m_resizeMask[ResizeTypes.Right].Contains(mousePos) ? 1 : 0);
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-03-26 19:49:53 +11:00
|
|
|
|
//if (m_resizeMask[ResizeTypes.Top].Contains(mousePos))
|
|
|
|
|
// mask |= ResizeTypes.Top;
|
|
|
|
|
//else if (m_resizeMask[ResizeTypes.Bottom].Contains(mousePos))
|
|
|
|
|
// mask |= ResizeTypes.Bottom;
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-03-26 19:49:53 +11:00
|
|
|
|
//if (m_resizeMask[ResizeTypes.Left].Contains(mousePos))
|
|
|
|
|
// mask |= ResizeTypes.Left;
|
|
|
|
|
//else if (m_resizeMask[ResizeTypes.Right].Contains(mousePos))
|
|
|
|
|
// mask |= ResizeTypes.Right;
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-03-26 19:49:53 +11:00
|
|
|
|
return (ResizeTypes)mask;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnHoverResize(ResizeTypes resizeType)
|
|
|
|
|
{
|
2020-10-23 02:56:22 +11:00
|
|
|
|
if (WasHoveringResize && m_lastResizeHoverType == resizeType)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
return;
|
2020-10-28 20:52:40 +11:00
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
// we are entering resize, or the resize type has changed.
|
|
|
|
|
|
2020-10-23 02:56:22 +11:00
|
|
|
|
WasHoveringResize = true;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
m_lastResizeHoverType = resizeType;
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeCursorObj.SetActive(true);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-10-23 02:56:22 +11:00
|
|
|
|
// set the rotation for the resize icon
|
|
|
|
|
float iconRotation = 0f;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
switch (resizeType)
|
|
|
|
|
{
|
|
|
|
|
case ResizeTypes.TopRight:
|
|
|
|
|
case ResizeTypes.BottomLeft:
|
2020-10-23 02:56:22 +11:00
|
|
|
|
iconRotation = 45f; break;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
case ResizeTypes.Top:
|
|
|
|
|
case ResizeTypes.Bottom:
|
2020-10-23 02:56:22 +11:00
|
|
|
|
iconRotation = 90f; break;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
case ResizeTypes.TopLeft:
|
|
|
|
|
case ResizeTypes.BottomRight:
|
2020-10-23 02:56:22 +11:00
|
|
|
|
iconRotation = 135f; break;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
Quaternion rot = m_resizeCursorObj.transform.rotation;
|
2020-10-23 02:56:22 +11:00
|
|
|
|
rot.eulerAngles = new Vector3(0, 0, iconRotation);
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeCursorObj.transform.rotation = rot;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
|
|
|
|
UpdateHoverImagePos();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-23 02:56:22 +11:00
|
|
|
|
// update the resize icon position to be above the mouse
|
|
|
|
|
private void UpdateHoverImagePos()
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeCursorObj.transform.localPosition = refCanvasTransform.InverseTransformPoint(InputManager.MousePosition);
|
2020-10-23 02:56:22 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
public void OnHoverResizeEnd()
|
|
|
|
|
{
|
2020-10-23 02:56:22 +11:00
|
|
|
|
WasHoveringResize = false;
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeCursorObj.SetActive(false);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnBeginResize(ResizeTypes resizeType)
|
|
|
|
|
{
|
|
|
|
|
m_currentResizeType = resizeType;
|
2020-10-23 02:56:22 +11:00
|
|
|
|
m_lastResizePos = InputManager.MousePosition;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
WasResizing = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnResize()
|
|
|
|
|
{
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Vector3 mousePos = InputManager.MousePosition;
|
|
|
|
|
Vector2 diff = m_lastResizePos - (Vector2)mousePos;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
|
|
|
|
if ((Vector2)mousePos == m_lastResizePos)
|
|
|
|
|
return;
|
|
|
|
|
|
2020-10-23 02:56:22 +11:00
|
|
|
|
m_lastResizePos = mousePos;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
float diffX = (float)((decimal)diff.x / Screen.width);
|
|
|
|
|
float diffY = (float)((decimal)diff.y / Screen.height);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
Vector2 anchorMin = Panel.anchorMin;
|
|
|
|
|
Vector2 anchorMax = Panel.anchorMax;
|
|
|
|
|
|
2020-10-23 01:50:33 +11:00
|
|
|
|
if (m_currentResizeType.HasFlag(ResizeTypes.Left))
|
2020-11-06 20:42:16 +11:00
|
|
|
|
anchorMin.x -= diffX;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
else if (m_currentResizeType.HasFlag(ResizeTypes.Right))
|
2020-11-06 20:42:16 +11:00
|
|
|
|
anchorMax.x -= diffX;
|
2020-10-23 01:50:33 +11:00
|
|
|
|
|
|
|
|
|
if (m_currentResizeType.HasFlag(ResizeTypes.Top))
|
2020-11-06 20:42:16 +11:00
|
|
|
|
anchorMax.y -= diffY;
|
|
|
|
|
else if (m_currentResizeType.HasFlag(ResizeTypes.Bottom))
|
|
|
|
|
anchorMin.y -= diffY;
|
|
|
|
|
|
2021-04-16 23:59:41 +10:00
|
|
|
|
var prevMin = Panel.anchorMin;
|
|
|
|
|
var prevMax = Panel.anchorMax;
|
|
|
|
|
|
2020-11-16 21:21:04 +11:00
|
|
|
|
Panel.anchorMin = new Vector2(anchorMin.x, anchorMin.y);
|
|
|
|
|
Panel.anchorMax = new Vector2(anchorMax.x, anchorMax.y);
|
2020-11-14 19:51:16 +11:00
|
|
|
|
|
2021-04-16 23:59:41 +10:00
|
|
|
|
if (Panel.rect.width < minResize.x)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
2021-04-16 23:59:41 +10:00
|
|
|
|
Panel.anchorMin = new Vector2(prevMin.x, Panel.anchorMin.y);
|
|
|
|
|
Panel.anchorMax = new Vector2(prevMax.x, Panel.anchorMax.y);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
2021-04-16 23:59:41 +10:00
|
|
|
|
if (Panel.rect.height < minResize.y)
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
2021-04-16 23:59:41 +10:00
|
|
|
|
Panel.anchorMin = new Vector2(Panel.anchorMin.x, prevMin.y);
|
|
|
|
|
Panel.anchorMax = new Vector2(Panel.anchorMax.x, prevMax.y);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
public void OnEndResize()
|
2020-10-23 01:50:33 +11:00
|
|
|
|
{
|
|
|
|
|
WasResizing = false;
|
|
|
|
|
UpdateResizeCache();
|
2021-03-30 19:50:04 +11:00
|
|
|
|
OnFinishResize?.Invoke(Panel);
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
internal void CreateCursorUI()
|
2020-10-23 02:56:22 +11:00
|
|
|
|
{
|
2020-10-28 20:52:40 +11:00
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-15 20:18:03 +10:00
|
|
|
|
var text = UIFactory.CreateLabel(refCanvasTransform.gameObject, "ResizeCursor", "↔", TextAnchor.MiddleCenter, Color.white, true, 35);
|
|
|
|
|
m_resizeCursorObj = text.gameObject;
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
RectTransform rect = m_resizeCursorObj.GetComponent<RectTransform>();
|
2021-03-26 19:49:53 +11:00
|
|
|
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 64);
|
|
|
|
|
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 64);
|
2020-10-23 02:56:22 +11:00
|
|
|
|
|
2021-04-15 20:18:03 +10:00
|
|
|
|
m_resizeCursorObj.SetActive(false);
|
2020-10-28 20:52:40 +11:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
2021-03-30 19:50:04 +11:00
|
|
|
|
ExplorerCore.LogWarning("Exception creating Resize Cursor UI!\r\n" + e.ToString());
|
2020-10-28 20:52:40 +11:00
|
|
|
|
}
|
2020-10-23 02:56:22 +11:00
|
|
|
|
}
|
|
|
|
|
|
2020-10-28 06:39:26 +11:00
|
|
|
|
#endregion
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|
2020-11-16 21:21:04 +11:00
|
|
|
|
|
|
|
|
|
// Just to allow Enum to do .HasFlag() in NET 3.5
|
|
|
|
|
public static class Net35FlagsEx
|
|
|
|
|
{
|
|
|
|
|
public static bool HasFlag(this Enum flags, Enum value)
|
|
|
|
|
{
|
|
|
|
|
ulong num = Convert.ToUInt64(value);
|
|
|
|
|
return (Convert.ToUInt64(flags) & num) == num;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-23 01:50:33 +11:00
|
|
|
|
}
|