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 c27ae71727
commit 8e16e9be04
4 changed files with 57 additions and 30 deletions

View File

@ -17,10 +17,19 @@ namespace HeavenStudio.Editor.Track
void Update()
{
//convert timeline layer scale to screen space
Camera cam = Editor.instance.EditorCamera;
float layerScaleDist = cam.WorldToScreenPoint(Timeline.instance.LayerCorners[1]).y - Camera.main.WorldToScreenPoint(Timeline.instance.LayerCorners[0]).y;
float modScale = Timeline.GetScaleModifier();
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale));
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 modScale = Timeline.GetScaleModifier();
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale));
}
catch (System.NullReferenceException)
{
return;
}
}
}