런타임 시 라이트 프로브를 이동해야 할 수도 있습니다. 예를 들어 여러 씬을 추가적으로 로드하여 월드를 생성한 다음 각 씬을 다른 위치로 이동하는 경우, 라이트 프로브를 관련 씬 오브젝트와 함께 이동해야 합니다.
런타임 시 LightProbes API를 사용하여 라이트 프로브를 이동할 수 있습니다. 트랜스폼은 베이킹에만 영향을 주기 때문에 라이트 프로브 그룹 오브젝트의 트랜스폼 컴포넌트를 업데이트하여 라이트 프로브를 이동할 수는 없습니다.
API를 사용하여 라이트 프로브를 이동하면 위치만 변경됩니다. 라이트 프로브에 저장된 베이크된 데이터는 동일하게 유지됩니다.
다음 단계를 따르십시오.
Scene
오브젝트)은 이제부터 이 복제된 데이터를 사용합니다.씬을 라이트 프로브가 포함된 다른 씬과 함께 베이크한 경우 반환된 데이터에는 베이크된 모든 씬의 라이트 프로브가 포함됩니다. 여러 씬에서의 라이트 프로브 사용에 대한 자세한 내용은 라이트 프로브 및 씬 로딩을 참조하십시오.
Tetrahedralize
API는 시간이 오래 걸릴 수 있습니다. 여러 라이트 프로브를 이동하는 경우 마지막에 한 번 사면체화하는 것이 가장 좋습니다.
씬에서 라이트 프로브의 위치를 이동하지 않고 읽어야 하는 경우에는 대신에 LightProbes.GetSharedLightProbesForScene API를 사용하면 됩니다.
다음 코드로 현재 씬의 라이트 프로브를 각 프레임마다 새 위치로 이동합니다.
씬의 모든 오브젝트에 스크립트를 첨부합니다. 프로젝트를 실행할 때 라이트 프로브를 사용하는 모든 오브젝트를 선택하면 이동하는 프로브를 볼 수 있습니다. 라이트 프로브 그룹 오브젝트는 이동하지 않습니다.
using UnityEngine;
using UnityEngine.SceneManagement;
public class LoadSingleSceneAndMoveProbes : MonoBehaviour
{
void Update()
{
// Get a copy of the Light Probes in the current scene
LightProbes lightProbes = LightProbes.GetInstantiatedLightProbesForScene(SceneManager.GetActiveScene());
// Get the Light Probe positions
Vector3[] positions = lightProbes.GetPositionsSelf();
// Update the positions
for (int i = 0; i < positions.Length; i++)
{
positions[i].x = positions[i].x + 0.01f;
}
// Copy the new positions back to the Light Probes
lightProbes.SetPositionsSelf(positions, true);
// Tetrahedralize to update the data in the LightProbes object of the scene.
LightProbes.Tetrahedralize();
}
}
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.