《新·快闪编辑器》快速一览常用功能、自动修改import路径、拖拽资源到代码自动绑定关系

这么夸张吗?为什么虚脱?

推广渠道有这需求的用户消耗完了

永远单身还是永远的神呀?

大图片预览预览我买了一个1块钱的插件,稍微修改挺合手,我虽然只敲了10来20行,但是也想去卖1块钱咋破?会被鄙视吗?

图片颜色拾取 | Cocos Store
https://store.cocos.com/app/detail/2539

我改了他的panel/index.js

Editor.Panel.extend({


    // html template for panel
    template: `
    <div style="height: 100%; width: 100%; overflow-y: auto; overflow-x: auto;">
    <h2>色值:</h2>
    <div style="display: flex; align-items: center; justify-content: center; height:30px">
    <div v-bind:style="colorShow"></div>
    <div style="height: 20px;vertical-align: middle;display: inline-block; ">
    <ui-input :value="nowColorHex" ></ui-input>
    </div>
    </div>
    
    <hr />
    <canvas id="image-canvas" width="300px" height="300px" style="border: 1px solid #c3c3c3;"></canvas>
    <hr />
    <h3>操作步骤</h3>
    <h4>1:选择资源管理器中的图片</h4>
    <h4>2:点击图片拾取颜色</h4>
    </div>
  `,

    // method executed when template and styles are successfully loaded and initialized
    $: {
        canvs: '#image-canvas'
    },

    ready() {
        this._vue = new Vue({
            el: this.shadowRoot,
            data: {
                nowColorHex: '',
                colorShow: {
                    display: 'inline-block',
                    verticalAlign: 'middle',
                    backgroundColor: '#FFFFFF',
                    width: '20px',
                    height: '20px'
                }
            }
        });
        let _ctx = this.$canvs.getContext('2d');
        _ctx.font = "40px Arial";
        _ctx.textAlign = "center";
        _ctx.fillText("没有选择图片", 150, 150);
        this.$canvs.addEventListener('click', (e) => {
            let _ctx = this.$canvs.getContext('2d');
            let x = e.pageX - this.$canvs.getBoundingClientRect().left
            let y = e.pageY - this.$canvs.getBoundingClientRect().top
            let _imgDatas = _ctx.getImageData(x, y, 1, 1);
            let _hexstring = '#';
            for (let i = 0; i < 3; i++) {
                let _hex = _imgDatas.data[i].toString(16);
                _hexstring += _hex.length == 2 ? _hex : '0' + _hex;
            }
            this._vue.nowColorHex = _hexstring;
            this._vue.colorShow.backgroundColor = _hexstring;
        })
    },

    // register your ipc messages here
    messages: {
        'show-image'(event_, url_) {
            let _ctx = this.$canvs.getContext('2d');
            let _img = new Image();
            _img.onload = function () {
                //		  debugger;
                //        _ctx.drawImage(_img, 0, 0, 300, 300);
                let scale = 1;

                if(_img.height > 768)
                {
                    scale = 768 / _img.height;//1280 * 0.6 = 768
                }else if(_img.width > 460)
                {
                    scale = 460 / _img.width;  //768 * 0.6 = 460.8
                }
                this.$canvs.width = Math.floor(_img.width * scale);
                this.$canvs.height = Math.floor(_img.height * scale);
                _ctx.clearRect(0, 0, Math.floor(_img.width * scale), Math.floor(_img.height * scale));
                _ctx.drawImage(_img, 0, 0, _img.width, _img.height, 0, 0, Math.floor(_img.width * scale), Math.floor(_img.height * scale));
            }.bind(this)
            _img.src = url_;
        }
    }
});
1赞

yyds啊

baby哥喝茶。 :tropical_drink: :wine_glass: :cocktail: :watermelon: :melon: :tangerine:

1赞

问下作者同意就行:grin:

想问一下大佬是怎么获取到 ts 中 import 的文件路径的?跪求

monaoc 框架ts解析器获取的

感谢大佬!!!

大佬,没找到… 有传送门吗?[暗中观察][暗中观察][暗中观察]

我来拍马蹄的,这个插件的快速拖节点绑定有点牛。的确省了不少时间。

就是经常写文件锁定文件了报小错,不知新版本如何了。

感谢反馈,报错截图看看

大佬,拖放的加属性绑定的时候,需要先选中某个节点,稍等,然后拖放才能识别选中的而不是拖放的。好像插件是取选中的节点而不是正在拖放的节点。

嗯,我也发现了,需要点一下再拖过去,如果已经选中了就可以直接拖过去
这是creator api 获取选中状态返回bug,鼠标没法放手不会标记选中状态
我在联系官方有没有解决方法

拖放节点的时候,如果节点既有Sprite也有Animation,这个时候默认都是Sprite绑定,不会弹框给用户选择哪个组件。

如果没有Sprite但是有Animation的时候,生成的类型是cc.Node,这个稍微不够智能。

可以,这个改一下

好像快速多按几次保存,也许会出现,出现机制不明。这个需要完全重启Creator才能变为不报错,直接CTRL + R 重启还不行。

2021-06-25T11:16:03.592Z - failed: [db-task][update] Failed to delete imported assets of dca4d4ca-7f5b-409b-8f26-b5506b186f9d during save, message: Error: EPERM: operation not permitted, unlink 'xxxxxxxxxx\library\imports\dc\dca4d4ca-7f5b-409b-8f26-b5506b186f9d.js'
2021-06-25T11:16:03.609Z - error: Failed to update asset db://assets/XXXXXXXXXXXXXXX/scripts/XXXXXXXX.ts, messages: Error: EPERM: operation not permitted, open 'xxxxxxxxxxxxxx\library\imports\dc\dca4d4ca-7f5b-409b-8f26-b5506b186f9d.js'
    at Object.openSync (fs.js:453:3)
    at Object.func [as openSync] (electron/js2c/asar.js:172:31)
    at Object.writeFileSync (fs.js:1246:35)
    at u.o.saveAssetToLibrary (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\asset-db\lib\utils.js:1:2662)
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\editor\share\assets\meta\javascript.js:1:2002
    at nextTask (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:4578:27)
    at next (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:4586:13)
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:325:20
    at compile (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\editor\share\assets\meta\precompile-script.js:1:693)
    at nextTask (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:4578:27)
    at u.o.error (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\asset-db\lib\utils.js:1:2118)
    at Object.callback (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\asset-db\lib\interface.js:1:5061)
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:1315:26
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:325:20
    at u.<anonymous> (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\asset-db\index.js:1:1779)
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\asset-db\lib\tasks.js:1:19779
    at wrapper (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:272:20)
    at next (C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:4584:24)
    at C:\CocosDashboard_1.0.10\resources\.editors\Creator\2.4.3\resources\app.asar\node_modules\async\dist\async.js:325:20

这个记得别绑定自定义组件(例如MyComp extends cc.Component)。自定义组件无法显示在属性上。Creator界面会报null,并且create按钮还不能变成输入框。

控制台搜索报错信息看没有 simple-code这个路径的
这日志全是creator路径下的不好分析:pensive:

这一点也一起改,到时吧自定义组件也import进来就好

应该没有。这都异步发消息给Creator了吧。你可能是调用了AssetDB的方法,调得太快导致Creator出现小BUG?