/**
         * Post-load initialisation.
         */
        public void load()
        {
            Texture2D[] envMapFaces = new Texture2D[6];

              foreach (GameDatabase.TextureInfo texInfo in GameDatabase.Instance.databaseTexture)
              {
            Texture2D texture = texInfo.texture;
            if (texture == null || !texture.name.StartsWith(DIR_ENVMAP, System.StringComparison.Ordinal))
              continue;

            string originalName = texture.name.Substring(DIR_ENVMAP.Length);

            switch (originalName)
            {
              case "PositiveX":
            envMapFaces[0] = texture;
            break;
              case "NegativeX":
            envMapFaces[1] = texture;
            break;
              case "PositiveY":
            envMapFaces[2] = texture;
            break;
              case "NegativeY":
            envMapFaces[3] = texture;
            break;
              case "PositiveZ":
            envMapFaces[4] = texture;
            break;
              case "NegativeZ":
            envMapFaces[5] = texture;
            break;
              default:
            Util.log("Invalid enironment map texture name {0}", texture.name);
            break;
            }
              }

              // Generate generic reflection cube map texture.
              if (envMapFaces.Any(t => t == null))
              {
            Util.log("Some environment map faces are missing. Static reflections disabled.");
              }
              else
              {
            int envMapSize = envMapFaces[0].width;

            if (envMapFaces.Any(t => t.width != envMapSize || t.height != envMapSize)
            || envMapFaces.Any(t => !Util.isPow2(t.width) || !Util.isPow2(t.height)))
            {
              Util.log("Invalid environment map faces. Static reflections disabled.");
            }
            else
            {
              try
              {
            staticEnvMap = new Cubemap(envMapSize, TextureFormat.RGB24, true);
            staticEnvMap.hideFlags = HideFlags.HideAndDontSave;
            staticEnvMap.wrapMode = TextureWrapMode.Clamp;
            staticEnvMap.SetPixels(envMapFaces[0].GetPixels(), CubemapFace.PositiveX);
            staticEnvMap.SetPixels(envMapFaces[1].GetPixels(), CubemapFace.NegativeX);
            staticEnvMap.SetPixels(envMapFaces[2].GetPixels(), CubemapFace.PositiveY);
            staticEnvMap.SetPixels(envMapFaces[3].GetPixels(), CubemapFace.NegativeY);
            staticEnvMap.SetPixels(envMapFaces[4].GetPixels(), CubemapFace.PositiveZ);
            staticEnvMap.SetPixels(envMapFaces[5].GetPixels(), CubemapFace.NegativeZ);
            staticEnvMap.Apply(true, false);

            Util.log("Static environment map cube texture generated.");
              }
              catch (UnityException)
              {
            if (staticEnvMap != null)
              Object.DestroyImmediate(staticEnvMap);

            staticEnvMap = null;

            Util.log("Failed to set up static reflections. Textures not readable?");
              }
            }
              }

              try
              {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream stream = assembly.GetManifestResourceStream("TextureReplacer.Visor-compiled.shader");
            StreamReader reader = new StreamReader(stream);

            shaderMaterial = new Material(reader.ReadToEnd());
            visorShader = shaderMaterial.shader;

            Util.log("Visor shader sucessfully compiled.");
              }
              catch
              {
            isVisorReflectionEnabled = false;
            Util.log("Visor shader loading failed. Visor reflections disabled.");
              }

              for (int i = 0; i < SHADER_MAP.GetLength(0); ++i)
              {
            Shader original = Shader.Find(SHADER_MAP[i, 0]);
            Shader reflective = SHADER_MAP[i, 1] == visorShader.name ?
                            visorShader : Shader.Find(SHADER_MAP[i, 1]);

            if (original == null)
              Util.log("Shader \"{0}\" missing", SHADER_MAP[i, 0]);
            else if (reflective == null)
              Util.log("Shader \"{0}\" missing", SHADER_MAP[i, 1]);
            else
              shaderMap.Add(original, reflective);
              }

              setReflectionType(reflectionType);
        }