Skip to content

Commit b90d868

Browse files
authored
fix: hide the button to update RenderCache if the Director GameObject is not selected (#447)
Others: * checks if the clip is selected in TimelineEditor (null checks) at the start of OnInpsectorGUI()
1 parent 4322289 commit b90d868

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

Editor/Scripts/Features/RenderCache/RenderCachePlayableAssetInspector.cs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ public override void OnInspectorGUI() {
6767
EditorGUILayout.Space(15f);
6868

6969
//Check if the asset is actually inspected
70-
if (null!=TimelineEditor.selectedClip && TimelineEditor.selectedClip.asset != m_asset) {
70+
TimelineClip selectedClip = TimelineEditor.selectedClip;
71+
if (null == selectedClip)
72+
return;
73+
74+
if (selectedClip.asset != m_asset) {
7175
return;
7276
}
7377

@@ -101,8 +105,8 @@ public override void OnInspectorGUI() {
101105

102106
//Capture Selected Frames
103107
using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
104-
DrawCaptureSelectedFramesGUI(TimelineEditor.selectedClip, clipData);
105-
DrawLockFramesGUI(TimelineEditor.selectedClip, clipData);
108+
DrawCaptureSelectedFramesGUI(selectedClip, clipData);
109+
DrawLockFramesGUI(selectedClip, clipData);
106110
}
107111

108112
GUILayout.Space(15);
@@ -126,13 +130,13 @@ public override void OnInspectorGUI() {
126130
GUILayout.Space(5);
127131
}
128132
GUILayout.Space(15);
129-
DrawUpdateRenderCacheGUI();
133+
DrawUpdateRenderCacheGUI(selectedClip);
130134

131135
}
132136

133137
//----------------------------------------------------------------------------------------------------------------------
134138

135-
private void DrawUpdateRenderCacheGUI() {
139+
private void DrawUpdateRenderCacheGUI(TimelineClip clip) {
136140
RenderCacheClipData clipData = m_asset.GetBoundClipData();
137141
Assert.IsNotNull(clipData);
138142
if (clipData.GetOwner().GetParentTrack().IsNullRef())
@@ -153,7 +157,7 @@ ShortcutBinding updateRenderCacheShortcut
153157
int captureStartFrame = Math.Max(0,editorConfig.GetCaptureStartFrame());
154158
int captureEndFrame = editorConfig.GetCaptureEndFrame();
155159
if (captureEndFrame < 0) {
156-
captureEndFrame = TimelineUtility.CalculateNumFrames(TimelineEditor.selectedClip);
160+
captureEndFrame = TimelineUtility.CalculateNumFrames(clip);
157161
}
158162

159163
captureStartFrame = EditorGUILayout.IntField("From", captureStartFrame);
@@ -173,19 +177,11 @@ ShortcutBinding updateRenderCacheShortcut
173177

174178
GUILayout.Space(10);
175179

180+
PlayableDirector director = TimelineEditor.inspectedDirector;
181+
if (null == director)
182+
return;
176183
if (GUILayout.Button($"Update Render Cache ({updateRenderCacheShortcut})")) {
177-
178-
PlayableDirector director = TimelineEditor.inspectedDirector;
179-
if (null == director) {
180-
EditorUtility.DisplayDialog("Streaming Image Sequence",
181-
"PlayableAsset is not loaded in scene. Please load the correct scene before doing this operation.",
182-
"Ok");
183-
return;
184-
}
185-
186-
//Loop time
187-
EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this);
188-
184+
EditorCoroutineUtility.StartCoroutine(UpdateRenderCacheCoroutine(director, m_asset), this);
189185
}
190186
}
191187

0 commit comments

Comments
 (0)