Friday, May 3, 2024
HomeGame DevelopmentSuggestion: a solution to toggle editor visibility - Cocos Creator

Suggestion: a solution to toggle editor visibility – Cocos Creator


Hello, I’ve components that I wish to be hidden by default, however I wish to see them in editor with out having to toggle the checkbox everytime for every of them, as a result of I’ve to cover them once more each time I wish to run the sport.
Wouldn’t or not it’s higher if there was a special checkbox or one thing to toggle solely editor visibility?
Am I the one one with this wrestle?


Good day!
I clear up this drawback like this:


onLoad() { this.node.lively = false; }

On this case, the worth of the checkbox within the editor doesn’t matter.

If it’s worthwhile to management visibility from the editor and also you want a second checkbox for this, then you may merely do one thing like this:


@property(CCBoolean)
seen: boolean = false;

onLoad() { this.node.lively = this.seen; }

Can I’ve a visible code instance please ??

Hey i wished the code instance please

Above is nearly all of the code you want. I’m working with the newest variations of CC, so the code is in typescript. For javascript, I feel it is not going to be very totally different, simply throw away the kind definitions. Basically, the module can be like this:

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

@ccclass("Seen")
export class Seen extends Element {

    @property(CCBoolean)
    seen: boolean = false;

    onLoad() { this.node.lively = this.seen; }

}

Simply add it to a node and mark whether or not the node ought to be displayed or not.



1 Like

This subject was mechanically closed 24 hours after the final reply. New replies are not allowed.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments