# IPlayReceiver

You can implement a method to be called when the graph is played.
Please note that in the case of function graphs, this is called when the function graph itself starts playing, regardless of the playback status of the parent graph.

## How to write a script

- Implement `LogicToolkit.IPlayReceiver` in types that inherit from various NodeComponents.
- Implement `public void OnPlay()`.

## Code example

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using LogicToolkit;

    [System.Serializable]
    public class PlayExample : ActionComponent, IPlayReceiver
    {
        [SerializeField]
        private OutputDataPort<float> elapsedTime;

        private float beginTime;

        public void OnPlay()
        {
            beginTime = Time.time;
        }

        protected override void OnAction()
        {
            elapsedTime.SetValue(Time.time - beginTime);
        }
    }

In this example, we'll store the time when the graph starts playing and print the elapsed time as it runs.