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

Question How to prevent a Gameobject variable of a prefab points to itself but to a prefab in Assets?

Discussion in 'Prefabs' started by s140335, Jan 19, 2021.

  1. s140335

    s140335

    Joined:
    Feb 19, 2020
    Posts:
    4
    The prefab has a script as component, which has a Gameobject variable. I drag the prefab itself to the Gameobject variable in this prefab's Inspector window. Then I drap this prefab to scene. The Gameobject variable in the instantiated prefab in scene points to itself but not to the one in assets. After I drag the prefab in assets to the variable in instantiated prefab in scene and then duplicate the prefab in scene, the variable in the copy still points to the copy itself.

    I need the variable always points to the prefab in assets not the one in scene. What should I do?
     
    Last edited: Jan 19, 2021
    rc82 likes this.