-
Notifications
You must be signed in to change notification settings - Fork 877
Expand file tree
/
Copy pathVisualEffectControlClip.cs
More file actions
165 lines (148 loc) · 5.5 KB
/
Copy pathVisualEffectControlClip.cs
File metadata and controls
165 lines (148 loc) · 5.5 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#if VFX_HAS_TIMELINE
using System;
using System.Collections.Generic;
using UnityEngine.Playables;
using UnityEngine.Timeline;
using System.Runtime.CompilerServices;
using UnityEngine.VFX.Utility;
[assembly: InternalsVisibleTo("VisualEffect.Playable.Editor")]
namespace UnityEngine.VFX
{
[Serializable]
class VisualEffectControlClip : PlayableAsset, ITimelineClipAsset
{
public ClipCaps clipCaps
{
get { return ClipCaps.None; }
}
public double clipStart { get; set; }
public double clipEnd { get; set; }
[NotKeyable]
public bool scrubbing = true;
[NotKeyable]
public uint startSeed;
public enum ReinitMode
{
None,
OnExitClip,
OnEnterClip,
OnEnterOrExitClip
}
[NotKeyable]
public ReinitMode reinit = ReinitMode.OnEnterOrExitClip;
[Serializable]
public struct PrewarmClipSettings
{
public bool enable;
public uint stepCount;
public float deltaTime;
public ExposedProperty eventName;
}
[NotKeyable]
public PrewarmClipSettings prewarm = new PrewarmClipSettings()
{
enable = false,
stepCount = 20u,
deltaTime = 0.05f,
eventName = VisualEffectAsset.PlayEventName
};
[Serializable]
public struct ClipEvent
{
public static Color defaultEditorColor = new Color32(123, 158, 5, 255);
public Color editorColor;
public VisualEffectPlayableSerializedEventNoColor enter;
public VisualEffectPlayableSerializedEventNoColor exit;
}
[NotKeyable]
public List<ClipEvent> clipEvents = new List<ClipEvent>()
{
new ClipEvent()
{
editorColor = ClipEvent.defaultEditorColor,
enter = new VisualEffectPlayableSerializedEventNoColor()
{
name = VisualEffectAsset.PlayEventName,
time = 0.0,
timeSpace = PlayableTimeSpace.AfterClipStart,
eventAttributes = new EventAttributes() { content = Array.Empty<EventAttribute>() }
},
exit = new VisualEffectPlayableSerializedEventNoColor()
{
name = VisualEffectAsset.StopEventName,
time = 0.0,
timeSpace = PlayableTimeSpace.BeforeClipEnd,
eventAttributes = new EventAttributes() { content = Array.Empty<EventAttribute>() }
}
}
};
[NotKeyable]
public List<VisualEffectPlayableSerializedEvent> singleEvents = new List<VisualEffectPlayableSerializedEvent>();
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<VisualEffectControlPlayableBehaviour>.Create(graph);
var behaviour = playable.GetBehaviour();
behaviour.clipStart = clipStart;
behaviour.clipEnd = clipEnd;
behaviour.scrubbing = scrubbing;
behaviour.startSeed = startSeed;
if (scrubbing)
{
behaviour.reinitEnter = true;
behaviour.reinitExit = true;
}
else
{
switch (reinit)
{
case ReinitMode.None:
behaviour.reinitEnter = false;
behaviour.reinitExit = false;
break;
case ReinitMode.OnExitClip:
behaviour.reinitEnter = false;
behaviour.reinitExit = true;
break;
case ReinitMode.OnEnterClip:
behaviour.reinitEnter = true;
behaviour.reinitExit = false;
break;
case ReinitMode.OnEnterOrExitClip:
behaviour.reinitEnter = true;
behaviour.reinitExit = true;
break;
}
}
if (clipEvents == null)
clipEvents = new List<ClipEvent>();
if (singleEvents == null)
singleEvents = new List<VisualEffectPlayableSerializedEvent>();
behaviour.clipEventsCount = (uint)clipEvents.Count;
var tempCollectedEvent = new List<VisualEffectPlayableSerializedEvent>();
foreach (var clipEvent in clipEvents)
{
tempCollectedEvent.Add(clipEvent.enter);
tempCollectedEvent.Add(clipEvent.exit);
}
foreach (var singleEvent in singleEvents)
{
tempCollectedEvent.Add(singleEvent);
}
behaviour.events = tempCollectedEvent.ToArray();
if (!prewarm.enable || !behaviour.reinitEnter || prewarm.eventName == null || string.IsNullOrEmpty((string)prewarm.eventName))
{
behaviour.prewarmStepCount = 0u;
behaviour.prewarmDeltaTime = 0.0f;
behaviour.prewarmEvent = null;
}
else
{
behaviour.prewarmStepCount = prewarm.stepCount;
behaviour.prewarmDeltaTime = prewarm.deltaTime;
behaviour.prewarmEvent = prewarm.eventName;
}
return playable;
}
}
}
#endif