Extension Infrastructure
The Cocos Creator editor is based on the kernel from GitHub.
Electron is a cross-platform development framework that integrates with Node.js and .
In Electron’s architecture, an application consists of a main process and a rendering process, with the main process managing platform-related scheduling, such as window opening and closing, menu options, basic dialogs, and so on. Each newly opened window is a separate rendering process. Each process has its own JavaScript content and is not directly accessible to each other. When data needs to be passed between processes, the Inter-Process Communication (IPC) mechanism is used.
You can read for a more in-depth understanding of the features The relationship between the main process and the rendering process in Electron.
The Cocos Creator editor follows the structure of Electron’s main process and rendering process. So when the extension is started and run inside the editor, the main defined by the extension is actually started in the main process, while the panels defined by the panels are started in the rendering process. The process structure is briefly summarized as follows.
Inter-process communication is actually the process of sending a message in one process and listening to it in another process.
Electron provides modules and ipcRenderer
for inter-process communication to help us with this task.
With a full Node.js environment inside the extension, it is easy to use the large number of tools available on the npm marketplace for the functionality you want.
If you need to interact with other features, you need to open up the corresponding operation messages for the corresponding features, and we do this within our own extension, via Message System to trigger, query and process functions or data in the editor.
The list of opened messages can be viewed in the top menu Developer -> Message Manager panel, as shown below.