Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

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

Discussion in 'Editor & General Support' started by unity_fgzF89-XxIWu9g, Apr 7, 2023.

  1. unity_fgzF89-XxIWu9g

    unity_fgzF89-XxIWu9g

    Joined:
    Apr 7, 2023
    Posts:
    4
    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
     
  2. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    717
    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.
     
  3. unity_fgzF89-XxIWu9g

    unity_fgzF89-XxIWu9g

    Joined:
    Apr 7, 2023
    Posts:
    4
    here, sorry but since i have no idea of what is going on i also have no idea of what information might be needed
     

    Attached Files:

  4. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    717
    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?
     
  5. unity_fgzF89-XxIWu9g

    unity_fgzF89-XxIWu9g

    Joined:
    Apr 7, 2023
    Posts:
    4
    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)

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class Bgobs : MonoBehaviour
    6. {
    7.     Vector3 fixedPos;
    8.     void Start()
    9.     {
    10.         fixedPos = transform.position;
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.         transform.position=new Vector3(fixedPos.x, fixedPos.y,transform.position.z);
    16.     }
    17. }
     

    Attached Files:

  6. unity_fgzF89-XxIWu9g

    unity_fgzF89-XxIWu9g

    Joined:
    Apr 7, 2023
    Posts:
    4
    please someone help i really can't take this anymore
     
  7. TimothyJoseph

    TimothyJoseph

    Joined:
    Mar 21, 2020
    Posts:
    1
    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.
     
    caiobrreis and Marrlie like this.
  8. luisgvecchio

    luisgvecchio

    Joined:
    Sep 23, 2021
    Posts:
    1
    HI, I am having the same issue. Did you find any solution? Thanks
     
  9. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    810
    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