[engine] 支持高 DPI 渲染

This commit is contained in:
SmallMain
2022-06-25 00:52:17 +08:00
parent 9447c862bf
commit bfbb3511eb
6 changed files with 96 additions and 13 deletions

View File

@@ -587,6 +587,13 @@ let Label = cc.Class({
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
},
enableRetina: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
notify(oldValue) {
this.setVertsDirty();
}
},
},
statics: {

View File

@@ -439,6 +439,26 @@ let RichText = cc.Class({
}
}
},
enableRetina: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
notify: function (oldValue) {
if (this.enableRetina === oldValue) return;
for (let i = 0; i < this._labelSegments.length; i++) {
const labelComponent = this._labelSegments[i].getComponent(cc.Label);
if (labelComponent) {
labelComponent.enableRetina = this.enableRetina;
}
}
for (let i = 0; i < this._labelSegmentsCache.length; i++) {
const labelComponent = this._labelSegmentsCache[i].getComponent(cc.Label);
if (labelComponent) {
labelComponent.enableRetina = this.enableRetina;
}
}
}
},
},
statics: {
@@ -1053,6 +1073,7 @@ let RichText = cc.Class({
labelComponent.autoSwitchMaterial = this.autoSwitchMaterial;
labelComponent.allowDynamicAtlas = this.allowDynamicAtlas;
labelComponent.enableRetina = this.enableRetina;
// 更新材质
if (this.customMaterial) {