event selection doesn't go offscreen anymore

github copilot is insane it wrote half of the code in this commit lmao
This commit is contained in:
minenice55 2022-06-30 15:51:13 -04:00
parent 157a4749d7
commit f31b328f1a
4 changed files with 57 additions and 30 deletions

View File

@ -10,7 +10,9 @@ TrueTypeFontImporter:
includeFontData: 1 includeFontData: 1
fontNames: fontNames:
- FOT-Rodin Pro - FOT-Rodin Pro
fallbackFontReferences: [] fallbackFontReferences:
- {fileID: 12800000, guid: d9b391ecd583bd54fa458814fbcad7be, type: 3}
- {fileID: 12800000, guid: 6d457cf9900bba748b3250de2e990fa2, type: 3}
customCharacters: customCharacters:
fontRenderingMode: 0 fontRenderingMode: 0
ascentCalculationMode: 1 ascentCalculationMode: 1

View File

@ -2328,7 +2328,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0}
m_AnchoredPosition: {x: -289.15, y: 2} m_AnchoredPosition: {x: -289.15002, y: 2}
m_SizeDelta: {x: -578.29, y: 49.92} m_SizeDelta: {x: -578.29, y: 49.92}
m_Pivot: {x: 0.5, y: 0} m_Pivot: {x: 0.5, y: 0}
--- !u!114 &156962255 --- !u!114 &156962255
@ -5290,8 +5290,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
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: 3.4249878, y: -19.679688} m_AnchoredPosition: {x: 3.4249878, y: -19.70996}
m_SizeDelta: {x: -6.85, y: -39.36} m_SizeDelta: {x: -6.85, y: -39.43}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &358789046 --- !u!114 &358789046
MonoBehaviour: MonoBehaviour:
@ -8438,8 +8438,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
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: -13039.025} m_AnchoredPosition: {x: 0, y: -13019.308}
m_SizeDelta: {x: 0, y: 26078.07} m_SizeDelta: {x: 0, y: 26117.389}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &590210127 --- !u!114 &590210127
MonoBehaviour: MonoBehaviour:
@ -8539,7 +8539,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 704039020} m_HandleRect: {fileID: 704039020}
m_Direction: 0 m_Direction: 0
m_Value: 0 m_Value: 0
m_Size: 0.032871284 m_Size: 0.03287128
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -12023,8 +12023,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1589389272} m_TargetGraphic: {fileID: 1589389272}
m_HandleRect: {fileID: 1589389271} m_HandleRect: {fileID: 1589389271}
m_Direction: 2 m_Direction: 2
m_Value: 0.9999996 m_Value: -0.0000033002277
m_Size: 0.52927834 m_Size: 0.5285789
m_NumberOfSteps: 0 m_NumberOfSteps: 0
m_OnValueChanged: m_OnValueChanged:
m_PersistentCalls: m_PersistentCalls:
@ -13928,8 +13928,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0} m_AnchorMin: {x: 0.5, y: 0}
m_AnchorMax: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 120.81002, y: 0} m_AnchoredPosition: {x: 120.830025, y: -19.690994}
m_SizeDelta: {x: 578.36, y: -4} m_SizeDelta: {x: 576.29, y: -43.38}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1056099133 --- !u!114 &1056099133
MonoBehaviour: MonoBehaviour:
@ -15065,7 +15065,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5} m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 129.93793} m_AnchoredPosition: {x: 0, y: 361.0897}
m_SizeDelta: {x: 0, y: 491} m_SizeDelta: {x: 0, y: 491}
m_Pivot: {x: 0.5, y: 1} m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1154875944 --- !u!114 &1154875944

View File

