Destroying assets is not permitted to avoid data loss | Unity resolve

 Destroying assets is not permitted to avoid data loss



Destroying assets is not permitted to avoid data loss




Example of error :

Function WaitAndDie()
    {
        
        var clonedeathEffect = Instantiate(deathEffecttransform.positionQuaternion.identity);       
            
        yield return new WaitForSeconds (dieDelay);
 
        Destroy(deathEffect);

    }


you get the error because this line :

Destroy(deathEffect);

To resolve the error you need to use this method var clonedeathEffect     like  this :

Function WaitAndDie()
    {
        
        var clonedeathEffect = Instantiate(deathEffecttransform.positionQuaternion.identity);       
    
        yield return new WaitForSeconds (dieDelay);

        Destroy(clonedeathEffect);

    }

destroying assets is not permitted to avoid data loss texture destroying a gameobject inside a prefab instance is not allowed unity destroy unity instantiate and destroy unity destroyimmediate destroy scene unity waitforseconds unity unity destroy component destroying a gameobject inside a prefab instance is not allowed unity destroyimmediate