Children gameobjects change position and size whenever i re-open the project

Every time i open my project the position and size of the childrens of a certain gameobject changes from the last time i saved and closed said project. This is so annoying cause everytime i have to move and resize back each gameobject before actually making any progress. please help

This is not enough information.

Does that object have any behaviours attached to it? One of them might be set to execute in edit mode (or might have a function that gets called when the scene is loaded).

Show us what's attached to this object.

here, sorry but since i have no idea of what is going on i also have no idea of what information might be needed

8934003--1224957--gameobject.png

This looks like it’s part of a canvas (since you have a RectTransform, rather than a regular Transform). Perhaps you have components on them that reposition them.

Can you show us the overall hierarchy?

Do those child objects have any components on them?

sure, here ther hierarchy, the components on the child objects (and of the canvas you were refering too just to be sure) and the code of the script attacted to each child (again, just in case)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bgobs : MonoBehaviour
{
    Vector3 fixedPos;
    void Start()
    {
        fixedPos = transform.position;
    }

    void Update()
    {
        transform.position=new Vector3(fixedPos.x, fixedPos.y,transform.position.z);
    }
}

8934060--1224963--hi.png
8934060--1224966--children type 2.png
8934060--1224969--children type 1.png
8934060--1224972--parent.png

please someone help i really can't take this anymore

I'm also experiencing this same issue. My project is on v2022.3.4f1, and every time I open it some UI child objects of my menu prefab will be overridden and shifted around as compared to when I saved and exited. The changes are only at the scene level, and not applied to the underlying prefab itself.

Looking more closely at the overrides, all of the affected children are having their "Pos Y" / "Top" values (depending on their anchors) set to 0 on the rect. I don't see any other common factors between them though. They all have different starting positions and different anchor presets, so I don't know how it decides which children to move, but it is the same ones each time. I do not have any scripts currently attached which affect the position of anything on the canvas in question, especially not in edit mode. Even some newly created objects are moved despite definitely not being referenced anywhere.

My current work-around is to just revert the changes on the prefab object when I reload. It is slightly annoying but saves me from having to move them back each time.

2 Likes

HI, I am having the same issue. Did you find any solution? Thanks

ok so it looks like they are UI type game objects where they could have anchors and are on a canvas possibly set to rescale depending, and in your ide, if you resize some of the windows such as make the project window or heirachy window bigger to see something it can make things appear to move or change size

Hey there. Same happens to me in Unity 2022.3.4f
I did some work around and noticed, if after openening your project you see that your objects are not on the right places, just open another scene and then go back to the previous one, all will be fine. No need to revert positions manually.

Thanks a lot!!! It works for position changing of canvas. After swapping scenes, broken canvas was in right state.