Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
0

WordPress for Unity

A topic by myBad Studios created May 09, 2018 Views: 4,455 Replies: 31
Viewing posts 1 to 32

Hi All. 

I just published my first ( of many :D ) product on Itch.io and it's something that I am super excited about. For the past few years, in between contract jobs, I have been building up a collection of features that bring WordPress into Unity games and the other way around.

Initially I was very proud to be able to say that all my assets required 0 configuration on the server end. Just install the plugin in WordPress then get back to Unity, drag a prefab into the scene and hit play. Done and dusted. As time went on, though, not only did I start giving people server side options but I also started adding code to build their websites for them!

So at this point I can generate your game's website, let you use the website login details to log into your game, let your game use the website's database for whatever you are doing, automatically make all games cloud based and cross device synced, then let you put the game up for play on your website but require that people buy it from you directly on your website first and then I go and prevent them from pirating your game on top of all of that. Just check out the product page to see all the currently included features.

This system has come a very long way from just logging you in and saying "You are logged in. good luck with the rest of your game!" and now it is available on icho.io in a "Buy everything I've done so far and get everything I will ever do added on for free"-version. I also include a full game template with all the assets integrated already so you can see how to use them in practice, not just in theory!  :D

I hope you guys like it!

Ryunosuke

P.s. in celebration of my first product on itch.io I am giving away 10 copies of THE Dialogue Engine to the first 10 people to buy this asset. THE Dialogue Engine was the first dialogue kit to be released for Unity, released almost a year before the Asset Store was created and still going strong. It's features are way too many to even list on it's own product page so I won't even attempt to list them here :D 

https://mybadstudios.itch.io/wordpress-for-unity


Admin

This is interesting, does that put a web browser inside of a unity game that will show the wordpress website, or does it work in another way?

(2 edits)

No, this is not a web browser for Unity. This is a means of directly connecting your Unity project with the WordPress database via the WordPress API. This means that you use Unity to create your game as normal but you use WordPress as a means of identifying you for logins, store your high scores and save game content etc directly to your WordPress database.  

This essentially means that all your games become cloud games since you can start playing on your web browser at work, continue playing on your phone while on the bus and then at home you can continue on your PC. Your progress, achievements, high scores, unlocks, everything is automatically synced since everything saves to one location and everything fetches it back from there again.

You can see an example of it in action here: http://guild.site/bad-dreams 

It's a free-to-play game that showcases how this asset logs you in via WordPress, displays your actual Gravatar avatar, stores your score and a leader board, has a shop where you can unlock stuff and then save your unlocks / upgrades / stock / currency online. Also, the kit includes virtual currency and obviously that is showcased also. Kill zombies, get cash, spend the cash to upgrade your weapons, get more cash for killing more zombies more easily, upgrade some more :D

I struggled to figure out how to showcase the serials and anti-piracy stuff since using it means you simply cannot play the game if you didn't pay for it... and yet I wanted to make this game free to play. So I used the third mode of the serials kit instead. Instead of forcing you to pay in advance or after a few levels I leave the game free to play but I give you in-game advantages IF you actually went ahead and bought a serial via the WooCommerce integration I added to the kit. Yes, you CAN buy virtual currency for the game via my WooCommerce store, sure, but that's optional. Just wanted to showcase that.

Then there are the achievements you can unlock and the candy crush style "you have 5 lives. If you die it will take 30 minutes before you get another life. Come back later" timers on display as well. All of this running on a WordPress back end with a Unity front end. 

This, of course, means an entire array of options that can be set via the WordPress dashboard. Each individual part of this kit has it's own configuration tab under the WUSS main menu and allows you to do all manner of things. 

For one, it lets you see exactly what data any player has stored on your server and allows you to edit or remove it. Remember: install once and then you can run as many games as you want off of this single website. Now imagine you have 3 games and 100 players each and all their progress and unlocks etc is saved to your site. Via the dashboard you can view and edit that info per user as and when required.

