Domanda

I have no experience with Unity3D so figured I would ask here.

I have an application built in Unity3D that allows the user to save a file at some point. This file can then be loaded back into the application for use later. Works fine in the iOS version of the app. However I also have the application embedded in a browser using webplayer.

When embedded I am unable to load files into the application due to, what I assume to be, security/browser restrictions.

So, is there a way to fix this, or is there a way to have a normal html form and have this allow the file to be uploaded and opened within the application?

Any help would be greatly appreciated :)

È stato utile?

Soluzione

Basically, you have two good ways to solve that issue.

1) The easiest with minimal work is to use PlayerPrefs for storing player progress data. You can use it on standalone build as well, and you don't have to worry about saving any files then. On web player, there are however few limits:

WebPlayer
On Web players, PlayerPrefs are stored in binary files in the following locations:

Mac OS X: ~LibraryPreferencesUnityWebPlayerPrefs
Windows: %APPDATA%\Unity\WebPlayerPrefs

There is one preference file per Web player URL and the file size is limited to 1 megabyte. If this limit is exceeded, SetInt, SetFloat and SetString will not store the value and throw a PlayerPrefsException.

Good to remember is to make sure you encrypt your values, to prevent cheating by users.

2) Second option in WebPlayer is to use server to provide authentication and saving progress. It is quite usual for web apps, especially on commercial platforms like Facebook.

This option is more versatile, because user can play from any desktop and he will always have access to his saves, where with PlayerPrefs it would be very hard to achieve.

On WebPlayer it is very difficult to force user to save anything because of the security limits. Solutions like providing user with save-download link and then reuploading it manually seems as very bad option, and it probably would involve a server anyway.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top