Jump to content

How to switch Lightning Profile programmatically from another script?


MeHowLipa
Go to solution Solved by MeHowLipa,

Recommended Posts

Hey, 

My setup:
Unity: 2021.3
Gaia: Gaia 2021 (not PRO)

I would like to write simple script to change time of day lightning base of my own timer. The problem is that I can't access/use programmatically any Gaia method to change lightning profile. 

My last script was trying to just use Gaia Lighting GameObject but I'm getting errors such as:

Quote

Assets/Code/Utilities/LightingManager.cs(15,9): error CS0246: The type or namespace name 'GaiaSceneLighting' could not be found (are you missing a using directive or an assembly reference?)

Assets/Code/Utilities/LightingManager.cs(15,74): error CS0246: The type or namespace name 'GaiaSceneLighting' could not be found (are you missing a using directive or an assembly reference?)
 



This is my example script:
 

using UnityEngine;

public class LightingManager : MonoBehaviour
{
    public GameObject gaiaLighting; // Drag and drop your Gaia lighting object in the inspector
    private Gaia.GaiaSettings m_gaiaSettings;

    private void Start()
    {
        m_gaiaSettings = Gaia.GaiaUtils.GetGaiaSettings();
    }

    public void UpdateLightingProfile(int hour)
    {
        GaiaSceneLighting gaiaLighting = gaiaLightingObject.GetComponent<GaiaSceneLighting>();

        // Morning: 5:00 - 9:00
        if (hour >= 5 && hour < 9)
        {
            gaiaLighting.SwitchProfile("UserMorning");
        }
        // Day: 9:00 - 17:00
        else if (hour >= 9 && hour < 17)
        {
            gaiaLighting.SwitchProfile("UserDay");
        }
        // Evening: 17:00 - 20:00
        else if (hour >= 17 && hour < 20)
        {
            gaiaLighting.SwitchProfile("UserEvening");
        }
        // Night: 20:00 - 5:00
        else
        {
            gaiaLighting.SwitchProfile("UserNight");
        }
    }
}

 

Link to comment
Share on other sites

I am looking into this, but everyone is gone due to the weekend I will get back with you as soon as I can. 

I do remember that it is possible, but cant remember exactly how it was done. 

Link to comment
Share on other sites

You might also check the lightingutils.cs there should be a function in there regarding the lighting profiles 

 

Link to comment
Share on other sites

Also take a look at the GaiaGlobal.cs 

Its in Assets-Procedural Worlds-Gaia-Scripts- Lighting System- Gaia Global

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

×
×
  • Create New...