RSS

Tag Archives: Unity3d

Firebase Unity3D example: a walk through tutorial


image

Read the rest of this entry »

Advertisements
 
3 Comments

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

Unity3D: using Visual Studio Code and hide meta and other unwanted files


Go to Visual Studio Code preference, click “Preference” > “User Settings” or “Project Settings”, add below code in the “Settings.Json” file:

vscode_hide2

// Place your settings in this file to overwrite the default settings
{
    "files.exclude": {
    "**/*.meta": true,
    "Temp": true,
    "Library": true,
    "ProjectSettings": true,
    "obj": true,
    ".vs": true,
    ".vscode": true,
    "Assembly-C*.*": true,
    "*.csproj":true,
    "*.orig":true,
    "*.user":true,
    "*.userprefs":true
    }
}

 

Now, the VS code will cleanly show the files that you need.

 
Leave a comment

Posted by on September 25, 2015 in Programming, Unity 3d

 

Tags: , , , , , , , , ,

Uniy3D: How to implement scrolled UI with texts


Unity3D 4.6+ comes with the new UI system that makes implementation of scrolled texts a piece of cake. This article explains, step-by-step, how to make such scrolled effects.

ScrolledText1

Read the rest of this entry »

 
1 Comment

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

 

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

Simple Line Chart in Unity


Just took 1 day and implemented the line chart in Unity3D. Below is a demo. It was built using Unity GUI and Graphic.DrawTexture() calls.

Happy coding!

 
1 Comment

Posted by on November 16, 2014 in Programming, Unity 3d

 

Tags: , , , , , , ,

Vuforia: cannot detect image target and view 3D object in Unity


Using Vuforia’s Unity package it is easy to develop an AR based application. The full tutorials can be found in Vuforia’s web page: Getting Started with the Unity Extension. Here is the outline:

  • Download vuforia-unity-android-ios-xx-yy-zz.unitypackage here, or directly download this file here.
  • Drag this unitypackage file to Unity3d, this will import the entire package. Click import button in the  popup dialog.

  • image  imageimage image

    Read the rest of this entry »

     
    1 Comment

    Posted by on August 28, 2014 in Programming, Unity 3d

     

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