Skip to content

BaseBlinkAction

BaseBlinkAction is an abstract base class for actions that toggle a target on and off in a repeating blink pattern.

It provides the common timing logic used by blink-style effects such as BlinkRenderer and BlinkLight.

Core Functionality

The class provides:

Two fields control the blink pattern:

  • OnDuration: How long the target stays on.
  • OffDuration: How long the target stays off.

The action starts in the on state, waits for OnDuration, then switches to off for OffDuration, repeating until the state changes.

Realtime Option

The UseRealtime field lets the action ignore Unity time scale:

  • false: Uses Time.deltaTime
  • true: Uses Time.unscaledDeltaTime

This is useful for blink effects that should continue while the game is paused or slowed down.

Current State Output

The optional IsOn output stores the current blink state.

You can use this to drive or synchronize other effects.

Update Mode Setup

BaseBlinkAction sets the appropriate update mode for a repeating blink action:

public override UpdateMode DefaultUpdateMode => UpdateMode.UpdateEveryFrame;
public override UpdateMode RequiredUpdateModes => UpdateMode.EveryFrame;

Required Overrides

Inheritors must implement:

protected abstract void Apply(bool on);

This method should enable or disable the specific target type.

Actions can also override:

protected virtual string Target => "Target";

This is used in the action summary.

Example

BlinkLight is a simple example:

using System;
using JetBrains.Annotations;
using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
    [Serializable, PublicAPI]
    [ActionCategory(Category.Blink)]
    [ActionDescription("Turns a Light on and off in a blink pattern.")]
    public class BlinkLight : BaseBlinkAction
    {
        [OwnerDefaultValue]
        [Tooltip("The Light to turn on/off.")]
        public LightVar Light;

        public override bool CanExecute() => CheckParameters(Light);

        protected override string Target => nameof(Light);

        protected override void Apply(bool on) => Light.Value.enabled = on;
    }
}

With this setup, the base class handles the blink timing and the derived action only needs to apply the current on/off state to its target.