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
Contributor

@2youyou2 2youyou2 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);
Copy link
Contributor Author

@2youyou2 2youyou2 May 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Loading

Copy link
Contributor

@caryliu1999 caryliu1999 May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Loading

Copy link
Contributor Author

@2youyou2 2youyou2 May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Loading

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

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

@caryliu1999 caryliu1999 May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Loading

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

@caryliu1999 caryliu1999 May 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Loading

Copy link
Contributor Author

@2youyou2 2youyou2 May 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Loading

@pandamicro
Copy link
Member

@pandamicro pandamicro commented May 9, 2019

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

Loading

@pandamicro
Copy link
Member

@pandamicro pandamicro commented May 9, 2019

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

Loading

@2youyou2
Copy link
Contributor Author

@2youyou2 2youyou2 commented May 13, 2019

Loading

@pandamicro
Copy link
Member

@pandamicro pandamicro commented May 13, 2019

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

Loading

@2youyou2
Copy link
Contributor Author

@2youyou2 2youyou2 commented May 13, 2019

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

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

Loading

@pandamicro
Copy link
Member

@pandamicro pandamicro commented May 15, 2019

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

Loading

@pandamicro pandamicro merged commit c77880a into cocos-creator:v2.1.2 May 15, 2019
1 check passed
Loading
jareguo added a commit that referenced this issue May 16, 2019
* 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
@2youyou2 2youyou2 deleted the v2.1.2-material branch Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants