1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 08:44:47 +00:00
Funkin/source/funkin/ui/haxeui/HaxeUIState.hx

49 lines
799 B
Haxe
Raw Normal View History

package funkin.ui.haxeui;
import haxe.ui.RuntimeComponentBuilder;
import haxe.ui.core.Component;
class HaxeUIState extends MusicBeatState
{
public var component:Component;
var _componentKey:String;
public function new(key:String)
{
super();
_componentKey = key;
}
override function create()
{
super.create();
if (component == null)
component = buildComponent(_componentKey);
if (component != null)
add(component);
}
public function buildComponent(assetPath:String)
{
try
{
return RuntimeComponentBuilder.fromAsset(assetPath);
}
catch (e)
{
trace('[ERROR] Failed to build component from asset: ' + assetPath);
trace(e);
return null;
}
}
override function destroy()
{
if (component != null)
remove(component);
component = null;
}
}