forked from j-be/ContentSpawner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScreenPlay.cs
50 lines (41 loc) · 992 Bytes
/
ScreenPlay.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.IO;
using UnityEngine;
using System.Collections.Generic;
public enum ItemType {
unknown,
audio,
image
}
public enum DelayType {
absolute,
relativeToPrevious,
relativeSynchronized
}
[System.Serializable]
public struct Delay {
public float seconds;
public DelayType type;
}
[System.Serializable]
public struct ScreenPlayItem {
public string url;
public Delay delay;
public ItemType type;
}
[System.Serializable]
public class ScreenPlay : System.Object {
[SerializeField]
private List<ScreenPlayItem> _screenPlayItems = new List<ScreenPlayItem>();
public void addItem(ScreenPlayItem screenPlayItem) {
_screenPlayItems.Add(screenPlayItem);
}
public List<ScreenPlayItem> getItems() {
return _screenPlayItems;
}
public void saveToFile(string fileName) {
File.WriteAllText(fileName, JsonUtility.ToJson(this));
}
public static ScreenPlay loadFromFile(string fileName) {
return JsonUtility.FromJson<ScreenPlay>(File.ReadAllText(fileName));
}
}