Skip to content

Toggle visibility of scene items on a timer

WarmUpTill edited this page May 25, 2023 · 6 revisions

Simple example

This simple example macro shows a source with the name "Overlay Source" on the current scene for exactly 5 seconds every 3 minutes.

Overlay

More advanced example

In the following example we will set up a series of macros which allow us to achieve the following effect:

  • On a set interval the visibility of sources on a scene will be toggled so that only one of the source is visible at a time
  • The automated loop can be started and stopped via the press of a hotkey

We will need to create macros for the following functionality:

  • A macro running the "main" loop
  • A macro to start the loop (*)
  • A macro to stop the loop (*)
  • A macro handling the hotkey (*)

(*) If you do not care about resetting the visibility of the sources (or performing other actions) after pausing / unpausing the main loop you will not have to set up separate macros for the hotkey handling or pausing / unpausing the main loop.
A hotkey to simply toggle the pause state of a macro will automatically be created for each macro and can be used instead.

The "main" loop

The goal of this macro is to continuously perform a set of actions.
So we use the the "Plugin state" condition type and specify "Advanced scene switcher is running" as this will always be true while the plugin is active.

The actions we will perform will consist of two actions types - the "Wait" action and the "Scene item visibility" action.
The former will allow us to specify the duration to wait for before advancing to the next set of actions.
The latter will be used to show or hide particular sources on a scene.

In this example we will toggle the visibility of three sources - "Color Source", "Color Source 2", and "Color Source 3".
As we only want to have one of the color sources be visible at a time we have to make sure that the previously shown color source is hidden.
Once we have adjusted the viability of the scene items we follow it up with a wait action to make sure the source is actually visible before hiding it again in the next step.
This series of actions - "hide" -> "show" -> "wait" - has to be repeated for each source resulting in a setup similar to the one below:

MainLoop

One point that can be important is to mark this "main loop" macro to run in parallel to other macros by pressing the "Run macro in parallel to other macros" button as it would otherwise block the execution of any other macro while it is running.

Start the loop

We will use the option to pause or unpause macros to control the "main loop".
This macro will not need to any conditions as we will trigger it from another macro (the one handling the hotkey).

The actions of this macro consist of one "Macro" action to unpause the macro and (optionally) "Scene item visibility" actions to reset the loop.

Start

Stop the loop and reset the visibility

This macro will work just the same as the one starting the loop, but instead of unpausing the main loop we will pause it this time.

Stop

Once again you could optionally add additional actions to reset the scene item visibility of the sources touched by the main loop.

Handling the hotkey

We will use the "Hotkey" condition type to register a new OBS hotkey with the name "Toggle Image Source Loop".
When this condition is true (meaning the hotkey was pressed) we run the "Sequence" action type.
This action will allow us to define a list of macros of which only one at a time will be run, but the key point being that each time the action is triggered it will advance to the next macro in the list.

Hotkey

Make sure to set up a keybind for this new hotkey in the OBS settings menu.

Example guides

Explanations

Clone this wiki locally