Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Use Wordpress as your game's database

Discussion in 'Assets and Asset Store' started by MrDude, Feb 17, 2014.

?

If I were to build the kits in order of preference, which kit would you like first?

  1. Friends system: Invite friends and see what they are playing. Include PM and chat services

    45.0%
  2. Online privacy: Protect your info select exactly who can see what

    17.5%
  3. Message boards system: Categories for author, clan leaders, groups personal

    20.0%
  4. Online market place: Trade with NPCs or real players. Includes gifting service

    37.5%
  5. Custom character system: Create a character in one game and take him into other games

    21.3%
  6. 2D narrative game template: Write a story, build a game in a day...

    13.8%
  7. Clan system: Access your friends arsenal during your own battles

    8.8%
  8. Wordpress Games portal: Display available games, sell them and show stats (ratings/reviews)

    23.8%
  9. Other: Please specify...

    5.0%
Multiple votes are allowed.
  1. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Oh, by the way, the packages have been updated so you can download the new ones from the asset store.
    Make sure to uninstall the WULogin kit on the website and install that from the new plugin in the kit. Then do the same for the WUData kit.

    Up till now, each kit has had a duplicate version of the settings and what not but as of now the WUData uses the WULogin kit's files and gets rid of the duplicate code. I implemented the 'name' fix inside the WULogin settings file so make sure to update both plugins and you are good to go.
     
  2. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    224
    Updated unity packages and also uninstalled then reinstalled WordPress files - but still get "404..." error. :( It could be that I missed something on my end, but I'm pretty sure I did it all correctly (you've kept it so simple, my mom could do it) :). I think I just need to re-update everything again. Will keep you posted.

    Also, I posted a couple great reviews for ya! :)
     
  3. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi dan

    Remember, after downloading the new packages off the asset store you need to remove the plugins from the website and install new new zip files! But just downloading and installing the kit on your wnd won't actually update the files sonce the files are already in the project so unity will just skip it, most likely. This is why I recommend downloading the new kits from the asset store and installing them into a new project. Just to make sure you get the new zip files for the website. After you have installed thise zips you can delete that new project and your original project will work just fine and no longer show that 404 thing, no code changes required. In fact, that is actually a good test to see if you HAVE the latest plugin installed :)
     
  4. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    P.s. Did you remember to set your build settings to desktop also?
     
  5. danreid70

    danreid70

    Joined:
    Aug 28, 2010
    Posts:
    224
    MrDude (coolest name on here, by the way!) - I do have my build set for PC (desktop), not web player. I did re-download latest update and used the new zip files for WordPress plugins. Uninstalled both first, then reinstalled them. I wonder if somehow I'm still getting older version in cache somehow... Let me send you my wordpress test site to see if you can connect and if you also get 404 error - then I'll know for sure it's my wordpress side. I'll pm it to you. Keep in mind, my site is "just for fun", just starting it to see what I can do with it, and try to impress my son and his merry band of leet-xbox-gamers... Lol
     
    Last edited: May 22, 2014
  6. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Right.... so today I have some big news for you all :)

    All kits have been updated so you are free to download them all again. The changes are only on the Wordpress end, though, so be aware.

    MULTISITE SUPPORT
    Firstly, thanks to Dan's struggles I was forced to address an issue I wanted to address at some later stage. Multisites. I had never used multisites before and had no idea wether or not my kits were multisite compatible. Turns out.... they were not. Notice my careful use of the word 'were' . :D That's right, people, as of right now the kits are compatible with multisites also! :D

    Just to clarify, these plugins are for Unity, not Wordpress and as such they don't work in exactly the same way as normal Wordpress plugins... Multisite support is yet another example of this. The way multisites traditionally work is that you install duplicate tables for each plugin on for every site. This means that each site will have it's separate and distinct data. This is not how these kits were intended to be used. They were intended, from the beginning, to be installed once and to be used by all future projects you make and to make the data available to all your products if you wanted it to be.

    To this end, instead of creating duplicate tables for each site in the multisite, when I detect you are running a normal WP website I prefix the kit's tables with your given prefix to make it fit better with the rest of your site... but when it is a mutisite, I omit the prefix (since it will be prefixed to match only ONE of your sites only) and thus leave it "global", so to speak, for all your sites (and Unity) to access. This also means that you cannot install it on each site separately nor remove it from individual sites.In fact it doesn't even show up in your site dashboards. To install or remove it you need to do so from the global dashboard.

    Slight differences there but the installation process is still the same as before. If you have a normal website, install as normal using the included instructions. If you have a multisite website, do exactly the same thing but from your global dashboard instead of your site-specific dashboard.

    OPTIMIZATIONS
    On a less impressive note, but still just as big a deal for the code junkies among you, I have updated all the kits by removing all duplicate scripts from all of them and forcing all of them to fetch shared code from the WULogin kit. Now more than ever, make sure to install the WULogin kit first. This makes the code much more modular in that all the scripts do what they do based off of one single shared resource and means that each new kit can contain a lot less code and still do their job, making it a lot easier for the code junkies out there to learn how these kits work.

    3RD PARTY COMPATIBILITY
    Third bit of news was that I was also forced to address a second issue I was planning on looking at at some point. Other people's plugins. As you may well be aware, there are more than just a hand full of Wordpress plugins floating around that little black box we call "The Internet". Back when I first started work on this kit I had the WPE-Commerce plugin installed and ran into a big problem... Their code simply assumed that the header was still available to write to so they just... wrote to it. Unfortunately, my kit had already run at that point and had already written data out so that means the header was no longer available and when their code ran, it caused my kit to bomb out because it was now receiving unexpected (and non properly formatted) data.

    I tried to work around this issue and when I contacted them about this issue they managed to fix their plugin by simply adding one line of code to their kit to first test the header availability before writing. Problem solved. Excellent! ...but the fact remained, other kits might do the same thing and at some point this error might arise again. Now, my workaround worked... but it required a lot of work to implement and what I had to do I guarantee you none of you would want to do simply BECAUSE of how much work it was... and you would have to manually do that for every kit that makes incorrect assumptions and do not do proper error checking to verify their assumptions...

    So what to do? How could I make sure that no other kit in the world simply make incorrect assumptions and write code that will break my kit? the good news is, I managed to do just that. I simply looked at what the very last filter is that WP executes and I moved execution of my code to there. This means that anything that needed to write to the header would have run it's course well before my stuff runs and thus, any conflicts are now well and truly avoided. All on the automatic so no work involved on your end. :D

    FREE PRODUCT
    Yeah, you read that right...! :D

    At some point I might get around to creating the art work for this and uploading this to the Asset Store but for now I am just making it available for direct download. Someone contacted me a few days ago and asked if I could make a kit that would integrate with the myCreds Wordpress plugin. At the time I had never heard of the kit and thought this would be a heavy strain on my time but when he explained that all he wanted was the ability to fetch the current balance and the ability to modify it, I thought to myself "That seems simple enough" so I downloaded the plugin, had a look through it and found the two functions required to do just that and built a quick interface to call them... voila. Instant compatibility! :D

    Obviously this kit does not integrate with all the plugin can do since that was not the request, but it does the key things: Fetch the balance and update it... It was such a simple little plugin to write... (like an hour or two for the php and 3 to 4 hours for the Unity end including testing, debugging and fixes)... I decided to give it to him for free... Make a happy customer a very happy customer! :) :p

    I am now also sharing it on here so anyone who does happen to use the myCreds plugin (Website link: http://codex.mycred.me) can download it and use it also :D All I ask is that you say "Thanks" if you find it useful so I know it is actually being used by someone. :D

    Apart from that, enjoy :D
    View attachment $WUMyCreds..zip

    USAGE INSTRUCTIONS...
    As always, this kit requires no configuration apart from the URL to your website. Simply drag the server prefab into a scene and you are good to go. From your own scripts, just call one of the overloaded versions of the two functions in the kit and you are done. That's it... two functions to learn. Drop the prefab in the scene and call one of two functions on it.

    Included is the demo scene that took most of the time in making this kit :p lol. This demo project is nothing more than a fancy gui interface to collect the data from the player before doing the actual hard work of calling those two functions.... You should have no problems learning this kit.
     
  7. IndieScapeGames

    IndieScapeGames

    Joined:
    Jul 3, 2012
    Posts:
    76
    This, MrDude, is amazing! :mrgreen: Will buy ASAP. I use WordPress extensively and have always wanted to do something like this but lack your epic skills!
     
  8. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I am glad to hear I have made your day, ChadM :)

    Keep your eyes peeled for more releases in future... :) I am currently busy working with the myCred plugin author and will soon be placing it on the Asset Store also. With this newly formed collaboration I might actually turn this "simple" integration into something with a bit more meat on it's bones but it will still be available for free if and when I do.

    There is so much more I want to do it's just not funny... One of the things I want to do is build a basic networking kit for the game also. Since Wordpress is NOT a realtime engine (lol) I won't be sending and data through it but I would like to turn it into a MasterServer replacement so it can track who is online and who is not and what games are active and which is not but there are a few logistical problems with this approach I need to figure out first. The key one being "Why would anyone want to use my networking component when they can get Photon Cloud instead?"... hmmm....

    The only real benefit is that there is no money to be paid for how many players you have playing your game... The down side being that a player is the host so you are severely limited in the amount of players that can play the game together... So if you want 10,000 players playing your game it will cost you $0.00 but only (let's say) 10 can play on the same map... If you want to create an MMO, you have no chance. For that you would need Photon cloud and pay something like $500 p/month for 10,000 concurrent players.

    I personally LOVE Photon Cloud. I think it's the best thing since sliced bread... but the thought of creating a Free To Play game and having 500,000 downloads in 3 months and having 500,000 players playing for free and none of them HAVING to spend money but I need to spend $2,000 a month to allow them to play... that scares me to death... Free games download like crazy. Money doesn't flow that freely and having to pay in advance and hoping to get some money coming in.... super scary. So, as much as I love Photon Cloud I would only ever consider using it for a production game after I have tested the waters with Unity's RakNet. Will people agree with me and spend $20 to $30 on my networking implementation? Who knows...

    But yeah, lots more planned. Be sure to vote for your favorite feature in the poll, yes? And don't be afraid to request more features in here. Always looking for feedback so post and be heard! :p
     
  9. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Oh yeah, I forgot to mention... I did add this to the change log but not the documentation so not sure if you noticed this or not but I actually added a class to the WULogin package and attached it to the WULogin prefab.

    It is called WULProfileImg and automatically contacts the server upon successful login to fetch the logged in player's profile image. It then stores it in the static WULProfileImg.ProfileImage field. As such, there is no work involved on your end to get the user's profile image. Just do
    Code (csharp):
    1. if (WULProfileImg.ProfileImage) GUI.DrawTexture(avatar_area, WULProfileImg.ProfileImage);
    ...that simple.

    Just wanted to highlight that in case any of you missed it. :)
     
  10. IndieScapeGames

    IndieScapeGames

    Joined:
    Jul 3, 2012
    Posts:
    76
    I wants please!
     
  11. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569


    Hi all! So the official myCred plugin just went live...! http://u3d.as/content/my-bad-studios/wordpress-user-creds/83R?aid=1101lGrs

    This is the plugin that prompted the complete rebranding of the WUSS series of products! Allow me to explain what this plugin does for you:

    myCreds is a FREE plugin for Wordpress available from http://mycred.me that allows you to reward your customers for interacting with your website. There is already a whole bunch of support for the myCreds plugin including:
    • the ability to integrate with WooCommerce to allow your customers to buy items using their myCreds balance.
    • Award or deduct points for users submitting comments via Disqus
    • Award or deduct points for users submitting Gravity forms
    • Buying myCreds points for cash via PayFast and Stripe
    • allows you to setup coupons that your users can redeem in order to gain points
    • Notifications
    • allows you to setup recurring point payouts or charge / offer interest on your users point balances
    • Email notices, BuddyPress integration, CSV imports, Vimeo, sms payments, lotteries...
    • and so the list goes on...
    myCreds allows you to reward your site visitors for interacting with your site and even to buy items using their virtual currency or buying virtual currency for real money... and myCreds is available for download for FREE.

    Enter WUCreds, my Unity package for integrating with myCreds. Take into account all the great things myCreds can do for your website and then add WUCreds to the mix... WUCreds gives you access to the logged in user's myCreds balance and allows you to modify it right inside Unity!

    Now you can offer your customer the opportunity to buy in-game content using a currency they earn (or buy) on your website. Give them Creds for completing a level, charge them Creds to unlock a dungeon. Don't have creds? No problem! Go tell your friends about the website and earn points for the referrals! The potential is staggering!

    By having myCreds installed on your Wordpress website you have a virtual currency linked to an actual payment solution and now you can access and modify that balance from right within your Unity project!

    And now for the best part... WUCreds is live on the Asset Store right now and is completely FREE for all customers who have the WULogin kit! So go ahead, download it now and enjoy the power this plugin gives you via only two simple functions that you need to learn...

    The kit includes a demo scene to demonstrate the use of those two functions. Note that the prefab in the scene is just to demonstrate the use and not for actual use. To use you need only call one of two functions to either get a balance or to update a balance... visual prefabs are not required!

    Enjoy
     
    Last edited: Apr 13, 2017
  12. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Attention all myCred users!

    The WUMyCred plugin has just been updated to version 2 and is a beast of an upgrade!

    The kit has been completely redone and now supports multiple cred-currencies. This has brought about a number of changes to how the kit works an it is no longer compatible with the first version of the kit. Please be aware of this… then look at the great new features this kit provides!

    In version 1, the kit only allowed you to fetch a balance and update that balance but it was up to you to create your own local variables to store anything you did. When contacting the server, the responses were neatly formatted as CML but it was still up to you to extract the data and save it to your local variables.

    This is no longer the case. Starting with WuMyCred v2.0, when you fetch the balances of a user, the currency’s type (i.e. points, gold, credits etc) is stored, along with it’s balance, inside a public array you can access at any time. Not only that, I now also provide you with a native array index so you can easily select a currency to deal with and not have to worry about keeping track of your selection manually. In fact, I go even one step further and abstract the array access from you by means of the ActiveCred property. Just call ActiveCred to fetch the currency’s type and balance and forget about where the data is being stored and how!

    Furthermore, I now do the data parsing for you, freeing you from having to decode the data the server sends you. You just call the function and reap the rewards when the data reaches your app. I still leave the callbacks in place for you so you can still trigger your own code to happen at the appropriate time and I stil pass the server’s response to your functions should you want it, but as of version 2.0 you are free to use the callbacks for menial things like showing or hiding windows… I do the rest of the heavy lifting for you…

    Get the update now! As always, Free on the asset store https://www.assetstore.unity3d.com/en/#!/content/18520?aid=1101lGrs.

    If you do not yet have myCred running on your website, check it out here: http://mycred.me.
    myCred is your one stop solution for currencies in your game. Give your site visitors points for visiting your site, promoting your site virally or even sell them points for real cash! there is so much you can do with myCred… then come back to Unity and spend all those lovely points inside your games!

    Check it out now!
     
    Last edited: Apr 13, 2017
  13. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Just released an update to the WULogin kit today

    The profile image script that fetches the logged in user's gravatar image upon successful login now has a drop down field from where you can select the type of gravatar image to download in case the user's email address is not registered on GRavatar.com.

    No longer are you forced to use the default Gravatar image. You are now presented with choice... in the form of a drop down box no less... :p

    Enjoy
    g.jpg
     
  14. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Just released a minor update to the WUSS kits today.

    Up till now you had to tell the WUServer what your website URL is and tell it wether you are working with live or local data. You then had to duplicate those fields in each of the other packages. I have now removed that requirement so as of now, all the other kits will automatically retrieve your website URL and online status from the WUServer.

    Enjoy :)
     
    Last edited: Sep 3, 2014
  15. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,281
    Thank you for the update.
    Are the other packages that you told us about and ask us to tell you what we like first still in development?
     
  16. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi Rand. Yes, they are. I am currently toggling working on updating the Turn Based Battle system and working on this but things are definitely progressing on this front. (In fact, I've wanted to do this update for a while now but this latest project of mine has forced me to work with all these kits in one project and now that I am doing that I noticed how annoying it is so I decided to stop procrastinating and get it done before I do anything else)

    The "make a game in a day" kit is almost done now. Instead of just giving you the package and trying to explain how this thing works in words, I am actually busy creating a whole game using this. I am now going to integrate myCreds as a payment method then I need to create my game's shop and then this thing is done! Then I just need a hell of a lot of 2D graphics and since I have no Photoshop skills to speak of, that is going to prove to be a tough one :p lol

    But yeah, I am making a game that I will be putting up on my website that shows you what you can do when you combine the WULogin, WUData, WUTimers, WUCreds and WUNarrative into one! He he! :D ...unfortunately, though, WUNarrative is built for uGUI so I cant release that until 4.6 comes out of beta. Rules are rules, unfortunately...

    The WUNarrative will require all those kits and use some of them as intended while manipulating their data on the server end in other places to avoid players cheating and what not but yeah... It will require that those kits be installed first, then it will behave as a game template requiring you to drag in the prefabs where required and you are done. Almost all of the work in this kit is done in Wordpress which means that once the game is published you can update it as you see fit without having to release a new build of the game. Of course it wold be wise to include the graphics in the binary instead of requiring that it be downloaded all the time so an occasional new build would be ideal... but not required.

    First I want to get it up and running on my site to show it works, then i'll do what I need to do to make it more "modular" or "moddable" or "customisable" or whatever... It might seem easy but there is a lot to take into account here...

    I've also started on a multiplayer module that I don't want to go too deeply into as I'm not sure what's gonna happen with that one. I've already come a long way with the friends and invite systems and spending a great deal of time on the Wordpress settings pages to manage your project settings from there and to emulate the Unity functionality on there also... So yes, lots of work going on in that department... :)
     
    Last edited: Sep 4, 2014
  17. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Just to wet your appetite, here is a screenshot from one of the config panels in the game portal kit... WUSSwp1.jpg
     
    BackwoodsGaming and princeWIGUAN like this.
  18. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I need to get some feedback from you today.

    I am preparing to release the Wordpress for Unity Starter Kit Edition of these kits which is simply all of these kits combined into one kit. There are a few things to note though. Firstly, the standalone kits and the Starter Kit cannot be used together so while it is convenient to install and all files are stored in one location in Wordpress, it does mean that new kits will either need to be modified and included into the Starter Kit edition or you won't be able to use it at all. (Well, that is not entirely true. It will just require a few very minor tweaks to the code just to get the paths right)

    This option is really only good for people who want a one stop solution for all the current kits. Probably the biggest advantage here is that you need only install one plugin on Wordpress and install one kit into Unity and everything is ready to go.

    This Starter Kit Edition, however, sees me implement a feature I have wanted to do for a long time now but I am not sure if you would welcome this feature or not. At the moment, all kits get the website url from WULogin and removes the need for you to manually specify the same url in every kit. The same is true with wether you are using the localhost or online version of your database... but not for the game id.

    The game id value is what keeps your one game's data separate from the next. It would make a lot of sense to just set the game's id in one place and have all kits fetch the value from there and this is what I do with the Starter Kit edition. However.... there is one minor little catch... the scoring kit has a bug that i like as a feature so I never changed it and actually promoted it.

    As I said, the game id value keeps your game's data distinct from one another so if you want to have 5 different leadeboards you can simply change the game id value each time before you submit a score or fetch the scores and that is that. Multiple scoreboards in one project. If I do this thing where I fetch the game id for all kits from a central location then this feature will fall away.

    So the question now arises: What would you like?
    A) In every project you do, for every kit you install manually specify the same game id ?
    B) Have me automate the process so you need only set the value once and be done with it, but then you can only have one leaderboard per game?
     
  19. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,281
    For me one leaderboard is enough.

    I have thought about these cred possebilities but here in germany cred is mainly unknown.
     
  20. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    WULogin kit updated. Other kits to follow

    v1.3
    This update requires that the WULogin plugin on the website be replaced with this version

    Now allows you to specify what fields to return upon login and also allows you to fetch any piece of info from the usermeta table. Need to know the user's role on the website? Done. Want his email address? Date registered? Some other field saved from within another package? Done. Simply tick the boxes in the inspector and write the names of the additional fields as a comma separated list in the inspector and you are done.

    All the info returned during login is stored in a publicly accessible cmlData variable called fetched_info. No need to set this manually in the GUI script like before. In the previous version only displayname and nickname were stored explicitly. Now, all data is stored in fetched_info and accessed via properties and includes email, website url, registration date and their WP user ID. All meta info can be fetched using normal CML routines. I.e. fetched_info.String("first_name");

    The logged_in variable is now set automatically upon login and logout so you no longer need to do this manually in the GUI script either.

    WULogin now contains a Static WULogin.GameID field that other kits can use to make sure all WU kits use the same game ID. As mentioned in my previous post, I want to update all the other kits to automatically fetch the GameID value instead of requiring you to manually set it for each package you installed. This will now be the GameID field for all those updated packages.

    WUServer now contains a public function to generate the WWW request. All other WU kits will be updated to use this function to contact the server.

    Fixed the bug where logging in without first logging out caused the previous login's cookie to be used. This is only really possible in the editor but rather safe than sorry.

    Updated WULProfileImage to only fetch personal info if the email was not requested during login, thereby saving one extra round trip to the server
     
    Last edited: Oct 16, 2014
  21. pushingpandas

    pushingpandas

    Joined:
    Jan 12, 2013
    Posts:
    1,405
    This is awesome!
     
  22. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Thanks very much :)

    All the other kits have now been updated also. All kits now derive their GameIDs from WULogin and use WULogin to create their connection to the WWW.

    WUScoreboards, though, is a bit of an exception. All these kits work on the principle that you install the kit once and then you can use it in all your future games. Now I can safely guarantee that all kits will share the same game id so when the portal kit is finally available all related data can be found without worrying about what belongs with what... BUT, although not initially intended to work this way, the scoreboards kit did allow you to have multiple scoreboards per game just by using different ids for each. Now that I force the gameid it means each game can only have 1 scoreboard.

    To combat this restriction I have modified the kit to only fetch the game id from WULogin if you do not manually specify a game id to use however, I did not modify the SubmitScore or FetchScores functions to allow you to specify custom ids so that is something you will still need to do yourself if this is something you require... Just say
    Code (csharp):
    1. cmlData myData = new cmlData();
    2. myData.Set("gid",myCustomID);
    3.  
    ...and then pass myData as the optional parameter. Done.

    ...but yeah, all kits are now updated. Enjoy
     
  23. rayfigs

    rayfigs

    Joined:
    Feb 8, 2009
    Posts:
    41
    Hi MrDude,

    I just picked up all of the plugins, very nice stuff :)

    I was curious if setting up accounts with social media single sign on would be possible where the user has the option to sign on with xyz account or manually create an account.

    Just curious.

    Thanks fo making really great kits,

    Cheers,
    ray
     
  24. rayfigs

    rayfigs

    Joined:
    Feb 8, 2009
    Posts:
    41
    I picked up the kit in hopes that I would be able to tune the game play on my server without having to update the game build. Is that something I can do with the wordpress kit series?

    I was just going through the docs and it seems that that data is always relative to the user which is awesome, but I'd like to be able to make global changes ( as well as individual user changes) Is that possible?

    Many thanks,

    Ray
     
  25. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi Ray.

    Thanks for the support. Much appreciated.

    Unfortunately the way social media sites work and how Unity's WWW class works, without going into too much detail here, the two are just not compatible, no.

    As for tuning the gameplay... I have no idea what that means in context of your game so I am not able to give you a definitive answer. What I can tell you, though, is that all of these kits were designed to isolate users data from one another. Under no circumstances can one user access another user's data except for the scoring kit that returns the top scores. In no other way does one user have access to another user's data...

    Having said that, the Data kit does allow you to store anything you want online so it would be possible for you to adjust settings on a per-player basis, store it online, fetch it back and adjust your game to work with the retrieved data but that you could do just as easily with PlayerPrefs since settings you save in-game is hardly something that needs to be managed on the server...

    But no, actual settings for the game as a whole that change for all users based on something you set online, no, that is not currently possible, no.

    I am busy with a kit that does exactly that though and actually does allow you to build the binary once and then forever more only update the game in Wordpress with all settings and content being fetched from there,yes... but all of that is specific to that game type. It cannot be used for any arbitrary game's settings, no.

    If that is something you want to do, I will need specifics of what data you want to "tune" online and then create a custom kit for that. If that is something you really need, contact me via the contact form on my website and provide the invoice number for your purchase along with the details of what you want to do. If it's simple enough I'll be able to help you from that or if it's a huge task I can quote you on doing a custom job for you. Either way, I will need specifics

    If you feel up to it, you might always decide to just change the WUData kit by making it save data to user 0's account. Since there IS no user 0 on any WP website you can see that as a 'global' user and just use the WUData kit to save some settings to there. Your game can then fetch that data for whatever purpose. Just make sure the scene where you set that data is in a separate project or at least not included in the final build and that way you can tune the data all other clients use...

    Good luck with that! :D
     
  26. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Just a little update on the progress of these plugins to show I haven't forgotten about you ;)

    As it is I wanted to create a few more packages that each relied heavily on the portal... The portal which I didn't want to release until all the packs that uses is are done... I.e. nothing for a long time then be spoiled for choice one day. As it is, I spent a lot of time on the portal side just making sure that I add the functionality required for each kit, thereby completely ignoring work on the display of the portal itself... well, with my current workflow that is all set to change...

    I have now found a completely new workflow which is far more simple, a lot faster and looks a great deal more consistent with the whole Wordpress experience. Since you will be spending a lot of time in Wordpress for these kits, I was not altogether happy with the way my configuration panels looked nothing like Wordpress. (See image a few posts up) it worked and got the job done but I wanted to create a more unified experience and I've found a way to do exactly that!

    With this new workflow, I no longer need to provide you with all or nothing. The interdependency on each other's kits is now broken and each kit can manage itself completely agnostic of the rest. With this being the case and with this new workflow being such a lot faster than my old workflow, I have decided not to give you a single "Portal" kit to buy, but instead to give you each portal section with the kit it works with and include that for free.

    For instance. The main product of the portal kit was the games database wherein you actually define your games and assign them banners, descriptions, posters and what not. These game records were then needed by the inventory class and could not proceed without it so if you don't have the portal kit then the inventory kit won't work... and from there it gets real convoluted with some of the tables from the inventory class being needed by another kit and it just felt like a complete mess. As far as possible I want to limit requirements to the Login kit only, not create a whole shlew of requirements...

    Now, the Login kit will be updated to include the functionality to create your games. This means you will all be guaranteed to have it so that is one less thing to worry about. Next, since each game you create on your website will automatically have a unique ID value assigned to it, it also solves the issue of you having to pick a game ID in the WULogin class. I will now endeavour to update that functionality to allow the kit to fetch the GameIDs from your Wordpress installation and present you with a drop down box from which to select your game's id. To avoid problems this will be an optional setting there only for convenience, yet highly recommended...

    Next, I am currently working on an inventory and shop system. Through this you will be able to define your game's items online as well as create your various stores. My intent is to allow you to say "MrBigs store only sells Magic items. further more, he only lists potion A,B and D. Now, Sally's shop sells food and she only sells fish, but Bobby's shop sells weapons and he sells all the weapons you can find in the game. Sally takes a 5% markup on the base value of items, Bobby takes 9% but will also buy magic from you but at 12% under market price" and that way flesh out the shops for your game. This info will then be pulled into your game at startup but, more importantly, you will specify how much stock a merchant carries of what and as you buy/sell stuff from that merchant, his stock levels will be adjusted for your game.

    The functionality to create these items and merchants will be included with the kit and form part of what was to become the portal eventually. This will also include a virtual currency for your games, obviously, but as an extra bonus, I have already managed to get this system working with WooCommerce meaning once you get this kit you will be able to define items that people can buy from your website using real money, then have the product available in your game. Rudrasen once mentioned the payment methods that are available in his country, well, because it runs on Wordpress and it uses WooCommerce it means you will be able to accept payment using any method you setup on your website. Credit Cards, PayPal, BitCoin, whatever...

    This functionality will not be available from within the games themselves, though. In game I will only do virtual currency transactions so this system would only be a good fit for selling rare items or content otherwise locked in the game. You will also be able to sell the actual game from your website also. What's the point of a portal if you can't sell games? :D You can make it free or you can charge money but once it s bought it will be listed in that customers inventory (that's the plan at least, still need to do that part) and will thus be available to your site's stats like "So many games purchased. So many people play this or that game" and of course, only if you own the game are you allowed to rate it and contribute to the star score :)

    So yes, that is just a little taste of what is coming. I am busy updating the inner workings of the whole system so this will not happen overnight but once I have verified everything works I will be releasing an update to all the existing kits and including the portal side pages where appropriate. I just want to complete the inventory/shop system first then I will do this (and then get back to completing my game :p) then back to updating the other kit in the series I've been working on....

    As always, so much to do, so little time... ;)

    Right, till later
     
  27. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Again, just as a little taste. This shop system is not yet complete but this is what it is going to look like...
    StoreConfig.jpg

    All configuration on the Wordpress side will endeavour to use the standard dashboard look and feel instead of my custom look. This should hopefully make it's use instantly familiar while also just look aesthetically more pleasing than the previous version...

    ...and let's not forget the integration between the game items and WooCommerce...
    ProductConfig.jpg
     
    Last edited: Nov 7, 2014
  28. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I'm currently running a weekend sale in which I give up to 60% off on most of my kits. Some kits start as low as $2 each!!!

    The Wordpress Login Standalone is currently on sale also so if any of you were looking to get it, now would be a good time to do so. Sale ends on Monday. Check it out.

    This weekend only: myBad Studios Core is FREE!
    https://www.assetstore.unity3d.com/en/#!/publisher/451?aid=1101lGrs
     
    Last edited: Apr 13, 2017
  29. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    189
    MrDude,

    This is nicely put together, I think (just started looking at it.) I think leveraging Wordpress for a user account system is a smart move. What I'd like to know, having not looked yet, is where is the data stored in the Wordpress database? What if I want to export my data, or port it to a new database sometime in the future, how would I do that?

    I appreciate how you've set this up to be user friendly. I'm not sure that creating a database schema in code is a great idea. For example, setting up game data via your user data plugin. I think this should be done on the Wordpress site, and not through Unity.

    Updating / retrieving data makes sense from Unity though, in my opinion.

    Actually, what I'd really like to do is set up my own tables and fields and access them through your Unity plugin. Something more generic and open ended.

    I've purchased your login, scoreboards, and user data plugins and I think they open a lot of doors. I just want to make sure I don't lock myself in to this method and get stuck with a major headache if it turns out Wordpress is a bad idea or if I decide to design my own backend.

    (Actually, I just found where the data is stored in the WordPress database. Now I'll noodle around and see if I can just create what I want there and have the user data plugin pick it up.)

    Cheers!
     
    Last edited: Nov 20, 2014
  30. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi EvilDingo

    this is the short version of the reply. Check your pm for the more detailed answer:

    I do not create the database in Unity, no. The tables are created in the plugin in Wordpress when you install the plugin and deletes the tables when you uninstall the plugin, just like all other Wordpress plugin do it.

    The login plugin itself doesn't create any new tables, though, as they are not needed. It uses the existing user info tables. The data and the scores plugins, though, they each create their own tables but still within your Wordpress database. If you are familiar with Wordpress coding then you can access all the data in my tables using the standard $wpdb. I am just waiting for an issue to be resolved on the store then I plan on releasing new versions of all the kits, though.

    In these new versions, the login kit will still not create any new tables but it will register a new post type or two and allow you to configure a 'Game product' so to speak. It will just register the name of the game, some graphics and prices etc for it for use in other kits. This part is WP only, not Unity. It will also register a few new taxonomies also for use by future kits.

    The score's kit, though, will now start saving it's scores into the usermeta table instead of into it's own tables. This gives you the added benefit of being able to request the player's own score during login also, instead of just seeing it on the high scores table. The login kit has a field where you can specify any number of fields from the usermeta file that you might want to fetch during login. By moving the scores to the usermeta table it means you just add it there and you are done, it is returned to your game as soon as the player logs in.

    The data kit is designed to allow you to store anything you want. That kit has it's own table in which it stores stuff and since that is the case, it is free from breaking other kits or updating your virtual currency balance on Site X if you know where to look ;) Again, still within the WP database so accessible as normal via the $wpdb object, but stored in it's own tables.

    In short, I want to use the normal WP tables wherever I can but isolate data where I feel it is required. All still within the same database but with access restriction where appropriate and not where not required. For instance, a player updating his personal info, if you have restricted a user to a role that does not include the right to update his details then I don't do the updates... Giving anybody free reign to update any table they want in any way they want without any form of control is just asking for trouble...

    Does that answer your questions?
     
  31. EvilDingo

    EvilDingo

    Joined:
    May 7, 2011
    Posts:
    189
    Yes, thanks for the detailed response. If you're changing the scoring mechanism, are you going to script a migration from the current score tables to the new meta tables?
     
  32. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I wasn't planning on it but, now that you mention it, that is an excellent idea, yes, thanks.:)
     
  33. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Just a quick update on what's happening...

    I am currently working on a project for a client so I have not been working on this for the past few weeks and won't be working on it for the next few weeks so unfortunately I have not completed the new additions I wanted to include with the 2.0 release but I also didn't want to keep you waiting forever so I released the version 2 versions of all the kits today.

    Please be aware that VERSION 2 IS NOT COMPATIBLE WITH VERSION 1.x VERSIONS of the kit!!! You will have to remove all the WUSS plugins from your website and install the new ones.

    Here is a roundup of what changed:
    1. Before, the cookies class was shared between all classes but apart from that, each component was completely self contained and contained all it's own code. As of version 2, the WULogin kit now includes a generic server class and all other kits use that to contact the server. This means that all other kits have had their server access classes removed.

    2. Server responses are now always passed along as 'CML', not 'object', and server access error responses are sent as cmlData. As such, it is no longer required to cast the server response before use and that there is no longer any confusion as to wether the response is sent as cmlData or CML.

    3. On the server side things are now drastically different....

    3.1. Functions are no longer called during the SHUTDOWN hook but are now called via AJAX. All kits now share common initialisation and validation code and thus no longer do their own authentication and validation before running. All of that is taken care of before your code runs. This means that the scripts are now drastically simplified in that each unity_functions.php script now contains ONLY the functions called from Unity and absolutely nothing else.

    3.2. Unity now no longer sends Int values as actions. It now sends strings. I still use enums to ensure no typos, but you can safely use strings if you want. So to add new functionality to the kit you can now just create a new function and call it from Unity by name. Additionally, I have specified only a hand full of functions that can be called without being logged in first (The login function itself, the test for being logged in and the function to create a new account). All other functions will require valid session credentials before being run.

    4. I also found a bug in Unity that made certain devices incompatible with my kit and fixed that issue. Specifically, the Vita and Firefox browsers were incompatible (not sure if any others were also) but after a lot of head scratching I found why and after some gawking and facepalming at the solution I did implement it and it is now up and running so if for no other reason than this, this is the reason why you want to upgrade to version 2. I was very surprised to find that my kit works on web browsers but not in Firefox... :O Anyway, that is now history and I am successfully using this login kit with UndeadInfestation on the Vita. :D

    Oh, and the kit still allows you to fetch any meta info you want but you can now specify the fields via an array in stead of a comma separated string. High scores for a particular user for a particular game can also be requested using [GameId]_HighScore. For example if you set the game's id to 5, just add 5_HighScore to the fetch_meta_info array in the WULoginGUI component and Bob's your uncle... :) The score set via the high scores kit will then be available to you as soon as the player has logged in. Simply convert that to an integer and use it to set your local score variable...

    I can't think of anything else to report at this point in time...
    Main points are that I am a bit busy with a project for a client so I have not been working on the addition stuff I wanted to add so that will come in a future release but I will definitely let you know when it becomes available; and the new release now offers greater compatibility.

    Right... enjoy :)
     
  34. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    @EvilDingo
    To address that concern of yours, I added a function to the WUScoring class: UpdateScoreTableFromVersion1()
    You can specify a function to handle the server response and any error responses if you want but really, that is all that you need...

    So in WUScoringGUI's Start() function, add UpdateScoreTableFromVersion1() as the first line of code. This will contact the server, look for the old table, update the meta table with the scores found in the table and then delete the old table.

    As such, it will only ever do anything the first time it is run and you can safely remove it from the Start function afterwards.
     
  35. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    88
    I have to following problem in Unity 5 B18 with myBad Studios Core:

    build target group {0} is unknown
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)
    WULDEFINE:.cctor() (at Assets/myBad Studios/Editor/WULDEFINE.cs:29)
    UnityEditor.EditorAssemblies:SetLoadedEditorAssemblies(Assembly[])

    Requested build target group doesn't existed
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)
    WULDEFINE:.cctor() (at Assets/myBad Studios/Editor/WULDEFINE.cs:29)
    UnityEditor.EditorAssemblies:SetLoadedEditorAssemblies(Assembly[])

    Is there an easy fix to it?
     
  36. bjornrun

    bjornrun

    Joined:
    Oct 29, 2013
    Posts:
    88
    Also this problem with v2 of Wordpress User Login for myBad Studio Core... on Unity 5 B18

    Assets/myBad Studios/WUSS/Scripts/Login/WPServer.cs(183,43): error CS0029: Cannot implicitly convert type `System.Collections.Generic.Dictionary<string,string>' to `System.Collections.Hashtable'

    BTW, the above error is also in User Login
     
  37. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi bjornrun

    The WULDEFINE script is part of WULogin, not MBSCore. It's purpose is to identify the Login Kit to other kits that might want to test if it's installed or not. So far nothing uses that functionality yet so you can feel free to delete the Assets/myBadStudios/Editor/WULDEFINE.cs file and that will get rid of the first error. I have not experienced either error so far but I don't have access to U5 so that explains that... :(

    As for the second error, I've updated the kit and the error is now taken care of. Sorry for the hassle and thanks for reporting it to me
     
    Last edited: Jan 16, 2015
  38. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    33
    Hey MrDude! Love the plugins. Having trouble getting the WUData working, but I'll stick at it for another while to figure it out before I post a question. What I do want to ask is, considering the WULogin works fine, is in regards to the v2.0 update:
    Q: If I update the wordpress plugins on the website, will they still work with an older build of the game? Or, do I have to update the build to v2.0 the same as the plugins?
     
  39. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Once you upgrade to version 2, apps using version 1 will no longer work, no. This is why I try to make it clear in advance that the upgrade is not compatible. fortunately the change from version 1 to 2 is very minor on the Unity end so you can update your existing app in a mater of minutes

    Hope that helps.

    If you don't want to or cant upgrade the app for whatever reason you will need to create a new website installation for future projects. Fortunately a change this big that breaks compatibility is not slated to happen again so the changeover is really worth it to get done now and get it over with. Future updates and kits will add features, not break existing stuff. Unfortunately, this change was necesarry this time round

    Any other questions, feel free to ask :)
     
    shaneK001 likes this.
  40. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    33
    Cool, cheers for the fast answer!
     
  41. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    33
    Ok, I eventually got around to trying the 2.0 update, but couldn't get it to work. I updated the plugins but it in wordpress it said the WUlogin was still version 1.0. Is that normal? I kept getting crossdomain missing errors with my updated webplayer, so it wasn't working. Luckily I could revert to the older one. I think the problem is with the wordpress plugin not being the newer one because when I reverted everything worked fine. I might be having asset store download issues because i tried a few times and it still said it was version 1 in the plugins listing in wordpress. I deactvated>deleted>add new>upload>activated each time I tried.
     
  42. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    woops... I forgot to update the version number ont he loginkit. The other kits I did, but the login kit I forgot. Having said that, that is not something that should make any difference at all...

    The thing is, the code on the Unity end is not compatible between versions so if your code is working with version 1 but not with version 2, that means the code on the unity side is not updated. For now I am going to assume you did this in a new project just to test things out and assume you have the correct code in place... The crossdomains thing is a Unity security issue. Thy explain it in the docs and give you a sample xml script you need to place in the root of your domain in order to make any work from within that domain. If you are getting that error then I need you to check something for me first... Hope I don't make you sound like a n00b for saying this ;P

    In the WUServer component there is a place to say wether you are currently running online or offline. Could you just verify that you are in deed running in online mode? If you have a localhost setup but don't have the crossdomain.xml file in your localhost/ folder then that would explain why you are getting that error and would also explain why the rest of the kit is not working.

    If you have checked this out and you ARE in online mode, please email me directly and I will work with you to figure out what's happening. Once we got it sorted out we can report back here what the issue was.

    To make sure you have the correct version, in the Asset Store window where you import the kit from, make sure THAT is version 2. If that is version 2 then you know you are on the correct version irrespective of my version number blunder :(
     
  43. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    @bjornrun
    That first error you got is in deed Unity5 specific. What happened there is that in U4 you were allowed to write settings to each individual build platform including "Unknown". In U5 you are not allowed to write to "Unknown" any more. If that error bothers you, simply open the WULDEFINE.cs file and inside the foreach loop just add this:
    Code (csharp):
    1. if (btg == BuildTargetGroup.Unknown) continue;
    Again, this is not something that will affect anything at all since the Unknown group is meant to write the setting out to all build platforms and I write to all build platforms individually anyway, but I know how annoying error messages are :p In the next update I will be sure to add that in. Thanks for making me aware of it
     
    bjornrun likes this.
  44. shaneK001

    shaneK001

    Joined:
    Dec 15, 2012
    Posts:
    33
    Ha ha ha, I'm a n00b 4eva! I am using the crossdomain from the docs, seemed to work for me before. Gonna try the empty project with a different test domain and mess around a bit more. Sorry if it says I'm online, I was away from the workstation. I'll report back asap.

    Edit: Took ages to get back to this, but it may have been a bit of stoopidity on my part. As in, the inspector has an online check box that I didn't check. Seemed to solve all my problems.
     
    Last edited: Jan 30, 2015
  45. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    There has been great demand for this so i decided to release this a bit earlier for you guys...

    As of right now you can download the new version of WUData. This version contains 3 enhancements:

    1. GLOBAL SETTINGS
    You can now store data globally to be shared between all users, instead of by the specific user only. This is for things like level difficulty settings or stuff like that. It allows you now to publish your game then make a few tweaks to the game afterwards and have those changes applied to all the players automatically without them having to download the game again.

    To enable this feature I added a few new functions. They are duplicates of existing functions so they work exactly the same as what you are already used to, they just have a slightly modified name. These functions are:
    FetchSharedField, FetchSharedCategory, FetchAllSharedInfo, RemoveSharedField, RemoveSharedCategory and UpdateSharedCategory

    2. DATA MAINTENACE
    This version of the kit includes a beta version of the data module I am including in the portal. The final version will include a few cosmetic changes like listing the games by name instead of as "Game with ID 5" but will work basically the same way. Please be aware that I have not tested this extensively so it may have a few bugs. If you find any, please email me at bugs@mybadstudios.com to report them. Thanks for understanding.

    So, what exactly is this feature? Well, after you update the kit on Wordpress, you will now have a new menu option in the dashboard. Click on WUSS Data and you will be presented with all the data all of your players have stored in all of your games... everything the WUData kit stores as well as a link to the user account of the person who's data you are inspecting.

    Data is first filtered by game and once you have selected what game you wish to work with it will present you with a list of all the users who have data saved for that game (i.e. it won't list all users who have an account on your website, only those who have data for the current game). Once you have selected your user you are then presented with all the data for that user. From here you have the ability to update any of the values or delete them if you so choose. So basically, this plugin gives you 100% control over the data the WUData kit stores on your website.

    3. ACCOUNT BANNING AND SUSPENSION
    This feature has been in the Login kit for a long time already but it had no interface for you to enable it. As of now you have the ability to ban or suspend players from logging in to your games via the WUSS DATA dashboard option on your website. This feature worked when I tested it but should also be considered a beta feature until I've had some feedback on it. If you find any bugs, please send them to the email I provided above. Thanks

    Please note that this won't log players out of a currently active game and it also won't block them from loggin in to your website but what this does is it makes the Login kit return false when their account is not in good standing. As such, if you ban them the next time they try to log in to any of your games they will find themselves stuck on the Login screen and can do nothing else...

    You are also presented with a one click means of lifting a ban or suspension.

    As I said above, these features were meant to be presented to you as part of the portal but due to overwhelming demand I have decided to release it early. As far as I am aware it all works just fine but if you find any bugs, please don't send me a bomb in the mail ;) Just let me know and I'll look into it

    For now, though, enjoy :)

    P.s. Something that might cause a bit of confusion at first... the data is first sorted by game and includes a section called "PLAYER SETTINGS". This is the data stored globally FOR THE PLAYER and is for things like which game he plays the most or what his dog's name is or anything else that he sets once and takes with him into different games but is still unique to the player.

    Once you have a game selected that HAS shared data, you will notice a new USER called SHARED DATA. Click on this user to see all the data you share between all users for that game.

    Right, that's it.... enjoy :D

    Screen Shot 2015-01-22 at 12.40.12 PM.jpg
     
  46. GregMeach

    GregMeach

    Joined:
    Dec 5, 2012
    Posts:
    249
    MrDude - You rock!! - the last few updates have been awesome, thank you

    Quick (way early I know) question about myCred v1.6(1): does your package still work okay with this (brand new) version?

    (1) Yea, it's like 18 hours old so I'm sure you've had time to test... ;):eek::cool:
     
  47. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Thanks, man. Glad you like it :)

    As for myCred, yeah, it works just fine. Remember, my kit deals only with the actual creds, not the badges or whatever else the site does so as long as he doesn't mess with THAT, all will remain just fine on my end :)

    One thing he DID mess up for me a while ago, though, was changing the name of the default cred from "myCred" to "<strong>myCred</strong>" and that he has not changed (and is most likely unlikely to ever change) in this or future versions. As a result, if you actually list the names of the creds as returned from your website, that default one of his will look weird in Unity. Of course that can be fixed quite easily with a simple string.Replace so it's not really an issue...

    Anyway, yeah, I ran the demo and it seems to work just fine so go forth and enjoy ;) :D
     
  48. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    So a few people have asked me about offline data saving and although my kits are made for the exact opposite, I figured you guys might like a bit of sample code of how you might handle such a scenario. The sample I provide here takes care of a number of pitfalls but I am sure there are a lot more that I am not not handling as I never actually had a need for this code myself to date...

    One such pitfall is if they play offline on 2 or more devices. The local and online data is synced between the active device and the server so one of the two devices's saved game will be lost if they both log in to the server at some point. Just be aware of that...

    In any event, enjoy... I think you'll really appreciate how much this script does and with how very little code it does all of it..!

    Quick overview of what this does:
    Firstly, it always loads the locally saved data. If a person successfully logged in using the WULogin kit and did not log out again, that person's game is automatically loaded again and ready for offline play. If no save game is found (i.e. nobody is currently logged in on the website), a default save game is loaded.

    Next, it will hook into the WULogin kit to load the logged in user's online data as soon as login is successful. Once the online data is fetched, the online and local data is compared to one another to determine which one is the more current version. If the online data is up to date, it uses that. If the local data is more current, it will update the online data to get it up to date.

    Furthermore, it also contains a sample inventory function whereby it show you how you can add stuff to your inventory and have it automatically update online so your data remains up to date.

    Notice also that this script creates and uses two separate sections in the settings file: Settings and Inventory. Using the same method you can create as many other sections as you choose and save all your game's settings via this single script and thus have this script be your complete, one stop online and offline data storage solution...

    To that end you will notice I have made the data static to it can be accessed from anywhere in your project. So simply fetch all your data from and store al your data to WUDataSettings.Settings and Bob's your uncle...

    Enjoy...

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using MBS;
    4.  
    5. public class WUDataSettings : MonoBehaviour {
    6.  
    7.     static public readonly string default_filename = "SavedData";
    8.     static public CML Settings;
    9.     static public string settings_filename = default_filename;
    10.  
    11.     public System.Action
    12.         onSettingsLoaded;
    13.  
    14.     /// If the login was successful, fetch the data from the server.
    15.     /// Initially, though, load the local data...
    16.     void Start()
    17.     {
    18.         WULogin.onLoggedIn += LoadSettings;
    19.         LoadOfflineData();
    20.     }
    21.  
    22.     /// Upon successful login, fetch the online data Also, make sure to use
    23.     /// the player's personal settings from this point onwards
    24.     void LoadSettings(CML response)
    25.     {
    26.         settings_filename = WULogin.username;
    27.         WUData.FetchGameInfo(onInfoFetched);
    28.     }
    29.  
    30.     /// Initially load the data of the last player who successfully logged in.
    31.     /// If no user has logged in before or the device never has access to
    32.     /// the internet it will use a default file name for the saved data.
    33.     static public void LoadOfflineData()
    34.     {
    35.         string last_logged_in_user = PlayerPrefs.GetString("username");
    36.         settings_filename = last_logged_in_user == string.Empty
    37.             ? default_filename : last_logged_in_user;
    38.         Settings = new CML(settings_filename);
    39.     }
    40.  
    41.     /// When we receive data from the server, compare the version
    42.     /// of the data with the local version
    43.     /// If the local version is newer, update the online version.
    44.     /// If the online version is newer, use that
    45.     void onInfoFetched(CML response)
    46.     {
    47.         //load the stored settings file...
    48.         int version = -1;
    49.         Settings = new CML(settings_filename);
    50.  
    51.         //if it was found, extract the version number
    52.         if (Settings.Count > 0)
    53.         {
    54.             version = Settings.GetFirstNodeOfType("settings").Int("version");
    55.         }
    56.         //if it wasn't found, create the initial settings file
    57.         else
    58.         {
    59.             Settings.ImbedCMLData();
    60.             Settings.AddNode("settings","version=-1");
    61.             Settings.Save(settings_filename);
    62.         }
    63.  
    64.         //make sure the response from the server is not empty...
    65.         //then compare it's version number with the local data
    66.         cmlData response_settings = response.GetFirstNodeOfType("settings");
    67.         if (null != response_settings && response_settings.Int("version") >= version)
    68.             Settings = response;
    69.         else
    70.         {
    71.             //if the local data is newer than the online data, update the server
    72.             foreach( cmlData category in Settings)
    73.                 if (category.data_type != "CML Header")
    74.                     WUData.UpdateCategory(category.data_type, category);
    75.         }
    76.  
    77.         //report the completion of event to any other functions listening for it...
    78.         if (null != onSettingsLoaded)
    79.             onSettingsLoaded();
    80.     }
    81.  
    82.     /// This function will add the inventory section to your settings
    83.     /// file if it doesn't exist. It will then update your inventory and
    84.     /// save the data locally with an updated version value.
    85.     /// It will also then attempt to store the data online so your
    86.     /// online details are always up to date
    87.     void buySomething(string item, int qty)
    88.     {
    89.         cmlData inventory = Settings.GetFirstNodeOfType("inventory");
    90.         if (null == inventory)
    91.         {
    92.             Settings.AddNode("inventory");
    93.             inventory = Settings.Last;
    94.         }
    95.         //update the inventory with qty items. If the item does not exist,
    96.         // it will be created
    97.         inventory.Seti( item , inventory.Int (item) + qty);
    98.  
    99.         //fetch the current version info
    100.         cmlData settings = Settings.GetFirstNodeOfType("settings");
    101.         if (null == settings)
    102.         {
    103.             Settings.AddNode("settings");
    104.             settings = Settings.Last;
    105.         }
    106.         settings.Seti("version", settings.Int("version") + 1);
    107.  
    108.         //save locally and online
    109.         Settings.Save("savedData");
    110.         WUData.UpdateCategory("inventory", inventory);
    111.         WUData.UpdateCategory("settings", settings);
    112.     }
    113. }
    114.  
     

    Attached Files:

  49. peanutgallery

    peanutgallery

    Joined:
    Oct 5, 2013
    Posts:
    31
    This suite looks fantastic, great work.
    What I'm looking for is something like this -- let me know if this is something that could work with WUData...

    There are two types of accounts -- Primary and Secondary. When Secondary accounts register, they select a Primary account to be linked to. Primary accounts can view the scores of all the Secondary accounts and possibly set specific global values for Secondary accounts to use when they log into the game.

    Is something like that possible with your system?
     
  50. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hi Peanutgallery

    Unfortunately, no. That would not be possible with WUData as one of all my kit's primary focus is to isolate user's data from one another. The WUScores kit shows the top X scores from the site, sure, but all other kits keep your dat isolated from everyone else. Nobody can see or modify your data and you can't modify anyone else's data.

    WUData was updated to allow game wide settings shared by ALL users but for one user to fetch details of another, specific user would entail permissions and a means of revoking that permission and viewing that permissions just to mention a few things. Currently my kits do not do that.

    One of the kits I had planned dealt with exactly that issue: Friends and what data you want to share with who. i.e. Clan members, friends an family each see more than the rest, respectively. This was, up till today, the least requested feature... Now have an "other" I still need to follow up on and try and see what that is ;)

    Sorry for the bad news :(
     
unityunity