How to use functions from c# in UVS?

Hi,

I have a third party package in my project.
In the documentation, there is this function:
EnviroSkyMgr.instance.ChangeWeather(EnviroWeatherPreset weatherPreset);

I need to use this function with my scripts in UVS, so I created the c# script below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WeatherEnviroAPI
{
    public void ChangeWeatherPreset(EnviroWeatherPreset weatherPreset)
    {
        EnviroSkyMgr.instance.ChangeWeather(weatherPreset);
    }
}

Then I added the class in Project Settings / Type Options to use it in UVS.
But it needs 2 arguments: the weather preset and another object.

I tried this:

But I am not sure what it is doing exactly: Is it creating an instance of the class WeatherEnviroAPI?
Is it creating an instance of EnviroSkyMgr.instance? (There is already a default EnviroSkyMgr.instance in my scene and I should not create a new one)
Why is this input needed?
Is this the correct way to do it?

The third party package is working with this solution, however, there are some features that are not working correctly and I don’t know if it is related to way I am using it with UVS, or if the package is faulty.

I am not a programmer, so please provided details.

Thank you!

I believe what the middle connector is asking for is the equivalent of the “EnviroSkyMgr.instance” portion of the statement “EnviroSkyMgr.instance.ChangeWeather(weatherPreset);”

if you have a public class, it doesn’t exist without an instance (.Create). You can change your function to a public static void, then you won’t need an instance.

That solved the issue! Thanks!

1 Like