LightProbes.needsRetetrahedralization is called only once?

The reference says:

If you are loading multiple scenes which each contain additional light probe data, you should wait for the corresponding number of needsRetetrahedralization events before retetrahedralizing…For example, if you were to additively load five scenes which each contain light probe data, you should wait for all five needsRetetrahedralization events before calling LightProbes.Tetrahedralize or LightProbes.TetrahedralizeAsync.

This makes sense, but the event seems to trigger only once. I made a script (You’ll need scenes with lightprobes in them added to the build settings):

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

public class LightProbesNeedingUpdates : MonoBehaviour {
 
    public string[] additiveSceneNames = new string[]{"AdditiveLightprobes1", "AdditiveLightprobes2" };
    public int scenesNeedingRetetrahedralization;

    public void TetrahedralizationCompleted(){
        Debug.Log("Tetrahedralization Completed!");
    }

    public void NeedsTetrahedralization(){
        Debug.Log("Calling NeedsTetrahedralization");
        scenesNeedingRetetrahedralization++;
        if(scenesNeedingRetetrahedralization >= additiveSceneNames.Length){
            scenesNeedingRetetrahedralization = 0;
            LightProbes.Tetrahedralize();
        }
    }

    private void OnEnable() {
        LightProbes.needsRetetrahedralization += NeedsTetrahedralization;
        LightProbes.tetrahedralizationCompleted += TetrahedralizationCompleted;
    }
    private void OnDisable() {
        LightProbes.needsRetetrahedralization -= NeedsTetrahedralization;
        LightProbes.tetrahedralizationCompleted -= TetrahedralizationCompleted;
    }

    private void Update() {
        if(Input.GetKeyDown(KeyCode.Z)){
            LoadAdditiveScenes();
        }
        else if(Input.GetKeyDown(KeyCode.X)){
            UnloadScenes();
        }
    }

    public void LoadAdditiveScenes(){
        scenesNeedingRetetrahedralization = 0;
        StopAllCoroutines();
        StartCoroutine(LoadAdditiveScenesCO());
    }
    // To simulate different loading times, we're faking it.
    private IEnumerator LoadAdditiveScenesCO(){
        for (int i = 0, length = additiveSceneNames.Length; i < length; i++) {
            SceneManager.LoadSceneAsync(additiveSceneNames[i], LoadSceneMode.Additive);
            yield return new WaitForSeconds(0.5f);
        } 
    }

    public void UnloadScenes(){
        for (int i = 0, length = additiveSceneNames.Length; i < length; i++) {
            SceneManager.UnloadSceneAsync(additiveSceneNames[i]);
        }
    }
}

Am I doing this incorrectly?

1 Like

Test in Unity2020.3.46f, it is OK.

1 Like