forked from Unity-Technologies/EntityComponentSystemSamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneReferenceAuthoring.cs
More file actions
41 lines (37 loc) · 1.31 KB
/
Copy pathSceneReferenceAuthoring.cs
File metadata and controls
41 lines (37 loc) · 1.31 KB
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
37
38
39
40
41
using Unity.Entities;
using Unity.Entities.Serialization;
using UnityEditor;
using UnityEngine;
namespace Streaming.SceneManagement.SceneLoading
{
public class SceneReferenceAuthoring : MonoBehaviour
{
#if UNITY_EDITOR
public SceneAsset scene;
class Baker : Baker<SceneReferenceAuthoring>
{
public override void Bake(SceneReferenceAuthoring authoring)
{
// We want to create a dependency to the scene in case the scene gets deleted.
// This needs to be outside the null check below in case the asset file gets deleted and then restored.
DependsOn(authoring.scene);
if (authoring.scene != null)
{
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new SceneReference
{
// Bake a reference to the scene, to be used at runtime to load the scene
Value = new EntitySceneReference(authoring.scene)
});
}
}
}
#endif
}
// Triggers the load of the referenced scene
public struct SceneReference : IComponentData
{
// Reference to the scene to load
public EntitySceneReference Value;
}
}