# GetDefinesCopy()

> Gets a copy of the constant defines.

## Definition

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

```csharp
public string[] GetDefinesCopy()
```

### Returns

| Type                                                               | Description                   |
| ------------------------------------------------------------------ | ----------------------------- |
| [string\[\]](https://learn.microsoft.com/dotnet/api/system.string) | An array of constant defines. |

### Remarks

This method gets the constant define data from a [ShaderBuildSettings](/engine/6000.6/script-reference/unityeditor/shaders/shaderbuildsettings.md) struct. To make sure data stays valid, you can't read or write the original data. To apply the modified data back to the original data, use [ShaderBuildSettings.Defines](/engine/6000.6/script-reference/unityeditor/shaders/shaderbuildsettings/defines.md). The valid format for the array element data is a pair of identifier and numeric value, separated by a whitespace.

Additional Resources: [ShaderBuildSettings](/engine/6000.6/script-reference/unityeditor/shaders/shaderbuildsettings.md).

### Examples

```csharp
using System;
using System.Collections.Generic;
using UnityEditor.Rendering;
using UnityEditor.Shaders;
using UnityEngine;


public class ConstantDefinesExample
{
    void AddShaderConstantDefines()
    {
        // Get current shader build settings either from the currently active build profile
        // or if none is active, the global graphics settings.
        ShaderBuildSettings buildSettings = EditorGraphicsSettings.GetShaderBuildSettings();

        // Get the copy of the existing defines and append the new ones
        var allDefines = new List<string>(buildSettings.GetDefinesCopy());
        allDefines.Add("MAX_NUM_LIGHTS 8");
        allDefines.Add("EPSILON 0.1f");
        var defineArray = allDefines.ToArray();

        // Check if the define array is valid
        string validationErrors;
        if (!ShaderBuildSettings.ValidateDefines(defineArray, out validationErrors))
        { 
            Debug.LogWarning(validationErrors);
            return;
        }

        // Set the modified defines. Throw an exception if the data is invalid.
        try
        {
            buildSettings.Defines = defineArray;
        }
        catch (ArgumentException ex)
        {
            Debug.LogError(ex.Message);
            return;
        }

        // Apply the modified settings data back to the Graphics settings or Build Profile settings
        EditorGraphicsSettings.SetShaderBuildSettings(buildSettings);
    }
}
```
