# IScriptableBakedReflectionSystem

> Defines the required members for a ScriptableBakedReflectionSystem implementation.

## Definition

* **Type:** Interface
* **Namespace:** [UnityEditor.Experimental.Rendering](/engine/6000.6/script-reference/unityeditor/experimental/rendering.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public interface IScriptableBakedReflectionSystem : IDisposable
```

## Remarks

You can use the empty implementation as base class, see [ScriptableBakedReflectionSystem](/engine/6000.6/script-reference/unityeditor/experimental/rendering/scriptablebakedreflectionsystem.md).

## Examples

```csharp
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();
}
```

## Properties

| Property                                                                                                                          | Description                                                                   |
| --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
| [stageCount](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/stagecount.md)   | Number of stages of the baking process.                                       |
| [stateHashes](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/statehashes.md) | The hashes of the current baked state of the ScriptableBakedReflectionSystem. |

## Methods

| Method                                                                                                                                                            | Description                                                                                                                                                                                                                                                                                                                                               |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [BakeAllReflectionProbes](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/bakeallreflectionprobes.md)         | Implement this method to bake all of the loaded reflection probes.                                                                                                                                                                                                                                                                                        |
| [Cancel](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/cancel.md)                                           | Cancel the running bake jobs.                                                                                                                                                                                                                                                                                                                             |
| [Clear](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/clear.md)                                             | Clear the state of the ScriptableBakedReflectionSystem.                                                                                                                                                                                                                                                                                                   |
| [SynchronizeReflectionProbes](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/synchronizereflectionprobes.md) | Synchronize the baked data with the actual components and rendering settings.                                                                                                                                                                                                                                                                             |
| [Tick](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystem/tick.md)                                               | This method is called every Editor update until the ScriptableBakedReflectionSystem indicates that the baking is complete, with `handle.SetIsDone(true)`. (See [IScriptableBakedReflectionSystemStageNotifier.SetIsDone](/engine/6000.6/script-reference/unityeditor/experimental/rendering/iscriptablebakedreflectionsystemstagenotifier/setisdone.md)). |

## Inheritance

**Inherited Members:**

* [IDisposable.Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)
