Home | Documentation | Atomic Chat | Github

Using Atomic UI


Hallo again AGE community,

I’m having a lot of trouble understanding how to use atomic UI in C#, I’ve looked at the UI periodic table but that just confused me even more. Does anyone have code for a main menu or HUD that I could look at?

Also, I’ve been having some trouble trying to create nodes, then assign them cscomponents. I used this:

Node node = Scene.CreateChild("node");
node.Position = Vector3.Zero;
node.Scale = new Vector3(1, 1, 1);

CSComponent csc = node.CreateComponent\.<CSComponent>();
csc.ComponentClassName = "Spinner";

It doesn’t submit an error, it just crashes.



Do you have a design or mockup of what you’d like the GUI to do? The range between main menu and HUD is quite large. The UIPeriodicTable is an example of the available widgets and how to get data in and out of them. For a simple example of CS UI, look into the FeatureExamples, specifically the script 02_HelloGUI.cs, which shows how to create the GUI entirely from code. The other option for gui is to use the UI layout files (like periodic does). To get data back, you have to assign event handlers to the widgets.

And the code :

 CSComponent csc = node.CreateComponent<CSComponent>();
 csc.ComponentClassName = "Spinner";

crashes with the statement System.NullReferenceException: Object reference not set to an instance of an object for what that is worth, I dont know the cause. All of the examples I seen of CSComponent are done in the Scene file, and have two initializers instead of the one you are using.


Thanks for that input on the CSComponent, I tried some other stuff but nothing worked.

And for the Main menu/HUD, I don’t even know how to create instances of Buttons or anything that appear in the scene.

If it helps at all, I’m making a Stellaris type 4x game


Stellaris, oh my, lots of UI… So a HUD and many windows with lots of data in them.
The UI (HUD) is layer above the Scene, and is always on top of it. UI WIndows (dialog boxes) are always above the HUD layer, and are active when created, and if there are multiples, they need to be clicked to bring them to the top.
Because there is so much UI that needs to be created, I will recommend using the UI layout files, they have good points, they can are a lot less typing than code, are hot-loaded, can be embedded later, the bad points are the leaning curve of the syntax and layouts.
The UIPeriodicTable may seem confusing, but was built that way for some of the same reasons, though it is not a good example of how to make a game.
There are not many examples for making a larger scale game in Atomic, I have Adventure Suite Game available, though it is Javascript, it has (primitive) game states, menus and a HUD on the main Scene.


Thank you, I’ll take another swing at the periodic table and check out your game as well.

I also think that the Atomic mutant has a method for adding CSComponents it’s sort of like this:

Character character;
//Character is a CSComponent Class

void Start()
    character = Node.CreateComponent<Character>();

And for clarification, my game is probably about 5 - 10% of stellaris, or probably less: a time based 4x game rather than turn based and it takes place in randomly generated space. So I’m not attempting to make a stellaris clone, it’s just the first game like that that came to mind.