Firebase Database for Unity

70 views
Skip to first unread message

SIVANN KH

unread,
Aug 6, 2018, 11:02:23 AM8/6/18
to Firebase Google Group
Hello everyone!

I have already read the official doc of firebase, but I still don't understand how can I save(write) and get(read) data from firebase database. Can someone help me please...

Edward Lawrence

unread,
Aug 6, 2018, 11:34:38 AM8/6/18
to fireba...@googlegroups.com
Hey Sivann, 

What are you developing you application in? there's plenty of knowledge here but people may be able to give a more solid direction for you if we know what you are working with!

A thing I got easily confused with is making sure all my dependancies were in place within my app to sync it to the my database

Thanks :)

On Mon, Aug 6, 2018 at 3:15 PM, SIVANN KH <siva...@gmail.com> wrote:
Hello everyone!

I have already read the official doc of firebase, but I still don't understand how can I save(write) and get(read) data from firebase database. Can someone help me please...

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c7374970-f821-4017-b096-565dd84943bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards,

Edward Lawrence,
Head Receptionist,
Toni&Guy,
Promenade Level,
One Canada Square,
Canary Wharf,
London,
E14 5AX
N:0207 987 6222

@toniandguycanarywharf

Salon of the Year 2017 (Salon Genius Awards)
Front of House Team of the Year 2017 (Salon Genius Awards)
L'Oréal Colour Trophy Grand Finalist 2017
Franchisee of the Year Finalist 2016 (British Hairdressing Business Awards)
Front of House Team of the Year Finalist 2016 (British Hairdressing Business Awards)
Retail Salon of the Year Finalist 2016 (British Hairdressing Business Awards)
Junior of the Year Finalist 2016 (British Hairdressing Business Awards)
Claire Williams, Manager of the Year 2016 (Salon Genius Awards)
Retail Salon of the Year 2016 (Salon Genius Awards)
Mens Grooming Salon of The Year 2015 (Salon Business Awards)
Individual Salon of The Year 2015 (Fellowship Awards)
L'Oreal Colour Trophy Finalist 2015

SIVANN KH

unread,
Aug 6, 2018, 9:30:32 PM8/6/18
to Firebase Google Group
I use Unity to make a game, and I want to save and get data from Firebase database, help me please... ( If can explain please )


On Monday, August 6, 2018 at 10:34:38 PM UTC+7, Edward Lawrence wrote:
Hey Sivann, 

What are you developing you application in? there's plenty of knowledge here but people may be able to give a more solid direction for you if we know what you are working with!

A thing I got easily confused with is making sure all my dependancies were in place within my app to sync it to the my database

Thanks :)
On Mon, Aug 6, 2018 at 3:15 PM, SIVANN KH <siva...@gmail.com> wrote:
Hello everyone!

I have already read the official doc of firebase, but I still don't understand how can I save(write) and get(read) data from firebase database. Can someone help me please...

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/c7374970-f821-4017-b096-565dd84943bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Kind Regards,

Edward Lawrence,
Head Receptionist,
Toni&Guy,
Promenade Level,
One Canada Square,
Canary Wharf,
London,
E14 5AX

Edward Lawrence

unread,
Aug 7, 2018, 6:57:34 PM8/7/18
to fireba...@googlegroups.com
Hey, 

it depends what data you are wanting to read/write from your database, I personally don't use unity, so if you need specifics for that someone else may be able to help, but as an example of the current application I am working on a simple read/write is below, I am saving my users firstname/surname to their uid to be used in the app, which they enter on the registration form, so see below for basic usage for me: 

Register form button
AppButton {
                        id: loginbutton
                        text: registerCheckbox.checked ? "Register" : "Login"
                        flat: false
                        anchors.horizontalCenter: parent.horizontalCenter
                        onClicked: {
                            loginPage.forceActiveFocus()
                            loginbutton.visible = false
                            registerCheckbox.visible = false
                            indicator.visible = true;
                            indicator.startAnimating()

                            if(registerCheckbox.checked) {
                                firebaseAuth.registerUser(txtUsername.text, txtPassword.text);
                            } else {
                                firebaseAuth.loginUser(txtUsername.text, txtPassword.text)
                            }
                        }
                    }
FirebaseAuth
onUserRegistered: {

            indicator.stopAnimating()

            console.debug("User login " + success + " - " + message)

            if(success) {
                loginDialog.title = "Success!"
                firebaseDb.setUserValue("Firstname", firstname.text)
                firebaseDb.setUserValue("Surname", surname.text)
                firebaseDb.setUserValue("E-mail", txtUsername.text)
            } else {
                loginDialog.title = "An Issue occured!"
            }
            loginDialog.text = message
            loginbutton.visible = true
            registerCheckbox.visible = true
            loginDialog.open()
        }

Welcome Text
        Text {
                id: userName
                width: parent.width
                height: mainPage / 10
                text: "Welcome " + firstname.text + " " + surname.text
            }

Hope this helps a little!!
L!


To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Kind Regards,

Edward Lawrence,
Head Receptionist,
Toni&Guy,
Promenade Level,
One Canada Square,
Canary Wharf,
London,
E14 5AX

Anthony Maurice

unread,
Aug 7, 2018, 7:16:17 PM8/7/18
to Firebase Google Group
Hi Sivann,

I'd recommend taking a look at our sample project for Firebase Database, https://github.com/firebase/quickstart-unity/tree/master/database/testapp
In it, specifically in https://github.com/firebase/quickstart-unity/blob/master/database/testapp/Assets/TestApp/UIHandler.cs, it uses transactions, via DatabaseReference.RunTransaction to write scores to a database, and uses the DatabaseReference.ValueChanged callback to read from the database.

Also, be sure to check out the getting started guide, which covers how to get the project set up, along with some of the different ways you can read/write to the database, https://firebase.google.com/docs/database/unity/start

SIVANN KH

unread,
Aug 8, 2018, 10:42:41 AM8/8/18
to fireba...@googlegroups.com
Thanks for you all's reply. But I want to know the trick. Ex. I want to save my coin to 'Coin' tag in firebase (any user just save to there ). And I want to get that data back. How I do ? Can Ex. for me 1, but don't ex. user account.

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

Anthony Maurice

unread,
Aug 8, 2018, 8:27:55 PM8/8/18
to fireba...@googlegroups.com
So, to write, it would be something like:
Firebase.Database.FirebaseDatabase.DefaultInstance.GetReference("Coin").SetValueAsync(coin);

To read:
Firebase.Database.FirebaseDatabase.DefaultInstance.GetReference("Coin").GetValueAsync().ContinueWith(task => {
  long coin = task.Result.Value;
});

This skips some of the error handling and such, but as a simple example those are the two calls you would want.  Note that both return Tasks, https://msdn.microsoft.com/en-us/library/system.threading.tasks.task(v=vs.110).aspx, as they are asynchronous operations that can take some time to resolve.

Reply all
Reply to author
Forward
0 new messages