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

Fix the issue of update the wrapMode after changing the image type #16315

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions editor/inspector/assets/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
nianba23 marked this conversation as resolved.
Show resolved Hide resolved
}
}
let wrapModeCache = await Editor.Profile.getConfig('inspector', `${meta.uuid}@${textureKey}.texture.wrapMode`, 'default');
nianba23 marked this conversation as resolved.
Show resolved Hide resolved
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'];
Expand Down
4 changes: 3 additions & 1 deletion editor/inspector/assets/texture/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,9 @@ const Elements = {
// 根据 wrapModeSelect 组合值同步相应的 wrapModeS/wrapModeT 到 userData
const value = event.target.value;
// 临时记录用户的修改配置
Editor.Profile.setConfig('inspector', `${this.meta.uuid}.texture.wrapMode`, value, 'default');
this.metaList && this.metaList.forEach((meta) => {
Editor.Profile.setConfig('inspector', `${meta.uuid}.texture.wrapMode`, value, 'default');
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this data for the interface temporary? Would it be better to put it in 'Temp'?
这个数据是界面用的临时数据吧?放到 Temp 会不会更好?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Temporary data is stored in the 'default' and is only valid for the current session. It won't be remembered next time. So, there is no need to store it in 'temp' for long-term recording.

});
if (ModeMap.wrap[value]) {
panel.userDataList.forEach((userData) => {
const data = ModeMap.wrap[value];
Expand Down