RSS

Tag Archives: Unity 3d

Using Firebase in Unity3D Tutorial 1: Basics and setup


Firebase is a platform that helps you quickly develop high-quality apps,  It is made up of a collection of features that is very handy for Unity3D, Android, iOS app developers.

In this series of tutorials, I am going to cover how to harness Firebase features to streamline your app development process. Each tutorial is designed to be compact, and follows the SRP (Single Responsibility Principle), so that you can use these take-aways quickly in your own development.

Read the rest of this entry »

 
1 Comment

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

 

Tags: , , , , , , , ,

Unity3D: Get inspector property values programatically


Recently, I found an interesting question in Unity3D. How to get some field value shown in Unity3D inspector programmatically? Largely this is an undocumented area, and it took me some research to get this done.

In what follows, I am getting the value for Input Manage Axes, as shown below:

image

Read the rest of this entry »

 
Leave a comment

Posted by on October 25, 2016 in Programming, Unity 3d

 

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

Using SmartFox with C# (III) : Frequently used functions


If you haven’t read below posts, you might wish to have a quick go through:

Using SmartFox with C# (I) : Installations and 1st handshaking
Using SmartFox with C# (II) : Login and join room

If you are comfortable with above implementations, you might be interested in below frequently called functions. Assuming below variable is instantiated successfully:

private SmartFox client;

To Send a message:

client.Send(new PublicMessageRequest(someMessage));
client.AddEventListener(SFSEvent.PUBLIC_MESSAGE, OnPublicMessage);
private void OnPublicMessage(BaseEvent evt) {
     User sender = (User) evt.Params[“sender”];
     string message = (string) evt.Params[“message”];   
}

To create a room:

var settings = new RoomSettings(“New Room Name”);
settings.maxUsers = 100;
Settings.groupId = “ChatGroup”;
client.Send(new CreateRoomRequest(settings));
client.addEventListener(SFSEvent.ROOM_ADD, OnRoomAdded);

For a zone, to join/remove a room:

client.Send(new Sfs2X.Requests.JoinRoomRequest(roomId));
client.AddEventListener(SFSEvent.ROOM_JOIN, OnRoomJoin);
private void OnRoomJoin(BaseEvent evt) {
     Room room = (Room) evt.Params[“room”];           
     //room.Name,  room.UserList
}

For user to enter/leave a room

client.Send(new Sfs2X.Requests.LeaveRoomRequest());
client.AddEventListener(SFSEvent.USER_EXIT_ROOM, OnUserExitRoom);
private void OnUserExitRoom(BaseEvent evt) { User user = (User) evt.Params[“user”]; }

For more information, have a read on SFSEvent class and Sfs2X.Requests namespace will be vey helpful.

 
2 Comments

Posted by on September 14, 2015 in Dotnet/C#, Programming, Unity 3d

 

Tags: , , , , ,

Unity3D: Progressbar using new UI system


Before Unity 4.6 new UI system came out, to create a progress bar, the typical process involve writing the OnGUI() function as follows:

public Texture2D emptyProgressBar; // Set this in inspector.
public Texture2D fullProgressBar;  // Set this in inspector.

void OnGUI() 
{
    GUI.DrawTexture(Rect(0, 0, 100, 50), emptyProgressBar);
    GUI.DrawTexture(Rect(0, 0, progress, 50), fullProgressBar);
    GUI.skin.label.alignment = TextAnchor.MiddleCenter;
    GUI.Label(Rect(0, 0, 100, 50), string.Format("{0:N0}%", 
progress * 100f)); }

UnityProgressBar

This is OK, however not recommended in the new GUI system in Unity 4.6+: you don’t want to mix the GUI with the new and legacy system, right?

Here is the process to create a progress bar using the new UI system:

Read the rest of this entry »

 
2 Comments

Posted by on August 6, 2015 in Programming, Unity 3d

 

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

Unity3D: using ReorderableList in Custom Editor


ReorderableList is not a widely used class in Unity3D, but good use of it can make your custom editor more professional.

ReorderableList[5]

Read the rest of this entry »

 
Leave a comment

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

 

Tags: , , , , , , ,

Unity: Detect GUI Window Created/Closed Event


On StackOverflow, someone asks how to detect the GUI Window Created/Closed Event, which Unity3D does not ship an off-the-shelf solution.

Below is my solution to this problem: to use property setter to handle this. Here is the sample code:

enter image description here

Read the rest of this entry »

 
Leave a comment

Posted by on June 11, 2015 in Programming, Unity 3d

 

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