diff --git a/editor/inspector/assets/image.js b/editor/inspector/assets/image.js index 2a3add79db1..da4c804e330 100644 --- a/editor/inspector/assets/image.js +++ b/editor/inspector/assets/image.js @@ -327,26 +327,22 @@ exports.methods = { // any -> sprite : texture.wrapMode -> Clamp if (['sprite-frame', 'texture'].includes(this.meta.userData.type)) { const textureKey = Editor.Utils.UUID.nameToSubId('texture'); - let wrapModeCache; - if (this.meta.subMetas[textureKey]) { - const textureUUID = this.meta.subMetas[textureKey].uuid; - wrapModeCache = await Editor.Profile.getConfig('inspector', `${textureUUID}.texture.wrapMode`); - } - if (!wrapModeCache) { - // use default wrapMode if not changed - const wrapModeName = this.meta.userData.type === 'texture' ? 'Repeat' : 'Clamp'; - this.metaList.forEach((meta) => { - const data = ModeMap.wrap[wrapModeName]; - if (!meta.subMetas[textureKey]) { - meta.subMetas[textureKey] = { - userData: {} - } - } + // use default wrapMode if not changed + const wrapModeName = this.meta.userData.type === 'texture' ? 'Repeat' : 'Clamp'; + this.metaList.forEach(async (meta) => { + const data = ModeMap.wrap[wrapModeName]; + if (!meta.subMetas[textureKey]) { + meta.subMetas[textureKey] = { + userData: {}, + }; + } + let wrapModeCache = await Editor.Profile.getConfig('inspector', `${meta.uuid}@${textureKey}.texture.wrapMode`, 'default'); + if (!wrapModeCache) { for (const key of Object.keys(data)) { meta.subMetas[textureKey].userData[key] = data[key]; } - }); - } + } + }); } if (this.originImageType === 'sprite-frame' || this.meta.userData.type === 'sprite-frame') { const changeTypes = ['texture', 'normal map', 'texture cube', 'sprite-frame']; diff --git a/editor/inspector/assets/texture/texture.js b/editor/inspector/assets/texture/texture.js index d666c55d174..e53026b585f 100644 --- a/editor/inspector/assets/texture/texture.js +++ b/editor/inspector/assets/texture/texture.js @@ -335,15 +335,15 @@ const Elements = { panel.userDataList.forEach((userData) => { const value = event.target.value; if (!value) { - // 没勾选 生成 mipmaps,不显示 mipfilter 选项 + // Generate mipmaps is unchecked, and the mipfilter option is not displayed userData.mipfilter = 'none'; panel.$.generateMipmapsSection.style.display = 'none'; } else { panel.$.generateMipmapsSection.style.display = 'block'; - // 为空的话默认 nearest + // Defaults to nearest if empty if (panel.$.mipfilterSelect.value === 'none') { panel.$.mipfilterSelect.value = 'nearest'; - // TODO: 目前 ui-select 通过 .value 修改组件值后没有触发 change 事件,需要手动提交 + // TODO: Currently, ui-select does not trigger the change event after modifying the component value via .value, so you need to submit it manually panel.$.mipfilterSelect.dispatch('change'); } } @@ -360,7 +360,7 @@ const Elements = { panel.$.generateMipmapsCheckbox.value = panel.userData.mipfilter ? panel.userData.mipfilter !== 'none' : false; - // 更新时判断是否显示 mipfilter 选项 + // Determine whether to display the mipfilter option on update panel.$.generateMipmapsCheckbox.value ? (panel.$.generateMipmapsSection.style.display = 'block') : (panel.$.generateMipmapsSection.style.display = 'none'); @@ -396,7 +396,7 @@ const Elements = { panel.$.mipfilterSelect.value = panel.userData.mipfilter || 'nearest'; - // 临时记录 mipfilter 配置 + // temporary logging of mipfilter panel.metaList && panel.metaList.forEach((meta) => { Editor.Profile.setConfig('inspector', `${meta.uuid}.texture.mipfilter`, panel.userData.mipfilter, 'default'); }); @@ -410,10 +410,12 @@ const Elements = { const panel = this; panel.$.wrapModeSelect.addEventListener('change', (event) => { - // 根据 wrapModeSelect 组合值同步相应的 wrapModeS/wrapModeT 到 userData + // Synchronize the corresponding wrapModeS/wrapModeT to userData based on the wrapModeSelect combination const value = event.target.value; - // 临时记录用户的修改配置 - Editor.Profile.setConfig('inspector', `${this.meta.uuid}.texture.wrapMode`, value, 'default'); + // temporary logging of wrapMode + this.metaList && this.metaList.forEach((meta) => { + Editor.Profile.setConfig('inspector', `${meta.uuid}.texture.wrapMode`, value, 'default'); + }); if (ModeMap.wrap[value]) { panel.userDataList.forEach((userData) => { const data = ModeMap.wrap[value]; @@ -423,10 +425,10 @@ const Elements = { }); panel.$.wrapAdvancedSection.style.display = 'none'; } else { - // 选择 advanced 显示自定义项 + // Select advanced to display customized items panel.$.wrapAdvancedSection.style.display = 'block'; } - // 校验是否显示警告提示 + // Calibrate whether to display a warning Elements.warnWords.update.call(panel); panel.dispatch('change'); }); @@ -439,14 +441,13 @@ const Elements = { const panel = this; let optionsHtml = ''; - // WrapMode 选项 const types = Object.keys(ModeMap.wrap).concat('Advanced'); types.forEach((type) => { optionsHtml += ``; }); panel.$.wrapModeSelect.innerHTML = optionsHtml; - // 匹配 wrapModeSelect 值,没有匹配到组合,则为自定义 Advanced + // Match wrapModeSelect value, no combination matched, then custom Advanced let value = 'Advanced'; for (const wrapKey of Object.keys(ModeMap.wrap)) { const wrapItem = ModeMap.wrap[wrapKey]; @@ -464,12 +465,12 @@ const Elements = { } panel.$.wrapModeSelect.value = value; - // 更新时需要判断是否显示自定义项 + // Determine whether to display customized items when updating value === 'Advanced' ? (panel.$.wrapAdvancedSection.style.display = 'block') : (panel.$.wrapAdvancedSection.style.display = 'none'); - // 校验是否显示警告提示 + // Calibrate whether to display a warning panel.updateInvalid(panel.$.wrapModeSelect, 'wrapMode'); updateElementReadonly.call(panel, panel.$.wrapModeSelect); },