Comments (6)
Thanks ggarek, this is a bug, and I hadn't noticed.
from cocos-engine.
Wait, this is by design, not a bug. Only assets under assets/resources
directory will be copied.
Please try:
var url = cc.url.raw("resources/particles/1.plist");
particleSystem.file = url;
from cocos-engine.
@jareguo I created new project from scratch to check it once again. I think there is a though, let me put some more details about it.
First of all, this thing is not correct
var url = cc.url.raw("resources/particles/1.plist");
because the cc.url.raw
adds the relative path prefix to the resources in runtime, so you need only pass a path to a specific resource you need relative to your assets/
folder within Cocos Creator.
So if you have
-- assets
-- textures
-- mytexture.png
then to get the correct url to mytexture.png
you need to make this call:
var url = cc.url.raw("textures/mytexture.png");
Regarding the bug.
I create a project, add particle resource, then drag the particle file to the scene in Cocos Creator. In this case both files (.plist and .png) are copied to the build directory.
But, when i add a particle to Assets in Cocos Creator, then i create the ParticleSystem in runtime, like this:
start: function () {
const node = new cc.Node();
const ps = node.addComponent(cc.ParticleSystem);
ps.file = cc.url.raw('/particles/fire-parts.plist');
node.setPosition(200, 200);
cc.director.getScene().addChild(node);
},
It works in development mode, but when i build the project, the .plist
file is absent in the output directory. The .png file though is copied.
Here is the assets dir listing:
➜ cc-particles-not-copied ls -al assets/particles
total 64
drwxr-xr-x 10 garek staff 340 Apr 18 13:10 .
drwxr-xr-x 11 garek staff 374 Apr 18 12:56 ..
-rw-r--r-- 1 garek staff 2463 Apr 18 12:47 fire-parts.plist
-rw-r--r-- 1 garek staff 88 Apr 18 12:47 fire-parts.plist.meta
-rwxr-xr-x 1 garek staff 622 Apr 18 12:47 fire.png
-rw-r--r-- 1 garek staff 633 Apr 18 12:47 fire.png.meta
-rw-r--r-- 1 garek staff 2872 Apr 18 12:45 meteor-tail.plist
-rw-r--r-- 1 garek staff 88 Apr 18 12:45 meteor-tail.plist.meta
-rw-r--r-- 1 garek staff 1210 Apr 18 12:45 particle2.png
-rw-r--r-- 1 garek staff 636 Apr 18 12:45 particle2.png.meta
And here is the build dir listing:
➜ cc-particles-not-copied ls -al build/web-desktop/res/raw-assets/particles
total 24
drwxr-xr-x 5 garek staff 170 Apr 18 13:11 .
drwxr-xr-x 4 garek staff 136 Apr 18 13:11 ..
-rwxr-xr-x 1 garek staff 622 Apr 18 13:11 fire.png
-rw-r--r-- 1 garek staff 2872 Apr 18 13:11 meteor-tail.plist
-rw-r--r-- 1 garek staff 1210 Apr 18 13:11 particle2.png
As you can see, fire.png
file is present, but fire-parts.plist
is not.
from cocos-engine.
But, when i add a particle to Assets in Cocos Creator, then i create the ParticleSystem in runtime
It works in development mode, but when i build the project, the .plist file is absent in the output directory. The .png file though is copied.
As mentioned above, only assets under assets/resources directory will be copied to the output directory.
from cocos-engine.
Ok, i tried to put the .plist and .png which i use to create ParticleSystem dynamically under assets/resources
and it is now copied during the build process. Thanks, now i get what you meant.
Still it seems not very convenient. If i create a node via editor then the resource files are copied to the build directory no matter the path, but if i do it dynamically, then i need to put it under a specific path.
But i guess, it may change through the versions, or there will be a hint so everybody know the name convention.
Anyways, thanks for the explanation!
from cocos-engine.
Yes there will be a hint in the future, thanks for the feedback ~~~
from cocos-engine.
Related Issues (20)
- cc.sp.spine lost EventType in native release mode
- [2D] [iOS web] Sprite is not rendered with RenderRoot2D and Camera.Far = 1000 (default value) HOT 5
- 在编辑器中给选中的模型增加描边 HOT 1
- 将碰撞组件的体积编辑功能独立成通用体积组件
- Potential bug in transformMat4Normal,but I’m not certain HOT 5
- Label 纹理释放问题
- import-map don't support db://
- [3.8.2] Modify active of different canvas when previewing editor To switch rendering content, render residue appears HOT 3
- [extensions] Support defining new recognized file formats - or resource files.
- Support Tinify API to compress images and Auto Atlas as well
- [Bug 3.8.2] Two BoxColliders fails to emit 'onTriggerEnter' event when using PhysX backend
- duplicative `timeScale` of Spine Animation HOT 2
- API to Get all skin names array of Spine Animaton
- about cc.d.ts : Please add defalut <T> to Tween
- SpriteFrame的clone的时候,packable没有正确进行克隆
- in `cc.d.ts` , doen't export `getUIPreviousLocation()`
- an API for getting number of ResolutionPolicy .
- [3.8.2] EditBox销毁后在屏幕尺寸变化时报错. HOT 2
- Nested property animation clip is not serialized properly on first try
- Remove "@cocos/build-engine" module
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cocos-engine.