Suggestion: a way to toggle editor visibility

Hi, I have elements that I want to be hidden by default, but I would like to see them in editor without having to toggle the checkbox everytime for each of them, because I have to hide them again every time I want to run the game.
Wouldn’t it be better if there was a different checkbox or something to toggle only editor visibility?
Am I the only one with this struggle?

I solve this problem like this:

onLoad() { = false; }

In this case, the value of the checkbox in the editor does not matter.

If you need to control visibility from the editor and you need a second checkbox for this, then you can simply do something like this:

visible: boolean = false;

onLoad() { = this.visible; }

ok i check

Can I have a visual code example please ??

I code with js

Hey i wanted the code example please

Above is almost all the code you need. I’m working with the latest versions of CC, so the code is in typescript. For javascript, I think it will not be very different, just throw away the type definitions. In general, the module will be like this:

import { CCBoolean, Component, _decorator } from "cc";
const { ccclass, property } = _decorator;

export class Visible extends Component {

    visible: boolean = false;

    onLoad() { = this.visible; }


Just add it to a node and mark whether the node should be displayed or not.

1 Like