On the flip side of the coin you can also save game data for other users to use in game. Examples may include chaning how many hitpoint an enemy boss requires to be defeated or how many coins you get when you unlock chest 3 or what character is unlocked when you reach spot x or where spot x is, even. Stuff like that can be edited after launching the game and all changes are live instantly and don't require the game to be downloaded again for your updates to take affect.

Another nice little feature is being able to kick or ban a user from being able to log in to the game. Just click on ban to ban and unban to unban. One click. Alternatively, set the days, hours and minutes to kick the person off the game for and their status is automatically restored when the timer runs out. 

Generate serials for physical copies sold in stores, one click. Generate serials to use with WooCommerce sales or to hand out manually, one click. Assign a serial to a user/ friend/ whoever, one click. Revoke the serial (you guessed it) one click. View all available serials per game / view all allocated serials per game / view all the games a specific user has a serial for... check, check and check.

And then of course there is the WordPress shortcodes that generate game posters, banner links to product descriptions, shows the currently logged in person's status (banned or good standing) for the game, the leaderboards (also available as a widget).  Check out the available shortcodes here: http://mybadstudios.com/wordpress-systems/wuss-portal/

Not shown there is the shortcode to display your WebGL game inside your WordPress pages / posts. To show Bad Dreams, for instance, all it takes is this [wuss_webgl name=BadDreams height=500] and that is that.

Truly, as I said a few paragraphs back, WordPress for the back end and Unity for the front end. :) The stuff listed on the product page is the features available right now but there is a heck of a lot more coming including a friends system, PM, something similar to a FB wall, an online auction house to allow users to sell/auction off rare in-game items between each other... just to mention a few.

This is what this kit is all about :)

(1 edit)

Some more control panel images





Creating a new game in WordPress...

One example of how you can present it to your site visitors...

After they clicked on one of these to get to the product page:


Pretty nifty idea!

Thanks :)

Glad you like it! :) I tend to update this quite regularly whenever I have a brainstorm moment. I'm sure there are a number of features I forgot to mention but that probably wont matter much since there will likely be new features added before I discover which ones I forgot :P 

I posted this one first as it includes everything current and future all in one so I definitely believe this to be the best value for money option but as soon as I am done with the asset I am busy working on I'll start posting the individual assets here also so people can get only the features they want and pay significantly less for them than buying absolutely everything in one go. That should allow people to ease into this system more gradually but eventually that option will turn out to cost more so yeah... Start with the best option then add the more affordable ones afterwards :)

My goal is to stop using the Unity Asset Store and sell content from my website exclusively but the one advantage they have over me is traffic. Itch.io offers me a solution to the traffic problem so I plan on releasing everything on here (assets and games) so if you are not following me yet, consider doing so cause there is a lot of content coming :)

Hello,

I'm interested on connecting a game with the WordPress database and I think that your product will be very useful for that goal. But first I need to be sure that will fit my particular needs. For that reason I have a couple of questions for you:

Is your content working with the latest version of Unity?

Your WordPress - Unity integration includes the source code?


Thank you in advance for your help!

Hi Diego

Thanks for the interest. Let me try and answer those questions for you...

1. All my assets require at least 2017.3 but it works just fine in all versions of Unity after that. Basically,  as long as you use .NET 4 (i.e. set Scripting Runtime Version to 4.x in Player Settings) then you are good to go.

2. Source code? Absolutely. I have never distributed a single DLL in all my life. Full source, always. :)

Check out the WordPress myCustom product for a free sample. It won't work unless you have the Login kit installed but at least you can see for yourself how the code is distributed. Unity code, Server code, Dashboard code... full source included for all of it. :)

Hi MyBad - I'm interested in using this approach also - I'm looking into writing a CMS that a pc unity build uses to display updatable info at a museum kiosk.  If you've already done it I'd love to try it out.  Will the unity plug-in be back in the asset store sometime soon ? or does it no longer required any kind of unitypackage ? ok thanks  :)

(2 edits)

Hi mate.

