Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
0

WordPress for Unity

A topic by myBad Studios created May 09, 2018 Views: 4,136 Replies: 31
Viewing posts 21 to 32 of 32 · Previous page · First page

One last question: We currently allow players to login to our mobile app using Facebook. Is it possible to route that flow through your plugin as well?

In the dashboard there is a setting asking you what the default role of new accounts should be. Just select it from the drop down list. Problem is that both website and Unity signups will be assigned the same role. As I explained above about setting that usermeta entry,  find that same place in the function (basically, just before returning success) and instead of writing that entry to usermeta change the user's role instead. If you need help with the code, just send me an email and I'll send it to you. Should only be about 2 lines of code. 1 to add the new role and one to remove the previous role. 

Actually, I don't know how the heck this works but for some reason WordPress actually lets you have multiple roles... When you query the user's roles it gets returned as an array :O Weird... Anyway, yeah, sould only be 2 lines of code so let me know if you struggle with that and I'll help you out :)

Facebook and my plugins is not an option, though, no. Sorry. Unity's internet access is super primitive: Send a URL, get a response. The end. Even if you just go to a url like http://mysite.com and your site then redirects you to http://www.mysite.com via a 301 redirect Unity will throw an error! Status 201 means "Everything is awesome after the redirect", Unity sees that as an error. Unity's web access is super simplistic: Call a URL, get back a page with a 200 status OR ELSE(!!!!!)

Thus, any type of AOUTH login that requires multiple calls to pages that send messages between servers before finally sending back a "Okay, all is good now, eventually"... yeah, I have no clue how to get that to work, unfortunately. I am thinking that will require writing an entirely separate system using non-Unity classes (maybe using sockets via some .NET native classs ??? I don't know). So, no, sorry, Facebook, Google, Twitter etc... all those OAUTH login systems are not supported by my kits. :(

(1 edit)

Sidenote... If you use Facebook's free native plugin for Unity to authenticate the person's login... well since I wasn't able to do the Facebook login thing myself and people kept asking about it I added an extra option to my kit where, if you are CERTAIN that a user is who he says he is then you can simply replace my call to AttemptToLogin() with DoTrustedLogin() and pass along the user's email address. My kit will then allow you to log that person in without a password. Thus, as long as the email address in his WordPress account matches the email in his Facebook account then you can log them in via the Facebook native plugin , get the user's email address from FaceBook directly and then pass that email to my function to leg them in that way.

Of course, by the same token, you can log them in via Facebook and then, if they don't yet HAVE an account on your site simply auto complete the email address from the FaceBook asset and submit a registration from my kit like normal. Thus also ensuring the email address matches :) 

Slightly more roundabout than I would like but at least this way you are using Facebook's own code and you are sure it will always be up to date and work as Facebook intended for it to work AND you get the added benefit of my kit no longer needed the login page / password to be entered.  Only problem here is that if they ever change their email address then they will need to make sure they update it in both places in order for FB login to succeed...

Hope that helps. :)

(1 edit)

Appreciate all the time you've spent on this! Your detail is great for us to understand the different ways we can authenticate. Does your plugin allow for an easy way of checking if a username is unique or email is unique? I am designing a registration flow right now that is asking for 1 field per page because mobile is tough to have a giant form. I'm asking for username on screen 1, email on screen 2, then password on the last screen before submission. I would ideally like to check the uniqueness of username on screen 1 and uniqueness of email on screen 2 (instead of on full registration) so that we don't send users backwards in the flow.  Is that something that's easy to check in your plugin?

Unfortunately that is something you will need to add as a custom feature. I don't check that at all. My kit has a hand full of error messages (like checking if an email address is validly formatted or that the password matches the verification) but apart from that it only relays any errors that WordPress or your site sends back. In the case of username and email, that is part of the registration process and I just say: "Do registration(); If there is a problem, send back what it was". WordPress determines if anything is wrong with the supplied info and if not I just relay to you what it said.

WordPress does have functions that you can use for stuff like that but I didn't implement any functions check for that, sorry. 

I tried dragging the zip file to my wordpress plugins but I received this error: https://screencast.com/t/jVxdLi6DPO

Then I tried to unzip the file downloaded (WULogin.zip_bd146.zip) and I noticed for a split second I saw WULogin.unityasset but then it disappeared from my computer and I can't find it via Spotlight. Unzipping generates a giant list of folders: https://screencast.com/t/Fbbmb4m4y

Any ideas how to both upload the plugin to Wordpress and find the assetpackage to install on Unity? I tried submitting this question via your website but for some reason it wasn't taking the invoice number.

(1 edit)

So sorry for the inconvenience, mate!

That thing you are getting with the huge list of folders is actually something I have encountered myself on a number of occasions and caused a lot of head scratching to be sure. That was super common for the longest time then it just stopped. You are officially the second person I know of in the last couple of years that this has happened to... and you won't BELIEVE what the problem is.... Are you ready for this? Unzip the file with some other app. Tadaa.... THAT is actually the problem, believe it or not! :O

Once extracted you should have the .unitypackage file and that is that. Install that into your Unity project and inside your project you will find a VERY small zip file that you then install on your website. The file is called wuss_login.zip. Once that is installed and activated you are good to go.

