Evren Çakmak
Evren Çakmak

Reputation: 1

Game scene sometimes starts dark

In my game, I tried Skybox Tint animation from dark to light. I used this on Menu and Game Over scenes. They are working but sometimes Game scene is starting dark. I tried change Skybox tint on Start function but didn't work. Only sometimes i have this problem. I couldn't find what i am changing.

Menu Scene Codes:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Menu : MonoBehaviour
{
    byte rgb;

    void Start()
    {
        rgb = 0;
        StartCoroutine(SkyboxAnimation());    
    }

    IEnumerator SkyboxAnimation()
   {
        while (rgb < 125)
        {
            RenderSettings.skybox.SetColor("_Tint", new Color32(rgb, rgb, rgb, 255));
            rgb += 3;
            yield return new WaitForSeconds(0.05f);
        }
    }
}

Everytime Menu codes are working. Scene is starting from dark to light.

Game Scene Codes on Main Camera:

    void Start()
    {
        RenderSettings.skybox.SetColor("_Tint", new Color32(126, 126, 126, 255));
    }

Game Over Scene Codes:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameOver : MonoBehaviour
{
    byte rgb;

    void Start()
    {
        Time.timeScale = 1;
        rgb = 0;
        StartCoroutine(SkyboxAnimation());      
    }

    IEnumerator SkyboxAnimation()
    {
        while (rgb < 125)
        {
            RenderSettings.skybox.SetColor("_Tint", new Color32(rgb, rgb, rgb, 255));
            rgb += 3;
            yield return new WaitForSeconds(0.05f);
        }
    }
}

Upvotes: 0

Views: 37

Answers (1)

Mike
Mike

Reputation: 11

Have you tried to put it in void Awake()? You could just be setting it back light slightly after the scene is loaded. That could explain why you're seeing it (if it's going back to light quickly.)

Upvotes: 0

Related Questions