Copy

Creates and returns a duplicate of the asset. Changes to one copy will not affect the other.

Syntax

Returns

A new copy of the Asset.

Remarks

If you want to create an instance of the asset, which will share the resource, use Object::AddRef() instead.

Example

local window = Window:Create()
local context = Context:Create(window)
local world = World:Create()
local camera = Camera:Create()
DirectionalLight:Create():SetRotation(35,45,0)

--Create a material and copy it
local material1 = Material:Create()
local material2 = tolua.cast(material1:Copy(),"Material")

--Set the two materials colors
material1:SetColor(1,0,0)
material2:SetColor(0,0,1)

--Create a model and apply the first material
local model1 = Model:Sphere()
model1:SetMaterial(material1)
model1:SetPosition(-1,0,2)

--Create a model and apply the second material
local model2 = Model:Sphere()
model2:SetMaterial(material2)
model2:SetPosition(1,0,2)

while true do
if window:Closed() or window:KeyDown(Key.Escape) then return false end

Time:Update()
world:Update()
world:Render()
context:Sync()
end