Of all the things you could possibly expect to go wrong, which unzipping tool you use... I know that was the last thing on my mind back when this happened to me, but...that is all it will take to get rid of your headaches :O Who would have thunk it!? :O

(1 edit)

Hello!

I recently incorporated your plugin into my Unity game. The WPServer object sees the game I created in my Wordpress plugin (i.e. it lists the game's name in the `Select Game` dropdown). 

Here is my simplified code:

CMLData loginCredentials = new CMLData();
loginCredentials.Set("username", "someUsername");
loginCredentials.Set("password", "superSecretPassword");
WULogin.AttemptToLogin(loginCredentials);

When I call this code, I get the following error:

WPServer Error: No Data Returned from Server

I've tried this with valid username/password pairs, invalid usernames, and valid usernames with invalid passwords. I get the same response for all combinations. 

I notice that I am able to get the same error when I hit the `Refresh Games List` button within the WPServer. The WPServer Select Game dropdown will then show `No Games Found` until I run my game in Unity. After playing and then stopping my game, my games shows back up in the dropdown menu.


Any idea what's going on? I checked the php scripts in Wordpress, and they appear to have the correct permissions. I have not made any changes or customizations to them.


  • Unity Version: 2018.1.9f2
  • Wordpress Version: 5.1.1
(1 edit)

Hi Alex

check your inbox for the longest email you have ever received in your life. I do love to type and it takes great restraint to keep my emails short... but I do try ever so hard ;) :P

You said "I posted on itch also but was told you might prefer email". Well you were right about that... but I was going "He posted something on itch? Really? Then why didn't itch let me know?" and just as I was finishing off your record breaking email I finally got the notification that you posted on here! :D

As you may have noticed above, I don't mind posting on here and I don't bother to skimp on details [read: write a lot] but via email it just makes life easier for me and I can include files etc if needed and we can share personal info you may not want public (like your game's URL or security string or whatever)  so I prefer to answer pre-sales questions in here but offer customer support via email directly. Either will do but email is simply preferred.

With that said, the support email is already in your inbox and by now you may have already solved the issue so all that is left to say is: If you have any other questions, feel free to email me and ask away! :D

(9 edits)

Hi myBad Studios,


I am very impressed with your work done here. I would like to get your vision from the expertise in the area on my idea that i am trying to achieve. I am really novice in making a game..and unity..

I am using WP latest version and doing LMS (learning management system), am interested to build a 2D isometric map based backgroun game (i.g. https://prnt.sc/n9j0fc)  for the learning. 

I wish to make it like when user hits each station on the map, a quiz or set of questions or task(s) pre-created from wordpress LMS pop up for user to complete and then user can continue the journey of the learning and wordpress somehow captures the record of the user like which stage and score of the task, etc and display in the user dashboard in WP LMS

This is the hypothetical idea. so...do you see your plugin will somehow play the role to enable this idea? if not, do you have any other recommendation/suggestion to enable this idea? 

Please share some light here. 

Thank you

(2 edits)

Hi Rohan

What you are asking for is indeed very little so this kit can definitely handle this, for sure... but if that is ALL you need then this kit may be a bit overkill for you. Contact me directly and I will sell you the login and data parts separately. That'll set you back $80 rather than $200.

The login part of this kit will manage everything to do with knowing who the current player is. Since you now know who the player i (stored in the background) you can now update this player's data (player id sent along automatically in the background). And job done...

Say the player completes the level and you now want to store the score online. All you need is the following function and then you can just call it once the score is calculated:

void SendScore(int level, int score) { 
    CMLData data = new CMLData();
    data.Seti("Level_"+ level, score);
    WUData.UpdateCategory("Scores", data);
}

That's it. Your score for that level is now stored online. Of course, this will overwrite the current value even if it is higher than the last score so you will have to test if the current score is higher before you call that function but , yeah, that is how easy it is. 

To fetch back the player's progress/scores you can either fetch it back one at a time or all at once. All at once seems a better choice. Do it right after the player has logged in and now you know exactly where the player is at and you have all the player's scores ready to test later for new high scores. You would do it like this:

CMLData Scores = null;
void StoreScores(CML response) => Scores = response[1];
void GetScores(CML ignore) => WUData.FetchCategory("Scores", StoreScores);
void Start() => WULogin.onLoggedIn += GetScores;

And that is that. Now you can see how many levels the player has completed by checking: Scores.Keys.Length;
And if you want the score for level 3 (I assume you will name your levels 0,1,2.etc... and not 1,2,3... so level 3 will have been saved as "Level_2") you just do this: 

int current_score = Scores.Int("Level_"+2);

Job done :) 

So as you can see that part is really really easy... The only part of what you want to do that is NOT handled out of the box is showing the player's score/progress on the website. That data is available for admins to see inside the dashboard but it is not visible to players at all. That will require some custom coding and will depend entirely on how you want to display your data.

As you can imagine, the number of ways that you can display data on a website is limited only by the number of ideas you can have in your lifetime... as such I can't give you a one-case-suits-all function to do that but once you know how you want to show your data on your website you can fetch it back super easily. When it's all said and done, it's just data in a table and data that is keyed in a way to make it easy to get to it...  so if you don't know how or don't have someone on your team that can write SQL code / WordPress plugins, just let me know and I'll see how I can help. :)

Viewing posts 21 to 32 of 32 · Previous page · First page