Thursday, December 1, 2022
HomeGame DevelopmentHow .ts part working even inside Cocos Creator Editor - Off Matter

How .ts part working even inside Cocos Creator Editor – Off Matter


Hello all, I began to create my very own recreation eninge + editor impressed by Cocos Creator. I’m utilizing electron for it, however I caught on the step the place I would like add chance so as to add any elements to the nodes.

The issue I don’t know how one can learn and parse .ts part information contained in the editor.

My hierarhy of full software is:

  1. Particular undertaking directrory what have primary recreation template and ready you dev will add personal elements, information. It additionally runs the sport on localhost once you open listing by Electron App.

  2. Electron App Backend that parse opened undertaking listing and ship knowledge to the Electorn App Entrance Finish Window.

  3. Electron App Entrance Finish Window receives knowledge from Electron App Backend gives by opened undertaking listing. It exhibits all information, scene hieracrhy and inspector panel for each node within the scene. Additionally gives posibility to alter any Node properties (transorm, energetic), hieracrhy of scene. Addeding eradicating the nodes, information (the identical as in Cocos Creator Editor).

So I got here to step the place once I create any elements in .ts file, the editor ought to parse this file and provides posibility so as to add this part to the node and alter properties of the part.

However the issue I don’t understand how can I do that?
Element inside .ts file and likewise in several scope (undertaking listing), whereas my editor runs in one other listing and simply pay attention undertaking listing adjustments.

Additionally this elements ought to be created dinamically within the editor, however how can I obtain this if I simply have the .ts file in one other listing? So I can’t simply write

import {MyComponent} from '../../project_directory/scripts';

new MyComponent();

it ought to be one thing like this:

new componentsCache['MyComponent']();

Why I have to create occasion of Element? as a result of it has @decorators as in Cocos Creator.
with them I can easely add any elements and its properties to the some storage or cache I can then use within the Electron App Fron Finish. So I can then show the names of cached elements developer and select what part so as to add, and likewise create fileds for each @property declared.

After new @cclass and @property calls additionally, I see this in Cocos Creator

I wrote easy take a look at decorator:

import { _decorator, Element, Node } from 'cc';
const { ccclass, property } = _decorator;

operate extendedProperty(choices) {
    console.log(false);
    return property(choices);
}

@ccclass('Foremost')
export class Foremost extends Element {
    // @property(MyOwn)
    // personal myOwn = null;

    @extendedProperty()
    personal quantity: quantity = 1;

    begin() {}

    replace(deltaTime: quantity) {}
}

so then I can see the log once I maximize Cocos Editor:

So I’m simply questioning the way you achieved this?

How does your part (what even isn’t imported wherever) run? I simply create it in folder and I see it runs within the editor even I don’t add it to any Node.

Or my Electorn Utility Arhitecture isn’t appropriate for these items? and you’ve got one other arhitecture in Cocos Creator Editor?

Thanks.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments