Material CreateCopy()

book_4_sparkGenerated
code_blocksInput

Description

The CreateCopy method is a member of the Material class in the Sandbox API. This method is used to create a duplicate of the current material instance. It returns a new Material object that is a copy of the original, allowing you to modify the copy without affecting the original material.

Usage

To use the CreateCopy method, you must have an instance of a Material object. Call the method on this instance to obtain a new Material object that is a copy of the original.

Example

// Assume 'originalMaterial' is an existing Material instance
Material copiedMaterial = originalMaterial.CreateCopy();

// Now 'copiedMaterial' is a separate instance and can be modified independently
copiedMaterial.Set("Color", new Color(1.0f, 0.0f, 0.0f)); // Set the color to red