Coder Social home page Coder Social logo

dinobattlesample's Introduction

firebase-unity

Firebase inside Unity3d!

Welcome to Firebase (www.firebase.com) on Unity3d plugin, which supports:

  • iOS
  • Android
  • The Unity Editor Player (currently works on Mac and Windows)

How to get started

  1. Read about Firebase at www.firebase.com
  2. Clone this git repo, then form Unity open the Unity project in the empty-project folder
  3. Open the MainScene and the example TestScript.cs to start coding against Firebase!

API Differences

You will find the API is very similar to the Java/iOS versions except that:

  1. You create a new Firebase reference with:

    IFirebase ref = Firebase.CreateNew("https://your-project-id.firebaseIO.com");

    This gives you the proper platform-dependent implementation.

  2. Certain parts of the API have been made C#-idiomatic with C# properties and events. For example, instead of getKey, you'll find a Key property.

    IFirebase root;
    IFirebase foo;
    
    void Awake() {
      root = Firebase.CreateNew("https://your-project-id.firebaseIO.com");
      foo = ref.Child("foo");
      foo.Child (DateTime.Now.ToString ("yyyy-MM-dd-HH-mm-ss-zzz")).SetValue ("Awake()");
    }
    
    void OnEnable() {
      foo.ChildAdded += FooChildAdded;
    }
    
    void OnDisable() {
      foo.ChildAdded -= FooChildAdded;
    }
    
    void FooChildAdded (object sender, ChangedEventArgs e) {
      Debug.Log("FooChildAdded: " + e.DataSnapshot.Key);
    }

Troubleshooting

  • You are not receiving events, its very likely you allowed your Firebase reference to GC.

    Instead of this:

     new Firebase("mypath").ValueChanged += (...) => { .... };

    do this:

    classMember = new Firebase("mypath");  //holds a reference until the behavior is released
    classMember.ValueChanged += (...) => {...} ;
  • iOS: XCode fails to link. Please follow instructions located at: https://www.firebase.com/docs/ios/alternate-setup.html You will need to do this again if you do a full build/replace from Unity, but an incremental build will keep these settings.

  • Mac: The plugin does not appear to be working at all for the player, but works for iOS and Android

    It could be that you have not installed the Java6 legacy runtime https://support.apple.com/kb/DL1572?locale=en_US It may also be that the plugin cannot locate Java on your machine. To patch the Java location, open the Fireproxy.bundle, cd into Contents/MacOS and run this command:

    install_name_tool -change "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/server/libjvm.dylib" << newpath >> FirebaseProxy

    where newpath is the location of libjvm.dylib under Java6.

  • Windows: The plugin does not work in the player (or you get a nullref/crash) but works for iOS and Android. Make sure you have installed the 64bit version of Java and that you've updated your PATH environment variable to include the path to jvm.dll. Note that the error you see will be something to the effect of could not locate Firebaseproxy.dll. This happens because FirebaseProxy.dll depends on jvm.dll which could not be located.

dinobattlesample's People

Contributors

kk60258 avatar

Watchers

James Cloos avatar  avatar

Forkers

ahmadnaser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.