Sorry to say but myBad Studios is no longer on the Asset Store. All the assets still work as before and everything is still the same as always... the only difference being all our assets can now be found only on our website (mybadstudios.com ) and on here.

None of our assets will be released on the Asset Store ever again. Existing Asset Store customers can download updates from our website but the Asset Store and us have gone our separate ways.

As for not needing a unitypackage any more, well, the login asset has a pretty comprehensive all-in-one ready made prefab that you can just skin and use as is... or redo completely, as you see fit... but the WordPress plugin is not dependent on Unity to work. As long as you send it the right params when you call it and you have a CML parser to parse the results then these kits can in fact work on any platform. Considering I have only written a CML parser for C#6 that limits the additional platforms to .NET platforms(I'd think. Welcome to prove me wrong! :D ). Sooooo, technically, no, it doesn't NEED the unitypackage (just the WP plugin(s) and the CML parser)... but the Unity prefab(s) sure speed up getting started... :)

Thanks for reaching out. :)

@myBad, I'm interested in your Wordpress login plugin but I was curious about 2 things:

1. How come you are not going to be on the Asset Store anymore?

2. How do you compare Wordpress as a database vs Google's FireBase, Amazon Cognito, or Playfab? Wordpress seems to be an uncommon way to authenticate users but it's interesting to us because we already have a Wordpress site for content creators (our application has user generated elements). Is Wordpress database performant at millions of users?

Hia

1. Unity and I had a falling out. They screwed up, my customers paid the price, I demanded they let me serve my customers, they demanded I leave. That is the short version. Everything I've created for the past 6 years all run on MBSCore and after the latest update they accepted I realized that I accidentally slipped in two bugs that broke the kit. I tried to fix it asap but Unity simply refused. Months went by during which I contacted numerous people via numerous media numerous times but the asset store vetting team kept refusing the update without giving a reason beyond "Something is wrong with something somewhere in the asset. Find that and fix it then resubmit". Not very helpful, is it? 

When I asked about this I simply got no response from anybody via any medium any time for all the weeks of trying... I said "The core of all my assets is broken. My customers are sitting with a broken asset for weeks now. You won't tell me why you reject the fix... what am I supposed to do?". The first response I got was "We have closed your store and all your assets have been removed". 

This resulted in everybody loosing everything they ever got from me during the last 8 years (including free assets) with 0 option to download it if they don't have a local copy still and 0 chance to get an update if they have an old copy. After 7 weeks of enough complaints from enough people they finally allowed people to download the latest versions of the assets they paid for. Isn't that nice of them? Unity also took only 2 months to finally get back to me regarding my emails saying "I keep getting emails from people asking me why the assets were removed and if the assets are no longer being supported or what. There is lots of confusion out there. Can I at least update the meta data to tell existing customers they can still get updates from my site?"... They agreed and let me do so... for everything except the broken asset and the turn based battle kit.

To this very day the asset you can download on the asset store is broken and to this very day Unity has made 0 effort to tell people this and they refuse to let me fix it, instead sending me emails that read (and I quote) "We are not interested"... So yeah, a few customers have asked me to return to the store and one literally begged me for days on end to return to the store but (a) they don't want me there and (b) with that level customer service I  don't want to be there. 

For the past 8 years almost all my reviews reviewed my customer service along with my assets and I got reviews like "I don't know where he finds the time to help me as much as he did", "He delivers the best customer service I have ever received on or off the asset store" and even "His support is so good that you should buy his asset even if you don't need them"...  For the past 8 years I put m customers first to the point where I would go to bed at 2am, receive a customer support email at 2:30am and get up to go reply. Like the Japanese say: "Customer is God". Customer first always... Yet, on the asset store I uploaded a broken asset at around August/September-ish and on the very next day I noticed the bug and sent an update to them the same day! It's been almost 6 months and Unity still hasn't even bothered to tell any of my  customers not to use that asset (that is at the core of everything). Me/ It took me less than a day to have a system up and running where all existing customers could download their assets from my site without having to pay for it again... Unity "are not interested" 6 months later in telling their customers that the asset on the store is broken... 

