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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Can't Restart Game "Destroying assets is not permitted to avoid data loss"

Discussion in 'Scripting' started by gogocook25, Nov 1, 2018.

  1. gogocook25

    gogocook25

    Joined:
    Sep 30, 2018
    Posts:
    36
    Hi everyone, wondering if you could help me restart my game. I want the game to restart as it would if you pressed the play button again. I saw a couple examples online try SceneManager.LoadScene(), but when I tried this I got the error mentioned: "Destroying assets is not permitted to avoid data loss". My scene shows all the assets in the hierarchy, but my scripts don't run. I looked over the documentation for loadScene, but couldn't find any clues. I would appreciate your help!
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Are you trying to call Destroy() on prefabs rather than instantiated instances?
     
    Kiwasi, gogocook25 and Joe-Censored like this.
  3. gogocook25

    gogocook25

    Joined:
    Sep 30, 2018
    Posts:
    36
    ahh, you are right I forgot to assign instance to variable. Thanks that solved the problem.
     
    Last edited: Nov 1, 2018