Search Unity

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