Destroying and recreating renderers/shaders at runtime

Hi, I am having trouble with changing Anti Aliasing at run time and I would like to find a work around, I believe it has something to do with not destroying and recreating renderers at run time. I have managed to destroy the renderers at run time but recreating them is proving difficult at the moment.

Has anyone had experience or has an idea how I would be able to do this?

            renderers = (Renderer[])FindObjectsOfType(typeof(Renderer));

            foreach (Renderer renderer in renderers)
            {
                if (renderer.sharedMaterial.mainTexture != null)
                {
                    //Save Textures
                    //textureForMaterial[renderer.sharedMaterial] = renderer.sharedMaterial.mainTexture;
                    //Remove Textures
                    //renderer.sharedMaterial.mainTexture = null;
                    Renderer.Destroy(renderer);
                    //print(renderer.sharedMaterial.shader);
                    //Shader.DestroyImmediate(renderer.sharedMaterial.shader, true);
                }
            }

Assuming you want to enable/disable it. Open up the AntiAliasaing.cs or js file and look for OnRenderImage(…)
From at the top of the method simply add.

if(PlayerPrefs.GetInt("AAEnabled") == 0)
{
    Graphics.Blit (source, destination);
    return;
}

I hope this information helps you. :wink:
Worth a shot I guess.