Net.Like.Xue.Tokyo/Assets/Artists/Scripts/LuminaSetupController.cs

36 lines
992 B
C#
Raw Normal View History

2025-02-26 20:56:15 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using Artngame.LUMINA;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Net.Like.Xue.Tokyo
{
public class LuminaSetupController : MonoBehaviour
{
[SerializeField]
private LUMINA lumina;
private void FixedUpdate()
{
if (!lumina.sun)
{
2025-02-27 12:34:18 +08:00
for (var i = 0; i < SceneManager.sceneCount; i++)
2025-02-26 20:56:15 +08:00
{
2025-02-27 12:34:18 +08:00
var scene = SceneManager.GetSceneAt(i);
foreach (var rootGameObject in scene.GetRootGameObjects())
{
if(rootGameObject.TryGetComponent<Light>(out var rootLight) is false)continue;
if(rootLight.type is not LightType.Directional)continue;
2025-02-26 20:56:15 +08:00
2025-02-27 12:34:18 +08:00
lumina.sun = rootLight;
return;
}
2025-02-26 20:56:15 +08:00
}
}
}
}
}