Move one object after all other child elements

I am doing a chat. I need to add new posts below the rest. I am using an object pool.
How can I move one entity after all other children?


I think the example project below can be helpful.

For chat I personally do the opposite, so new messages on top.

Probably because I was unable to make the new messages on the bottom visible, with the example project above. :see_no_evil:

In this project, new objects are constantly being added.

However, I have already created 20 objects in advance, which represent a pool from which the oldest message is taken, its text is changed, and it should be moved to the end.

It is important not to create new objects, but to use existing ones, as creating new objects affects performance. Another issue is that your strings are fixed, but the text should be able to wrap depending on its length, and the message height should adjust automatically based on the number of lines.

I need a method similar to what is well-implemented in Unity Unity - Scripting API: Transform.SetAsLastSibling.

With the example project shared, I was be able to create a chat for my own project.

An example project is not exactly what you need. You can study the project and modify it to your needs.

Maybe someone else has a better suggestion.

1 Like

You would have to unparent the element and reparent it so that it moves last in the list of children. I’m afraid we don’t have help functions like Unity’s to move entities around.

At best we have, insertChild, addChild, reparent and removeChild

1 Like

I think changing the parent is a suitable option in the absence of others.

However, I have already implemented my own system for organizing the list of messages :slightly_smiling_face: