From cb8723272d8255ed5f675a087d6ad57fc16232b0 Mon Sep 17 00:00:00 2001 From: mati-nvidia Date: Thu, 19 Jan 2023 20:16:42 -0500 Subject: [PATCH] added comments --- exts/maticodes.layers.mute/maticodes/layers/mute/window.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exts/maticodes.layers.mute/maticodes/layers/mute/window.py b/exts/maticodes.layers.mute/maticodes/layers/mute/window.py index c757b93..d81112b 100644 --- a/exts/maticodes.layers.mute/maticodes/layers/mute/window.py +++ b/exts/maticodes.layers.mute/maticodes/layers/mute/window.py @@ -10,8 +10,10 @@ class LayerMuteWindow(ui.Window): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + # Using ui.Frame.set_build_fn() provides a function to be called with ui.Frame.rebuild() self.frame.set_build_fn(self.build_frame) + # Using the same interfaces as Layers window self.layers: usd_layers.Layers = usd_layers.get_layers() self.layers_state: usd_layers.LayersState = self.layers.get_layers_state() @@ -34,6 +36,7 @@ def build_frame(self): ui.Label("There are currently no sublayers in this Stage.", alignment=ui.Alignment.CENTER) for layer_id in layer_ids: layer_name = self.layers_state.get_layer_name(layer_id) + # Skip the root layer since it can't be muted. if layer_name != "Root Layer": is_muted = self.layers_state.is_layer_locally_muted(layer_id) button = ui.Button(layer_name, height=25, checked=not is_muted) @@ -41,12 +44,15 @@ def build_frame(self): def _on_clicked(self, layer_id, button): button.checked = not button.checked + # Using the Kit command allows users to undo the change with Ctrl+Z omni.kit.commands.execute("SetLayerMuteness", layer_identifier=layer_id, muted=not button.checked) def _on_stage_opened(self, event: carb.events.IEvent): + # If user changes stages, rebuild the window with a new list of layers. self.frame.rebuild() def _on_layers_changed(self, event: carb.events.IEvent): + # If layers are added, removed or layer muteness changed. self.frame.rebuild() def destroy(self) -> None: