Hi!
I’m trying to create sprite programmatically. For now no success.
Is it even possible to create sprite from texture and add it to scene programmatically WITHOUT Editor?
I’ve tried different approached. Nothing seems to works.
My code for now is:
Sprite is just doesn’t render. No errors.
What should I do? I’ve tried to set sprite field to sprite component, different mixes of properties - no errors, no sprite rendering.
Unfortunately, I can’t share project because of NDA. And the project in Editor is using just for assets, everything creating from scratch from code. The problem that by pipeline everything should be recreated from code without Editor. Models, particles work fine. But sprites just don’t render, without errors.
Textures load fine, they work with models and particles.
TextureAtlas I’ve created by Playcanvas documentation.
Can’t recognize what data Sprite requires to render.
@yaustar Thanks.
It’s similar to what I do. But I need the Sprite to render on the 3D scene, not for UI.
It works in Editor, I can easily add Sprite on the scene. But I can’t accomplish it manually from code.
But it renders nothing. I can add particle system and everything is working just fine.
But sprite isn’t working on the same entity. That’s how I know that’s entity on the scene and everything is ok.
Maybe I should to provide more data to sprite component? Or should I do it in some specific order?
It works like a charm! Thank you a lot! You’re brilliant!
My code wasn’t working because I didn’t get that atlas waits textureAsset.resource, not textureAsset itself.
The problem is that project that I’m working on now doesn’t use Playcanvas as web service and wants everything to be done from code manually . It confuses me, as I understand Playcanvas is designed like web service, so it is strange to not use it power.
You all, Playcanvas team, is doing a magnificent work! Great engine with great possibilities.
Thank you all!