游戏虚荣一直停在java download fileasset file

I've begun work on trying to answer thequestions I gatheredconcerning Cordova's FileSystem support. As I work through the questions I'm trying to build &real& samples to go along with the text. My first sample is a simple one, but I think it is pretty relevant for the types of things folks may do with Cordova and the file system - checking to see if a file exists locally and if not - fetching it.I'll begin by sharing the code and then explaining the parts. Here is the entire JavaScript file for the application.document.addEventListener(&deviceready&, init, false);//Will be a directory entry object for our data storevar storeOb;//Used for status updatesvar $//URL of our assetvar assetURL = &/cfjedimaster/Cordova-Examples/master/readme.md&;//File name of our important data file we didn't ship with the appvar fileName = &data.txt&;function init() {
$status = document.querySelector(&#status&); $status.innerHTML = &Checking for data file.&; //The directory to store data var store = cordova.file.dataD //The Object version - no error handler because this must work window.resolveLocalFileSystemURL(store, function(ob) {
//Let's check the directory to see if our file exists
storeOb.getFile(fileName, {create:false}, function(f) {
console.log('yes, the file existed');
appStart();
}, function(e) {
console.log('file did not exist');
$status.innerHTML = &We need to download the file.&;
downloadAsset();
}); });}function downloadAsset() { var fileTransfer = new FileTransfer(); console.log(&About to start transfer&); console.log(&dest: &+storeOb.fullPath + fileName); console.log(&dest: &+storeOb.toURL() + fileName); fileTransfer.download(assetURL, storeOb.toURL() + fileName,
function(entry) {
console.log(&Success!&);
appStart();
function(err) {
console.log(&Error&);
console.dir(err);
});}//I'm only called when the file exists or has been downloaded.function appStart() { $status.innerHTML = &App ready!&;}Ok, let's break it down. The first step is to check to see if our file exists already. The question is - where should we store the file? If you look at thedocs for the FileSystem, you will see that the latest version of the plugin adds some useful aliases for common folders. Unfortunately, the docs are not exactly clear about how some of these aliases work. I asked for help (both on the PhoneGap Google group and the Cordova development list) and got some good responses from Kerri Shotts and Julio Sanchez.The directory that I thought made sense, cordova.file.applicationStorageDirectory, is incorrectly documented as being writeable in iOS. A pull request has already been filed to fix this mistake. For my application, the most appropriate directory is the next one, cordova.file.dataDirectory. Once I have my directory alias, I can transform it into a DirectoryEntry object. This then lets me use the getFile API to see if the file exists.If the file does not exist, we then have to download it. For this we use a second plugin,FileTransfer. This is where one more confusion comes in. We need to convert that DirectoryEntry object earlier, the one we used to get an API for files and directories, back to a URL so we can give a path to the Download API.So to recap - we've got a few moving parts here. We've got a directory alias, built into the plugin for easily finding common folders for our application. Again, the docs here are currently a bit wrong but they should be corrected soon. We can use that alias to get access to the directory and check for files. We can also use the directory to get a proper URL (local file URL) to use with FileTransfer calls.Simple... but even a simple application caused me a bit of trouble, so hopefully this helps other. You can get the full source code here:/cfjedimaster/Cordova-Examples/tree/master/checkanddownload
无相关信息Navigation
Unity Account
You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio.
Sell Assets
Whether you're a programmer, game designer, texture artist or 3D modeler, you’re welcome to share your creations with everybody in the Unity developer community!
You can sell 3D models, editor extensions, audio and many other types of content. It’s easy – just submit your awesome creations to the Asset Store and we’ll take care of the rest. You can actually make enough money to !
Once your submission is reviewed, you are free to set your own price for the asset. You’ll receive a 70% cut of each sale, which we pay out monthly or quarterly, depending on your selected payment method. Don’t forget to read the default
that covers end-user use of the assets you sell.
Submitting your content to the Asset Store:
If you do not yet have an Unity Account, you can create one .
Carefully read the
for legal information, and the
to learn about the submission process.
If you are not already registered as an Asset Store Publisher login with your Unity Account
and create an Asset Store Publisher Account.
Package Manager to create or update your package metadata and upload key images, screenshots, etc. ensuring that all the content you provide matches the specifications in the .
Open the Asset Store inside Unity and download and import the
into the project containing the content you want to submit to the Asset Store. Use the Asset Store Tools Package Upload tool to upload your content and associate it with the package you created.
Package Manager to submit your package. The Asset Store team will then review your submission!
Already a Publisher?
Existing publishers can access the Asset Store administration page here.
Quick links
About Unity
Get Unity news
I agree to the
and the processing and use of my information
Nearly there...
To start receiving news from Unity Technologies, click on the link we've sent to your e-mail account.
Something went wrong, please try again.
Copyright & 2015 Unity Technologies
have been updated.
We use cookies to ensure that we give you the best experience on our website. Click
for more information.Unity3d动态数据管理(2)Download AssetBundles
终于!!!
编辑:www.fx114.net
本篇文章主要介绍了"Unity3d动态数据管理(2)Download AssetBundles
终于!!!",主要涉及到Unity3d动态数据管理(2)Download AssetBundles
终于!!!方面的内容,对于Unity3d动态数据管理(2)Download AssetBundles
终于!!!感兴趣的同学可以参考一下。
我们在使用Unity3D制作大型场景的时候,往往需要加载大容量的数据文件,特别是对于三维数据而言,模型、材质、贴图、特效等资源都是组成项目不可或缺的一部分。数据体量越大,数据加载就越明显。对于良好的人机交互体验而言,让用户处于长时间的等待,是一种非常差的体验感,很多用户很可能就是因为没有耐心等待,就直接关闭你的应用,离开。
&&&所以,做任何的项目之前,必须要先解决场景数据管理的问题。针对Unity3D而言,该引擎提供了一种称为AssetBundles的外部整合数据,可以让我们把编辑器中的物件分门别类的输出,这种方法是目前为止最好的管理unity3D的方法,如果还有好的,请大家多多推荐。
&&&这种称为AssetBundles的东西,其实是一种文件格式unity3d,它能在需要的时候重新被加载到场景中,而这种文件格式可以是模型、贴图、声音,甚至是场景文件。虽然看上去,输出这种类型的文件对于整个场景资源是一种浪费,但其简便的使用方法,不失为一种有效地入门手段。
&&&项目组在开发阶段,AssetBundles数据资源通过unity3D编辑器被分别输出出来,这部分是本文的重点。然后通过一些外部的上传方法,存储到服务器中,这部分unity3D本身并没有提供,可以使用的方法很多,比如FTP、ASP结合数据库等。
上图表示项目开发阶段,开发者通过AsserBundles来建立数据文件,并上传到服务器的工作流程。
&&&项目运行阶段,用户首先通过局域网、互联网来下载数据资源AssetBundles,一旦下载完毕后,就可以对数据资源进行加载等一系列操作。
上图表示项目运行阶段,使用者通过AssetBundles,实现数据资源动态加载、管理的目的。
&&&下面演示创建AssetBundles的过程和方法:
&&&在AssetBundles中,共有三种方法来创建数据资源。
&&&实例如下:
&&&现在unity3d的帮助文档BuildPipeline.BuildAssetBundle中,复制以下C#代码。
// C# Example
// Builds an asset bundle from the selected objects in the project view.
// Once compiled go to &Menu& -& &Assets& and select one of the choices
// to build the Asset Bundle
using UnityE
using UnityE
public class ExportAssetBundles {
&&&[MenuItem(&Assets/Build AssetBundle From Selection - Track dependencies&)]
&&&static void ExportResource () {
&&&&&&&// Bring up save panel
&&&&&&&string path = EditorUtility.SaveFilePanel (&Save Resource&, &&, &New Resource&, &unity3d&);
&&&&&&&if (path.Length != 0) {
&&&&&&&&&&&// Build the resource file from the active selection.
&&&&&&&&&&&Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
&&&&&&&&&&&BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | pleteAssets);
&&&&&&&&&&&Selection.objects =
&&&[MenuItem(&Assets/Build AssetBundle From Selection - No dependency tracking&)]
&&&static void ExportResourceNoTrack () {
&&&&&&&// Bring up save panel
&&&&&&&string path = EditorUtility.SaveFilePanel (&Save Resource&, &&, &New Resource&, &unity3d&);
&&&&&&&if (path.Length != 0) {
&&&&&&&&&&&// Build the resource file from the active selection.
&&&&&&&&&&&BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path);
以上为代码部分
&&&在unity3d编辑器中,新建C# script,取名为ExportAssetBundles,该脚本必须存储在unity3d项目(Project)面板的Editor目录下,如下图所示。
&&&这时候,在菜单Assets中,我们会发现多了两项新的菜单列表,如下图所示。
&&&在这个例子中,我们在编辑器中创建一个cube,通过菜单GameObject - Create Other - Cube,在层级视图(Hierachy View)中,会创建了一个新的cube物体,把他拖动到项目视图(Project View)中,称为预置物(Prefabs)。在项目视图中,鼠标右键点击cube,选择Build AssetBundle From Selection - Track dependencies,生成数据资源,并把它存储到项目的AssetBundles目录中,如下图所示。
&&&生成完毕的Cube.unity3d文件,可以根据项目的要求,存储到磁盘的任何位置,或者上传到服务器。
&&&这种手动存储的方法,在项目建立之初能快速的帮助项目建立原型,但随着资源文件的壮大,通过手动来输出明显是不可能的。比较有效的方法,就是写一个函数,来自动创建项目中所有的AssetBundles,同时用一个text文本来标示项目中要创建数据资源的列表清单。
本文标题:
本页链接:Grails Plugin: Asset Pipeline Plugin
Asset Pipeline Plugin
Latest: 2.4.3
Last Updated: 29 July 2015
Grails version: 2.2 > *
Authors: David Estes, Brian Wheeler
Organization:
Dependency:
compile ":asset-pipeline:2.4.3"
The Asset-Pipeline is a plugin used for managing and processing static assets in Grails applications. Asset-Pipeline functions include processing and minification of both CSS and JavaScript files. It is also capable of being extended to compile custom static assets, such as CoffeeScript.
Description
Asset Pipeline is intended to replace the defacto Grails equivalent (`resources-plugin`) with a more efficient, developer friendly architecture (similar to rails asset-pipeline). The asset-pipeline levereges the latest in minification (UglifyJS) to reduce your asset sizes as much as possible. A few differences between the resources plugin and asset-pipeline include:
On the fly processing - No more waiting for your assets to reload after making a change
Compiled assets on war create - No more hanging up application boot times while processing files. `grails war`
Reduced Dependence - The plugin has compression, minification, and cache-digests built in.
Easy Debugging - Makes for easy debugging by keeping files seperate in development mode.
Simpler manifests and taglibs - Read on for more information.
Asset-Pipeline automatically creates a series of folders within your grails-app directory: grails-app/assets/javascript , grails-app/assets/images, grails-app/assets/stylesheetsPlace your static assets in those directories and simply include them into your layouts. Asset pipeline supports setting up manifests using these files.Example 'grails-app/javascripts/application.js'://This is a javascript file with its top level require directives
//= require jquery
//= require app/models.js
//= require_tree views
//= require_selfconsole.log("This is my javascript manifest");The above is an example of some of the require directives that can be used. Custom directives can be created and overridden into the DirectiveProcessor class.Optionally, assets can be excluded from processing if included by your require tree. This can dramatically reduce compile time for your assets. To do so simply leverage the excludes configuration option:grails.assets.excludes = ["tiny_mce/src/*.js"]Including Assets in your ViewsAsset pipeline provides several new tag libs for including javascript and css into your gsp files.Example:
<head>
<asset:javascript src="application.js"/>
<asset:stylesheet href="application.css"/>
</head>These helpers will automatically adjust to point to the cache-digested versions of the files when running in a non-development environment.NOTE: In development mode your stylesheets and javascripts will be included as individual script tags. This is intended to make it easier for debugging. Bundling is enabled in all other environments and can be forced in development mode by adding grails.assets.bundle=true to your Config.groovy.Precompiling For Production
Assets are now compiled upon war generation into target/assets. This can be done by running: grails warDuring war build your assets are also minified using UglifierJs. To disable this feature you can add the following option to your config:grails.assets.minifyJs = falseServing Assets from External Storage DirectoryAsset Pipeline can be configured to copy your assets files out into an external storage path. This can be useful for setting up your web server (i.e. Nginx) to directly server your static assets. To do so, simply define a config variable in your Config.groovy environment blockenvironments {
production {
grails.assets.storagePath = "/full/path/to/storage"
}It is also possible to configure a custom CDN asset url for serving this assets:environments {
production {
grails.assets.url = "/asset-pipe/assets"
}Custom FilesAsset Pipeline uses a Class type called AssetFile. These AssetFiles are included into the AssetHelper.assetSpecs static array. By default, this plugin comes with a JsAssetFile, and CssAssetFile. These define the match pattern syntax for understanding requires directives, known extensions, processors, and content-type. The application bases its file look-up on content-type of the request rather than extension. This allows the user to, for example, define a CoffeeAssetFile with the javascript content type and a request to localhost/assets/app.js would be able to find assets/app.coffee.

我要回帖

更多关于 java download file 的文章

 

随机推荐