RSS

Category 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: , , , , , , , ,

Firebase Unity3D example: a walk through tutorial


image

Read the rest of this entry »

 
1 Comment

Posted by on January 16, 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: , , , , , , , , , , ,

Step-by-Step guide for developing Android Plugin for Unity3D (II)


In previous blog, I have covered how to handshake Native Android code with Unity3D. The example shown therein is pretty simple: how to call a java function in C#!

In this blog, I am trying to step one more stride further: to create and use an Android View in Unity3D. The example shown here is an Android ImageView, however, this approach is generally applicable to all kinds of Android Views, ViewGroups and custom views.

imageAn Android ImageView

imageUse Android ImageView in Unity3D

Read the rest of this entry »

 
8 Comments

Posted by on August 10, 2016 in Android, Programming, Unity 3d

 

Tags: , , , , , , ,

Backend server for Unity3D MMO games


There are many backend server systems that are commonly used in MMO games. Below are a few of them.

  1. You might try SmartFox, this link might be a good start for you. Below tutorials are also helpful for a quick start:

Specifically, you can connect to the smartfox server and get notified on connection:

private SmartFox client;
private string serverIP = "127.0.0.1";
private int serverPort = 9933;  
private string zone = "BasicExamples";

client = new SmartFox();           
client.ThreadSafeMode = false; //true for Unity3D
client.AddEventListener(SFSEvent.CONNECTION, (evt) =>
        {
            bool bSuccess = (bool)evt.Params[“success”];
            Console.WriteLine(client.IsConnected ?
                “Successfully connected to SmartFox Server” :
                “Failed to connect to SmartFox Server”);
        });           
client.Connect(serverIP, serverPort);            

To Login and get hooked when login succeeds:

var request = new LoginRequest("UserName", "Password", zone);  //[1]
client.Send(request);                                          //[2]

client.AddEventListener(SFSEvent.LOGIN, (evt) => {             //[3]
            Console.WriteLine("The User login success");       
});

client.Connect(serverIP, serverPort);   

 

2.  Photon is another popular backend server/service.

Photon Server provides you with turnkey frameworks for multiplayer games. Start from scratch or build your own custom logic on top of several demo applications included in source code with the free server SDKs. This lets you achieve great results fast and easy.

Code snippet for setup connection:

using UnityEngine;

public class RandomMatchmaker : MonoBehaviour
{
    void Start() {
        PhotonNetwork.ConnectUsingSettings("0.1");
    }

    void OnGUI(){
       GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
    }
} 

Code snippet for join room/lobby:

public override void OnJoinedLobby()
{
    PhotonNetwork.JoinRandomRoom();
}

Code snippet for setup logging:

PhotonNetwork.logLevel = PhotonLogLevel.Full;

Code snippet for error handling:

void OnPhotonRandomJoinFailed()
{
    Debug.Log("Can't join random room!");
    PhotonNetwork.CreateRoom(null);
}

A good tutorial on this topic can be found here.

3. Firebase might be the 3rd choice, though the performance is arguably unclear.

  • As an example, in roll20.net, you might find MMO game powered by Firbase.
  • Among others, FireSharp might be a very useful open source project for your quick start.

4. Others (OpenSpace, RedDwarf, ElectroServer, Player.IO, Red5, Mesmotronic Multiuser Server etc.)

See this great post for details.

 
Leave a comment

Posted by on December 31, 2015 in Programming, Unity 3d

 

Tags: , , , , , , ,

Step-by-Step guide for developing Android Plugin for Unity3D (I)


This series of post outlines the development of Android plugins for Unity3D. I had been asked to develop Android plugins for Unity3D every few days or months, each time following similar paths which I think would be useful to those who will do the same job. And here is how.

Clone the source code in GitHub here !

Tools you need:

  • Android Studio
  • Unity3D
  • Android Devices for testing
  • Some patience to go through this post

Let’s get started.

The 1st example is extremely simple. We define a function DoSthInAndroid() that dump some information using Java Log.i() function, and get this function called in Unity3D. Though simple enough, it outlines all the required procedures, and are very useful to understand the entire workflow.

  • Start Android Studio, create an Android project (AndroidAddin) with an Empty Activity.
  • In Android Studio, create another library project (AndroidLib) by clicking the menu File > New > New Module

image

Read the rest of this entry »

 
13 Comments

Posted by on December 31, 2015 in Programming, Unity 3d

 

Tags: , , , , , , ,