Skip to content

Instantly share code, notes, and snippets.

@Alan-FGR
Created June 19, 2017 12:46
Show Gist options
  • Save Alan-FGR/bd0b60c5f9aad5edac301508e748b2b9 to your computer and use it in GitHub Desktop.
Save Alan-FGR/bd0b60c5f9aad5edac301508e748b2b9 to your computer and use it in GitHub Desktop.
using AtomicEngine;
using AtomicPlayer;
public class AtomicMain : AppDelegate
{
private UIView uiView_;
public override void Start()
{
uiView_ = new UIView();
var rootLayout = new UILayout();
rootLayout.Axis = UI_AXIS.UI_AXIS_X;
rootLayout.Rect = uiView_.Rect;
rootLayout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_GRAVITY;
uiView_.AddChild(rootLayout);
Player player = GetSubsystem<Player>();
string[] sampleTypes = { "Scene1", "Scene2", "Scene3" };
foreach (var sample in sampleTypes)
{
var button = new UIButton();
button.Text = sample;
button.SubscribeToEvent<WidgetEvent>(button, e =>
{
player.UnloadScene(player.CurrentScene);
Scene newScene = player.LoadScene($"Scenes/{button.Text}.scene");
Vector<Camera> cameras = new Vector<Camera>();
newScene.GetComponents(cameras, true);
Viewport viewport = GetSubsystem<Renderer>().GetViewport(0);
viewport.SetScene(newScene);
viewport.SetCamera(cameras[0]);
});
rootLayout.AddChild(button);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment