# Create advanced interface

**URL:** <https://discussions.unity.com/t/create-advanced-interface/550115>\
**Category:** Scripting\
**Tags:** Scripting\
**Created:** [September 10, 2014, 10:12pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115 "2014-09-10T22:12:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![J\_b](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_b](https://discussions.unity.com/u/J_b)\
**Post date:** [September 10, 2014, 10:12pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/1 "2014-09-10T22:12:27Z")

</div>

Hi there!  
I’ve some programming experience but I’m pretty new to unity.  
I want to create an advanced interface where i want to simulate a combat phase.  
The combat is based on a dice roll.  
I’m using the onGui function to handle all the interface stuff. I splitted them in 3 parts: “next turn”, “unit information” and “combat”. I’ve 3 variables to show every part when i need it.

Example:

```auto
	void OnGUI () {
/*	bool guiShowAbility = true;
 *	bool guiShowTurn = true;
 *	bool guiShowCombat = false;
 */
		GUI.Box(new Rect((ScreenWidth - 150),(ScreenHeight - 180),150,180),"");

		if (selectedObject != null && guiShowAbility) {
			GUI.Label(new Rect((ScreenWidth - 149),(ScreenHeight - 180),ScreenWidth,ScreenHeight), "Info");
		}

		if (guiShowTurn) {
			if (GUI.Button (new Rect((ScreenWidth/2) - 50, ScreenHeight - 50, 100, 50), "Next Turn")){
				...
			}
		}
		if (guiShowCombat )
		{
			.....
		}
	}

```

How could I create a combat simulation? I need two throws and a button between each throw. Is there a better way than the OnGui function?

---

<div class="post-metadata">

**Author:** ![Deecann](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/deecann/32/589241_2.png) [@Deecann](https://discussions.unity.com/u/Deecann)\
**Post date:** [September 11, 2014, 12:38pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/2 "2014-09-11T12:38:35Z")

</div>

Yeap, there is. Don’t use it. OnGUI is pain in the ass for performance, especially if you create many objects. Try to use some stuff, eg. nGUI.

Now, about combat simulation, I don’t get it. What do you want to appear on the screen ? Animations ?

---

<div class="post-metadata">

**Author:** ![J\_b](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_b](https://discussions.unity.com/u/J_b)\
**Post date:** [September 11, 2014, 12:40pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/3 "2014-09-11T12:40:49Z")

</div>

Do you have any link for ngui? Maybe a tutorial…  
If possible i want to show the dice rolling, and then compare the two result and decide who win. Every player throws a dice of course, so they have to be synchronised

---

<div class="post-metadata">

**Author:** ![Deecann](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/deecann/32/589241_2.png) [@Deecann](https://discussions.unity.com/u/Deecann)\
**Post date:** [September 11, 2014, 12:52pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/4 "2014-09-11T12:52:42Z")

</div>

I think the better way of doing this will be second camera with proper culling mask. On main cam do some fade screen and create second cam to show your dice stuff somewhere in the scene.

---

<div class="post-metadata">

**Author:** ![cdevl](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/cdevl/32/395816_2.png) [@cdevl](https://discussions.unity.com/u/cdevl)\
**Post date:** [September 11, 2014, 12:55pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/5 "2014-09-11T12:55:42Z")

</div>

I agree that you should use some package like nGUI. Historically Unity GUI/HUD capabilities were limited. nGUI (or comparable GUI packages like Daikon GUI) are on sale all the time if you don’t want to spend the full amount. Just search Asset store. nGUI website (linked from the asset store) has tons of tutorials. nGUI also has a free trial package that you can use to see if it does what you want before spending the money. I bought nGUI a long time ago on sale and so far it did what I wanted. It does have a learning curve though.

---

<div class="post-metadata">

**Author:** ![J\_b](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_b](https://discussions.unity.com/u/J_b)\
**Post date:** [September 11, 2014, 12:57pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/6 "2014-09-11T12:57:09Z")

</div>

I’ll take a look at it thanks!

---

<div class="post-metadata">

**Author:** ![orb](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/orb/32/197925_2.png) [@orb](https://discussions.unity.com/u/orb)\
**Post date:** [September 11, 2014, 1:10pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/7 "2014-09-11T13:10:40Z")

</div>

There’s also the built-in GUI in the 4.6 beta, if you don’t have need of more than the basic controls. Should it be insufficient, NGUI has a trial version (or possibly older version that is free now).

---

<div class="post-metadata">

**Author:** ![J\_b](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_b](https://discussions.unity.com/u/J_b)\
**Post date:** [September 11, 2014, 1:45pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/8 "2014-09-11T13:45:54Z")

</div>

Probably what I’m gonna do is something very easy like:  
Click a button and open the combat interface;  
Calculate a random number from 1 to 6 and show an immage of the number as a dice face. Maybe I’m gonna add a “close” button to end the combat phase and close the interface.

---

<div class="post-metadata">

**Author:** ![TonyLi](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/tonyli/32/611093_2.png) [@TonyLi](https://discussions.unity.com/u/TonyLi)\
**Post date:** [September 11, 2014, 2:01pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/9 "2014-09-11T14:01:49Z")

</div>

> [@orb](#):
>
> There’s also the built-in GUI in the 4.6 beta, if you don’t have need of more than the basic controls. Should it be insufficient, NGUI has a trial version (or possibly older version that is free now).

The new UI in the Unity 4.6 beta is really great (and free!). It has an excellent [set of tutorials](http://unity3d.com/learn/tutorials/modules/beginner/ui). If you don’t mind developing on a beta version until Unity 4.6 is released to production, I recommend it. No sense learning NGUI or the legacy Unity GUI, with their own complexities, if you can use the new UI.

You can create a simple dice-rolling animation in Unity (or six, one for each number) and play that in a UI canvas. The example project animates a spinning rabbit sculpture. Playing the animation for dice would use the same technique.

---

<div class="post-metadata">

**Author:** ![J\_b](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@J\_b](https://discussions.unity.com/u/J_b)\
**Post date:** [September 11, 2014, 2:03pm UTC](https://discussions.unity.com/t/create-advanced-interface/550115/10 "2014-09-11T14:03:39Z")

</div>

Thank you very much! I’ll check it as soon as I can!
