playcanvas / playcanvas/engine
LayoutGroup force validation and fire event
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Hello,
I’ve a menu with a 2D Screen, an image with a layout group and finally several buttons in children of this group. They are centered on the middle of the screen.
I want to create a tween animation, from the left screen border to their final position :
HomeManager.prototype.postInitialize = function()
{
const startPosition = this.play.getLocalPosition().clone();
this.play.setLocalPosition(new pc.Vec3(-500, startPosition.y, startPosition.z));
this.play.tween(this.play.getLocalPosition()).to(startPosition, 1, pc.BackOut).start();
};
The tween works, however the final position is not correct. It’s because the layout group calculations wasn’t finished, and we have to wait a frame. If I put a setTimeout, or wait a frame via this.app.once('update', function() {, no problem.
How to know when calculations is done? Can we force calculation or have an event when ready?
It would be nice to have a method to force/refresh validation and perhaps an event fired?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the LayoutGroup validation flow and the app update event mentioned in the issue, using postInitialize as the reproduction entry point. Verify when child positions become final, then define and test a public way to force validation or signal completion; done means the tween can start without waiting for a frame.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100