RSS

Tag Archives: Unity 3d

Unity3D: How to create a link button, with fun


How to create a link style button in Unity3D? Here the considerations include:

  1. The link button should look like a label, instead of a button
  2. The link button should work like a button, with clickable responses such as navigating to a URL;
  3. When the mouse hovers, the mouse cursor should look like a hand cursor, instead of the arrow cursor.

image

 

Read the rest of this entry »

Advertisements
 
1 Comment

Posted by on January 21, 2015 in Programming, Unity 3d

 

Tags: , , , , , , , , , , ,

Unity3D: how to implement Tabbed UI


Unity3D does not ship with the tabbed UI, however, we can cheat to implement this!

The key ideas include:

  • To use Toggle control
  • To make Toggle control look like a tab control

UnityTabDemo

The following code illustrates how this is done:

Read the rest of this entry »

 
3 Comments

Posted by on December 27, 2014 in Programming, Unity 3d

 

Tags: , , , , , , , , , ,

iTween onComplete event handler example


iTween is a handy library to implement tween/ease type animations. One of the useful callback it provides is the onComplete event. Below is an example code of how to use it:

iTween.MoveTo(lotus_leaf, iTween.Hash(
                      “y”, 80f,
                      “onComplete“, “OnShadeHidden”)
             );

void OnShadeHidden()
{
        Debug.Log(“The shade is hidden”);
        lotus_leaf.SetActive(false);
}

where lotus_leaf is the game object to be tweened in y position, and OnShadeHidden() is the callback function or event handler.

However if you run this code, you will see the callback OnShadeHidden is NOT fired when the tween is completed! The reason is that iTween needs another parameter: onCompleteTarget, to specify which object handles the onComplete event, so the right way to get it done will be like this:

iTween.MoveTo(lotus_leaf, iTween.Hash(
                      “y”, 80f,
                      “onComplete“, “OnShadeHidden”,
                      “onCompleteTarget“, gameObject)
             );

Run the code, the onComplete event handler will be properly addressed. Happy coding!

 
2 Comments

Posted by on December 14, 2014 in Unity 3d

 

Tags: , , , , , , , , ,

Unity3D 4.6 UI: get the button and handle the click event in code


In the new Unity3D UI in v4.6, it is much easier to design fancy UI right within Unity without tertiary tools such as NGUI.

One question frequently met is: how to get access the UI elements such as text, button object in code? Here is the tip:

image

Read the rest of this entry »

 
2 Comments

Posted by on December 12, 2014 in Programming, Unity 3d

 

Tags: , , , , , , , , ,

Unity3D: Animated UI using ui camera


You might have seen many animated UI examples in games, for instance, in the cut the rope game, when you press the exit button, you can see animated UI pops up, which looks super cool!

Now, the question is, how do we implement the same effect using Unity3D? In this post, I am going to show you how this can be easily done with a step-by-step demo.

Read the rest of this entry »

 
Leave a comment

Posted by on October 6, 2014 in Unity 3d

 

Tags: , , ,

UnityVS now free: Use Visual Studio instead of MonoDevelop to design games


UnityVS is now a product of Microsoft, as Microsoft Acquired SyntaxTree. This means that you can use Visual Studio to develop Unity Apps, Games, for free.

Visual Studio 2010 Tools for Unity
Visual Studio 2012 Tools for Unity
Visual Studio 2013 Tools for Unity

Some cool features include:

Project Explorer right inside VS, no need to jump over to Unity while coding

image

Read the rest of this entry »

 
Leave a comment

Posted by on August 9, 2014 in Unity 3d

 

Tags: , , , , , , ,

Unity3D: inspector control value changed event handling


Unity3D has offered very handy interface to expose variables so that users can edit them in inspector. Take a look at below snapshot: one can define some public fields, and these fields are immediately seen in the inspector, once the script is attached tom some game object:

image  image

That is cool! But you might expect another feature: when the value changes, you get notified, and can hook your own action with it!

In C# and winform, it is trivial: SomVarTextBoxControl.TextChanged += YourAction(…)

Unfortunately, this kind of handy event handler does not exist in Unity3D! To get similar functionality, you need use custom editor!

Read the rest of this entry »

 
1 Comment

Posted by on January 11, 2014 in Programming, Unity 3d

 

Tags: , , , , , , , ,