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

fixed material not save correctly #4390

Merged
merged 1 commit into from May 15, 2019

Conversation

@2youyou2
Copy link
Collaborator

commented May 7, 2019

Re: cocos-creator/2d-tasks#1394

Changes:

  • fixed material not save correctly

@2youyou2 2youyou2 requested review from pandamicro and caryliu1999 May 7, 2019

}
else {
material = Material.getInstantiatedMaterial(material, this);
}

let texture = spriteFrame.getTexture();
material.setProperty('texture', texture);
material.define('USE_TEXTURE', true);

This comment has been minimized.

Copy link
@2youyou2

2youyou2 May 7, 2019

Author Collaborator

如果用户创建了一个默认的 sprite 材质并且赋值给了 CCSprite 的 Materials ,这时 USE_TEXTURE 是为 false 的,都需要打开这个开关

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 May 8, 2019

Contributor

如果用户创建了一个默认的 sprite 材质并且赋值给了 CCSprite 的 Materials ,这时 USE_TEXTURE 是为 false 的,都需要打开这个开关

  • 这里如果是内置的builtin-gray-sprite,因为没有USE_TEXTURE的定义会一直输出not found的警告,有没有影响?

This comment has been minimized.

Copy link
@2youyou2

2youyou2 May 13, 2019

Author Collaborator

是的,这就要在 builtin-gray-sprite 也加一个 USE_TEXTURE 定义了,或者定义 sprite material 就需要用到 texture ,其他的再加个材质

}
else {
material = Material.getInstantiatedMaterial(material, this);
}

let texture = spriteFrame.getTexture();
material.setProperty('texture', texture);
material.define('USE_TEXTURE', true);

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 May 8, 2019

Contributor

如果用户创建了一个默认的 sprite 材质并且赋值给了 CCSprite 的 Materials ,这时 USE_TEXTURE 是为 false 的,都需要打开这个开关

  • 这里如果是内置的builtin-gray-sprite,因为没有USE_TEXTURE的定义会一直输出not found的警告,有没有影响?
let texture = spriteFrame.getTexture();
material.setProperty('texture', texture);
material.define('USE_TEXTURE', true);
material.setProperty('texture', spriteFrame.getTexture());

This comment has been minimized.

Copy link
@caryliu1999

caryliu1999 May 8, 2019

Contributor
  • 直接把spriteFrame的texture作为材质纹理的话,会覆盖掉材质在编辑器里设置好的texture,2D这边的设想是不是完全忽略材质本身绑定的texture资源?

This comment has been minimized.

Copy link
@2youyou2

2youyou2 May 13, 2019

Author Collaborator

是的,这样也不用添加一个 sprite 就要用户新建一个材质(因为 texture 不一样)

@pandamicro

This comment has been minimized.

Copy link
Member

commented May 9, 2019

现在如果按照引擎逻辑去设置用户材质的 property,对用户来说有什么意义呢?

@pandamicro

This comment has been minimized.

Copy link
Member

commented May 9, 2019

或者说,用户自己挂载材质的用例是什么?

@2youyou2

This comment has been minimized.

@pandamicro

This comment has been minimized.

Copy link
Member

commented May 13, 2019

但是用户实际上失去了对 mainTexture 和 一些 Define 的控制了是吧?

@2youyou2

This comment has been minimized.

Copy link
Collaborator Author

commented May 13, 2019

但是用户实际上失去了对 mainTexture 和 一些 Define 的控制了是吧?

是的,我觉得使用 render component 上的属性更符合习惯,不过需要强制定义 USE_TEXTURE 就不太友好了,所以分开材质实现可能更好

@pandamicro

This comment has been minimized.

Copy link
Member

commented May 15, 2019

嗯,这个你判断就好,我合并了

@pandamicro pandamicro merged commit c77880a into cocos-creator:v2.1.2 May 15, 2019

1 check passed

ci/circleci: test Your tests passed on CircleCI!
Details

jareguo added a commit that referenced this pull request May 16, 2019

Merge v2.1.2 into v2.2.0
* commit '0cebb2d032bac98d68ea986eb4625d690e0bbaf2':
  fixed material not save correctly (#4390)
  refine CCAudio code (#4407)
  fix richtext code err (#4225) (#4414)
  fixed set  node.z has no effect (#4408)
  save eulerAngles instead of quaternion for node (#4383)
  fix auido code noteGrainOn error (#4406)
  compatible with old webgl (#4394)
  fixed webview and video player display wrong in editor (#4386)

# Conflicts:
#	cocos2d/core/CCNode.js
#	extensions/spine/Skeleton.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.