[MUSIC]
>> Hello, and welcome to Lux news.
I'd like to announce today's news is,
we will be doing a Microsoft sponsored
Azure PlayFab section of the stream today
where we will be covering logging in, registering an account.
If you guys don't know what PlayFab is,
it is a platform that helps you basically set up
a game where you can have multiplayer,
use analytics, you can have in-game purchases.
We're going to be covering registering for that in a game,
and that's the news for today.
Thank you for tuning in.
Okay. Now, we can get started. Today, we're going to be using
PlayFab to register users that we can track through PlayFab.
So we're going to be starting
a project that's going to be two parts,
at least to start, which will be registration and signing in.
So we're going to make
a little login window area on the title screen.
It'll default to registration.
There's another part I want to do,
and that's to automatically sign the user in.
So we're going to default to registration,
but we're going to have a tab for signing in.
So we'll have a register, a sign in,
and then next stream we're going to be it,
and so that we'll automatically sign you in,
if it's already saved your credentials in the game.
To get started, let's make ourselves a little "UI" area here.
We're going to use an "Input,"
So use "UI" "InputFields"
and we're going to have the username, the e-mail,
the password, and then we're going to need a button.
So it'll be the login area.
Let's make it a different color.
Let's make it blue.
So here's our login area.
Let's make an empty child.
In that we'll make a panel that we'll put it all in,
and that would be our login area.
Do you guys have logins on your games?
Have you guys done this kind of thing before?
Then let's put in a thing that says a login.
Register.
Beautiful. It's good this got looking like that.
Yeah. That's fancy.
Button. Register. Let's say sign up.
Sign up, register.
Maybe register is better for games.
Sign up I feel is more like an app type wording.
It's a little tall, and
you guys wanted to see a duplicate passwords.
But what if you register to the wrong e-mail?
Well if you register the wrong e-mail
then you've got to register again.
Maybe sign up is better.
Sign up. Login. Sign up.
We don't need this text here.
We can do it, so it's in here.
Disabled one, we make it white,
so we can have a normal color here that's blue.
Eye dropper it, this one is going to be deactivated.
It can still be blue, we'll just make it more transparent.
I changed my mind, I'll make it gray.
You know what? You guys aren't going to kill me.
We're going to go like this;
sign up, and what
I'm going to do is change the color of
the button when it's active.
App Center is killing me.
Look, you guys know how to make things look nice,
I'm just making it look nice and functional, okay?
See it's beautiful, I'm going to call this InputFields.
This one should be a color or rather this one is active,
we should make it white with
dark texts to make it look like the panel here.
Here we go, we're just building a nice login field.
Look at this, beautiful.
Let's start putting in these inputs,
then we can put into the code.
So a place holder will be confirm e-mail,
and let's make this password is what we want to confirm.
Password; do we really need to confirm password?
I don't like it, I feel like it's unnecessary.
You guys, if you want to put it into yours,
you can do that, but we're not going to put it in here.
I changed my mind, keeping it simple.
This text is going to be of type or is it type password,
this one is username.
Now, you know what? Let's do e-mail.
E-mail second, and we'll set that here; e-mail,
and the top one is going to be input alphanumeric,
and I will say Username.
Beautiful. Why do you've both sign up and register?
Because I messed up real big.
Sign up, there we go. We good?
We happy with this so we continue
on to the code part? It looks good?
Okay, let's call it PlayFab sign up,
and let's make an empty called Controls.
Keep it here so we can find it easily.
Will attach this to it, and let's open
it up in Visual Studio Code.
We're going to need to get the text from this,
so let's go serialize fields text,
and if we're going to do that, we're going to need to
use, Unity is UI.
So we're going to need the username,
user e-mail, and user password.
Voila.
We will also need to be using PlayFab.
Let's put at the bottom, I like
to do it in order so I can keep track.
Put PlayFab, and using PlayFab.ClientModels.
You guys want to get those Unity extension and SDK,
there's some info there on that,
setting it up and getting yourself all good to go.
We're going to use string up to encrypt the password because you
do need to have an encrypted password for this sign up to work.
Encrypted password, wonderful.
Let's make public void register,
and this is going to be what we do when
we hit this button here, our sign-up button.
I'll keep this side-by-side.
So we need var registerRequest,
equals new RegisterPlayFabUserRequest.
Let's put in the user first,
so username equals username.text e-mail, I think it's user,
no it's just E-mail equals userEmail.texts and
Password equals Encrypt userPassword.texts.
Then we'll need PlayFabClientAPI.RegisterPlayFabUser,
registerRequest, OnregisterRequestSuccess and OnRegisterFailure.
It will do this when we're requesting it,
if it's successful, we'll do a function where it's successful,
we should capitalize that,
and if it's not successful,
we'll do one where it's fails,
and we'll tell the user why register failure.
So let's do one of these for each.
Sorry, this is what it does on its own, registerRequest,
we don't need to do anything in Unity,
if it just does its thing.
This is what it does, registerRequest,
so we don't need to detach this,
this is what would happen if it's successful,
this is what happens if it fails, and this is what it does.
So void, copy this,
and on failure will make us case this guy,
let's say here we're just going to put
in debug.log User Registered.
Here we're going to put it in debug.log User Registration Failed.
Now, the last thing we need to do is encrypt the password.
I've got this function here that we can use to do so.
So we enter the string in,
and it will encrypt it for us using MD5 Crypto Service Provider.
There's a lot of information you can get
on this for Unity, which is nice.
Do it different ways, this is also one we're going to use.
So when we put in, I spelled it wrong too,
we put it in over here,
encrypt, it will give us the encrypted password that we can use.
So I might have typed something wrong here,
let's see 14, register request.
I typed wrongly here, RegisterPlayFabUserRequest
has our errors looking.
I typed it wrong yet again over here.
I think I need to do some typing practice on the word register.
Just type it over and over.
Register, register, register.
I think that's it. Hopefully, that's all.
What else we got? Fifteen OnRegisterRequestSuccess,
OnRegisterFailure. Well, let me see.
I did this earlier to make sure I could get it working okay.
Did I miss something?
PlayFabClientAPI, of course, we need a way.
Maybe we don't need this. Before we go any further,
I want to start by making
sure we have our input coming in properly.
Sometimes I like to do
the things slow at a time because if something goes wrong,
it's harder to figure out where that is.
So let's make sure that things come in okay.
We have our userEmail.text, and unencrypted password.
We're good. So now, we can put this on the button.
So let's assign our controls
register and we're going to assign our text to the right place.
So this text here,
this text here, this text here.
When we press this button, it should spit out
the correct strings, lana,
e-mail, lana@lana.com.
So far so good. Next steps,
turn this back on and
figure out if I've done something wrong here.
Username, e-mail.
Let me look this up. Whatever I
need to do this in order, I don't think I do.
Display name, e-mail, encrypted request.
Here's the stuff we have for it.
The title ID, did I put that in?
I have that already in the PlayFab stuff.
What do I need to put it in?
PlayFabClientAPI.
RegisterPlayFabUser, registerRequest.
Let me make sure I have this setup properly.
PlayFab. So we're using "Title ID" is test.
So this is okay, this should be fine.
Do you have these here? I wonder if I need to include them, I do.
So we need to include in our success RegisterPlayFabUserResults,
and we need to include our PlayFabError if it doesn't work.
Right now, we don't have anything to log into,
but we can test it from our PlayFab login area.
So here is what it looks like when you
sign up and you make some games.
We're using our test game right here.
While I was doing versions of this,
I signed up with four different users.
Because they're linked through this,
I've made them on different machines and in different games,
and they're all going to show up here.
So if we're successful,
we should be adding a fifth user.
So let's play it and double-check that.
So username Lana, e-mail, hi@lanalux.games.
Password, I can't tell you.
"Sign-up", user registered.
Looks like we were successful, voila, five users.
So now, here it actually shows you the title overview,
who's logged in, where, it gives you analytics.
Nobody because I just did the registration.
So there's not much to see,
but we can learn more about this on
the next streams where we cover this stuff.
We have these registered users.
It all works pretty well.
Obviously, we're going to want to build into
the games and feedbacks so that when you sign up,
it says, "User successfully registered."
We're going to want to have a login area next time.
We're going to go through that on the next stream.
Does anybody have questions about this?
What fees are associated with PlayFab? That's a good question.
Basically from what I understand,
it's free up until you start doing a lot with it.
Let's look at the pricing together.
That's the part that I'm most impressed with,
is that you have all those available for free,
which is really cool.
I figured there would be a lot of costs and
a lot of technical stuff involved,
but it doesn't seem to be the case.
So you sign up for free, it's fun.
Pricing. Essentials are free.
Indie Studio wears on a comparative go, compare pricing tiers.
So if we want more,
what's the things that we can get?
Player segmentation, targeted stores, live events,
advanced analytics A/B testing,
real-time rules, scheduled tasks, dedicated support.
So that's what you'd be paying for it, a 100 bucks a month,
which is still not bad if you have an online game like this.
But you do get player profiles,
content management, in-game commerce, real-time analytics,
leaderboards, receipt validation, customer
service logic, documentation forums.
So it's quite a good starting point.
This alone is super useful.
It's pretty good, actually. Yeah, I think so too.
If you guys are interested in checking out more,
I'll be doing this again, like I said,
next month because I'm really looking
forward to getting more involved with PlayFab.
I would love to learn how to do
in-game purchases, in-game commerce.
I don't know how technical that will be.
I'm hoping not too bad,
but I think it'd be really cool.
I might actually make a mini-game as we're going through
these to test all of
the different stuff like logging in and buying stuff.
I think that'd be pretty cool.
Essentials is sufficient.
Yeah, I've covered a lot of things people would want to do.
If I remember correctly,
one of the reasons I looked at it was because it
allows you to manage an in-app currency purchasing.
It also stores some of the data elements over on
PlayFab so you could easily add new content and push it out.
I did in-game purchases for my app on Google Play.
It wasn't too difficult while following a tutorial.
I'm sure it's similar process through PlayFab.
Yes, we'll find out as we look into it further.
Features, game services, there's
some stuff I haven't even
begun to look into and I'm excited about.
Let me login. I think I'm already logged in,
but let me do it over here.
So some of the things I want to
start learning about is Multiplayer.
I haven't even enabled it.
There's so much to learn.
Groups, maybe groups could be
good for moderators or higher tier people.
Group is an entity type that gives you
the ability to create different roles for members,
invite members into the group,
and manage group membership.
I wonder if that links well with the e-commerce so you
could have paid users and free users.
Add-ons. Extend your game and reduce
SDK fatigue with Add-ons from the PlayFab marketplace.
Add-ons are tools and services from across
a gaming ecosystem fully integrated for use with PlayFab.
I want to learn about this.
I want to learn about integrating PlayFab
and Twitch to see what's available.
Here's the "Economy", "New Catalog".
So we're doing registration today.
Next time we'll be signing in and saving credentials.
I would love to learn how to set up
a catalog and start doing e-commerce next.
Leaderboards is cool too. That might be actually the next thing.
That'd be very cool to do.
Having leaderboards, that was
the first online element I was
looking to start implementing to games.
That's all about that.
Thanks guys for learning about PlayFab with me.
Next month, I will be showing the log-in process.
Now that we've got the sign-up working,
we'll be learning more about the other things in the future.
Thanks for showing. You're welcome, guys.
Thank you again for watching.
Have a good one. Now, that we have done that.
Our next thing to work on-