コード例 #1
0
    private void initSkyboxColor()
    {
        Color skyboxColor = new Color();

        skyboxColor.r = levelColor.r;
        skyboxColor.g = levelColor.g;
        skyboxColor.b = levelColor.b;
        skyboxColor.a = 128.0f;

        // skybox.material is a shared material and we don't want to modify the prefab, so just clone it
        GameObject camera              = GameObject.FindGameObjectWithTag("MainCamera");
        Skybox     originalSkybox      = camera.GetComponent <Skybox> ();
        Material   levelSkyboxMaterial = Material.Instantiate(originalSkybox.material);

        levelSkyboxMaterial.SetColor("_Tint", skyboxColor);
        Skybox.Destroy(originalSkybox);
        Skybox levelSkybox = camera.AddComponent <Skybox>();

        levelSkybox.material = levelSkyboxMaterial;
    }