Event colors

This commit is contained in:
Braedon 2022-01-11 22:29:27 -05:00
parent e8f4b24490
commit 602f351e87
5 changed files with 107 additions and 8 deletions

View file

@ -1223,6 +1223,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 547319783} - component: {fileID: 547319783}
- component: {fileID: 547319786} - component: {fileID: 547319786}
- component: {fileID: 547319784}
m_Layer: 5 m_Layer: 5
m_Name: Viewport m_Name: Viewport
m_TagString: Untagged m_TagString: Untagged
@ -1250,6 +1251,20 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!114 &547319784
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 547319782}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3312d7739989d2b4e91e6319e9a96d76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding: {x: 0, y: 0, z: 0, w: 0}
m_Softness: {x: 0, y: 0}
--- !u!222 &547319786 --- !u!222 &547319786
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1257,7 +1272,7 @@ CanvasRenderer:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 547319782} m_GameObject: {fileID: 547319782}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 0
--- !u!1 &555373788 --- !u!1 &555373788
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1789,7 +1804,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.6, g: 0.6, b: 0.7490196, a: 1} m_Color: {r: 0.84705883, g: 0.84705883, b: 1, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
@ -2332,6 +2347,9 @@ MonoBehaviour:
PosPreviewRef: {fileID: 2142375787} PosPreviewRef: {fileID: 2142375787}
Icon: {fileID: 820032006} Icon: {fileID: 820032006}
length: 0 length: 0
NormalCol: {r: 0.8470589, g: 0.8470589, b: 1, a: 1}
SelectedCol: {r: 0.8470589, g: 1, b: 1, a: 1}
DeleteCol: {r: 0.89019614, g: 0.7254902, b: 0.7254902, a: 1}
--- !u!222 &798021451 --- !u!222 &798021451
CanvasRenderer: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -4719,7 +4737,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -0.060000002, y: -6} m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1921041736 --- !u!114 &1921041736
MonoBehaviour: MonoBehaviour:
@ -4734,14 +4752,14 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.8470589, g: 0.8470589, b: 1, a: 1} m_Color: {r: 0, g: 0, b: 0, a: 0.2}
m_RaycastTarget: 1 m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1 m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_Sprite: {fileID: 0} m_Sprite: {fileID: 21300000, guid: f9232c079e126cd48a7344b23eaf42a5, type: 3}
m_Type: 1 m_Type: 1
m_PreserveAspect: 0 m_PreserveAspect: 0
m_FillCenter: 1 m_FillCenter: 1

View file

@ -21,6 +21,8 @@ namespace RhythmHeavenMania.Editor
[Header("Components")] [Header("Components")]
[SerializeField] private Timeline Timeline; [SerializeField] private Timeline Timeline;
public static List<TimelineEventObj> EventObjs = new List<TimelineEventObj>();
public static Editor instance { get; private set; } public static Editor instance { get; private set; }
private void Start() private void Start()

View file

@ -112,7 +112,10 @@ namespace RhythmHeavenMania.Editor
private void SetColor(int ind) private void SetColor(int ind)
{ {
for (int i = 0; i < EventRef.transform.parent.childCount; i++) EventRef.transform.parent.GetChild(i).GetComponent<TMP_Text>().color = Color.white; for (int i = 0; i < EventRef.transform.parent.childCount; i++)
{
EventRef.transform.parent.GetChild(i).GetComponent<TMP_Text>().color = Color.white;
}
EventRef.transform.parent.GetChild(ind + 1).GetComponent<TMP_Text>().color = Color.cyan; EventRef.transform.parent.GetChild(ind + 1).GetComponent<TMP_Text>().color = Color.cyan;
} }

View file

@ -223,10 +223,36 @@ namespace RhythmHeavenMania.Editor
{ {
eventObj.OnDown(); eventObj.OnDown();
} }
Editor.EventObjs.Add(eventObj);
// entity.eventObj = g.GetComponent<TimelineEventObj>(); // entity.eventObj = g.GetComponent<TimelineEventObj>();
// entity.track = (int)(g.transform.localPosition.y / 51.34f * -1); // entity.track = (int)(g.transform.localPosition.y / 51.34f * -1);
} }
public void DestroyEventObject(TimelineEventObj eventObj)
{
var e = GameManager.instance.Beatmap.entities.Find(c => c.eventObj == eventObj);
GameManager.instance.Beatmap.entities.Remove(e);
GameManager.instance.SortEventsList();
Destroy(eventObj.gameObject);
Editor.EventObjs.Remove(eventObj);
}
#endregion
#region Commands
public void Move()
{
}
public void Undo()
{
}
#endregion #endregion
} }
} }

View file

@ -25,9 +25,31 @@ namespace RhythmHeavenMania.Editor
private int enemyIndex; private int enemyIndex;
public float length; public float length;
private bool eligibleToMove = false; private bool eligibleToMove = false;
private bool lastVisible;
[Header("Colors")]
public Color NormalCol;
public Color SelectedCol;
public Color DeleteCol;
private void Update() private void Update()
{ {
// Optimizations
bool visible = GetComponent<RectTransform>().IsVisibleFrom(Camera.main);
if (visible != lastVisible)
{
for (int i = 0; i < this.transform.childCount; i++)
{
this.transform.GetChild(i).gameObject.SetActive(visible);
}
}
lastVisible = visible;
// -------------
if (Conductor.instance.NotStopped()) if (Conductor.instance.NotStopped())
{ {
Cancel(); Cancel();
@ -43,16 +65,25 @@ namespace RhythmHeavenMania.Editor
mousePos = Camera.main.ScreenToWorldPoint(mousePos); mousePos = Camera.main.ScreenToWorldPoint(mousePos);
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0); this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
this.transform.localPosition = new Vector3(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), Mathp.Round2Nearest(this.transform.localPosition.y, 51.34f)); this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.y, 51.34f), -51.34f * 3, 0));
if (lastPos != transform.localPosition) if (lastPos != transform.localPosition)
OnMove(); OnMove();
lastPos = this.transform.localPosition; lastPos = this.transform.localPosition;
SetColor(1);
}
else
{
SetColor(0);
} }
if (Input.GetMouseButtonUp(0)) if (Input.GetMouseButtonUp(0))
OnUp(); OnUp();
if (Input.GetKeyDown(KeyCode.Delete))
Timeline.instance.DestroyEventObject(this);
} }
private void OnMove() private void OnMove()
@ -110,5 +141,24 @@ namespace RhythmHeavenMania.Editor
if (eligibleToMove) OnComplete(); if (eligibleToMove) OnComplete();
Cancel(); Cancel();
} }
public void SetColor(int type)
{
Color c = Color.white;
switch (type)
{
case 0:
c = NormalCol;
break;
case 1:
c = SelectedCol;
break;
case 2:
c = DeleteCol;
break;
}
transform.GetChild(0).GetComponent<Image>().color = c;
}
} }
} }