Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Cannot move scene game object into a prefab.

Discussion in 'Prefabs' started by Funonium, Mar 25, 2021.

  1. Funonium

    Funonium

    Joined:
    Aug 7, 2019
    Posts:
    5
    This seems like it should be trivial. I have an instance of a prefab in my scene and there is a game object next to it in the hierarchy. I want this game object to become a child of the prefab and apply it so that all instances have this game object. I cannot drag the game object into the prefab, I get the following message:

    "Children of a prefab instance cannot be deleted or moved, and components cannot be reordered. You can open the prefab in prefab mode to restructure the prefab asset itself, or unpack the prefab instance to remove its prefab connection."

    Obviously, if I open prefab mode, I do not have access to the scene objects to add them to the prefab. This is just an empty game object, something I can easily add anywhere into the prefab through the right-click menu, just not through a drag and drop.

    Why do I care? I am trying to rotate/position a game object relative to an object outside of the prefab (so making it a child and resetting the transform), then I want to move that game object into the prefab so it generates a relative position/rotation within the prefab that I can use to check for alignment with other objects later. My only option seems to be to unpack the prefab, add the posed game object, manually record position/rotation, undo the unpack, directly add the game object through the right click menu and type in the position/rotation. Just seems... unnecessary.

    EDIT: Just discovered that I can copy the game object and paste as child into the prefab instance, then delete the old game object. Still, why not a move option?
     
    Last edited: Mar 25, 2021
  2. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,105
    I think you need to put the scene object as a child of the prefab then go to the prefab properties and use the override option to apply the changes (make the child object part of prefab permanently)

    as explained here

    https://docs.unity3d.com/Manual/EditingPrefabViaInstance.html

    so no drag directly into the prefab, add under, then use override options
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    You can move it, you just can't insert it as anything else than the last child of a transform.

    So this is not allowed:
    upload_2021-3-31_10-46-17.png

    This is allowed:
    upload_2021-3-31_10-46-34.png

    This is also allowed, and does the same thing as the image above:
    upload_2021-3-31_10-46-55.png

    This is a major problem for UGUI, so it for sure should be fixed, but I'm not sure if the prefab team is still making improvements.
     
  4. Daahrien

    Daahrien

    Joined:
    Dec 5, 2016
    Posts:
    100
    This is by design. Also you can add the object as a child of a child of the prefab. Same thing it will be added as the last child of the child of the prefab :p

    I doubt UGUI matters now since they practically abandoned it 2 years ago in favor of the new UIElements.