Search Unity

Destroying object is not allowed at this time.

Discussion in 'Scripting' started by tfgrip, Aug 5, 2019.

  1. tfgrip

    tfgrip

    Joined:
    Oct 12, 2017
    Posts:
    20
    Hello,

    I am trying to destroy RenderTexture, but I'm getting an

    > Destroying object "Ceto Wave Spectrum GPU Buffer" is not allowed at this time.

    Any idea what does it mean? When is it "not allowed time"?

    Thank you
     
  2. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    2,426
  3. tfgrip

    tfgrip

    Joined:
    Oct 12, 2017
    Posts:
    20
    It's literally just the destruction of RenderTextures

    Code (csharp):
    1.  
    2. texList[i].Release();
    3. UnityEngine.Object.Destroy(texList[i]);
    4.  
    where texList is list of RenderTextures. I'm not sure what more context to give you, as the error is not saying much and I have no idea what can it even be caused by.

    It does not matter when is it destroyed (Update, OnDisable, OnDestroy). If you can tell me when can this error fire, I will be able to check it on my side.
     
  4. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    92
    Hmmm I don't think I've ever needed to call Object.Destroy(...) on a RenderTexture. I figured renderTexture.Release() was enough, but do correct me if I'm wrong.
     
  5. WhendricSo

    WhendricSo

    Joined:
    Jan 1, 2011
    Posts:
    168
    Did you try DestroyImmediate?
     
  6. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    210
    The RenderTexture as configured by that package may be different than other render textures. I'm not sure you should be manually destroying that. Did you talk to the package author about this?

    Also I'm not sure if you should be calling Destroy after Release. Both may defer releasing actual resources, so maybe what Destroy is telling you is that the texture is already scheduled to be released.
     
  7. tfgrip

    tfgrip

    Joined:
    Oct 12, 2017
    Posts:
    20
    DestroyImmediate had same effect.

    @doctorpangloss It's normal Unity's RenderTexture. I was thinking about Destroy as well, I can't see anywhere in the manual mentioned whether they should/can be destroyed or whether just releasing them is enough. This is a 3rd party code (CETO), so I believe they had a reason to do both. I sure hope so.
     
  8. erizzoalbuquerque

    erizzoalbuquerque

    Joined:
    Jan 23, 2015
    Posts:
    2
    Hi @tfgrip . I"m having the same problem with CETO. Any news?
     
  9. tfgrip

    tfgrip

    Joined:
    Oct 12, 2017
    Posts:
    20
    None, we're just ignoring it and hoping for the best ¯\_(ツ)_/¯
     
    Joe-Censored likes this.