# SDK Upgrade Guide

{% hint style="info" %}
Any new version of **coherence** should install automatically in the Unity Editor's *Package Manager*. To check the version, open up *coherence > coherence Hub* and the version should be displayed at the top.
{% endhint %}

### **General updates**

* After an SDK upgrade, bake process will be initiated automatically by the SDK to make sure the baked scripts are up to date.
* If you were using the old manual code generation system and you run into any compilations or runtime errors in **coherence** code after the update, you need to delete `Assets/coherence/baked` folder. These steps might help resolve the issue:

If you were using an old code generation system and you run into any compilation or runtime errors in **coherence** code after the update, you need to delete `Assets/coherence/baked` folder and these steps might help resolve the issue:

<figure><img src="/files/PhBtejPWdi1vJKdTgky6" alt=""><figcaption></figcaption></figure>

1\) Go to *coherence > Bake*

This will generate baked skeleton scripts which will compile but not work at runtime. If you still have compilation errors at this point, it's better to go into `Safe mode` and fix possible API upgrade issues, as detailed below, in [the second part of this article](#sdk-upgrade-0.7.x-0.8.x-greater-than-0.9.0).

2\) Go to *Project settings* > *coherence > Gather Schema* to fully generate the baked code (this can also be done via any of the other baking options). After that click *Project settings* > *coherence > Bake.*

3\) This process should handle old bindings which are different from the updated version. If the errors persist, check the bindings window for the relevant Prefab to make sure they are set up properly. Then perform steps 1 and 2 again. This also makes sure old baked components are removed (these are now added at runtime).

The 0.9 version introduces two new features:

* You can update your CoherenceSync prefabs outside the Resources folder and use [PrefabMapper](https://docs.coherence.io/0.10/additional-resources/pages/-MYMcuWV2fBpQVo-zzDr#3.2.-prefab-mapper-utilities).
* Source Generator system is introduced for Baking. You can read more on it [here](/0.10/coherence-sdk-for-unity/baking-and-code-generation.md#two-bake-modes).

### **SDK Upgrade 0.7.x (0.8.x) -> 0.9.0**

* Notable API changes include:

1. `Coherence.Network` is removed now. `OnConnected` and `OnDisconnected` events are moved to `IClient` and have changed a signature:\\

   ```csharp
       private void OnEnable()
       {
           if (!MonoBridgeStore.TryGetBridge(gameObject.scene, out CoherenceMonoBridge monoBridge))
               return; 
           
           client = monoBridge.Client;
           client.OnConnected += OnConnect;
           client.OnDisconnected += OnDisconnect;
       }

       private void OnDisable()
       {
           client.OnConnected -= OnConnect;
           client.OnDisconnected -= OnDisconnect;
       }

       private void OnConnect(ushort u)
       {
           onConnect.Invoke();
       }

       private void OnDisconnect(ConnectionCloseReason reason)
       {
           onDisconnect.Invoke();
       }
   ```

2\. `MonoBridgeStore.GetBridge` is now obsolete, and will be replaced with\
`MonoBridgeStore.TryGetBridge`.

```csharp
MonoBridgeStore.TryGetBridge(gameObject.scene, out monobridge);
```

3\. `CoherenceSync.isSimulated` is now obsolete, and will be replaced with `CoherenceSync.HasStateAuthority`.

4\. `CoherenceSync.RequestAuthority` is now obsolete, and will be replaced with `CoherenceSync.RequestAuthority(AuthorityType).`

{% hint style="info" %}
For more information, see [Release Notes](/0.10/overview/release-notes.md).
{% endhint %}

{% hint style="info" %}
For detailed documentation of the updated CoherenceSync component, see [CoherenceSync](/0.10/coherence-sdk-for-unity/components/coherencesync.md).
{% endhint %}

#### CLI Tools

The CLI tools have been updated, especially the ones that handle Simulators. To learn more about this, see [CLI utilities](/0.10/coherence-sdk-for-unity/cli-utilities.md).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coherence.io/0.10/additional-resources/sdk-update-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
