Working Directory
Project Path
Editor.projectPathThe absolute path of current project.
Custom Protocols
We introduce the custom protocols to ease the path search in main and renderer process.
db://Introduced in Asset Management, will mapping the root direcotry of assets. We can get assets by writingdb://assets/script/MyScript.jspackages://The packages installed path. Mapping to local project'spackagesfolder and global package folder$HOME/.CocosCreator/packages映射到项目本地的插件目录packages和全局的插件目录$HOME/.CocosCreator/packages, for examplepackages://foobar/package.jsonmeans thefoobarpackage'spackage.jsonfile.unpack://The unpacked folder in Cocos Creator, including:unpack://engineJavaScript Enigne Pathunpack://cocos2d-xC++ Engine Pathunpack://simulatorSimulator Path
You can use Editor.url() convert the url to absolute path.
Use seprate html and css file in panel define
We can use Editor.url define the HTML and CSS so that they lives in the separate file:
var Fs = require('fs');
Editor.Panel.extend({
// css style for panel
style: Fs.readFileSync(Editor.url('packages://foobar/panel/index.css', 'utf8')),
// html template for panel
template: Fs.readFileSync(Editor.url('packages://foobar/panel/index.html', 'utf8')),
//...
});