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 Unity : Destroy a GameObject that is part of a prefab

Discussion in 'Android' started by Clashman, Jul 28, 2021.

  1. Clashman

    Clashman

    Joined:
    Feb 18, 2019
    Posts:
    53
    The console shows me this error :
    Code (CSharp):
    1. Cannot destroy GameObject that is part of a prefab instance. UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
    I'm confused. The Logs don't tell which prefab or GameObject is involved. Can u help me ?

    Thanks a lot for answers !
     
  2. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    Me too!

     
  3. steinbitglis

    steinbitglis

    Joined:
    Sep 22, 2011
    Posts:
    254
    Turns out, I had instantiated a prefab with
    PrefabUtility
    during the build process. Instantiating with
    Object.Instantiate
    instead worked as intended.