mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
Improvements to editor objects
This commit is contained in:
parent
ed8b3a6db8
commit
dea5860e95
5 changed files with 127 additions and 92 deletions
|
@ -1121,22 +1121,6 @@ MonoBehaviour:
|
|||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- eventID: 3
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 798021450}
|
||||
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp
|
||||
m_MethodName: OnRightUp
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- eventID: 0
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
|
@ -1946,7 +1930,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &321288860
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -3712,7 +3696,19 @@ MonoBehaviour:
|
|||
m_TargetGraphic: {fileID: 678553527}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 1423699437}
|
||||
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.Editor, Assembly-CSharp
|
||||
m_MethodName: DebugSave
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &678553527
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4363,7 +4359,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &798021449
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -4409,6 +4405,8 @@ MonoBehaviour:
|
|||
selectedImage: {fileID: 2127582758}
|
||||
outline: {fileID: 1231936949}
|
||||
resizeGraphic: {fileID: 880758902}
|
||||
leftDrag: {fileID: 2046851080}
|
||||
rightDrag: {fileID: 184364176}
|
||||
length: 0
|
||||
selected: 0
|
||||
mouseHovering: 0
|
||||
|
@ -5251,7 +5249,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1031646381
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -7410,7 +7408,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1474986788
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -9486,7 +9484,7 @@ GameObject:
|
|||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1921041735
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -10118,22 +10116,6 @@ MonoBehaviour:
|
|||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- eventID: 3
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 798021450}
|
||||
m_TargetAssemblyTypeName: RhythmHeavenMania.Editor.TimelineEventObj, Assembly-CSharp
|
||||
m_MethodName: OnLeftUp
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
- eventID: 0
|
||||
callback:
|
||||
m_PersistentCalls:
|
||||
|
|
|
@ -128,7 +128,7 @@ namespace RhythmHeavenMania.Editor
|
|||
{
|
||||
int selected = 0;
|
||||
|
||||
if (!Input.GetKeyDown(KeyCode.LeftShift)) Selections.instance.DeselectAll();
|
||||
// if (!Input.GetKeyDown(KeyCode.LeftShift)) Selections.instance.DeselectAll();
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
TimelineEventObj e = GameManager.instance.Beatmap.entities[i].eventObj;
|
||||
|
|
|
@ -92,6 +92,15 @@ namespace RhythmHeavenMania.Editor
|
|||
Debug.Log(json);
|
||||
}
|
||||
|
||||
public void DebugSave()
|
||||
{
|
||||
// temp
|
||||
string path = UnityEditor.AssetDatabase.GetAssetPath(GameManager.instance.txt);
|
||||
path = Application.dataPath.Remove(Application.dataPath.Length - 6, 6) + path;
|
||||
System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(GameManager.instance.Beatmap));
|
||||
Debug.Log("Saved to " + path);
|
||||
}
|
||||
|
||||
public void SetGameEventTitle(string txt)
|
||||
{
|
||||
GameEventSelectorTitle.text = txt;
|
||||
|
|
|
@ -23,6 +23,8 @@ namespace RhythmHeavenMania.Editor
|
|||
[SerializeField] private Image selectedImage;
|
||||
[SerializeField] private RectTransform outline;
|
||||
[SerializeField] private RectTransform resizeGraphic;
|
||||
[SerializeField] private RectTransform leftDrag;
|
||||
[SerializeField] private RectTransform rightDrag;
|
||||
|
||||
[Header("Properties")]
|
||||
private Beatmap.Entity entity;
|
||||
|
@ -34,6 +36,9 @@ namespace RhythmHeavenMania.Editor
|
|||
public bool resizable;
|
||||
public bool resizing;
|
||||
public bool moving;
|
||||
private bool resizingLeft;
|
||||
private bool resizingRight;
|
||||
private bool inResizeRegion;
|
||||
|
||||
[Header("Colors")]
|
||||
public Color NormalCol;
|
||||
|
@ -106,7 +111,7 @@ namespace RhythmHeavenMania.Editor
|
|||
{
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
|
||||
{
|
||||
if (!mouseHovering && !moving && !BoxSelection.instance.selecting)
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
|
@ -116,7 +121,8 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
OnUp();
|
||||
}
|
||||
if (moving && selected)
|
||||
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
|
@ -129,7 +135,51 @@ namespace RhythmHeavenMania.Editor
|
|||
lastPos = this.transform.localPosition;
|
||||
}
|
||||
}
|
||||
else if (resizingLeft)
|
||||
{
|
||||
SetPivot(new Vector2(1, rectTransform.pivot.y));
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(-mousePos.x + 0.15f, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
OnComplete();
|
||||
}
|
||||
else if (resizingRight)
|
||||
{
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(mousePos.x + 0.15f, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
OnLeftUp();
|
||||
OnRightUp();
|
||||
}
|
||||
|
||||
if (resizing && selected || inResizeRegion && selected)
|
||||
{
|
||||
if (resizable)
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
|
||||
}
|
||||
else if (Timeline.instance.eventObjs.FindAll(c => c.inResizeRegion).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
}
|
||||
|
||||
#region ClickEvents
|
||||
|
@ -142,21 +192,28 @@ namespace RhythmHeavenMania.Editor
|
|||
}
|
||||
else
|
||||
{
|
||||
Selections.instance.ClickSelect(this);
|
||||
if (!selected)
|
||||
{
|
||||
Selections.instance.ClickSelect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDown()
|
||||
{
|
||||
if (!selected) return;
|
||||
if (selected)
|
||||
{
|
||||
for (int i = 0; i < Timeline.instance.eventObjs.Count; i++)
|
||||
{
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
Timeline.instance.eventObjs[i].startPosX = mousePos.x - Timeline.instance.eventObjs[i].transform.position.x;
|
||||
Timeline.instance.eventObjs[i].startPosY = mousePos.y - Timeline.instance.eventObjs[i].transform.position.y;
|
||||
}
|
||||
|
||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
startPosX = mousePos.x - this.transform.position.x;
|
||||
startPosY = mousePos.y - this.transform.position.y;
|
||||
moving = true;
|
||||
|
||||
moving = true;
|
||||
|
||||
OnComplete();
|
||||
OnComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUp()
|
||||
|
@ -185,68 +242,55 @@ namespace RhythmHeavenMania.Editor
|
|||
|
||||
public void DragEnter()
|
||||
{
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
|
||||
inResizeRegion = true;
|
||||
}
|
||||
|
||||
public void DragExit()
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
inResizeRegion = false;
|
||||
}
|
||||
|
||||
public void OnLeftDown()
|
||||
{
|
||||
SetPivot(new Vector2(1, rectTransform.pivot.y));
|
||||
resizing = true;
|
||||
}
|
||||
|
||||
public void DragLeft()
|
||||
{
|
||||
if (!resizing) return;
|
||||
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(-mousePos.x + 0.1f, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, rectTransform.localPosition.x), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
|
||||
OnComplete();
|
||||
if (resizable && selected)
|
||||
{
|
||||
ResetResize();
|
||||
resizing = true;
|
||||
resizingLeft = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnLeftUp()
|
||||
{
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
resizing = false;
|
||||
if (resizable && selected)
|
||||
{
|
||||
ResetResize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void OnRightDown()
|
||||
{
|
||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
||||
resizing = true;
|
||||
}
|
||||
|
||||
public void DragRight()
|
||||
{
|
||||
if (!resizing) return;
|
||||
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, Input.mousePosition, Camera.main, out mousePos);
|
||||
|
||||
sizeDelta = new Vector2(mousePos.x, sizeDelta.y);
|
||||
sizeDelta = new Vector2(Mathf.Clamp(sizeDelta.x, 0.25f, Mathf.Infinity), sizeDelta.y);
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(Mathp.Round2Nearest(sizeDelta.x, 0.25f), sizeDelta.y);
|
||||
|
||||
OnComplete();
|
||||
if (resizable && selected)
|
||||
{
|
||||
ResetResize();
|
||||
resizing = true;
|
||||
resizingRight = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRightUp()
|
||||
{
|
||||
if (resizable && selected)
|
||||
{
|
||||
ResetResize();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetResize()
|
||||
{
|
||||
resizingLeft = false;
|
||||
resizingRight = false;
|
||||
resizing = false;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue