123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- let selectedNode = null;
- let previewMaterial = null;
- module.exports = {
- 'update-material': function (event, ...args) {
- // var canvas = cc.find('Canvas');
- cc.loader.loadRes("preview.mtl", cc.Material, function(err, data) {
- previewMaterial = data;
- //
- if (selectedNode) {
- selectedNode.getComponent(cc.RenderComponent).setMaterial(0, previewMaterial);
- }
- });
- },
- 'update-uniform': function (event, ...args) {
- var canvas = cc.find('Canvas');
- // Editor.log(args);
- if (selectedNode) {
- var material = selectedNode.getComponent(cc.RenderComponent).getMaterial(0);
- for (var k in args[1]) {
- if (material && material.getProperty(k) != undefined) {
- material.setProperty(k, args[1][k]);
- }
- }
- }
- },
- 'node-select-process': function (event, ...args) {
- var canvas = cc.find('Canvas');
- // Editor.log('node-select-process');
- let uuid = Editor.Selection.curSelection('node')[0];
- let node = cc.engine.getInstanceById(uuid);
- selectedNode = node;
- let renderComponent = node.getComponent(cc.RenderComponent);
- if (renderComponent instanceof cc.Sprite) {
- if (node.getComponent(cc.Animation)) {
- // Editor.log('ANIMATION');
- }
- else if (renderComponent._atlas) {
- // Editor.log('SPRITE_ATLAS');
- }
- else {
- // Editor.log('SPRITE');
- Editor.assetdb.queryInfoByUuid(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid, function (err, info) {
- // Editor.log(err)
- // Editor.log("info.path: ");
- // Editor.log("info.path: " + info.path);
- // Editor.log("info.url: " + info.url);
- // Editor.log("info.type: " + info.type)
- Editor.Ipc.sendToPanel('ssr-shaderfx-gallery', 'ssr-shaderfx-gallery:c2p_test', info.url);
- });
- // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid);
- // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.ext);
- // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture().nativeUrl);
- // Editor.Ipc.sendToPanel('ssr-shaderfx-gallery', 'ssr-shaderfx-gallery:c2p_test', node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid);
- if (previewMaterial) {
- node.getComponent(cc.RenderComponent).setMaterial(0, previewMaterial);
- }
- }
- }
- else if (renderComponent instanceof cc.Label) {
- if (renderComponent.font instanceof cc.BitmapFont) {
- // Editor.log('BM_FONT');
- }
- else if (renderComponent.font instanceof cc.TTFFont) {
- // Editor.log('TTF_FONT');
- }
- else if (renderComponent.font instanceof cc.LabelAtlas) {
- // Editor.log('ATLAS_FONT');
- }
- else {
- // Editor.log('SYSTEM_FONT');
- }
- }
- else if (renderComponent instanceof dragonBones.ArmatureDisplay) {
- // Editor.log('DRAGONBONES');
- }
- else if (renderComponent instanceof sp.Skeleton) {
- // Editor.log('SPINE');
- }
- else if (renderComponent instanceof cc.ParticleSystem) {
- // Editor.log('PARTICLE_SYSTEM');
- }
- else if (renderComponent instanceof cc.Graphics) {
- // Editor.log('GRAPHICS');
- }
- else if (renderComponent instanceof cc.MotionStreak) {
- // Editor.log('MOTION_STREAK');
- }
- else if (renderComponent instanceof cc.TiledLayer) {
- // Editor.log('TILED_LAYER');
- }
- else if (renderComponent instanceof cc.Mask) {
- // Editor.log('Mask');
- }
- else {
- if (node.getComponent(cc.RichText)) {
- // Editor.log('RICH_TEXT');
- }
- else if (node.getComponent(cc.TiledMap)) {
- // Editor.log('TILED_MAP');
- }
- // Editor.log('Node');
- }
- // Editor.log(typeof(node.getComponent(cc.RenderComponent)));
- // Editor.log(node.__scriptUuid);
- }
- };
|