# Adding a function to update

**URL:** <https://discussions.unity.com/t/adding-a-function-to-update/72714>\
**Category:** Questions & Answers\
**Created:** [June 6, 2013, 1:21am UTC](https://discussions.unity.com/t/adding-a-function-to-update/72714 "2013-06-06T01:21:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scottstephan](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@scottstephan](https://discussions.unity.com/u/scottstephan)\
**Post date:** [June 6, 2013, 1:21am UTC](https://discussions.unity.com/t/adding-a-function-to-update/72714/1 "2013-06-06T01:21:15Z")

</div>

Kind of new to C#, or at least to not coding like a dummy. Here’s a question: I have a function I’d like to update every frame, but only under certain circumstances. I could SendMessage from a dispatch every frame, but that seems expensive and odd.

What I’d like to do is: SendMessage(startUpdateEveryFrame) and later, SendMessage(stopUpdateEveryFrame). Will awake help me do that? What are my best practices here?

---

<div class="post-metadata">

**Author:** ![MiKo51](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@MiKo51](https://discussions.unity.com/u/MiKo51)\
**Post date:** [June 6, 2013, 2:29am UTC](https://discussions.unity.com/t/adding-a-function-to-update/72714/2 "2013-06-06T02:29:10Z")

</div>

bool updateEveryFrame=false;

```
void Update()
{
   if (updateEveryFrame)
   {
      CallYourFunction();
   }
}

```
