-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScriptableSceneTransition.cs
82 lines (72 loc) · 2.28 KB
/
ScriptableSceneTransition.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections;
using UnityEngine;
namespace CHARK.ScriptableScenes.Transitions
{
/// <summary>
/// Transition used to transition between <see cref="ScriptableSceneCollection"/> when they are
/// loaded and unloaded.
/// </summary>
public abstract class ScriptableSceneTransition : ScriptableObject
{
/// <summary>
/// Invoked when <see cref="ShowRoutine"/> is starts.
/// </summary>
public event Action OnShowEntered;
/// <summary>
/// Invoked when <see cref="ShowRoutine"/> is finishes.
/// </summary>
public event Action OnShowExited;
/// <summary>
/// Invoked when <see cref="HideRoutine"/> is starts.
/// </summary>
public event Action OnHideEntered;
/// <summary>
/// Invoked when <see cref="HideRoutine"/> is finishes.
/// </summary>
public event Action OnHideExited;
/// <returns>
/// Enumerator which transitions into the <see cref="ScriptableSceneCollection"/>. Called
/// before the collection is loaded.
/// </returns>
public IEnumerator ShowRoutine()
{
OnShowEntered?.Invoke();
try
{
yield return OnShowRoutine();
}
finally
{
OnShowExited?.Invoke();
}
}
/// <returns>
/// Enumerator which delays the transition into the
/// <see cref="ScriptableSceneCollection"/>.
/// </returns>
public IEnumerator DelayRoutine()
{
yield return OnDelayRoutine();
}
/// <returns>
/// Enumerator which transitions out of the <see cref="ScriptableSceneCollection"/>. Called
/// before the collection is unloaded.
/// </returns>
public IEnumerator HideRoutine()
{
OnHideEntered?.Invoke();
try
{
yield return OnHideRoutine();
}
finally
{
OnHideExited?.Invoke();
}
}
protected abstract IEnumerator OnShowRoutine();
protected abstract IEnumerator OnDelayRoutine();
protected abstract IEnumerator OnHideRoutine();
}
}