Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Shaders declared as strings not being destroyed?

Discussion in 'Scripting' started by BigRedSwitch, Aug 31, 2011.

  1. BigRedSwitch

    BigRedSwitch

    Joined:
    Feb 11, 2009
    Posts:
    724
    Hey, all,

    I'm using the character shadow script from the Unify wiki in my game, which declares 2 shaders for use with the shadow system.

    I've noticed that the amount of shaders in my game is increasing per frame, and when I get Unity to log which are in memory, there are numerous versions of these 2 shaders.

    I've modified the original script to include an OnDestroy function to make sure there is nothing referencing these shaders, but this hasn't helped.

    This is less than optimal, as it means that my game is progressively leaking memory (which is being taken up by multiple instances of these shaders), so does anyone know why this is happening?

    Cheers,

    SB