Skip to content

Commit 9ebe484

Browse files
alex-vazquez-unity3dEvergreen
authored andcommitted
Render Pipeline Converter - Disable the tool while running playmode.
1 parent a1b5f0b commit 9ebe484

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,40 @@ internal static void DontSaveToLayout(EditorWindow wnd)
168168
void OnEnable()
169169
{
170170
GraphicsToolLifetimeAnalytic.WindowOpened<RenderPipelineConvertersEditor>();
171+
172+
// Subscribe to play mode changes
173+
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
174+
175+
// If CreateGUI already ran, update UI state now
176+
UpdateUiForPlayMode(EditorApplication.isPlaying);
171177
}
172178

173179
private void OnDisable()
174180
{
175181
GraphicsToolLifetimeAnalytic.WindowClosed<RenderPipelineConvertersEditor>();
182+
183+
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
184+
}
185+
186+
private void OnPlayModeStateChanged(PlayModeStateChange state)
187+
{
188+
// Update visibility whenever state changes
189+
UpdateUiForPlayMode(EditorApplication.isPlaying);
190+
}
191+
192+
private void UpdateUiForPlayMode(bool isPlaying)
193+
{
194+
if (rootVisualElement == null)
195+
return;
196+
197+
var disabledHelpBox = rootVisualElement.Q<HelpBox>("disabledToolHelpBox");
198+
var convertersMainVE = rootVisualElement.Q<VisualElement>("converterEditorMainVE");
199+
200+
if (disabledHelpBox == null || convertersMainVE == null)
201+
return;
202+
203+
disabledHelpBox.style.display = isPlaying ? DisplayStyle.Flex : DisplayStyle.None;
204+
convertersMainVE.SetEnabled(!isPlaying);
176205
}
177206

178207
public void CreateGUI()
@@ -255,6 +284,8 @@ public void CreateGUI()
255284

256285
HideUnhideConverters();
257286
EnableOrDisableConvertButton();
287+
288+
UpdateUiForPlayMode(EditorApplication.isPlaying);
258289
}
259290

260291
private bool CanEnableConvert()

Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.uxml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
2+
<ui:HelpBox message-type="Warning" text="The Render Pipeline Converter is disabled during Playmode." name="disabledToolHelpBox" style="flex-grow: 1;" />
23
<ui:VisualElement name="converterEditorMainVE" class="converter-editor-main">
34
<ui:VisualElement name="topInformationVE" class="converter-top-info">
45
<ui:TabView index="-1" name="conversionsTabView" class="converter-dropdown"/>

0 commit comments

Comments
 (0)