logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityUiMouseInteractionLock

    Unity-specific implementation of mouse interaction locking with owner tracking.
    When locked, only the active owner's hierarchy receives pointer events; all other UI elements are blocked.
    Uses ICanvasRaycastFilter pattern via child blocker components to selectively filter pointer events.

    Inheritance
    object
    UnityUiMouseInteractionLock
    Implements
    IUiMouseInteractionLock
    Namespace: Serenity.Ui.Infrastructure.Services
    Assembly: Serenity.UnityUi.Infrastructure.dll
    Syntax
    public class UnityUiMouseInteractionLock : MonoBehaviour, IUiMouseInteractionLock

    Constructors

    UnityUiMouseInteractionLock()

    Declaration
    public UnityUiMouseInteractionLock()

    Properties

    ActiveOwner

    Gets the current lock owner's GameObject, or null if not locked.

    Declaration
    public GameObject ActiveOwner { get; }
    Property Value
    Type Description
    GameObject

    IsLocked

    Gets whether mouse interaction is currently locked.

    Declaration
    public bool IsLocked { get; }
    Property Value
    Type Description
    bool

    Methods

    ForceUnlockAll()

    Forces release of all mouse interaction locks regardless of owner.
    Use for emergency cleanup scenarios.

    Declaration
    public void ForceUnlockAll()

    ForceUnlockOwnedBy(GameObject)

    Forces release of all mouse interaction locks owned by the specified owner.
    Use for cleanup scenarios like component destruction or error recovery.

    Declaration
    public void ForceUnlockOwnedBy(GameObject owner)
    Parameters
    Type Name Description
    GameObject owner

    The GameObject to release locks for.

    Initialize(ILogService)

    Initializes the mouse interaction lock with the logging service.

    Declaration
    public void Initialize(ILogService logService)
    Parameters
    Type Name Description
    ILogService logService

    The logging service for outputting log messages.

    IsPointerAllowedFor(Transform)

    Checks if a given Transform is allowed to receive pointer events.
    Returns true if not locked, or if the target is part of the active owner's hierarchy.

    Declaration
    public bool IsPointerAllowedFor(Transform target)
    Parameters
    Type Name Description
    Transform target

    The Transform to check.

    Returns
    Type Description
    bool

    True if pointer events should be allowed for this target.

    Lock(GameObject)

    Acquires a mouse interaction lock for the specified owner.
    While locked, only UI elements that are children of the owner's Transform will receive pointer events.
    If already locked by another owner, this call is ignored (first owner wins).

    Declaration
    public void Lock(GameObject owner)
    Parameters
    Type Name Description
    GameObject owner

    The GameObject that owns the lock (e.g., the input component's root).

    Unlock(GameObject)

    Releases the mouse interaction lock for the specified owner.
    Only the current owner can release the lock. Other callers are ignored.

    Declaration
    public void Unlock(GameObject owner)
    Parameters
    Type Name Description
    GameObject owner

    The GameObject that owns the lock.

    Implements

    IUiMouseInteractionLock
    In this article
    © 2026 Serenity. All Rights Reserved