With me placing the customer first and THEM forcing ME to give the customers bad service simply by blocking me from getting updates and bug fixes to my customers... that is not a place I want to be on. Get the products from me, get updates within seconds after I created them. Compare that with Unity's "we are not interested" attitude and yeah, I have no interest in being on there...

2. How does one technology compare to another? I honestly can't say. I haven't used the others so I don't even know how well they perform on their own, let alone compared to one another. :( 

The reason why I decided to go with WordPress was because i had created a very very, very simple login kit using vanilla php and mysqli and that asset sold like hotcakes for months... yet apart from saying "Yes, this username and password match what was stored back when the account was created" the asset didn't do anything else. By adding WordPress to the mix I was able to make use of their security features and user tracking across server contacts (i.e. I didn't have to send the username and password along with every single server contact and re-authenticate the user with every single contact) and also, thanks to the WP codebase it meant I could very easily add loads of new features very easily.

Working with WP was both fun and offered great flexibility.  I fell in love with it, simple as that :D 

As for how well it performs, well, like I said above, Unity calls WP, WP does stuff and send back a custom text response instead of generating an HTML page (using the themes and templates and all that stuff) so from Unity's end there really isn't much going on: Contact the server, wait for the reply then do something. On the WP side of things, that works like WP normally works (except it doesn't generate the HTML output) so if your question is "How well does WP perform for a busy site with millions of people?" then you need to contact the WP guys and ask them for those figures cause that sounds like something they might know... from my end, using my kits is 100% the same as making people visit your website.

  • Considering 26% of the entire internet runs on WP I would assume it doesn't do a bad job, though ;) 
  • I myself was curious about all the SQL queries WP runs and how it will affect performance so I spoke to a DBA who all but laughed in my face as he told me that mySQL can easily run hundreds of thousands of instructions at the same time so no way would I be able to create a tool that will break SQL... So, basically, subject to things like record locking, of course, it seems me thinking my kits will break the website is akin to me having an ego the size of the moon... apparently ;) :P
  • BUT, having said all of that, there is one very important thing to note! Since this works like a web page this means my kits are meant to be used passively, not for real time games. I.e. Login in now, fetch the player data a second later, submit a high score every 5 or 10 minutes, save the game data whenever he reaches a save point and click's "Yes, please save" then wait for the server to say "I'm done"... do NOT try and save player position and rotation 50 times a second. That will absolutely NOT work!!!

If you want to use the kits for use with multiplayer games like shooters or MMOs etc, the by-the-frame updates will be handled by your server application but the data itself... well... thisi s where my kits get interesting. :D MBSCore (The broken asset of the Asset Store) has a class called CML which runs everything in all my applications. CML is like XML on steroids with loads of search and filtering functions that allow you to view your CML object as an in-memory database... and i mean that in every sense of the word. Every single CML object can contain any number of "tables" if you care to go as complex as that, otherwise you could simplify your life and use one CML object for each table.

The key thing to keep in mind here is that when your player logins in, you contact the server to fetch all his data. You then keep that data in memory inside that CML file and use that single object for all your game data (achievements, inventory, game settings, position, rotation, quests, whatever you want) and whenever the player reaches a checkpoint or whenever you feel like it you just send all or parts of that data to the server to say "Track this for next time" and then don't even bother with the server result. Send the "store this" command and continue playing. Next time the player logs in after starting your app, all the data is fetched again and you use everything from there. (You don't HAVE to do it this way but I tend to do it this way as it makes sense to me to do this).

What this boils down to is that your players log in and then don't contact the server very often after that... so will millions of players that only contact the server every few minutes kill your server? I doubt that but, like i said, I am not the expert in THAT particular department. All I can do is make an educated guess based on my understanding of the kits and the DBA who laughed at me when I asked if my kits could kill the server ;) 

Hope that answers your questions :)

(1 edit)

