> For the complete documentation index, see [llms.txt](https://cowsinss-organization.gitbook.io/save-and-load-add-on/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cowsinss-organization.gitbook.io/save-and-load-add-on/how-to-use-and-guides/saving-instantiated-objects.md).

# Saving Instantiated Objects

When weapons are dropped or loot is collected from a loot box, the objects are automatically instantiated and saved using the Save & Load add-ons. However, there may be times when you want to manually instantiate an object in your scene and ensure it’s saved, so that it appears the next time the game is loaded. Fortunately, the Save & Load Add-On makes this process simple and straightforward.

{% stepper %}
{% step %}

### Identifiable Inheritance

Ensure your object to instantiate has a script that inherits from Identifiable, so the [GameDataManager ](/save-and-load-add-on/content/03.-content/03.1-datapersistence/gamedatamanager.md)can recognize it.

```csharp
using UnityEngine;
using cowsins;

public class ClassToSave : Identifiable 
{

}
```

{% endstep %}

{% step %}

### Type To Prefab Mapping Assignment

Now, navigate to the Main Menu & locate DataPersistenceManager. This objects contains the GameDataManager component, where the Type To Prefab Mappings are stored. Create a new entry, select your CustomClassSaveData, and attach the Prefab to instantiate to it.

<figure><img src="https://2305086192-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNTLRi1iZ5Q5ZZ3QJ1Q70%2Fuploads%2FGqvFiYvxFGek5YDzeDCz%2Fimage.png?alt=media&amp;token=104c6b3a-e0dd-47fc-a0bc-1d21ded6847b" alt=""><figcaption></figcaption></figure>

Check[ this guide](/save-and-load-add-on/how-to-use-and-guides/type-to-prefab-mappings-in-game-data-manager.md) for more related information.
{% endstep %}

{% step %}

### Saving the Object

Now, you just need to instantiate the object, then access its Identifiable component, and call the following line:

```csharp
identifiable.SaveInstance();
```

Here´s an example:

```csharp
// Stores a reference of the instantiated object
GameObject instantiatedObj = Instantiate(objToInstantiate, transform.position, Quaternion.identity);
// Access Identifiable Component.
Identifiable identifiable = instantiatedObj.GetComponent<Identifiable>();

// Store instance.
identifiable.SaveInstance();
```

{% endstep %}
{% endstepper %}
