interface in UnityEditor.Experimental.Rendering
定义 ScriptableBakedReflectionSystem 实现所需的成员。
您可以将空实现用作基类,请参阅 ScriptableBakedReflectionSystem。
using System.Collections.Generic; using UnityEngine; using UnityEngine.Rendering; using UnityEditor.Experimental.Rendering;
public interface IBakeJobs { // Add job counts + remove jobs count int count { get; } int toAddCount { get; } int toRemoveCount { get; } }
public interface IBaker<TProbe> { IBakeJobs PrepareBakeJobsFor(SceneStateHash sceneStateHash); void IssueJobs(IBakeJobs jobs); List<TProbe> bakedProbes { get; set; } void StopRunningJobs(); }
abstract class CustomScriptableBakedReflectionSystem : ScriptableBakedReflectionSystem { enum Stage { None, BakeReflectionProbes }
IBaker<ReflectionProbe> m_ReflectionProbeBaker;
public CustomScriptableBakedReflectionSystem( IBaker<ReflectionProbe> reflectionProbeBaker) // Our custom system processes in 1 stage: reflection probes : base(1) { m_ReflectionProbeBaker = reflectionProbeBaker; }
public override void Tick( SceneStateHash sceneStateHash, IScriptableBakedReflectionSystemStageNotifier handle) { // Reflection Probes { // Calculate reflection probes to remove and to bake and add var jobs = m_ReflectionProbeBaker.PrepareBakeJobsFor(sceneStateHash); if (jobs.count > 0) { // Update progression information of current stage // Progress is the progression of to bake and add jobs handle.EnterStage( (int)Stage.BakeReflectionProbes, string.Format("Reflection Probes | {0} jobs", jobs.toAddCount), 1 - (jobs.toAddCount / (float)m_ReflectionProbeBaker.bakedProbes.Count));
// Perform removal of remove jobs // Issue baking of add jobs if they are not in progress m_ReflectionProbeBaker.IssueJobs(jobs);
return; } handle.ExitStage((int)Stage.BakeReflectionProbes); }
// Update the hash of the reflection system stateHashes = CalculateStateHash(); // Baking is complete for this sceneStateHash handle.SetIsDone(true); }
public override void SynchronizeReflectionProbes() { // Synchronize Reflection Probes for (int i = 0, c = m_ReflectionProbeBaker.bakedProbes.Count; i < c; ++i) { var probe = m_ReflectionProbeBaker.bakedProbes[i]; probe.bakedTexture = GetReflectionProbeBakedTexture(probe); } }
public override void Clear() { m_ReflectionProbeBaker.bakedProbes.Clear(); DeleteBakedReflectionProbeTextures(); }
public override void Cancel() { m_ReflectionProbeBaker.StopRunningJobs(); }
Cubemap GetReflectionProbeBakedTexture(ReflectionProbe probe) { throw new System.NotImplementedException(); }
protected abstract void DeleteBakedReflectionProbeTextures(); protected abstract Hash128[] CalculateStateHash(); }
stageCount | 烘焙过程的阶段数。 |
stateHashes | ScriptableBakedReflectionSystem 当前烘焙状态的哈希。 |
BakeAllReflectionProbes | 实现此方法可烘焙所有加载的反射探针。 |
Cancel | 取消正在运行的烘焙作业。 |
Clear | 清除 ScriptableBakedReflectionSystem 的状态。 |
SynchronizeReflectionProbes | 将烘焙数据与实际组件和渲染设置同步。 |
Tick | 每次编辑器更新都会调用此方法,直到 ScriptableBakedReflectionSystem 指示烘焙完成,即 handle.SetIsDone(true)。(请参阅 IScriptableBakedReflectionSystemStageNotifier.SetIsDone)。 |
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.