-
-
Notifications
You must be signed in to change notification settings - Fork 911
/
Prefab.cs
36 lines (33 loc) · 1.26 KB
/
Prefab.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.Collections.Generic;
using Stride.Core;
using Stride.Core.Collections;
using Stride.Core.Serialization;
using Stride.Core.Serialization.Contents;
using Stride.Engine.Design;
namespace Stride.Engine
{
/// <summary>
/// A prefab that contains entities.
/// </summary>
[DataContract("Prefab")]
[ContentSerializer(typeof(DataContentSerializerWithReuse<Prefab>))]
[ReferenceSerializer, DataSerializerGlobal(typeof(ReferenceSerializer<Prefab>), Profile = "Content")]
public sealed class Prefab
{
/// <summary>
/// The entities.
/// </summary>
public List<Entity> Entities { get; } = new List<Entity>();
/// <summary>
/// Instantiates entities from a prefab that can be later added to a <see cref="Scene"/>.
/// </summary>
/// <returns>A collection of entities extracted from the prefab</returns>
public List<Entity> Instantiate()
{
var newPrefab = EntityCloner.Clone(this);
return newPrefab.Entities;
}
}
}