Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add property 'url' to indecate the true url of native object #4536

Merged
merged 3 commits into from Jun 14, 2019

Conversation

@holycanvas
Copy link
Contributor

commented May 31, 2019

Re: cocos-creator/2d-tasks#

Changes:

  • 给asset增加url属性用于表示真实url,在某些平台上可以直接使用平台api来使用这些url
  • 修改加载字体的timeout时间,之前是60s,造成太长等待时间
  • 修复释放远程图片释放失败的问题

@holycanvas holycanvas force-pushed the holycanvas:v2.1.2 branch from 7ae7b21 to bd0e14c May 31, 2019

@holycanvas holycanvas force-pushed the holycanvas:v2.1.2 branch from bd0e14c to ced44de Jun 4, 2019

* If you want to make use of the native file on those platforms, you should use url instead of nativeUrl.
* !#zh
* 资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。在web平台(web-mobile, web-desktop)或者原生平台(iOS,安卓等)上url与
* nativeUrl是相等的,nativeUrl与url的区别在于,某些带缓存机制的小游戏平台(微信等)上url可能会指向临时文件路径或者缓存路径,如果你需要在这些平台上使用资源的原生文件,

This comment has been minimized.

Copy link
@pandamicro

pandamicro Jun 5, 2019

Member

“原始文件”吧?

This comment has been minimized.

Copy link
@holycanvas

holycanvas Jun 5, 2019

Author Contributor

这里概念不好描述,准确一点的说法应该是原生资源的文件。比如cc.Texture2d的原生资源的文件是图片,但是cc.Texutre2d本身也有个json文件,为了区别这个json和图片,所以描述为“原生”

* @property url
* @type {String}
*/
url: '',

This comment has been minimized.

Copy link
@pandamicro

pandamicro Jun 5, 2019

Member

用户为什么会想要原始资源的 url ?

This comment has been minimized.

Copy link
@holycanvas

holycanvas Jun 5, 2019

Author Contributor

有时候用户想要直接用平台的api处理资源文件,比如播放音频,会需要这个url

// 60 seconds timeout
let _timeout = 60000;
// 3 seconds timeout
let _timeout = 3000;

This comment has been minimized.

Copy link
@jareguo

jareguo Jun 6, 2019

Contributor

如果网络差一点,加载超过 3 秒咋办?

This comment has been minimized.

Copy link
@pandamicro

pandamicro Jun 6, 2019

Member

之前的 60 太长了,这个只能取一个折衷值, @holycanvas 可以测一下一个中文的标准 ttf 文件 加载在 4G 网络环境下需要多久,取一个可以容纳的近似值

This comment has been minimized.

Copy link
@holycanvas

holycanvas Jun 6, 2019

Author Contributor

其实超过三秒也没关系,如果在字体还没加载完成的情况下就进行使用,系统会用默认字体来渲染,等真正字体加载完成后,会替换为正确的字体的,也就是说,在字体比较大的时候,可能会有一段的时间显示的是系统字体,然后突然变成正确的字体。有点类似延迟加载的感觉。关键是想要准确把握这个时间点很麻烦,标准中文字体一般15M以上,4g的网速也就500kb左右,这样至少也要30s的时间,提前进入游戏感觉还是好一点,即便字体不对

This comment has been minimized.

Copy link
@dumganhar

dumganhar Jun 6, 2019

Contributor

没人会为 web 游戏带上一个 15M 的字体的,都是需要裁剪的ttf

This comment has been minimized.

Copy link
@jareguo

jareguo Jun 6, 2019

Contributor

这个时间我没意见,60 确实太长。

* !#zh
* 资源的原生文件的真实url,只在资源被加载后以及没有启用延迟加载时才有效。在web平台(web-mobile, web-desktop)或者原生平台(iOS,安卓等)上url与
* nativeUrl是相等的,nativeUrl与url的区别在于,某些带缓存机制的小游戏平台(微信等)上url可能会指向临时文件路径或者缓存路径,如果你需要在这些平台上使用资源的原生文件,
* 请使用url,避免使用nativeUrl

This comment has been minimized.

Copy link
@jareguo

jareguo Jun 6, 2019

Contributor

赞,很清晰的注释!!!

This comment has been minimized.

Copy link
@baiguo

baiguo Jul 29, 2019

试试看哈。

@jareguo

jareguo approved these changes Jun 6, 2019

// 60 seconds timeout
let _timeout = 60000;
// 3 seconds timeout
let _timeout = 3000;

This comment has been minimized.

Copy link
@pandamicro

pandamicro Jun 6, 2019

Member

之前的 60 太长了,这个只能取一个折衷值, @holycanvas 可以测一下一个中文的标准 ttf 文件 加载在 4G 网络环境下需要多久,取一个可以容纳的近似值

@pandamicro pandamicro merged commit e2b45d1 into cocos-creator:v2.1.2 Jun 14, 2019

1 check passed

ci/circleci: test Your tests passed on CircleCI!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.