Hi All,
Is there a way to overwrite the base class function to define our own implementation?
Requirement :- Since zIndex support is not available anymore in 3.8.2 I am using setSiblingIndex() to update the priority of the node as per my game requirement. I have to shuffle the node priority few time.
Example :- Children in node are
child1, child2, child3, child4, child5
to
child1, child2, child5, child3, child4
to
child1, child2, child5, child4, child3
I am setting the setSiblingIndex() value to a high number by keeping a reference of number attach to type of image kept in node.
But base code is always push the element to the end if index is greater than no of children. So I cannot leave gap within index range.
Please tag core member for update or guidance how to overwrite it.
Thanks
Below is the core definition of function.
/**
* @en Set the sibling index of the current node in its parent's children array.
* @zh 设置当前节点在父节点的 children 数组中的位置。
*/
public setSiblingIndex (index: number): void {
if (!this._parent) {
return;
}
if (this._parent._objFlags & Deactivating) {
errorID(3821);
return;
}
const siblings = this._parent._children;
index = index !== -1 ? index : siblings.length - 1;
const oldIndex = siblings.indexOf(this);
if (index !== oldIndex) {
siblings.splice(oldIndex, 1);
if (index < siblings.length) {
siblings.splice(index, 0, this);
} else {
siblings.push(this);
}
this._parent._updateSiblingIndex();
if (this._onSiblingIndexChanged) {
this._onSiblingIndexChanged(index);
}
this._eventProcessor.onUpdatingSiblingIndex();
}
}