P.s. for examples of how CML works, visit my website at https;//mybadstudios.com and visit the product page in the store. Since leaving the Asset Store I updated the site quite a lot and products now contain Tutorial and FAQ and other tabs to give people a better understanding thereof. MBSCore has quite a detailed demonstration of how CML works.

Quick recap:

  • In-memory database
  • Search and filter functions
  • Runtime strongly typed variable generation
  • When compared to a database you COULD have multiple "tables" inside a file since each one just needs a node to mark where it starts and then you just add your rows under that
  • When comparing to DB tables, CML "rows" do not need to have the same  cols for every row. Each row can be as unique as you want it to be
  • Technically speaking, each "row" could be a separate "table" if you want it to be. CML absolutely supports nested tables within nested tables up to infinity deep (or int.MaxValue, at least :P )
  • Safely access data that is not stored in the "row" without runtime errors. CML will return default values by type thus if a variable has the default value for that type you don't even have to bother saving it to the database. This applies to all supported typed: int, long, float, Rect, Vector2, Vector3, Color, Quaternion, string
  • Save anything that you can turn into a string (including base64 encoded binary files)

As you can see, quite a nifty little class to have :) See the product page for sample code to see just how insanely easy this is to use and why you will never want to use XML ever again after trying this! :D 

Sounds like you're the guy to talk to when it comes to all things Wordpress/Unity. Funny how Wordpress powers a huge amount of the internet, Unity supposedly runs over 50% of the indie games and yet the universe of folks who have a login solution for the 2 services is you. Well we're grateful and will almost definitely pick up a copy of the login system tomorrow morning. Quick question on compatibility. We're game adjacent and so we're using a variety of SDKs to manage third-party services which makes it difficult to upgrade (we're limited by each SDK providing support for the higher version of Unity). As a result we're currently stuck on 2017.2.  Is there any way you solution will support that? I noticed in your changelog something about 2017.3 being required for future updates. Does that still stand?

You can try and install it into 2017.2 but I can't guarantee Unity will play nice. The only problem you might encounter is that the prefabs will be broken. I include a demo to get you up and running but by no means are you FORCED to use it. I specifically isolated all WordPress functionality and GUI stuff from one another so that you can use any GUI system you want and create a GUI to suit your taste so, again, by no means are you being forced to use the prefab I include... but having said that, the thing is pretty darn comprehensive and even goes so far as to localize the entire login kit into 4 languages and auto detect the presense of additional assets and expose login preferences for them if found... If you have to create it from scratch you'd be losing out on a lot. Fortunately, the code will still be functional so you can easily recreate the entire thing by just dropping the scripts onto the right objects and dragging the right stuff to the right field. Easy... just very tedious and mind numbingly boring work... That is the only problem I predict might happen if you install the asset into 2017.2...

As far as the code is concerned, that will work just fine in any version of Unity that supports .NET4. So here is what happened...

I created the kits for Unity 4 and it worked perfectly fine since day 1, never requiring any fixes as new versions of Unity was released. The only reason to ever download a new version was to get access to new features. From Unity 4.... right up to 2017.2. Then came Unity 2017.3 and they broke the WWW class. Using Debug.Log you could clearly see they leave one of the mandatory headers empty but they still maintain "We didn't break it. We didn't", even though the facts are right there, staring everyone in the face... So what did this empty header mean for my kits? Simple: I can no longer contact the server. The server always returned an error because it wanted that header (the header tells it how long the header info is so since the header.length value was always blank WordPress couldn't process the request). So, yeah, no biggie... :( Sigh...

As it is, they said that the WWW class was just a wrapper around the UnityWebRequest class and eventually they want to get rid of the WWW class completely so I figured that since all my kits are now completely broken anyway, now would be a good time to change my code to work with UnityWebRequest and so I did that. At that point, though, since I was now forced to create a new version for 2017.3 and later I figured, well, since C#6 is as awesome as it is and 2017.3 supports it, why NOT update the code to require it? And so that came to pass...

Thus... the code now uses the alternate version of internet access, the version Unity prefers us to use, and thus it should work just fine in any version of Unity that has the UnityWebRequest class... BUT I made .NET4 a requirement so that is the only REAL restriction on what version of Unity you can use the CODE with. I am not sure what version of Unity they first introduced .NET4 in but I think it was 2017.1 so the code should work just fine in 2017.2

The ONLY problem here is that Unity does not allow you to install assets made in one version of Unity into another version of Unity that is older than the other one. For models and scripts etc it won't make much difference but for prefabs and materials they tend to break them completely. By completely I mean you will see the folder structure of the prefab in the hierarchy but all scripts on it will be missing and the entire thing is just.... well... broken. 

As a general rule of thumb, if you get something in, say, 2017.3.15 and you try to install it into 2017.3.0 there is a huge probability that it will work just fine... but if you get something in 2017.3.0 and try to import it into 2017.2.x the chances are huge that it will break the prefabs. :( Unfortunately the only way to know for sure is to install it and see... and if push comes to shove then I can just send you screenshots of what the prefabs should look like and you can just recreate what you see from that... that is basically the worst case scenario I can imagine...

Nothing wrong with my code... just issues with importing .unityasset files into incompatible versions of Unity

We ended up upgrading to get ready for your plugin. We have a Wordpress website that we use for folks that want to create interactive stories and a mobile app (made with Unity) for the players who want to consume these stories.  Do you know if there's any way to differentiate the registrations from the website vs your Unity plugin? Ideally I would like to sync these users a little differently.

Hmmm..... the entire point of this exercise was to make the distinction be as invisible as possible so this is not something I've ever thought about. But now that the question is raised, I DO use WordPress's own code to actually create the accounts and everything BUT I do so inside a function I created as part of the plugin. All you would have to do is just open up the unity_functions.php and find the loginRegisterAccount() (or something similar) function, read through the code till you get to the part where I have verified the login and say everything is now fine then just add this:

      update_user_meta($current_user->ID, "unity_registration", 1);

Now, inside Unity you can check to see if the account was created via the website or not by adding "unity_registration" into the meta fields array and after login just check for either:

if (results[1].Int("unity_registration") > 0) or if (results[1].Bool("unity_registration"));

On your website, though, I don't have access to any of your plugins, obviously, but since you just added a simple usermeta field during a registration made via Unity you just need to update whatever scripts you are writing to just check if that usermeta field exists and if it's 1.

if (get_user_meta($current_users->ID, "unity_registration", true) == 1) echo "WoHoo! Unity detected!";

I think that should do the trick, no?

By the way, just some food for thought... Since my dialogue engine comes with a Visual Novel prefab I have been toying with the idea of creating a Visual Novel game for my website. Thing is that the code never needs to change between one story and the other, all that has to change is the text file for the story so I would build the game once and then just add new stories over time. One of the things I wanted to do was to allow site visitors to create stories also. Since they don't need access to the binary to do so I would then just give them a web page they can access via the Dashboard and have them write the dialogue in there.

In order to get access to this page in the dashboard I would just assign them a custom role or capability on my website (most likely a capability). Using WordPress Money I could sell them Dialogue Editing capabilities right on the site and as soon as the payment clears, voila, go to the dashboard and now they have access to edit / create stories.

This may be another avenue for you to explore. Give ppl a custom role on your site and then in Unity simply tick the box to fetch back the roles during login and inspect that instead of the custom meta which you won't have to write any more. This basically moves the automation from the Unity registration function into a manual process done on the website somehow. Not sure what it is you want to sync but by using custom roles you can give authors and consumers different pages on the website without involving my kits at all. In addition you can still check the roles like before so there is that... but if a custom role is overkill for your needs then the method in the previous post should work just fine :)

At least now you have options :)

We do have custom roles on our website!  Do you know if role can be a) set on registration or is it b) set on an update?  What I can do is have website folks who register automatically be assigned "writer" and then the mobile app registration role can be set to "player". If role can be set on registration that would work wonderfully for our existing webhooks.

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. :)