Unity WriteAllBytes Web Player alternative - c#

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.

Related

How should I store images for my website/app?

My team and I (all students, this is a college project) are creating a software, that's basically 2 frontends (a website and an app) connected to a backend through an API. We have the entity user in this software, and one of its properties its image since we expect to have a lot of users, We don't think storing the images directly on the database it's the best thing.
So in this kind of cases what should we do ? What's the best practice ? (all the components are going to be deployed so local storing it's not really an option).
(We had in mind to get some 3rd party service where we could upload the images and just store the link in the DB, but is this possible? is this fine?).
You can consider using cloud storage like
Amazon S3 (https://aws.amazon.com/s3/)
Google Cloud Bucket (https://cloud.google.com/storage/docs/creating-buckets)
Microsoft Azure Storage (https://learn.microsoft.com/en-us/azure/storage/common/storage-introduction)
They have some free of charge for experiments/learnings but you also need to be aware of charge fees after some certain usages limits. They're using cloud computing, so you don't need to worry about the performance.
Another choice that you can build your own image server and serve images directly to your website. The benefits could be
Having the same connection directly to your website via domains (faster than cloud sometimes)
You can flexibly control your image sizes/types according to your image requests. For example, you can convert your images to WebP or compress them to fit users' local devices
Of course, with this way, you need to have knowledge about building an image server.
there are many different cloud storage services that you can use to host images for your project. most popular of them is imgbb & imgur . I've been using them for a long time and they work great. Both have api's which are very simple to implement. If its your first time using them, you might want to watch a tutorial on youtube . Hopefully this helped you.

Developing a C# reporting tool - should I use Google Analytics?

I need to develop or obtain a reporting tool that will allow us to obtain information to answer the following questions:
Frequency of use (Must)
Usage of application on a person level (Must)
Successful pages/slides (frequency of use) (Must)
Who updated the application software (Must)
Who updated the application content (Must)
Popular in which regions (Must)
Number of people who download the app vs number of people who own a device Must)
Time spent using the app (Should)
Exit pages (Should)
Number of users of share function (Should)
Number of users of search function (Should)
Time taken to update the app (software) (Should)
Time taken to update the app (content) (Should)
Use of media types (video) (Should)
Use of media types (downloads) (Should)
Average number of pages/slides visited (Could)
Number of users of feedback button (Could)
Environment app is being used (customer, office, MyCompanysOffice) (Could)
The application is a simple installer that communicates with a REST service to download and install HTML and media content, which the user browses LOCALLY. The app provides a kind of on-demand service for downloading and viewing content.
Media formats include mp4, docx, pdf, ppt which are viewed by launching media player, adobe etc.
The use of Google Analytics has been put forward as reporting tool, but I'm not sure if this would be appropriate for the following reasons:
1. GA is a tool for monitoring website traffic rather than user activity
2. GA is not really intended for tracking local pages ie ones using the file:// protocol (although I think it may be possible with one or two hacks)
My specific questions are - would Google Analytics be appropriate for generating reports of the information I described?
Would it be better/simpler to obtain this information through the logging (eg via log4net) and generate a report from that?
Is there another, better tool I could be using to generate these reports?
I can recommend Application Insights for application telemetry (performance, user activity etc). It very flexible and configurable and i think you can make it fit your needed measurements.
You can read more about Microsofts Application Insights service here: https://azure.microsoft.com/en-us/services/application-insights/

How to save/ load game data for webGL

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.

how to implement video webcast on the website?

we have a video file which we have to "webcast" on the website (ASP.NET MVC 4 C#) to about 1000 users. I have absolutely no idea how to do this. I'm looking for answers to the following questions:
How webcasts are implemented in general? what are keywords I should be googling for?
How to synchronize video streams sent to different users?
How much computing power do I need for 1000 users? Need a rough answer of course. One server, or tens of servers.
any links, blog articles etc would be appreciated.
Thank you.
In general webcasts are implemented where there is a client software that sends tcp packets of stream data to server and server represents those packets as moving pictures.
In theory they already should be synchronized since you don't send the full video, you only send the current packets that are then buffered and represented as moving pictures. There will always be inconstancy in milliseconds because you cannot control every users ping to server.
It all depends on quality of your video as well as your webserver. No one will give you straight answer, you should always profile your applications on your own and see what bests fits your needs.
Since you are using C# MVC it is coupled with IIS, and IIS has something they call IIS Media Services that does exactly what you need. Definitely check it out.
Also you should check out c# live streadming in google, I found very interesting approach right here.
Well, as a streaming media person, here are my suggestions.
You could do a "live" webcast or an on-demand webcast depending on your choice. Live means, if you have a video file, you could broadcast it to multiple users at once and all will see it as if watching in a TV. They cannot pause your video. Normally, only live events are being broadcasted like this, unless you have a specific reason to broadcast an existing video file as a "fake" live broadcast.
You could use Windows Media Server (Add the media role in Windows Server 2003/2008/2012). Configuring and starting a windows media server needs intermediate level of familiarity with the streaming process, server, firewalls, exceptions. You have a lot of configurations which you can manage in this way, and generally suggested if you are very serious about your streaming. RTSP saves a lot of bandwidth for you too.
You could use Flash Media Server/Wowza media Server, Real Streaming Server also inplace of Windows media server.
For limited number of users, you can download the free Windows media Encoder, and select your file to be streamed, and click to stream easily. This is the easiest.
You could use managed streaming services from few thirdparties, like Livestream, Brightcove etc to stream video files.. Once you signup with them, the will give you an FTP/web space to upload your files, and they provide a link to the file (streaming media link). This link, you could embed in any popular player (like JWPlayer or any of that kind), and embed your player in your webpage for your users to start seeing the media. This is the most easy way to set it up. Maybe you can even get a 15 day trial services from brightcove or Mogolous.
Hope this answers your question.

Creating an online high score table

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.

Categories