@ -20,6 +20,7 @@ namespace HeavenStudio.Editor
public GameObject GameEventSelector; public GameObject GameEventSelector;
public GameObject EventRef; public GameObject EventRef;
public GameObject CurrentSelected; public GameObject CurrentSelected;
private RectTransform GameEventSelectorRect;
private RectTransform eventsParent; private RectTransform eventsParent;
[Header("Properties")] [Header("Properties")]
@ -29,9 +30,15 @@ namespace HeavenStudio.Editor
private int dragTimes; private int dragTimes;
public float posDif; public float posDif;
public int ignoreSelectCount; public int ignoreSelectCount;
private float selectorHeight;
private float eventSize;
private void Start() private void Start()
{ {
GameEventSelectorRect = GameEventSelector.GetComponent<RectTransform>();
selectorHeight = GameEventSelectorRect.rect.height;
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
eventsParent = EventRef.transform.parent.GetChild(2).GetComponent<RectTransform>(); eventsParent = EventRef.transform.parent.GetChild(2).GetComponent<RectTransform>();
SelectGame("Game Manager", 1); SelectGame("Game Manager", 1);
@ -59,6 +66,9 @@ namespace HeavenStudio.Editor
UpdateIndex(currentEventIndex - Mathf.RoundToInt(Input.mouseScrollDelta.y)); UpdateIndex(currentEventIndex - Mathf.RoundToInt(Input.mouseScrollDelta.y));
} }
} }
//moved here so this updates dynamically with window scale
UpdateScrollPosition();
} }
#region Functions #region Functions
@ -75,26 +85,32 @@ namespace HeavenStudio.Editor
else if (currentEventIndex > eventsParent.childCount - 1) else if (currentEventIndex > eventsParent.childCount - 1)
currentEventIndex = 0; currentEventIndex = 0;
if (currentEventIndex > 2 && eventsParent.childCount >= 8)
{
if (eventsParent.childCount - 4 > currentEventIndex)
{
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (currentEventIndex - 2), 0.35f).SetEase(Ease.OutExpo);
}
else
{
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (eventsParent.childCount - 7), 0.35f).SetEase(Ease.OutExpo);
}
}
else
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
CurrentSelected.transform.DOLocalMoveY(eventsParent.transform.GetChild(currentEventIndex).localPosition.y + eventsParent.transform.localPosition.y, 0.35f).SetEase(Ease.OutExpo); CurrentSelected.transform.DOLocalMoveY(eventsParent.transform.GetChild(currentEventIndex).localPosition.y + eventsParent.transform.localPosition.y, 0.35f).SetEase(Ease.OutExpo);
if (updateCol) if (updateCol)
SetColors(currentEventIndex); SetColors(currentEventIndex);
} }
private void UpdateScrollPosition()
{
selectorHeight = GameEventSelectorRect.rect.height;
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
if (currentEventIndex * eventSize >= selectorHeight/2 && eventsParent.childCount * eventSize >= selectorHeight)
{
if (currentEventIndex * eventSize < eventsParent.childCount * eventSize - selectorHeight/2)
{
EventRef.transform.parent.DOLocalMoveY((currentEventIndex * eventSize) - selectorHeight/2, 0.35f).SetEase(Ease.OutExpo);
}
else
{
EventRef.transform.parent.DOLocalMoveY((eventsParent.childCount * eventSize) - selectorHeight + (eventSize*0.33f), 0.35f).SetEase(Ease.OutExpo);
}
}
else
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
}
public void SelectGame(string gameName, int index) public void SelectGame(string gameName, int index)
{ {
if (SelectedGameIcon != null) if (SelectedGameIcon != null)

View File

@ -17,11 +17,20 @@ namespace HeavenStudio.Editor.Track
void Update() void Update()
{ {
//convert timeline layer scale to screen space //convert timeline layer scale to screen space
Camera cam = Editor.instance.EditorCamera; Camera cam;
//"your program can't crash if you put everything in a try block"
try
{
cam = Editor.instance.EditorCamera;
float layerScaleDist = cam.WorldToScreenPoint(Timeline.instance.LayerCorners[1]).y - Camera.main.WorldToScreenPoint(Timeline.instance.LayerCorners[0]).y; float layerScaleDist = cam.WorldToScreenPoint(Timeline.instance.LayerCorners[1]).y - Camera.main.WorldToScreenPoint(Timeline.instance.LayerCorners[0]).y;
float modScale = Timeline.GetScaleModifier(); float modScale = Timeline.GetScaleModifier();
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale)); rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale));
} }
catch (System.NullReferenceException)
{
return;
}
}
} }
} }