Multiple canvas traits possible?


I was going to add multiple canvas traits to the scene to keep things sorted.
In general this works and shows up. But the also attached Nodes trait does not have infuence any more. Guess it cannot differentiate between the two. I also tried to pause the first trait before but this caused and error. Saying not such trait exists.
Has anybody done multiple canvas traits in a game yet? If yes, how did you accomplish this, if no I am still fine and go in another direction.



It should be able to have multiple Canvas as long as the names of the elemnts in them are not the same. That way, your canvas is organized and you dont need to worry about choosing the wrong element.

If you want to hide/ show an entire canvas, you can use a string array and iterate through all the elements and hide/ show them.

thanks for the response. Tried it today again. But it still doesn´t work. After some tinkering and testing I found out that only the canvas in the upmost trait location is working properly when multiple are attached to the scene. I also recognized that events on button are working. But getting and setting anything doesn´t work and returns null.
Also moving the Canvas to another random Object does not solve this.
I think this might be a bug. I must say I am only using Nodes instead of Haxe scripts, maybe this behaves differently. If it´s a bug I am using Amory 2021-8 just as info.

I think this is a consequence of how traits are accessed:;

You can see that each trait is accessed only by its class, so if you have multiple traits with the same class then only the first of them will be accessed in all the logic nodes. This API was probably made with only one trait type per object in mind, which – if you think about all other traits than canvases – is almost always the case.

But every trait has a name, so that could be used instead (however it’s probably not unique yet). I’m not exactly sure why the current approach was chosen (maybe the name is for debugging only), but I think there should be a way around this. It’s simply a limitation right now.

Or, there could be a way to get all traits of a type in an array. It might be useful as well and every approach has its pros and cons.

It is possible to parent Canvas elements but this doesn’t seem to be documented and no feedback in the UI.

By parenting some element, its visibility / position / rotation is influence by its parent, but i don’t have sure how good this works.

Few considerations:

  • No proper way to unparent elements
  • Anchoring the parent doesn’t change the children anchoring
  • In some specific situation the Canvas Editor crashes after you parent some element. I don’t remember how and this couldn’t be too hard to fix. Make sure to save the canvas a lot while using this functionality.

Steps to parent elements:

  • While hovering some element, hold mouse right button (if you release it, the element will leave the drag and drop state). Then the element is now in “drag and drop” state, but no visual feedback

  • To parent the element in “drag and drop” state, just hover the element you wish to be its parent and click mouse left button.

This should work for you. Create two empties called for example “Hud” and “Menu”, then just add child elements to it and set its visibility to hide its children when needed

1 Like


great, thanks for the reply.
Funny coincidence that´s exactly the workaround I used to get it working at the weekend. I used other names but in general it´s the same method.


1 Like