I've used playerprefs and also added serialization, everything works but i need another way of saving and loading because i have the game on a website, and on the site, there's a login, i need to find out if there is a way to save data to a persons account and also be able to load the data back into the game when the person logs in , even from a different pc
There's many ways to do this. You can write your own server side code, or use a third party plugin to accomplish this.
If you're interested in trying your own implementation, Unity Wiki's Server Side Highscore is an excellent starting point.
The example contains a step-wise explanation on how to setup your database, some PHP code (which allows you to GET & POST) and Unity side code in both JS & C#.
Some time back I have created a server for writing data on server for my webGL game in unity. Here is path of git repository.
Related
I was checking for some tutorials how to implement Share button for Unity games. I want to share my game with custom picture, text and link together with my description over the share automatically.
I found this link: https://developers.facebook.com/docs/games/services/sharing
but I am not sure if this thing even works anymore. I found somewhere that I have to create custom HTML file with all og metadata inside in order to work this through. I tried that too, but when I press share button, Facebook automatically scrapes data from my website and not custom HTML file. In Unity I have initialized everything correctly, so there should not be problem in initialization, I guess something is either wrong in my code or in Facebook side.
Can someone share simle example how can I make HTML file connected to my unity game in order to correctly share custom data (Title, description, image....) like on link: https://developers.facebook.com/docs/games/services/sharing
Kindly appreciate it.
Best regards
First time asking a question here so just let me know if I have forgotten anything important!
I currently have a system in which a user's highscores for a game being developed in Unity 5.3.5 are stored in a MySQL database. As a part of this system, I am also developing a web app using Ruby on Rails 4.2.5.1, which is what I am using to get the data from the game to the MySQL database, and which I also plan to use to visualize data (and other features not related to this question).
My current issue is that I am trying to display that data from the database back in Unity, but I have been having trouble accessing the information I need. I have been trying to use Unity's WWW class through WWW.text, but that just ends up giving me all the HTML code in addition to the information I need (we're talking about A LOT of HTML code here).
I have done this successfully in PHP before. For example, I wrote my own version of this script from a Unity tutorial on server-side highscores (the following is just an example I used as a reference, it's pretty old code from what I understand): http://wiki.unity3d.com/index.php?title=Server_Side_Highscores#PHP_-_display.php
When using this script (ex. www.example.com/display.php), I was able to get the information I needed (something along the lines of Jon 10 for example). In my rails app right now I have tried to do the same, but have not been able to access that data.
In one of my controllers I have the following code which retrieves the data I want from my database:
def getData
#current_highscores = MyModelName.order(score: :desc).pluck(:username, :score)
end
In one of my views I also have the following code that displays the scores on the web page (ex. www.example.com/data/getData):
<% #current_highscores.each do |highscore| %>
<%= highscore %>
<% end %>
This displays the information I pulled from the database in the format that I want (ex. `Jon 10'), but like I mentioned earlier I am not sure how to get that data from the database back into my game. I am a bit new to Ruby on Rails and am struggling to figure out a proper solution to this, so any help or advice that anyone has would be appreciated!
I'm not familar with ruby on rails but you should be able to return a json containing the information you need.
See how to return json in ruby and rails3 how to return a json document on how to return json from rails.
Then parse it in your Unity3D app. Many json parsers are available. I used LitJson in a project and I think it is quite easy to work with.
Use UnityEngine.WWW to get the json you need.
I have an app that uses a sync function where all the content is saved locally from a server (CMS).
On the server I have text, images and videos. The script is downloading all that info and then is saving the text in text files and images and videos as bytes. In the editor and on android is working well and my question is how I can use an alternative to File.writeAllBytes for the web player. I searched a lot for solutions but I didn't find any. How I can access the file system on local storage from the web player or how can I use the cache system for this?
How I can access the file system on local storage from the web player
For security reasons, games run via the Unity Web Player are not given direct access to the file system. Unity's built-in PlayerPrefs system does allow you to store some data locally, but it only supports a few primitive types, and the Web Player limits the data to 1 MB.
It doesn't sound like you're using AssetBundles, but in case you are, the WWW class has a function LoadFromCacheOrDownload that can do some local caching. I'm not aware of any specific reason to limit that function to AssetBundles, but I would speculate that it was originally meant to push devs into buying the Pro license.
You can call JavaScript on the page that's hosting the game, with Application.ExternalCall and Application.ExternalEval, and the page itself can also send messages to the game by interacting with the web player object. I'm not a particularly savvy JS developer, but that may open up some other workarounds.
These limitations may impact your design options.
So I'm making a online chat program.
Technologies: -AJAX(methodology) -PHP -C# -ASP.net -JQuery -HTML5 -MYSQL -IIS
Issue (Long):
I've implemented group chat which works fine up to now. My issue is with multi-chat. Mind you I now realize i should have done the entire thing in PHP, but only knew ASP.net and C# when i started and will end up using PHP only, as a last resort. Anyway, when a multi-chat window is made, it injects the pre-made code via jquery into a div, stores it in sessionStorage for when the page refreshes, it loads the code from sessionstorage, and all ID's are incremented by one, for each user to have a max of 6 windows open at any given time. Now i'm trying to get specific query's for each specific users request like "SELECT * WHERE user1 privateChatID = '1' AND user2 privateChatID = '1'; (not the actual query, just pseudo code)", but since i'm using AJAX to get the query, I cant really manipulate the php file since it's loaded because the main file is a .aspx page. Now for group chat I'm using an update panel which works fine, but i can't dynamically make a draggable chat window, inside the update panel, because I'd have to use an ' runat="server" ' attribute, and if i run that in the pre-scripted jquery and wanted to increment the ID (like so: 'IDName "+ i +"'), visual studio/iis gives an error, hence the reason i'm trying to use Ajax. So all the problems I've worked out so far, once i get a working version I'll probably rethink the whole structure all together. My only issue now:
Issue (short):
Would it be easier since i can't manupulate functions or variables in the php file, to just select everything from the DB ('message table') and sort everything client side? or would that not be optimal? OR is there a way to alter query's externally for a php file that is loaded by jquery?
So my solution was to create php files on the server that would have their own queries, and users would have their own directories on the server for those files and i guess any other files that might need to be added to them in the future if any. I'm taking a chance if the load of bandwidth is too much because a number of users will be creating files on the server, when a chat window is create, i don't even know how secure it'll be but it's working for the time being, i'll tweak security issues, after i can get everything working.
I want to create a very simple online high score table for my recently developed game in Windows 8 (C# and XAML).
What's the easiest and fastet way to do this?
WITHOUT A DOUBT WINDOWS AZURE MOBILE SERVICES, and yes I'm shouting :)
All of the infrastructure you need is provided in the cloud, and you get a client SDK that makes recording the score literally a one-liner. Take a look a my blog post on doing exactly this (along with incorporating push notifications). The post covers an HTML 5/JavaScript game, but I think you'll easily be able to translate to C#/XAML.
Windows Azure Mobile Services is free*, you can get access with the Windows Azure 3-month trial offer, and after that expires you're service remains free (although you will pay for data, in your case probably $5 a month)
I would use HttpClient and simple PHP script that would be reciving scores with post method and second one that would be displaying these scores.
The first thing you need is a server that is up ALL the time and able to handle the traffic. I use Godaddy hosting. Its cheap and great service and easy to ftp to.
Next you need a php page.
The php page should grab GET data out of the URL regarding the score and user info
There are a couple ways you can implement the score recording.
1. You could have the receiving php page alter and sort a master file that contains a userid and score list
2. You could have the receiving php page save a unique txt file for each player id and stick their score in it. Then when your app calls for the scores it can pull all of the txt files and sort them on the phone.
Personally I prefer way one.
Finally you need a domain name that you can point your app too. You will need a directory for sending info and one for receiving.
I glossed over a TON of stuff. An experienced developer could do this in a day. To debug it though it would take some time. Good luck
If you're used to C#, build an ASP.NET MVC web application. You can develop and test this locally without going live. MVC may have a tough learning curve, but it's a great framework, and uses technologies you may already be familiar with as a C# coder, such as Linq. You need a database, and Visual Studio should help you get started with all of this.
You want a post or get controller action, with a url like http://server.com/scores/player1. An HTTP GET on that url could return the view of the scores, whereas a post to that url with parameters of, say, difficulty=easy and score=1100.
Your game client could use either WebClient (simpler) or HttpWebRequest for finer control. Build a class that encapsulates the scoring interaction, with a method that can get all high scores, and another method that sends a new score to the scoring server with args playername and score.
Get that up and going as a demo on your localhost, then maybe think about how to restrict players from posting their own scores, like having the game client authenticate with the server.
use service , or httpclient to update the score
Xbox live services have leader-boards support. Since you have a Win8 game you should look at this video from //build 2012 : Building Cross-Device Xbox Games, they get into useful details around 30 min into the video.