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

V3.8.0 fix edit material cache editing data bug in inspector #15550

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Changes from 3 commits
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
45 changes: 27 additions & 18 deletions editor/inspector/assets/material.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ exports.methods = {
$container.$children[i].querySelectorAll('ui-prop').forEach(($prop) => {
const dump = $prop.dump;
if (dump && dump.childMap && dump.children.length) {
if (!$prop.$children) {
$prop.$children = document.createElement('section');
$prop.$children.setAttribute(
if (!$prop.$childMap) {
$prop.$childMap = document.createElement('section');
$prop.$childMap.setAttribute(
'style',
'margin-left: var(--ui-prop-margin-left, unset);',
);
$prop.$childMap.$props = {};

for (const childName in dump.childMap) {
if (dump.childMap[childName].value === undefined) {
Expand All @@ -335,29 +336,29 @@ exports.methods = {
loopSetAssetDumpDataReadonly(dump.childMap[childName]);
}

$prop.$children[childName] = document.createElement('ui-prop');
$prop.$children[childName].setAttribute('type', 'dump');
$prop.$children[childName].render(dump.childMap[childName]);
$prop.$children.appendChild($prop.$children[childName]);
$prop.$childMap.$props[childName] = document.createElement('ui-prop');
$prop.$childMap.$props[childName].setAttribute('type', 'dump');
$prop.$childMap.$props[childName].render(dump.childMap[childName]);
$prop.$childMap.appendChild($prop.$childMap.$props[childName]);
}

if (Array.from($prop.$children.children).length) {
$prop.after($prop.$children);
if (Array.from($prop.$childMap.children).length) {
$prop.after($prop.$childMap);
}

$prop.addEventListener('change-dump', (e) => {
if (e.target.dump.value) {
$prop.$children.removeAttribute('hidden');
$prop.$childMap.removeAttribute('hidden');
} else {
$prop.$children.setAttribute('hidden', '');
$prop.$childMap.setAttribute('hidden', '');
}
});
}

if (dump.value) {
$prop.$children.removeAttribute('hidden');
$prop.$childMap.removeAttribute('hidden');
} else {
$prop.$children.setAttribute('hidden', '');
$prop.$childMap.setAttribute('hidden', '');
}
}
});
Expand All @@ -366,7 +367,11 @@ exports.methods = {
// when passes length more than one, the ui-section of pipeline state collapse
if (technique.passes.length > 1) {
$container.querySelectorAll('[cache-expand$="PassStates"]').forEach(($pipelineState) => {
$pipelineState.removeAttribute('expand');
const cacheExpand = $pipelineState.getAttribute('cache-expand');
if (!this.defaultCollapsePasses[cacheExpand]) {
$pipelineState.expand = false;
this.defaultCollapsePasses[cacheExpand] = true;
}
});
}
}
Expand Down Expand Up @@ -410,7 +415,6 @@ exports.methods = {
'children',
'defines',
'extends',
'pipelineStates',
];

const cacheData = this.cacheData;
Expand All @@ -434,7 +438,7 @@ exports.methods = {
cacheData[name] = {};
}

const { type, value } = prop[name];
const { type, value, isObject } = prop[name];
if (type && value !== undefined) {
if (!cacheData[name][passIndex]) {
if (name === 'USE_INSTANCING' && passIndex !== 0) {
Expand All @@ -449,7 +453,9 @@ exports.methods = {
}
}

if (prop[name].childMap && typeof prop[name].childMap === 'object') {
if (isObject) {
cacheProperty(value, passIndex);
} else if (prop[name].childMap && typeof prop[name].childMap === 'object') {
cacheProperty(prop[name].childMap, passIndex);
}
}
Expand Down Expand Up @@ -503,7 +509,9 @@ exports.methods = {
}
}

if (prop[name].childMap && typeof prop[name].childMap === 'object') {
if (prop[name].isObject) {
updateProperty(prop[name].value, passIndex);
} else if (prop[name].childMap && typeof prop[name].childMap === 'object') {
updateProperty(prop[name].childMap, passIndex);
}
}
Expand Down Expand Up @@ -578,6 +586,7 @@ exports.update = async function(assetList, metaList) {
* Method of initializing the panel
*/
exports.ready = function() {
this.defaultCollapsePasses = {};
this.canUpdatePreview = false;
// Used to determine whether the material has been modified in isDirty()
this.dirtyData = {
Expand Down