-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathWeakSceneAuthoring.cs
More file actions
64 lines (53 loc) · 2.28 KB
/
WeakSceneAuthoring.cs
File metadata and controls
64 lines (53 loc) · 2.28 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Unity.Collections;
using UnityEngine;
using Unity.Entities;
using Unity.Entities.Content;
using Unity.Entities.Serialization;
namespace ContentManagement.Sample
{
#if UNITY_EDITOR
public class WeakSceneAuthoring : MonoBehaviour
{
public WeakSceneListScriptableObject Settings;
public UnityEditor.SceneAsset HighFidelityScene;
// We use WeakObjectSceneReference here instead of UntypedWeakReferenceId because
// UntypedWeakReferenceId does not take a scene as input in the inspector.
// Alternatively, we could use SceneAsset and then create a WeakObjectSceneReference in the baker with this code:
// new WeakObjectSceneReference { Id = UntypedWeakReferenceId.CreateFromObjectInstance(authoring.LowFidelityScene) };
public WeakObjectSceneReference LowFidelityScene;
class Baker : Baker<WeakSceneAuthoring>
{
public override void Bake(WeakSceneAuthoring authoring)
{
var entity = GetEntity(TransformUsageFlags.None);
AddComponent(entity, new HighLowWeakScene
{
HighSceneRef = UntypedWeakReferenceId.CreateFromObjectInstance(authoring.HighFidelityScene),
LowSceneRef = authoring.LowFidelityScene,
});
if ((authoring.Settings.ContentSource & ContentSourcePath.Local) != 0)
AddComponent<LocalContent>(entity);
if ((authoring.Settings.ContentSource & ContentSourcePath.Remote) != 0)
AddComponent(entity, new RemoteContent { URL = authoring.Settings.RemoteURL });
}
}
}
#endif
public struct HighLowWeakScene : IComponentData
{
public UntypedWeakReferenceId HighSceneRef;
public WeakObjectSceneReference LowSceneRef;
public bool IsHighLoaded; // indicates whether high- or low-fidelity is currently loaded
public Entity LoadedScene; // stores a reference to the currently loaded scene (null if no scene is currently loaded)
}
public struct ContentIsReady : IComponentData
{
}
public struct RemoteContent : IComponentData
{
public FixedString512Bytes URL;
}
public struct LocalContent : IComponentData
{
}
}