Click or drag to resize

VisualClone Method

Create a copy of a visual and its children placed in the top level scene.

Namespace:  Demo3D.Visuals
Assembly:  Demo3D.Core (in Demo3D.Core.dll) Version: 15.0.2.11458
Syntax
C#
public Visual Clone()

Return Value

Type: Visual
A new visual with the same properties as the original visual.
Remarks
The parent of the new visual is the Scene, and so may need reparenting. The world location of the new visual will be the same as the original, so may not be visible until moved.
Examples
C#
[Auto] void OnReset(Visual sender)
{
    // This example will create a copy of a child named "Prototype"
    // every time the Reset button is pressed:
    var proto = sender.FindChild("Prototype");
    if (proto == null) return;

    var copy = proto.Clone();

    // Make it a child 
    copy.Reparent( sender );

    // Make sure it's in a different location
    // to the original
    copy.LocationZ = proto.LocationZ + 1;

    print("New copy of prototype :" + copy.Name);
}
See Also