System.IDisposable AddHook( Sandbox.GameObjectSystem/Stage stage, int order, System.Action action, string className, string description )

robot_2Generated
code_blocksInput

Description

The AddHook method allows you to add a hook to a specific stage of the game object system within a scene. This hook is executed at a specified order and can be used to perform custom actions during the lifecycle of the game object system. The method returns an IDisposable object, which can be used to remove the hook when it is no longer needed.

Usage

To use the AddHook method, you need to specify the stage at which the hook should be executed, the order of execution, the action to be performed, a class name for identification, and a description of the hook. The method returns an IDisposable that should be disposed of when the hook is no longer needed to ensure it is removed from the system.

Example

// Example of adding a hook to a scene
var scene = new Scene();

// Define the action to be executed
Action myAction = () => {
    // Custom logic here
};

// Add the hook to the scene
IDisposable hook = scene.AddHook(
    stage: GameObjectSystem.Stage.Update,
    order: 10,
    action: myAction,
    className: "MyCustomHook",
    description: "This hook performs custom logic during the update stage."
);

// Later, when the hook is no longer needed, dispose of it
hook.Dispose();