Search Unity

  1. Unity 2020.2 has been released.
    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.7%
  2. Online privacy: Protect your info select exactly who can see what

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

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

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

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

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

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

    23.5%
  9. Other: Please specify...

    4.9%
Multiple votes are allowed.
  1. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    The entire Demo 3 consists of 2 scripts. The first gets the data from the website and then passes one post to each prefab. The second script merely takes the data from the post and displays it via UnityUI.

    The entire first script:
    Code (csharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using System.Collections.Generic;
    5.  
    6. namespace MBS{
    7.     public class WUQueryDemo3 : MonoBehaviour {
    8.  
    9.         public FeedEntry[] entries;
    10.  
    11.         void Start()
    12.         {
    13.             WULogin.onLoggedIn += FetchLatestNews;
    14.         }
    15.  
    16.         void PrintError(cmlData data)
    17.         {
    18.             Debug.LogWarning(data.ToString());
    19.         }
    20.  
    21.         void FetchLatestNews(CML news)
    22.         {
    23.             WUPostalQuery q = new WUPostalQuery();
    24.             q.SpecifyCategorySlug("uncategorized");
    25.             q.SpecifyPostStatus(eWUPostalStatus.publish);
    26.             q.UsePagination(ignore_stickys:true);
    27.             q.pagination.PostCountToReturn(5);
    28.             q.featured_image = new WUPFeaturedImage(true);
    29.             WUPostal.RunQuery(q.QueryString, FillViewer, PrintError);
    30.         }
    31.  
    32.         void FillViewer(CML data)
    33.         {
    34.             List<int> posts = data.AllNodesOfTypei("POST");
    35.             for ( int i = 0; i < entries.Length; i++)
    36.             {
    37.                 entries[i].gameObject.SetActive(i < posts.Count);
    38.                 if (i < posts.Count)
    39.                     entries[i].PopulateFrom(posts[i], data);
    40.             }
    41.         }
    42.        
    43.     }
    44. }
     
    BackwoodsGaming likes this.
  2. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,209
    Nice! Enjoying seeing this one come to life! Can't wait to see what other kinds of goodies you are able to work into it!
     
  3. FiveFingers

    FiveFingers

    Joined:
    Oct 15, 2009
    Posts:
    540
    Hi, I'm freelancing help an oversea client with a Unity application using your plugin (version 2.2) for wordpress with WULogin. This is a multiplatform application (PC/Android/iOS).
    The PC and Android version work great so far, but I encounter an issue on iOS.

    It might be a bug with the new iOS, the problem I met is visible only on the device.
    From what I am seeing, is working everything of this plug-in on iOS just like Android and on PC (is registering a new user, is logging in the new user)

    but, differently from Standalone PC and Android build, when you launch a second time the app, you remain logged in...so I cannot create a new User as it requires me to LogOut....so weird...can you help with this ?
     
  4. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I take it you have the "Remember me" button off when you log in with the first user, yes? And you still get this issue?
     
  5. lalexl

    lalexl

    Joined:
    May 17, 2014
    Posts:
    2
    hello, I board a problem with the WULoginUGUI with the OnAccountInfoReceived

    my unity version 5.4.0b10
     
  6. MrDude

    MrDude

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

    I'm sorry to say I don't know what's happening there as I've never had that problem before. Please go to the OnAccountInfoReceived function and printing of the function's arguments using ToString() and send that to me. Perhaps there might be a clue in there... as I said, this is a first for me...
     
  7. lalexl

    lalexl

    Joined:
    May 17, 2014
    Posts:
    2
    okay thank you for the quick response^^
     
  8. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    No problems, mate.

    Another happy customer :D Please don't forget to leave a review and good luck with your project.
    Feel free to post screenshots in here when it's ready :)
     
  9. ransomec

    ransomec

    Joined:
    Oct 21, 2014
    Posts:
    4
    Hi MrDude. First off, hats off on the plugin, it's been a pleasure to use. I am running into a bit of an issue with WebGL tho. Everything works good from inside Unity but when I test the WebGL build the network requests return empty and I get "No results returned" in the console. I can see the same error is happening in the demo you posted up a little while back:

    http://www.guild.site/WebGLTest/index.html

    Attached a SS. Tried on both Chrome and FF, same results. Any thoughts?

    Image9.png
     
  10. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Uggghhh... WebGL. The new bane of my existence. How I morn the death of the WebPlayer. That test project I uploaded was indeed a test for me to see if the kit worked and I failed to make it do so... So I started reading the docs and it seems that unlike WebPlayers you actually need to do some work on your website to actually make it work. I forgot what it was but it all sounded like a lot of bother and I hated WebGL ever since...

    I did eventually manage to get my kit to work with WebGL but unfortunately I forgot what I did to make it so. I was planning on releasing a few WebGL demos over the course of the next few weeks and was going to have to figure it out again then, but unfortunately you asked me a bit too soon. I know it is possible for my kit to work with WebGL... I just don't recall the steps required to do so. For a change I am going to have to refer you to the Unity documentation for into on how to make WebGL behave.

    I'll have a look over the weekend also and if I make any revelations I'll be sure to post on here immediately. I might very well be wrong here, but I think it had something to do with the build settings and having to NOT build in developer mode and enabling some setting and then there was also the issue of asking the player for permission to access the internet...

    Sorry, mate, I only ever did one WebGL test and that was ages ago. I don't remember the steps off hand but I will look into it and let you know as soon as I've figured it out. Oh woe the day the webplayer was so viciously slain... :(

    One thing to try first, though... In the WPServer, try changing GET to POST or vice versa to see if that makes any difference.
     
  11. ransomec

    ransomec

    Joined:
    Oct 21, 2014
    Posts:
    4
    Thanks for the quick reply! I understand your frustrations with WebGL, I'm impressed at the support that Unity has managed to add for it over the past couple of years.

    Your suggestion to switch from POST to GET worked! One odd thing is that, although GET is set, the WebGL build still sends requests over POST. This is preferable imo, but just a bit misleading. Anyhow, I just tried the login, but so far so good! Going to be incorporating WUData now and will let you know if I run into more issues. Thanks again!
     
    Last edited: Apr 7, 2016
  12. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,071
    I've got WPUser Login and WP User Data and I'm quite happy with them. I'm at a point where I'm considering adding something like high score tracking/leaderboards. It's not essential to have, but it would be a nice touch.

    My product is a speedboat racing game where you have a few different race courses and types, one of which is a top speed shootout where you build the fastest boat you can. It'd be fun for players to compare top speeds and set records. I looked at Wordpress User Scoreboards which looked at first like it might be just what the doctor ordered, but it looks like it's restricted to one score per game? What I'd need are multiple scores. There would be different boat classes and each one would have its own top speed record score. I.e., there'd be a 150 horsepower 18 foot class, a 300, etc..


    If that can be done without too much trouble, one other thing would be the laptimes on the other type of courses stored individually by course and class. So I'd want to store the best laptimes on some tracks (smallest times, really a low score instead of a high score). I might be getting in over my head quite quickly with that, but am curious if Wordpress User Scoreboards might be able to do all that without too much trouble, or is it just one score per game? I can imagine on the server/database side it would be pretty complicated to do what I'm thinking here.


    If not, it's no big deal, just figured I'd ask. :)
     
  13. MrDude

    MrDude

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

    Actually that question has been answered a number of times throughout the course of the 5 pages worth of replies to read through... Somewhere in there... :p

    Anyway, the good news is that what you want to do is actually super, super simple to do with the WUScoring kit. As it is, when you create a game with the WUSS kits you will have noticed in WPServer.cs that I ask you to give your game an ID value. That value has to be unique for every game you make and since all the kits go through WPServer to do what they do it means all my kits automatically use the game ID value you set... all of them except WUScoring...

    I purposely modified WPServer to allow you to manually specify alternate game ID's for the WUScoring kit. If you don't then it uses the one set in WPServer. So here is how it works: You install WUScoring on your website once. You then create 10 games and have all 10 games link to the same website. Each of the 10 games have a unique ID value and that ID allows me to distinguish between your games so by installing the kit once you automatically have a scoring system for all 10 your current and future games...

    ...BUT, if you simply change the GameID before you submit a score or request the scores list WUScoring will use the id you specified so... If you have 10 classes of boats, 5 types of races and 2 modes of play and you want to keep track of high scores for each of those then you would need 100 score boards just for the one game... So simply use 100 different ID values in your game. Specify a relevant ID when you submit a score, specify a relevant ID when you fetch back the top scores... Done. That simple.

    Of everything you said here, though, the only thing I the kit can't do at the moment is return a list of the top 10 LOWEST scores... You can create an infinite number of scoreboards per game, but all of them will return the top HIGHEST scores...

    Hope that helps.
     
    Last edited: Apr 28, 2016
    Todd-Wasson likes this.
  14. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,071
    Thanks. I saw something in your docs that said the same thing, I was curious if it had changed. I'll give it some thought and perhaps buy it and try this. For laptimes (lowest scores instead of highest) I could probably just store 1/laptime or something like that so low laptimes would show up as high scores, yet be convertible back into laptimes on the game side.

    Appreciate the help. :)
     
  15. Todd-Wasson

    Todd-Wasson

    Joined:
    Aug 7, 2014
    Posts:
    1,071
    One more question if I may: Right now my database table (I think it's a table, not a database guy so don't know?) is wordpress_wuss_data. Would the high score stuff be written to a separate table? Hope so, that's what I would prefer. My current table is used for something pretty specific and I'd rather not pollute it with tons of other stuff on a per user basis.
     
  16. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Yeah... I liked isolating my data from the rest of the Wordpress stuff so all my stuff could run in it's own little ecosystem with every kit storing it's data in it's own tables and only that kit had access to that kit's data...but I came under fire for that because apparently most people want to access the data from 3rd party plugins, share it between kits and genrally have the data available to anything and everything...

    So I changed my mindset for this system from creating new tables by default to only creating new tables when I feel it is warranted and the rest of the time, as much as I am against doing so, store the data as usermeta like my customers have asked me to. WUScoring is one such example. It used to have it's own tables but the scores are now stored in (in your case) wordpress_usermeta. If you open phpmyadmin, open that table and do a query to list all the entries for a specific user, you will find their scores listed among the results. Example, fetching the admin's details:
    SELECT * FROM wordpress_usermeta WHERE ID = 1;

    WUData is a separate kit. WUData and WUScoring run independently of one another and hold no references to one another. As such you need not worry about the table being used by other kits. WUData is an example of where I felt a custom table was warranted and thus it still runs within that closed ecosystem I spoke of.
     
  17. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    27
    I have WUData and it works great!
    I was just curios if it was possible to have the data posted to a category accessible to all players?
    If not, would it be possible change the Php to accomplish this?
     
  18. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    All the functions also have a "Shared" version. For instance, if you say UpdateCategory() then the details you provide is visible to that user only. On the other hand, if you say UpdateSharedCategory() then the details you provide is visible to all players.
     
  19. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    27
    Sweet! Thank you for the reply!
     
  20. kayke

    kayke

    Joined:
    Oct 21, 2015
    Posts:
    27
    With the WUData I can use the normal functions fine, but when I use the shared versions, UpdateSharedCatagory, I get a message "No Results Returned". And when I check the Wordpress it shows that nothing was pushed to the website.
     
  21. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Interesting...

    Please PM me your url and I'll look into it...
     
    Last edited: May 2, 2016
  22. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    New version of WU Scoring is now available! https://www.assetstore.unity3d.com/en/#!/content/15329

    The one thing that I have been asked about most about this kit was wether or not it allowed for multiple scoreboards per game. In this new version I have made that answer abundantly clear by creating a new demo scene in which you can submit scores to and fetch scores from multiple scoreboards.

    In the old version of the kit you only had to call SubmitScore(score) or FetchScores() but in this new version you can now include an optional second parameter indicating your high score board's id. This means that if you have need of 100 scoreboards, just add keep track of them via an int value and use that value when you submit your scores or fetch them back.

    There are a number of changes to be aware of, though:
    1. MOST IMPORTANTLY: This kit is not compatible with any previous version of the kit. To make use of this new version you are going to have to make a few code changes to your project. It is nothing major but still, some changes will be required. For instance, before the scoreboard was just drawn on screen using OnGUI. Now it needs to be instantiated and be made a child of a canvas...

    2. All OnGUI code has been removed. This new version works with UnityUI.

    3. The WUScoring script is now a static class so you no longer need to derive your GUI code from it. Instead, the GUI background and the entries it contains are now two separate prefabs. Each one does only it's own thing so the scripts for both are incredibly small and easy to follow along with so it should be a simple matter to convert it to work with other GUI systems, should you wish to do that

    4. The button on the window now triggers an event so you can call custom code when the window closes

    5. You can now specify different Gravatar image types simply by selecting it in the Inspector

    6. As mentioned before, you can have multiple score boards and specify the one to use in the functions. Also, the GUI itself is also loaded via code. To load the gui you don't have to keep a reference to the prefab in some or other script and then instantiate it from there then place it under a canvas or bla bla bla.... Whenever you want to see a scoreboard you just have to call two functions:
    Code (csharp):
    1. WUScoringUGUI.SpawnInstance(canvas);
    2. WUScoring.FetchScores();
    7. In the old version I determined wether or not to show a score based on the nickname or display name you used. Since username is the only name that is guaranteed to be unique this means that if another player chose the same nickname as you and his score comes up, his score will be highlighted. The best way to guarantee that your score was yours was by using your unique ID which was an optional field you could fetch during login and might thus not exist in the game. Well in the new version I determine the highlighting on the server side and the client just does as it's told. No more client side code to determine highlighting and no more possibility of highlighting the wrong name.

    All and all the system still looks the same, it's implementation is just a bit different but the incompatibilities are easy enough to work around but it is still worth mentioning that the new version is not compatible with the old version and will require that you rip out the old and plug the new one in it's stead.

    Apart from that. Enjoy! :)
     
    Last edited: May 2, 2016
    danreid70 likes this.
  23. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    It turns out that Kayke's issue was actually due to a typo in the Unity5 version of the wuss_data website plugin. I have already uploaded the fix to the Asset Store so feel free to download.

    You don't have to change any code in your project, just reinstall the WP plugin on your website and you are good to go.
     
    danreid70 likes this.
  24. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    After the user logs in, is their username saved into a variable so that it can be accessed via other C# scripts? For example, say I wanted to use the username variable to personalize dialogue or in game instructions.

    Also, I could not find any PHP scripts included in the package contents on the asset store. How exactly are you verifying the username and password without PHP?
     
  25. MrDude

    MrDude

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

    Yes, those details are stored as static variables available from anywhere in your project. You also get to specify any other field(s) in wp_usermeta that you want and a bunch in wp_users. All of them are accessible from anywhere in your project.

    As for the php, this kit is made to allow you to integrate your Unity project with your Wordpress website. In wordpress you simply tell it to install the included plugin by pointing it to the zip file in myBadStudios/wuss/wordpress and Wordpress will then upload and unzip the php files into the folder where it needs to go.

    Steps you need to follow:
    1. Install the kit into your project
    2. Go to your Wordpress site and install the included plugin from the admin panel
    3. Find the Login prefab and enter your website's url
    4. Drag the prefab into a scene
    5. Write whatever custom code you want to happen when the various events fire: OnLoginSuccess, OnLoginFail, OnPasswordResetSuccess, etc etc etc

    That simple.... :) If you have any more questions, feel free to ask
     
  26. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    Ah ok, so you use a custom Wordpress plugin to communicate with Unity. Great work.

    Would you consider creating a similar asset for another CMS? I have used Wordpress in the past but I tend to use Drupal now a days for most websites. I would imagine that from the C# side there would not be a lot of changes necessary, but from the PHP side I am guessing that a Drupal module would be needed, similar to the current Wordpress plugin.

    What are your thoughts on this?
     
  27. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Unfortunately I have never used Drupal before in my life so I would not have a clue where to even begin. You are right when you say the c# part is the easy part. I'm afraid I don't see that happening unless I find the Drupal API super easy to work with.

    On the other hand, I have made a comitment to my customers to provide a system that is only about 5% done now. I still have so much, much,much more coming in this series. Recreating existing stuff over and over for multiple CMSs detracts from expanding the system I've already started and people are already using. I might expand into other CMS once this system is done but there is still soooo sooooo sooooo much left to do so not anytime soon. So let's just leave it at maybe...but not likely
     
  28. Hamesh81

    Hamesh81

    Joined:
    Mar 9, 2012
    Posts:
    405
    That's fair enough. Wordpress is much more beginner friendly, but Drupal is more developer focused therefore you may find the API more straight forward, but I am not a PHP programmer so I cannot guarantee it..

    For my purposes I would only need 2 things; (1) a way for Unity to be able to check user login details stored in the Drupal database, and (2) a way to store high scores from Unity into the Drupal database.

    If you do have plans to implement more great things via Wordpress though, it will probably be easier to only maintain the one system :)
     
  29. Gottn

    Gottn

    Joined:
    May 1, 2013
    Posts:
    2
    Is it possible to change displayname, email, password on my wordpress site ones i got the wordpress plugin installed for WUlogin?
     
  30. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    yes. You use the same login details in game and on the website and can edit it in both also.
     
    Gottn likes this.
  31. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    257
    Hi to anyone reading this. Having a strange issue I'm hoping someone already ran into and can give me the fix before I spend time on it. I have two projects with the wordpress login and data assets. One is my project, with that stuff integrated, the other is comprised of the stock assets. In the "stock" one, all works as expected. But in my project, at some unknown point in the past I started getting an error when I attempt to register an account. The error text doesn't appear in the code from the asset, so I assume it comes from wordpress because I did something dumb. It says exactly:
    "Please log out before creating a new account."

    Thanks!
     
  32. MrDude

    MrDude

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

    That problem is real simple to explain. It is in fact an error coming from WordPress as you suspected. What it means is simply that you have logged in before and not logged out again. Someone who is logged in can't create an account for themselves.

    You just have to make sure you are not logged in when trying to create an account, that is all
     
  33. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    257
    What state allows me to be logged in, but still have the login screen appear, registration available, etc? I can get this error in one project, while simultaneously successfully registering in another, two separate editor windows.

    ---edit---
    I wonder if this is related to problems I have with the autologin functionality? I'm not sure if this is another error on my part, or by design, but to get the preferences (last user, autologin) to save, I have to actually click the checkbox at least once, regardless of whether it was already set how you wanted it, or it doesn't save the state for next time. After that, if left "off" autologin appears disabled when the app starts, but the checkbox is still checked. I wonder if it's actually logged in, but something is just causing the login screen to appear anyway?
     
    Last edited: Aug 8, 2016
  34. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I am not entirely sure I follow what it is you are trying to do...

    But in any event, the "Allow autologin" tick box in the inspector does behave differently to what you might expect. When the project is built and the end user (player) uses the "Remember me" option, it will work exactly like the Wordpress website and exactly as they expect it to.

    In the editor, though, that is a different story. In the final build, when they log out, the cookie is erased and they have to log in again. If they never log out then they can auto login next time they start the game because the cookie is saved. that is how the system works: If there is a cookie then use it to log in. If there is no cookie, ask them to log in. The cookie is only deleted when they log out. In the editor, though, you simply press the Play button and all my code is bypassed. If you hit play then log out inside the scene, the cookie will be removed so if you hit play again you will not auto login the next time around.

    This is where the confusion comes in. The "Allow autologin" that you see in the inspector determines wether or not to store the cookie. If you have it turned off and log in, auto login will not work the next time. If you have it on and login then the cookie is stored so when you play it again it doesn't matter wether you have it on or off... There is a cookie, use it. So that is the secret. If you want to turn off auto login you first have to run the scene and log out THEN turn off "Allow autologin".

    I hope that explains some of what you wre confused about... You also asked me what state allows you to see the login screen while you are already logged in. The simple answer is that the way I coded it, it should never be possible if you use my code without altering it... BUT... showing any of the screens is as simple as calling the function to show it so technically speaking you can see it at any time if you wanted to. As I said, though, the way I coded the interface you should never have that happen.

    And then you mention the one thing I have no idea about... You say you have two copies of Unity open? Now THAT I do not know. The cookie is saved as a player prefs and as I understand it Unity uses the name of your company as well as the name of the project to determine where to save the player prefs to. If you have two copies of Unity running and both use the same settings then maybe they share PlayPrefs also? That is a situation I never tried before. Having two copies of the editor try to log into the same account by sharing one cookie... Let's just say "Don't do that" and be safe. Build the project to any platform you want(webplayer, desktop, anything) and run the game in that and the other copy in the editor but don't run 2 copies of the editor as that, I simply cannot predict what that might do.

    More importantly, what is it you are trying to do, exactly? Contact me on support@mybadstudios.com and let me see if I can help you out.
     
    Last edited: Aug 8, 2016
  35. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    257
    Sorry to not be clear about the problem. I'm not trying to do anything abnormal, but my registration stopped working and I don't know why. I don't normally run two projects at the same time--it was merely a test. I'm trying illustrate conclusively that it works normally in one project (containing nothing but your asset) and not another. The behavior is the same if I do the same test, but sequentially with the two different clients. The point being, it shows I likely messed something up in my project, not my wordpress site. Let me just describe what I'm seeing:

    If I start my program and it doesn't autologin, I can click login and login as the user of my choice. OR I can click register, and that says "
    "Please log out before creating a new account."

    I'll post back here when I figure out what the issue is.
     
  36. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    That sounds to me like you were logged in before, then hit the play key to stop the project while logged in then you turned off "Allow autologin" in the inspector. The cookie is still there and if the cookie is there, it uses it. I realize now that in my previous post it may have come across that the cookie is only used during login. The cookie is in fact used for every single time you contact the server to tell it who you are and, as I said, if the cookie is there, it is used... So try this... Find the function where I call the registration function and just before that do this: (Function RegisterAccount in WULogin.cs)
    Code (csharp):
    1. if (logged_in) WUCookie.ClearCookie();
    That will force the system to clear the cookie before you register and will thus stop Wordpress from identifying you. Be aware, though, that if this is your problem that this can only happen under a specific series of steps in the editor. This issue cannot happen on your built project as there is no way to duplicate the steps required (i.e. you turning off something in the inspector at the wrong time), but yeah, that is a simple enough workaround. Ideally, though, start the scene, log out, turn off auto login in the editor, hide the autologin button in the scene and play again. Now you are safe for good, no hacks required.

    A much better approach, to be honest, would be to modify Start() from this:
    Code (csharp):
    1.             WUCookie.LoadStoredCookie();
    2.  
    to this:
    Code (csharp):
    1.             if (!attempt_auto_login)
    2.                 WUCookie.ClearCookie();
    3.             else
    4.                 WUCookie.LoadStoredCookie();
    5.  
    Basically, if not using autologin then don't load the cookie in the first place.
     
    Last edited: Aug 9, 2016
    BackwoodsGaming likes this.
  37. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I have a question for you guys and I am going to be needing your input or else you might not like the next update.... so if you have an opinion, please let me know.

    Someone has requested that I add a security feature to the WUData kit to further protect the data being sent back and forth. After giving it a bit of thought it would make the most sense to include that fix in the WULogin kit and implement it across all kits in one go. This would be an optional step but if you want to make use of it you would need to fill in a value into the prefab and then go to your website to enter the matching value. Leave both blank and the additional security is removed.

    This extra step is only really required in one use case scenario in one kit so you are free to ignore it and continue to use the simple drag and drop and enter your URL system that you are used to. If you do want to make use of it then you will have two extra steps to follow in the form of choosing a security string and entering it on the prefab and the website. Your choice wether to use it or not but it will be included in a very near update...

    However, having said that... It has been brought to my attention that my documentation is by now seriously out of date with all the changes I have made to improve this system over time so I will be updating the docs for a future release also but realise that I have two completely separate versions of the kit that get installed together every time... I am thinking of retiring the old OnGUI version and keeping only the Unity UI version. I cannot think of any reason why anyone would still want to use the resources heavy OnGUI version when the resource friendly Unity UI version is available...

    Would you like me to zip it up and include it as a backup or would you miss it at all if it were simply deleted and I continue to focus my efforts only only one version of the kit and only maintaining one version in the docs also? What do you say? Do you use the OnGUI version? Can I delete it? Do you want it as a backup? What do you think?

    Thanks
     
  38. BackwoodsGaming

    BackwoodsGaming

    Joined:
    Jan 2, 2014
    Posts:
    2,209
    I prefer the new uGui. So no problem from my end with you retiring the OnGui stuff. :)
     
    MrDude likes this.
  39. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Regrettably I have had to update my product description to now read "Works on all platforms except WebGL".

    Ironic as it might be, the web platform is the only platform that can't login via Wordpress. Believe me I've tried.

    First issue I ran into is the fact that WebGL content posted using the POST method simply doesn't send any info along to the website at all. All POST content is simply ignored. So, solution, use the GET method.

    This manages to log you on successfully and even return your login details as requested... except the WebGL build does not receive any cookies from the website. Well, it receives 4 specific ones and the ones Wordpress sends out, well they are simply ignored by Unity. Thanks a lot. This poses 2 problems: 1. I can't store the cookie to authenticate you with later and 2. well, let me first explain the next problem...

    Chrome does not allow you to send a cookie with a WWW call. Yup. Even if I HAVE a cookie to authenticate you with, the WebGL build does not allow me to send it when I use WWW. Thank you very much whoever is to blame for this stupid limitation.

    Solution to problem 2 is easy. I send the cookie as a normal field, not as something in the headers then, when it reaches the website I immediately copy it into the cookies super global array and make it SEEM like it was sent via the headers. Problem 2 solved. How so send a cookie to Wordpress. How to make Unity receive a cookie via Wordpress, well that is another matter.

    As far as I can tell and after asking on the web, it doesn't appear possible to see what cookie WP sent out when you logged in. Strange but true. Instead, I can generate a new cookie of my own using the same function WP uses and so I do that. To bypass WebGL not being able to RECEIVE cookies either, I send the newly created cookie as a normal field and save THAT instead of the one that should have been in the headers. Sounds like a winner here but unfortunately, for reasons I cannot yet explain, when I send back the cookie I generated, WP fails to authenticate with it... leaving me up the creek with no paddle. :(

    WebGL is the worst thing to happen to Unity since Unity was created. I firmly believed this and now with all these stupid and pointless limitations placed on it being brought to light I just absolutely hate this platform even more. Never the less, I am going to continue trying to find a way to hack this thing into working despite Unity being useless in answering my questions or making this platform viable. Just cause they can't do it doesn't mean I can't.... but unfortunately I can't YET... so for the time being, no WebGL support. :(

    The only way I can make it work right now is to send your username and password every single time you make a call and re-authenticate you with every single call... but sending your username and password unencrypted via a normal GET call EVERY single time you contact the website... I think most people would agree with me that that is not a good idea. :( Apart fro that, until I can figure out why the newly generated cookie I generate doesn't authenticate, WebGL is out for the count.

    Sorry guys :(
     
    danreid70 likes this.
  40. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    And the very next post I reply with good news! :D

    So after days of struggling and many emails and forum posts to a number of people (including unity support directly) the final verdict is:
    It ain't gonna happen. :( This CORS nonsense is just too much trouble and nothing but hassle and for the life of me I cannot get it to work... Apparently nor can the guys from Unity who monitor these forums...

    Fortunately, one of them earned his status as my hero for the time and trouble he put into trying to help me figure this out. Eventually he realised that my server setup is odd and I need to modify the index.html Unity generates for me or else I get the errors I got when I tried to run my projects directly from the website. Once I got the index.html to actually SEE the project files, the login kit worked without any worries! :D Both POST and GET worked just fine. Sure Chrome still moans about my setting of Cookies and refuses to do it... and yet it works just fine non the less! Up yours Chrome! :p

    So final verdict... The kit works in the editor, the kit works on your website. The kit does NOT work across domains so that means no testing in your browser without uploading it. I call that an acceptable compromise... Do just that and get the kit to work? I call that a win :D
     
    danreid70, zyzyx and BackwoodsGaming like this.
  41. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Big news. The Wordpress kits got a facelift. Unity said I can't get featured or go on sale until I make my graphics less boring than what they were. So since I had to redo all the kits anyway I figured it would be a good idea to update the graphics while I do the version 3 update.

    So yeah, that is the big news. All the kits were updated and just pending review at the moment. I was recently made aware that my kits don't work on Windows Phone and I thought to myself "Nonsense"... till I tried it myself. Unfortunately they were right...but it was much worse than I thought. The problem is not with Windows phone but with Windows RT. It ues .NET while the other platforms use Mono and as such my kits don't work on any device running Windows 10

    This is due to a simple little inconsistency that required that all the Wordpress kits be updated. And so it has come to pass that all the wordpress kits have now been updated. Please be sure to update all of your plugins or the one(s) you don't upgrade will no longer return any input when called.

    Basically, the problem is that I send back the responses as a series of strings and Unity then decodes them upon arrival in your game. .NET, however, sees this concatenated string as invalid and requires that I send back exactly 1 string and no more. Thus I had to update all the kits to concatenate their values rather than sending them and then just sending the final result once done. The functions that used to SEND data now just RETURN a string, thus unless you update the plugin the plugin will send back nothing from now on.

    On the Unity end virtually everything stays the same and don't require any updating. Virtually...

    - CML.cs needs replacing. Again, Windows RT does not allow the use of the System.IO library nor, by proxy, the streamreader and streamwriter functions. I now hide them when building for Windows RT.
    - I also added a minor change to WPServer to just get rid of some warning messages about deprecated build platforms.
    - Some of you might have noticed some errors popping up in U5.4 about non supported build platforms. Those errors were totally harmless but extremely annoging so they have now been averted also.
    - The OnGUI version of the login kit has been completely removed and no longer supported

    First time in a long time that I had to do so many updates at once for two versions of Unity while supporting a third. I'm quite anxious to see if I made any mistakes during upload but with my uploads being pending it's rather hard to see... But 1 lol moment I noticed... The data kit was accepted already and when I looked at it I noticed I uploaded every prefab and image and everything else except the actual script that makes up the data kit :p Facepalm :p Now awaiting that fix to be approved also... But yeah... in the next day or so, be on the lookout for the new versions of the kits and be sure to update all of them on your wordpress site(s).
     
    Last edited: Sep 26, 2016
    BackwoodsGaming likes this.
  42. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Oh, yeah, one more thing, before I forget. Unity has now made a new rule that we are no longer allowed to install anything into the Assets/ root folder. All our stuff needs to go into a sub-folder. MBSCore used to go into Assets/Plugins but that is no longer allowed. I have thus moved the Core scripts into Assets/myBadStudios instead of Assets/Plugins.

    Fortunately this seems to work quite nicely however, I tried installing Unity's Tanks demo today and integraiting my kits with that. Unity placed the entire demo inside the Assets/StandardAssets folder and since that folder gets compiled first it means nothing in there has access to any of my kits.

    Unity has instructed us to inform our customers of any folders that need to be moved to the root and have them do so themselves rather than us just placing it in the right place in the first place. Stupid rule, but what can you do? So yeah, my kits work nicely with the core kit where it is now and should work just fine for you also... but should you ever get errors about scripts not finding my code, please move Assets/myBadStudios/Core to Assets/Plugins and you will be good to go again.
     
    BackwoodsGaming likes this.
  43. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Okay, all except the myCreds are now live. I'll update that one next weekend.
    Enjoy
     
    BackwoodsGaming likes this.
  44. retox

    retox

    Joined:
    Sep 12, 2012
    Posts:
    29
    Hi there,

    This seems to be the tool I need for a development I'm currently working on. Can I ask, is it possible to lock a user account and thus lock access to the game content? So only when an active account is working will users be able to access games content.

    Many thanks.
     
  45. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Yes and no. The main login kit has the functionality to ban and suspend user accounts, yes...but since the data kit is cuttently the only kit with an interface in the WordPress dashboard you really need both kits to make use of this properly... but yes... all accounts can be active, suspended or permanently locked and if not active, login will fail and cite that as the reason why
     
    BackwoodsGaming likes this.
  46. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    The myCreds package has been updated now also so those of you who have been waiting for it, check the store in a little bit.

    Enjoy :)
     
  47. MadMapp

    MadMapp

    Joined:
    Nov 15, 2012
    Posts:
    49
    any time line for the friends plugin?? money waiting, your products are all great
     
  48. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Unfortunately, no timelines, no. The friends one is far down the line, though, I can tell you this much...

    First order of business is improving security, working on the portal front page so you can generate a games with description and what not and use that to display your game info on your web page, but also to get a system defined Game ID, required for the security mentioned above. More importantly is the custom POST types that will come with that so you can list your games and in-game items via WooCommerce.... Then a game serial number generator and validator to authenticate purchases and players with, generic post reading and writing system so you can access any and all post and pages on your website as well as create your own from within the game... and something you should be very excited about is the virtual currency system I am busy working on. It will allow you to earn real money by charging your customers no money :p Virtual currency for them, real money for you, no money out of their pockets... Think that might come in handy? :p

    As you can see, the friends system isn't even on the list yet :( Loads to do and no time to do it in... bad combination. But hang tight, I am nowhere NEAR done with this system.... ;)

    Good news is I am now focusing on the portal and the friends system will need that so at least I am heading in the right direction for that... even if in a roundabout way
     
    Last edited: Nov 12, 2016
    BackwoodsGaming likes this.
  49. MadMapp

    MadMapp

    Joined:
    Nov 15, 2012
    Posts:
    49
    all further development sounds lovely and yes, all, much needed aspects,(i would certainly like to add woocommerce to my project) unfortunately friend system will play a big part in my project, ill hang tight for another few months and check back later
     
  50. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    New FREE tool available today.

    For those of you who do not know yet, Unity has a new program called Unity Affiliates where you can advertise any product on the Asset Store and when you send someone to the store and they buy that item within 24 hours, you get a 5% commission.

    Unfortunately, they don't currently have a link generator link anywhere on their website so either you bookmarked the link when they emailed it to you or you are screwed. Well, that never really bothered me much since I was not a big fan of going there, doing a search for an asset, waiting for it to find it, then clicking on "create link" then waiting for the next page to load so I could decide what style of link I wanted then copying IFRAME code and pasting it into my website and then redoing the entire thing all over again... So right from the start I created my own tool to duplicate what they do... only much faster and a lot less PT. :D

    Instead of doing all of the above, I just type in
    Code (csharp):
    1.  [as_aff_widget asset=29385]
    and I am done. :D Sooooo much easier :D

    Well, as of right now, that plugin is available to you for only 99.95! Oh wait, I said "free", first, right? Okay then, it is available to you for free, right now!
    :D

    Enjoy
    http://guild.site/development/wordpress-systems/unity-affiliate-shortcodes/
     
    BackwoodsGaming and theANMATOR2b like this.
unityunity