Bug with setSiblingIndex()?

I am using Cocos Creator version 3.6.2, here is my issue:

I create two card,then i register touch event for each card that will process this:

this.node.setSiblingIndex(1);

When clicking on Clover 1 :

console: 1 sibling index: 1 //2 sibling index: 0
Here’s my problem: everytime i click on red areas, clover2 will change siblingindex to 1:
(after click):
console:1 sibling index: 0 //2 sibling index: 1.
Can anyone explain why??


Many thanks,

parent.pauseSystemEvents(true);
node.setSiblingIndex(length - 1);
parent.resumeSystemEvents(true);

try this.

1 Like

thanks,its works :smiley:

let uiTransform = this.node.getComponent(UITransform);
if (uiTransform)
uiTransform.priority = zIndex;

try this, i have tested, it work with me

use priority is better than setsibling in some case, its like zIndex in 2x, i have tried but you should use pauseSystemEvents as @Koei 's reply to avoid error.

1 Like

this is a bug, an issue has been created to handle it.a

1 Like

@Koei I’ve detected that your advice only works on Web preview, not in simulator or phone preview, any suggestions?

I find out this solution instead of using setsiblingindex():

var parent=this.node.parent;

this.node.removeFromParent();

parent.insertChild(this.node,position);

I tested it is normal,are you sure you are using 3.6.2? Or can you give a demo to see?
Native doesn’t work has been fixed before.

NewProject_3.zip (2.9 MB)
here, i try preview on simulator.

image
try this.

image
Why is the project version 3.6.0 and not 3.6.2? :joy:

sorry my bad, i change version recently LOL, any differents?

The native non-effective issue was fixed after 3.6.1, if you want to use 3.6.0, you need to merge this pr manually

1 Like