From aaf1376b53f28bdf228b8a03e5ba5043c3cf1df8 Mon Sep 17 00:00:00 2001
From: Cameron Taylor <cameron.taylor.ninja@gmail.com>
Date: Thu, 25 Aug 2022 05:18:09 -0400
Subject: [PATCH] stage editor Y key fix (and streets repositioning)

---
 source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
index 7c04e6652..6c43d42c6 100644
--- a/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
+++ b/source/funkin/ui/stageBuildShit/StageOffsetSubstate.hx
@@ -22,6 +22,8 @@ import openfl.net.FileReference;
 
 class StageOffsetSubstate extends MusicBeatSubstate
 {
+	var uiStuff:Component;
+
 	override function create()
 	{
 		super.create();
@@ -31,7 +33,7 @@ class StageOffsetSubstate extends MusicBeatSubstate
 		FlxG.camera.target = null;
 
 		var str = Paths.xml('ui/stage-editor-view');
-		var uiStuff:Component = RuntimeComponentBuilder.fromAsset(str);
+		uiStuff = RuntimeComponentBuilder.fromAsset(str);
 
 		uiStuff.findComponent("lol").onClick = saveCharacterCompile;
 		uiStuff.findComponent('saveAs').onClick = saveStageFileRef;
@@ -96,6 +98,11 @@ class StageOffsetSubstate extends MusicBeatSubstate
 				thing.alpha = 1;
 			}
 
+			if (uiStuff != null)
+				remove(uiStuff);
+
+			uiStuff = null;
+
 			PlayState.instance.resetCamera();
 			FlxG.mouse.visible = false;
 			close();