Skip to content

Commit c946640

Browse files
authored
Merge pull request #47 from CompositionInc/fix/stagelighttimelinemixer_performance
初期化の処理を初回のみ実行するよ
2 parents 8a65d47 + c291060 commit c946640

1 file changed

Lines changed: 35 additions & 21 deletions

File tree

jp.iridescenet.stagelightmaneuver/Runtime/StageLightTimeline/StageLightTimelineMixerBehaviour.cs

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
2525
if (!trackBinding)
2626
return;
2727

28-
if (firstFrameHappened)
28+
if (!firstFrameHappened)
2929
{
3030
trackBinding.Init();
31+
32+
for (int i = 0; i < clips.Count; i++)
33+
{
34+
var clip = clips[i];
35+
var stageLightTimelineClip = clip.asset as StageLightTimelineClip;
36+
if (stageLightTimelineClip == null) continue;
37+
UpdateProperty(clip);
38+
}
3139
firstFrameHappened = true;
3240
}
3341

@@ -40,23 +48,13 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
4048
var stageLightTimelineClip = clip.asset as StageLightTimelineClip;
4149
if (stageLightTimelineClip == null) continue;
4250
float inputWeight = playable.GetInputWeight(i);
43-
var clockProperty = stageLightTimelineClip.StageLightQueueData.TryGetActiveProperty<ClockProperty>();
44-
if (clockProperty != null)
45-
{
46-
clockProperty.clipProperty.clipStartTime = (float)clip.start;
47-
clockProperty.clipProperty.clipEndTime = (float)clip.end;
48-
}
49-
50-
foreach (var stageLightProperty in stageLightTimelineClip.StageLightQueueData.stageLightProperties)
51+
52+
#if UNITY_EDITOR
53+
if (!Application.isPlaying)
5154
{
52-
if(stageLightProperty == null) continue;
53-
stageLightProperty.InitStageLightFixture(trackBinding);
54-
if (stageLightProperty.propertyType == StageLightPropertyType.Array )
55-
{
56-
var additionalArrayProperty = stageLightProperty as IArrayProperty;
57-
additionalArrayProperty?.ResyncArraySize(trackBinding.stageLightFixtures);
58-
}
55+
UpdateProperty(clip);
5956
}
57+
#endif
6058

6159
if (inputWeight > 0)
6260
{
@@ -65,13 +63,29 @@ public override void ProcessFrame(Playable playable, FrameData info, object play
6563
hasAnyClipPlaying = true;
6664
}
6765
}
68-
6966
}
70-
71-
7267

68+
private void UpdateProperty(TimelineClip clip)
69+
{
70+
var stageLightTimelineClip = clip.asset as StageLightTimelineClip;
71+
if (stageLightTimelineClip == null) return;
72+
var clockProperty = stageLightTimelineClip.StageLightQueueData.TryGetActiveProperty<ClockProperty>();
73+
if (clockProperty != null)
74+
{
75+
clockProperty.clipProperty.clipStartTime = (float)clip.start;
76+
clockProperty.clipProperty.clipEndTime = (float)clip.end;
77+
}
7378

74-
75-
79+
foreach (var stageLightProperty in stageLightTimelineClip.StageLightQueueData.stageLightProperties)
80+
{
81+
if(stageLightProperty == null) continue;
82+
stageLightProperty.InitStageLightFixture(trackBinding);
83+
if (stageLightProperty.propertyType == StageLightPropertyType.Array )
84+
{
85+
var additionalArrayProperty = stageLightProperty as IArrayProperty;
86+
additionalArrayProperty?.ResyncArraySize(trackBinding.stageLightFixtures);
87+
}
88+
}
89+
}
7690
}
7791
}

0 commit comments

Comments
 (0)