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. The new material will have the same properties and settings as the original, allowing for modifications 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 with the same properties as 'originalMaterial'.
// You can modify 'copiedMaterial' without affecting 'originalMaterial'.
// Example of modifying the copied material
copiedMaterial.Set("Color", new Color(1.0f, 0.0f, 0.0f)); // Set the color to red