Removing/Disabling Canvas

Is there anyway to disable/remove canvas?
Removing trait doesn’t work, and canvas can’t be hidden by changing canvas’s .json on run time

Can you test on the ui_canvas example? If I remove the canvas trait there with canvas.remove() then it’s gone.

function onToggleMenu() {
	canvas.remove();
}
3 Likes

Thanks, it works perfectly fine!

3 Likes

I tried to do this using nodes, I looked for along the forum. Doesnt, run.

I used the nodes Pause/Resume trait and Remove/Add trait. Same result…

Pruebas Canvas 01b.blend (784.6 KB)

I want to alternate two cambas (or hide both of them) an edit texts(no problem with this).

It seems that an error occurs when “Remove Trait” is performed using a logic node. It might be a bug.

Do you want to change or delete canvas text strings using logic nodes?
You can change or delete the canvas text string using the “Canvas Set Text” node.

As another method, it becomes a big scale, but you can change or hide the canvas by preparing and switching three scenes.

scene1:canvas1
scene2:canvas2
scene3:Without canvas

When you switch scenes, the object’s transform information is reset, so you must save and load each time you switch.

Thanks a lot. I thought it was a good workaround, but…

little problem: it spend a few seconds to return.
big problem: I loose the active camera, the position of player and virtual gamepad change position in screen and doesn’t work.

You must save the object’s transform information before switching scenes and load it after switching scenes.
Every time.

It may be more solid to wait for the logical nodes to improve.

  1. ok i umderstand. I’m not sure how to save loc and rot vectors. Im going to investigate

  2. I’ll try too not disabling canvas but togglimg visibolity of all elements of canvas.

  3. on the ui_canvas ecample i run well canvas.remove(). Is it posible to restore it with something like scene.setTrait(MyCanvas) ?

  1. There is a method of saving transform information in the blend file created by Musa on this page.
    Rotation information is reset when switching to another scene (Link Objects)

  2. Of course, it is possible if it is realized by Haxe without using a logic node. But 3. looks better.

  3. I don’t know how to add traits using Haxe.

Option 2. Example. Hide / Unhide a canvas by setting all elements to .visible=false.

Hide: with Exit button using canvas event in MyTrait sets a text named “visi” to “No”.
Unhide: Picking the cube -> with nodes sets text named “visi” to “Yes”.

.blend + Canvas + MyTrait.hx:

When “visi” changes a funcion SetVisibiity is launched inside MyTrait.

1 Like

option 1. thanks @Musa and @Sandy.
For me it crashed Musa’s project so I changed it a little bit.
On the first scan it crashed.
I used a property to detect the first scan (or frame I don´t know witch is the correct term in animation) and use the name of the object to have a different storage and

  • On init. if first scan: (property = null) I launch write storage. and set property to 1.
  • On init. (property = 1) I restore the position, I launch write storage and set property

I hope this will be usefull for more people.

SwitchSceneMantainPos.blend (844.4 KB)

1 Like

It’s simple and very nice. This seems to be the best way.

In my case, @Musa’s blend file works fine. Is the initial storage value different depending on the environment?The difference looks like that part.

Good node :grinning: