# GUI Troubles

**URL:** https://discussions.unity.com/t/gui-troubles/420507
**Category:** Scripting
**Tags:** Scripting
**Created:** [August 13, 2010, 2:41pm UTC](https://discussions.unity.com/t/gui-troubles/420507 "2010-08-13T14:41:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![anon\_5325452](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@anon\_5325452](https://discussions.unity.com/u/anon_5325452)
#### Post date: [August 13, 2010, 2:41pm UTC](https://discussions.unity.com/t/gui-troubles/420507/1 "2010-08-13T14:41:55Z")

</div>

So I’ve been having troubles with GUI, thing is I want to make things outside of the OnGUI() Function, is there anyway I can do this?

---

<div class="post-metadata">

### Author: ![Kokumo](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kokumo/32/513541_2.png) [@Kokumo](https://discussions.unity.com/u/Kokumo)
#### Post date: [August 13, 2010, 4:19pm UTC](https://discussions.unity.com/t/gui-troubles/420507/2 "2010-08-13T16:19:57Z")

</div>

What kind of problems did you have?

---

<div class="post-metadata">

### Author: ![anon\_43237147](https://avatars.discourse-cdn.com/v4/letter/a/3bc359/32.png) [@anon\_43237147](https://discussions.unity.com/u/anon_43237147)
#### Post date: [August 14, 2010, 10:48pm UTC](https://discussions.unity.com/t/gui-troubles/420507/3 "2010-08-14T22:48:25Z")

</div>

If you mean you want to create/draw GUI controls from outside OnGUI(), it can’t be done. GUI functions can only be called from OnGUI(). You can have code elsewhere that sets a flag (or creates other data) which is then checked for in OnGUI(), though.

---

<div class="post-metadata">

### Author: ![BlackMantis](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/blackmantis/32/593530_2.png) [@BlackMantis](https://discussions.unity.com/u/BlackMantis)
#### Post date: [August 15, 2010, 1:15am UTC](https://discussions.unity.com/t/gui-troubles/420507/4 "2010-08-15T01:15:56Z")

</div>

What kind of things are you trying to create outside the OnGUI()? All you have to do is create a custom function and call on it from insde the OnGUI().

```auto
function OnGUI(){
   MyCustom();
}

function MyCustom() {
   //Cut the grass
}

```

Inside your Custom Function You can have guiElements.  
Remember that the function is called all the time unless you use conditions ect to only call it once.
