Improvements to editor objects
This commit is contained in:
parent
ed8b3a6db8
commit
dea5860e95
|
@ -1121,22 +1121,6 @@ MonoBehaviour:
|
||||||
m_StringArgument:
|
m_StringArgument:
|
||||||
m_BoolArgument: 0
|
m_BoolArgument: 0
|
||||||
m_CallState: 2
|
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
|
- eventID: 0
|
||||||
callback:
|
callback:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
@ -1946,7 +1930,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &321288860
|
--- !u!224 &321288860
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3712,7 +3696,19 @@ MonoBehaviour:
|
||||||
m_TargetGraphic: {fileID: 678553527}
|
m_TargetGraphic: {fileID: 678553527}
|
||||||
m_OnClick:
|
m_OnClick:
|
||||||
m_PersistentCalls:
|
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
|
--- !u!114 &678553527
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -4363,7 +4359,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!224 &798021449
|
--- !u!224 &798021449
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -4409,6 +4405,8 @@ MonoBehaviour:
|
||||||
selectedImage: {fileID: 2127582758}
|
selectedImage: {fileID: 2127582758}
|
||||||
outline: {fileID: 1231936949}
|
outline: {fileID: 1231936949}
|
||||||
resizeGraphic: {fileID: 880758902}
|
resizeGraphic: {fileID: 880758902}
|
||||||
|
leftDrag: {fileID: 2046851080}
|
||||||
|
rightDrag: {fileID: 184364176}
|
||||||
length: 0
|
length: 0
|
||||||
selected: 0
|
selected: 0
|
||||||
mouseHovering: 0
|
mouseHovering: 0
|
||||||
|
@ -5251,7 +5249,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &1031646381
|
--- !u!224 &1031646381
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -7410,7 +7408,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &1474986788
|
--- !u!224 &1474986788
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -9486,7 +9484,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!224 &1921041735
|
--- !u!224 &1921041735
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -10118,22 +10116,6 @@ MonoBehaviour:
|
||||||
m_StringArgument:
|
m_StringArgument:
|
||||||
m_BoolArgument: 0
|
m_BoolArgument: 0
|
||||||
m_CallState: 2
|
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
|
- eventID: 0
|
||||||
callback:
|
callback:
|
||||||
m_PersistentCalls:
|
m_PersistentCalls:
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace RhythmHeavenMania.Editor
|
||||||
{
|
{
|
||||||
int selected = 0;
|
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++)
|
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||||
{
|
{
|
||||||
TimelineEventObj e = GameManager.instance.Beatmap.entities[i].eventObj;
|
TimelineEventObj e = GameManager.instance.Beatmap.entities[i].eventObj;
|
||||||
|
|
|
@ -92,6 +92,15 @@ namespace RhythmHeavenMania.Editor
|
||||||
Debug.Log(json);
|
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)
|
public void SetGameEventTitle(string txt)
|
||||||
{
|
{
|
||||||
GameEventSelectorTitle.text = txt;
|
GameEventSelectorTitle.text = txt;
|
||||||
|
|
|
@ -23,6 +23,8 @@ namespace RhythmHeavenMania.Editor
|
||||||
[SerializeField] private Image selectedImage;
|
[SerializeField] private Image selectedImage;
|
||||||
[SerializeField] private RectTransform outline;
|
[SerializeField] private RectTransform outline;
|
||||||
[SerializeField] private RectTransform resizeGraphic;
|
[SerializeField] private RectTransform resizeGraphic;
|
||||||
|
[SerializeField] private RectTransform leftDrag;
|
||||||
|
[SerializeField] private RectTransform rightDrag;
|
||||||
|
|
||||||
[Header("Properties")]
|
[Header("Properties")]
|
||||||
private Beatmap.Entity entity;
|
private Beatmap.Entity entity;
|
||||||
|
@ -34,6 +36,9 @@ namespace RhythmHeavenMania.Editor
|
||||||
public bool resizable;
|
public bool resizable;
|
||||||
public bool resizing;
|
public bool resizing;
|
||||||
public bool moving;
|
public bool moving;
|
||||||
|
private bool resizingLeft;
|
||||||
|
private bool resizingRight;
|
||||||
|
private bool inResizeRegion;
|
||||||
|
|
||||||
[Header("Colors")]
|
[Header("Colors")]
|
||||||
public Color NormalCol;
|
public Color NormalCol;
|
||||||
|
@ -106,7 +111,7 @@ namespace RhythmHeavenMania.Editor
|
||||||
{
|
{
|
||||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
|
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))
|
if (!Input.GetKey(KeyCode.LeftShift))
|
||||||
{
|
{
|
||||||
|
@ -116,7 +121,8 @@ namespace RhythmHeavenMania.Editor
|
||||||
|
|
||||||
OnUp();
|
OnUp();
|
||||||
}
|
}
|
||||||
if (moving && selected)
|
|
||||||
|
if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
|
||||||
{
|
{
|
||||||
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||||
|
|
||||||
|
@ -129,7 +135,51 @@ namespace RhythmHeavenMania.Editor
|
||||||
lastPos = this.transform.localPosition;
|
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
|
#region ClickEvents
|
||||||
|
@ -142,21 +192,28 @@ namespace RhythmHeavenMania.Editor
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Selections.instance.ClickSelect(this);
|
if (!selected)
|
||||||
|
{
|
||||||
|
Selections.instance.ClickSelect(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDown()
|
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);
|
moving = true;
|
||||||
startPosX = mousePos.x - this.transform.position.x;
|
|
||||||
startPosY = mousePos.y - this.transform.position.y;
|
|
||||||
|
|
||||||
moving = true;
|
OnComplete();
|
||||||
|
}
|
||||||
OnComplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUp()
|
public void OnUp()
|
||||||
|
@ -185,68 +242,55 @@ namespace RhythmHeavenMania.Editor
|
||||||
|
|
||||||
public void DragEnter()
|
public void DragEnter()
|
||||||
{
|
{
|
||||||
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
|
inResizeRegion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DragExit()
|
public void DragExit()
|
||||||
{
|
{
|
||||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
inResizeRegion = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLeftDown()
|
public void OnLeftDown()
|
||||||
{
|
{
|
||||||
SetPivot(new Vector2(1, rectTransform.pivot.y));
|
if (resizable && selected)
|
||||||
resizing = true;
|
{
|
||||||
}
|
ResetResize();
|
||||||
|
resizing = true;
|
||||||
public void DragLeft()
|
resizingLeft = true;
|
||||||
{
|
}
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnLeftUp()
|
public void OnLeftUp()
|
||||||
{
|
{
|
||||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
if (resizable && selected)
|
||||||
resizing = false;
|
{
|
||||||
|
ResetResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void OnRightDown()
|
public void OnRightDown()
|
||||||
{
|
{
|
||||||
SetPivot(new Vector2(0, rectTransform.pivot.y));
|
if (resizable && selected)
|
||||||
resizing = true;
|
{
|
||||||
}
|
ResetResize();
|
||||||
|
resizing = true;
|
||||||
public void DragRight()
|
resizingRight = true;
|
||||||
{
|
}
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnRightUp()
|
public void OnRightUp()
|
||||||
{
|
{
|
||||||
|
if (resizable && selected)
|
||||||
|
{
|
||||||
|
ResetResize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetResize()
|
||||||
|
{
|
||||||
|
resizingLeft = false;
|
||||||
|
resizingRight = false;
|
||||||
resizing = false;
|
resizing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue