scene-walker.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. let selectedNode = null;
  2. let previewMaterial = null;
  3. module.exports = {
  4. 'update-material': function (event, ...args) {
  5. // var canvas = cc.find('Canvas');
  6. cc.loader.loadRes("preview.mtl", cc.Material, function(err, data) {
  7. previewMaterial = data;
  8. //
  9. if (selectedNode) {
  10. selectedNode.getComponent(cc.RenderComponent).setMaterial(0, previewMaterial);
  11. }
  12. });
  13. },
  14. 'update-uniform': function (event, ...args) {
  15. var canvas = cc.find('Canvas');
  16. // Editor.log(args);
  17. if (selectedNode) {
  18. var material = selectedNode.getComponent(cc.RenderComponent).getMaterial(0);
  19. for (var k in args[1]) {
  20. if (material && material.getProperty(k) != undefined) {
  21. material.setProperty(k, args[1][k]);
  22. }
  23. }
  24. }
  25. },
  26. 'node-select-process': function (event, ...args) {
  27. var canvas = cc.find('Canvas');
  28. // Editor.log('node-select-process');
  29. let uuid = Editor.Selection.curSelection('node')[0];
  30. let node = cc.engine.getInstanceById(uuid);
  31. selectedNode = node;
  32. let renderComponent = node.getComponent(cc.RenderComponent);
  33. if (renderComponent instanceof cc.Sprite) {
  34. if (node.getComponent(cc.Animation)) {
  35. // Editor.log('ANIMATION');
  36. }
  37. else if (renderComponent._atlas) {
  38. // Editor.log('SPRITE_ATLAS');
  39. }
  40. else {
  41. // Editor.log('SPRITE');
  42. Editor.assetdb.queryInfoByUuid(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid, function (err, info) {
  43. // Editor.log(err)
  44. // Editor.log("info.path: ");
  45. // Editor.log("info.path: " + info.path);
  46. // Editor.log("info.url: " + info.url);
  47. // Editor.log("info.type: " + info.type)
  48. Editor.Ipc.sendToPanel('ssr-shaderfx-gallery', 'ssr-shaderfx-gallery:c2p_test', info.url);
  49. });
  50. // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid);
  51. // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.ext);
  52. // Editor.log(node.getComponent(cc.Sprite).spriteFrame.getTexture().nativeUrl);
  53. // Editor.Ipc.sendToPanel('ssr-shaderfx-gallery', 'ssr-shaderfx-gallery:c2p_test', node.getComponent(cc.Sprite).spriteFrame.getTexture()._nativeDep.uuid);
  54. if (previewMaterial) {
  55. node.getComponent(cc.RenderComponent).setMaterial(0, previewMaterial);
  56. }
  57. }
  58. }
  59. else if (renderComponent instanceof cc.Label) {
  60. if (renderComponent.font instanceof cc.BitmapFont) {
  61. // Editor.log('BM_FONT');
  62. }
  63. else if (renderComponent.font instanceof cc.TTFFont) {
  64. // Editor.log('TTF_FONT');
  65. }
  66. else if (renderComponent.font instanceof cc.LabelAtlas) {
  67. // Editor.log('ATLAS_FONT');
  68. }
  69. else {
  70. // Editor.log('SYSTEM_FONT');
  71. }
  72. }
  73. else if (renderComponent instanceof dragonBones.ArmatureDisplay) {
  74. // Editor.log('DRAGONBONES');
  75. }
  76. else if (renderComponent instanceof sp.Skeleton) {
  77. // Editor.log('SPINE');
  78. }
  79. else if (renderComponent instanceof cc.ParticleSystem) {
  80. // Editor.log('PARTICLE_SYSTEM');
  81. }
  82. else if (renderComponent instanceof cc.Graphics) {
  83. // Editor.log('GRAPHICS');
  84. }
  85. else if (renderComponent instanceof cc.MotionStreak) {
  86. // Editor.log('MOTION_STREAK');
  87. }
  88. else if (renderComponent instanceof cc.TiledLayer) {
  89. // Editor.log('TILED_LAYER');
  90. }
  91. else if (renderComponent instanceof cc.Mask) {
  92. // Editor.log('Mask');
  93. }
  94. else {
  95. if (node.getComponent(cc.RichText)) {
  96. // Editor.log('RICH_TEXT');
  97. }
  98. else if (node.getComponent(cc.TiledMap)) {
  99. // Editor.log('TILED_MAP');
  100. }
  101. // Editor.log('Node');
  102. }
  103. // Editor.log(typeof(node.getComponent(cc.RenderComponent)));
  104. // Editor.log(node.__scriptUuid);
  105. }
  106. };