# GetPreloadedAssets()

> Returns the assets that will be loaded at start up in the player and be kept alive until the player terminates.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.6/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public static Object[] GetPreloadedAssets()
```

### Returns

| Type                                                                | Description                 |
| ------------------------------------------------------------------- | --------------------------- |
| [Object\[\]](/engine/6000.6/script-reference/unityengine/object.md) | The assets to be preloaded. |

### Remarks

This example shows how a ScriptableObject can be used to store data that can be accessed at any time throughout the lifetime of the player.

```csharp
using System.Linq;
using UnityEngine;

// We use this class to store general config data that can be used in the player
public class ConfigObject : ScriptableObject
{
    public string text;

    public static ConfigObject configInstance;

    #if UNITY_EDITOR
    [UnityEditor.MenuItem("Assets/Create/Config Object")]
    public static void CreateAsset()
    {
        var path = UnityEditor.EditorUtility.SaveFilePanelInProject("Save Config", "config", "asset", string.Empty);
        if (string.IsNullOrEmpty(path))
            return;

        var configObject = CreateInstance<ConfigObject>();
        UnityEditor.AssetDatabase.CreateAsset(configObject, path);

        // Add the config asset to the build
        var preloadedAssets = UnityEditor.PlayerSettings.GetPreloadedAssets().ToList();
        preloadedAssets.Add(configObject);
        UnityEditor.PlayerSettings.SetPreloadedAssets(preloadedAssets.ToArray());
    }
    #endif

    void OnEnable()
    {
        configInstance = this;
    }
}
```

```csharp
using UnityEngine;

public class UseConfigObject : MonoBehaviour
{
    void OnGUI()
    {
        if (ConfigObject.configInstance != null)
        {
            GUILayout.Label("Found the config asset. The message was: " + ConfigObject.configInstance.text);
        }
    }
}
```

Additional Resources: [PlayerSettings.SetPreloadedAssets](/engine/6000.6/script-reference/unityeditor/playersettings/setpreloadedassets.md), [EditorBuildSettings.TryGetConfigObject](/engine/6000.6/script-reference/unityeditor/editorbuildsettings/trygetconfigobject.md).
