GithubHelp home page GithubHelp logo

cocos-plugin-import-2.x's Introduction

plugin-import-2.x

中文

Cocos Creator 3.0 Upgrade Guide

This plugin is used to reduce the workload of developers upgrading v2.x projects to v3.0.0.

As the editor does not currently support hot updates for plugins, if developers encounter problems with the plugin, use the tutorial below to update the plugin so that they can quickly fix the problem without having to wait for the editor version to be updated.

Update Notes

  • Optimize the interface to add version display and prompt after import

How to update the plugin

Editor Version >= 3.7.0

  1. Open Extension Manager from the main menu

img.png

  1. Find the plugin-import-2x plugin and click Install or Update to get the latest version

img_1.png

Editor Version <= 3.6.x

  1. Store in the relevant designated location, as follows
    • To apply globally (all projects), just store the plugins folder under User/.CocosCreator/extensions
    • To apply to a single project, simply store the folder in the extensions folder at the same level as the assets file

Note: If you do not have an extensions folder, you will need to create one yourself

  1. Enable Extension

    1.Open Extension Manager via the main menu

    img

    2.Click on the Refresh button

    img

    3.Enable extension

    img

NOTE: If 2 menus appear, restart the editor. (This is a known issue and will be fixed later)

How to give feedback

  1. New New issue
  2. Forum

If an existing project needs to be upgraded under special circumstances, and technical or workload difficulties are encountered, please contact [email protected] for assistance!

cocos-plugin-import-2.x's People

Contributors

knoxhuang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cocos-plugin-import-2.x's Issues

error

Require stack:

  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\package\dist\browser\package.ccc
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\package\dist\browser\index.js
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\package\index.js
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\creator\dist\profile\browser\index.ccc
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\creator\dist\profile\index.ccc
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\node_modules@editor\creator\dist\index.js
  • D:\Program Files\CocosDashboard\resources.editors\Creator\3.6.0\resources\app.asar\index.js

关于脚本转换的一点问题和建议

问题

1、未知问题

我有几个脚本出现了 import {eded} from "cc"),疑似我的脚本中有succeeded(因为另一个脚本中我有个变量叫succeededEvent,然后变成了 import {ededEvent} from "cc"),同时,方法名变了

目前主要碰到有以下几种情况:

名称 类型 3.x 导入中多了的部分
xxxSucceeded 方法 xxxSueded import {eded} from "cc"
succeededEvent 属性 无变化 import {ededEvent} from "cc"
xxxSuccessed 方法 xxxSussed import {ssed} from "cc"

2、EventHandler的问题

2.x中,这个类全称是 cc.Component.EventHandler,3.x中,应该是 import {EventHandler} from "cc";。但当前转换之后是

@property(Component.EventHandler)
xxx: Component.EventHandler = new Component.EventHandler();

3、spine的问题

2.x中,通常是sp.xxxxx来使用,3.x好像没有处理这个

建议

1、关于全局变量cc

我个人是比较喜欢用cc.xxx的,3.x中把全局的cc添加了deprecated,但是ts的语法是支持下面这种的

import * as cc from "cc";

建议导入时,不要直接把cc.XXX给转换了,而是在最新面加上面这行代码。

或者作为可选项,由开发者决定。

2、关于property

当前转换的property的类型全部变成了

@property(Sprite)
xxxSprite: Sprite | null = null;

建议直接转换成

@property(Sprite)
xxxSprite: Sprite = null!;

毕竟之前能跑的代码,大概率空安全问题不太会存在,这样的话,在修改逻辑的地方也比较好的处理。

暂时碰到了这么多

面向 ECMAScript 模块时,不能使用导入分配。

之前的2.4.4项目升级至3.2.0
之前的项目是用ts写的

大量ts脚本报这个错误:
无法加载模块 file:///Users/droidhenmini/Documents/ccTile3D/ccTile3D/assets/Script/Item/HomeLevelNodeControl.ts :SyntaxError: unknown: import = is not supported by @babel/plugin-transform-typescript
Please consider using import <moduleName> from '<moduleName>'; alongside Typescript's --allowSyntheticDefaultImports option.

报错位置是这种代码:
import ChangeButton = require("./ChangeButton");

vscode给的错误提示是:
面向 ECMAScript 模块时,不能使用导入分配。请考虑改用 "import * as ns from "mod""、"import {a} from "mod""、"import d from "mod"" 或另一种模块格式。ts(1202)

目前我只能手动修改项目中的类似代码,建议吧这种情况放到导入插件内自动化掉。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.