Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Can't remove sub assets with DestroyImmediete(object,true) (in 2017 it works)

Discussion in 'Prefabs' started by Nirvan, Jan 30, 2020.

  1. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    100
    I can't remove sub assets from my prefabs. (unity 2019.3)
    I using DestroyImmediate(mySubAsset, true); after reimporting nothing changes, but when I do it in exact situation in unity 2017 it works without any trouble.
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    544
    After the call to DestroyImmediate try to add a call to
    Code (csharp):
    1. AssetDatabase.SaveAssets()
     
  3. Nirvan

    Nirvan

    Joined:
    Nov 16, 2013
    Posts:
    100
    They're still here, I also doing

    Code (CSharp):
    1. AssetDatabase.SaveAssets();
    2. AssetDatabase.ImportAsset(prefabPath);
    3. AssetDatabase.Refresh();
    Edit:
    Lol, I figured out I was performing this actions on nulls.
    I created list of <Object> to remove and after calling AssetDatabase.ImportAsset(prefabPath);
    all list elements becoming null, wtf? Anyway, when I not call import asset before removing actions then it works.
     
unityunity