> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.ksscriptguidupdater.md).

# Class ksScriptGuidUpdater

Namespace: [KS.Reactor.Client.Unity.Editor](/reactor/api-reference/ks.reactor.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

Utility for updating script GUIDs in Unity asset files to fix missing scripts when metafiles change. To use this, you must know the old file IDs and GUIDs that you want to replace, as well as the new file IDs and GUIDs. You must also set Unity's asset serialization mode (Edit > Project Settings > Editor > Asset Serialization > Mode) to Force Text BEFORE the metafiles change to the new GUIDs and scripts are missing. If you change it to Force Text after the metafiles change, Unity will be unable to serialize the prefabs that contain missing scripts, and we will be unable to update the GUIDs in those prefab files.

```csharp
public class ksScriptGuidUpdater
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksScriptGuidUpdater](/reactor/api-reference/ks.reactor.client.unity.editor/ks.reactor.client.unity.editor.ksscriptguidupdater.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Methods

### AddReplacement(int, string, int, string) <a href="#ks_reactor_client_unity_editor_ksscriptguidupdater_addreplacement_system_int32_system_string_system" id="ks_reactor_client_unity_editor_ksscriptguidupdater_addreplacement_system_int32_system_string_system"></a>

Adds a mapping between an old file ID + GUID to be replaced with a new file ID + GUID. Once you've added all the replacements you want, call [ReplaceAll](#KS_Reactor_Client_Unity_Editor_ksScriptGuidUpdater_ReplaceAll) to replace the old IDs with the new IDs in all prefab and scene files.

```csharp
public void AddReplacement(int oldFileId, string oldGuid, int newFileId, string newGuid)
```

#### Parameters

`oldFileId` [int](https://learn.microsoft.com/dotnet/api/system.int32)

Old file ID of missing script to replace.

`oldGuid` [string](https://learn.microsoft.com/dotnet/api/system.string)

Old GUID of missing script to replace.

`newFileId` [int](https://learn.microsoft.com/dotnet/api/system.int32)

New file ID of the script.

`newGuid` [string](https://learn.microsoft.com/dotnet/api/system.string)

New GUID of the script.

### ReplaceAll() <a href="#ks_reactor_client_unity_editor_ksscriptguidupdater_replaceall" id="ks_reactor_client_unity_editor_ksscriptguidupdater_replaceall"></a>

Replaces file IDs and GUIDs in all prefab and scene files for missing scripts with the file IDs and GUIDs for the new scripts that were registered using [AddReplacement](#KS_Reactor_Client_Unity_Editor_ksScriptGuidUpdater_AddReplacement_System_Int32_2cSystem_String_2cSystem_Int32_2cSystem_String_). To use this, Asset Serialization Mode must be Force Text.

```csharp
public void ReplaceAll()
```
