-
+
@@ -35,7 +35,7 @@ exports.template = `
-
+
@@ -46,7 +46,7 @@ exports.template = `
-
+
@@ -288,7 +288,7 @@ const Elements = {
},
};
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -302,7 +302,7 @@ exports.update = function (assetList, metaList) {
}
};
-exports.ready = function () {
+exports.ready = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.ready) {
@@ -311,7 +311,7 @@ exports.ready = function () {
}
};
-exports.close = function () {
+exports.close = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.close) {
diff --git a/editor/inspector/assets/fbx/preview.js b/editor/inspector/assets/fbx/preview.js
index 29d42f8ecc..5d12d43d5f 100644
--- a/editor/inspector/assets/fbx/preview.js
+++ b/editor/inspector/assets/fbx/preview.js
@@ -86,29 +86,29 @@ exports.$ = {
const Elements = {
playButton: {
- ready () {
+ ready() {
this.$.playButton.addEventListener('confirm', this.onPlayButtonClick.bind(this));
},
},
stopButton: {
- ready () {
+ ready() {
this.$.stopButton.addEventListener('confirm', this.onStopButtonClick.bind(this));
},
},
animationTimeSlider: {
- ready () {
+ ready() {
const slider = this.$.animationTimeSlider;
slider.addEventListener('change', this.onAnimationTimeSliderChange.bind(this));
},
},
preview: {
- ready () {
+ ready() {
const panel = this;
panel.$.canvas.addEventListener('mousedown', async (event) => {
await Editor.Message.request('scene', 'on-model-preview-mouse-down', { x: event.x, y: event.y });
- async function mousemove (event) {
+ async function mousemove(event) {
await Editor.Message.request('scene', 'on-model-preview-mouse-move', {
movementX: event.movementX,
movementY: event.movementY,
@@ -117,7 +117,7 @@ const Elements = {
panel.isPreviewDataDirty = true;
}
- async function mouseup (event) {
+ async function mouseup(event) {
await Editor.Message.request('scene', 'on-model-preview-mouse-up', {
x: event.x,
y: event.y,
@@ -139,7 +139,7 @@ const Elements = {
panel.glPreview = new GlPreview('scene:model-preview', 'query-model-preview-data');
panel.isPreviewDataDirty = true;
},
- async update () {
+ async update() {
const panel = this;
if (!panel.$.canvas) {
@@ -156,10 +156,10 @@ const Elements = {
},
},
modelInfo: {
- ready () {
+ ready() {
this.infoUpdate = Elements.modelInfo.update.bind(this);
},
- update (info) {
+ update(info) {
if (!info) {
return;
}
@@ -167,13 +167,13 @@ const Elements = {
this.$.triangles.value = `Triangles:${info.polygons}`;
this.isPreviewDataDirty = true;
},
- close () {
+ close() {
Editor.Message.send('scene', 'hide-model-preview');
},
},
};
-exports.update = async function (assetList, metaList) {
+exports.update = async function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -198,7 +198,7 @@ exports.update = async function (assetList, metaList) {
this.refreshPreview();
};
-exports.ready = function () {
+exports.ready = function() {
const panel = this;
this.gridWidth = 0;
@@ -238,7 +238,7 @@ exports.ready = function () {
panel.resizeObserver.observe(panel.$.container);
};
-exports.close = function () {
+exports.close = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.close) {
@@ -255,7 +255,7 @@ exports.close = function () {
};
exports.methods = {
- async refreshPreview () {
+ async refreshPreview() {
const panel = this;
// After await, the panel no longer exists
@@ -296,7 +296,7 @@ exports.methods = {
panel.refreshPreview();
});
},
- async onTabChanged (activeTab) {
+ async onTabChanged(activeTab) {
if (typeof activeTab === 'string') {
this.activeTab = activeTab;
this.$.animationInfo.style.display = this.activeTab === 'animation' ? 'flex' : 'none';
@@ -304,7 +304,7 @@ exports.methods = {
await this.stopAnimation();
}
},
- async onStopButtonClick (event) {
+ async onStopButtonClick(event) {
event.stopPropagation();
if (!this.curEditClipInfo) {
return;
@@ -312,35 +312,35 @@ exports.methods = {
await this.stopAnimation();
},
- async stopAnimation () {
+ async stopAnimation() {
if (!this.curEditClipInfo) {
return;
}
await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'stop');
},
- async onPlayButtonClick (event) {
+ async onPlayButtonClick(event) {
event.stopPropagation();
if (!this.curEditClipInfo) {
return;
}
switch (this.curPlayState) {
- case PLAY_STATE.PAUSE:
- await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'resume');
- break;
- case PLAY_STATE.PLAYING:
- await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'pause');
- break;
- case PLAY_STATE.STOP:
- await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'play', this.curEditClipInfo.clipUUID);
- break;
- default:
- break;
+ case PLAY_STATE.PAUSE:
+ await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'resume');
+ break;
+ case PLAY_STATE.PLAYING:
+ await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'pause');
+ break;
+ case PLAY_STATE.STOP:
+ await Editor.Message.request('scene', 'execute-model-preview-animation-operation', 'play', this.curEditClipInfo.clipUUID);
+ break;
+ default:
+ break;
}
this.isPreviewDataDirty = true;
},
- async onAnimationTimeSliderChange (event) {
+ async onAnimationTimeSliderChange(event) {
event.stopPropagation();
if (!this.curEditClipInfo) {
return;
@@ -352,7 +352,7 @@ exports.methods = {
this.isPreviewDataDirty = true;
},
- onModelAnimationUpdate (time) {
+ onModelAnimationUpdate(time) {
if (!this.curEditClipInfo) {
return;
}
@@ -366,28 +366,28 @@ exports.methods = {
this.isPreviewDataDirty = true;
},
- setCurPlayState (state) {
+ setCurPlayState(state) {
this.curPlayState = state;
let buttonIconName = '';
switch (state) {
- case PLAY_STATE.STOP:
- buttonIconName = 'play';
- break;
- case PLAY_STATE.PLAYING:
- buttonIconName = 'pause';
- break;
- case PLAY_STATE.PAUSE:
- buttonIconName = 'play';
- break;
- default:
- break;
+ case PLAY_STATE.STOP:
+ buttonIconName = 'play';
+ break;
+ case PLAY_STATE.PLAYING:
+ buttonIconName = 'pause';
+ break;
+ case PLAY_STATE.PAUSE:
+ buttonIconName = 'play';
+ break;
+ default:
+ break;
}
if (this.$.playButtonIcon) {
this.$.playButtonIcon.value = buttonIconName;
}
},
- async setCurEditClipInfo (clipInfo) {
+ async setCurEditClipInfo(clipInfo) {
this.curEditClipInfo = clipInfo;
if (clipInfo) {
this.curTotalFrames = Math.round(clipInfo.duration * clipInfo.fps);
@@ -404,7 +404,7 @@ exports.methods = {
await this.stopAnimation();
}
},
- onAnimationPlayStateChanged (state) {
+ onAnimationPlayStateChanged(state) {
this.setCurPlayState(state);
},
};
diff --git a/editor/inspector/assets/image-preview.js b/editor/inspector/assets/image-preview.js
index a94f3755b4..5547d1930b 100644
--- a/editor/inspector/assets/image-preview.js
+++ b/editor/inspector/assets/image-preview.js
@@ -73,7 +73,7 @@ const Elements = {
* @param assetList
* @param metaList
*/
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -90,7 +90,7 @@ exports.update = function (assetList, metaList) {
/**
* Method of initializing the panel
*/
-exports.ready = function () {
+exports.ready = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.ready) {
@@ -99,7 +99,7 @@ exports.ready = function () {
}
};
-exports.close = function () {
+exports.close = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.close) {
diff --git a/editor/inspector/assets/image.js b/editor/inspector/assets/image.js
index b79d9c457f..c7693d4573 100644
--- a/editor/inspector/assets/image.js
+++ b/editor/inspector/assets/image.js
@@ -18,7 +18,7 @@ exports.template = `
-
+
@@ -136,7 +136,7 @@ const Elements = {
* @param assetList
* @param metaList
*/
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -155,7 +155,7 @@ exports.update = function (assetList, metaList) {
/**
* Method of initializing the panel
*/
-exports.ready = function () {
+exports.ready = function() {
for (const prop in Elements) {
const element = Elements[prop];
if (element.ready) {
diff --git a/editor/inspector/assets/javascript.js b/editor/inspector/assets/javascript.js
index d7506f1ba7..bbc481de16 100644
--- a/editor/inspector/assets/javascript.js
+++ b/editor/inspector/assets/javascript.js
@@ -348,7 +348,7 @@ const Elements = {
},
};
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -362,7 +362,7 @@ exports.update = function (assetList, metaList) {
}
};
-exports.ready = function () {
+exports.ready = function() {
for (const key in Elements) {
const element = Elements[key];
if (element.ready) {
diff --git a/editor/inspector/assets/json.js b/editor/inspector/assets/json.js
index 61aa0f2711..f34cfad37a 100644
--- a/editor/inspector/assets/json.js
+++ b/editor/inspector/assets/json.js
@@ -27,11 +27,11 @@ exports.$ = {
code: 'ui-code',
};
-exports.ready = function () {
+exports.ready = function() {
this.code = this.$.code;
};
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.meta = metaList[0];
diff --git a/editor/inspector/assets/label-atlas.js b/editor/inspector/assets/label-atlas.js
index 02f7bde4f3..2c35a88b2b 100644
--- a/editor/inspector/assets/label-atlas.js
+++ b/editor/inspector/assets/label-atlas.js
@@ -127,7 +127,7 @@ exports.methods = {
},
};
-exports.ready = function () {
+exports.ready = function() {
for (const key in Elements) {
if (Elements[key].ready) {
Elements[key].ready.call(this);
@@ -135,7 +135,7 @@ exports.ready = function () {
}
};
-exports.update = function (assetList, metaList) {
+exports.update = function(assetList, metaList) {
this.metaList = metaList;
this.assetList = assetList;
this.meta = metaList[0];
diff --git a/editor/inspector/assets/material-header.js b/editor/inspector/assets/material-header.js
index 88a8b50d56..898013d7a0 100644
--- a/editor/inspector/assets/material-header.js
+++ b/editor/inspector/assets/material-header.js
@@ -1,7 +1,12 @@
'use strict';
exports.style = `
-:host > .section { height: 200px; display: flex; }
+:host > .section {
+ height: 200px;
+ display: flex;
+ background: var(--color-normal-fill);
+ border-bottom: 1px solid var(--color-normal-border);
+ }
:host > .section > canvas { flex: 1; min-width: 0; }
:host > .section > .tools { display: flex; flex-direction: column; padding: 6px 4px; }
`;
@@ -32,8 +37,8 @@ exports.$ = {
};
exports.methods = {
- hideAllContent (hide) {
- this.$.container.style= hide ? 'display:none' : '';
+ hideAllContent(hide) {
+ this.$.container.style = hide ? 'display:none' : '';
},
async refreshPreview() {
const panel = this;
@@ -78,7 +83,7 @@ exports.methods = {
const panel = this;
panel.isPreviewDataDirty = true;
- }
+ },
};
/**
@@ -86,7 +91,7 @@ exports.methods = {
* @param assetList
* @param metaList
*/
-exports.update = async function (assetList, metaList) {
+exports.update = async function(assetList, metaList) {
const panel = this;
panel.assetList = assetList;
@@ -112,7 +117,7 @@ exports.update = async function (assetList, metaList) {
/**
* Method of initializing the panel
*/
-exports.ready = async function () {
+exports.ready = async function() {
const panel = this;
Editor.Message.request('scene', 'set-material-preview-light-enable', true);
@@ -171,7 +176,7 @@ exports.ready = async function () {
Editor.Message.addBroadcastListener('material-inspector:change-dump', this.updatePreviewDataDirtyBind);
};
-exports.close = function () {
+exports.close = function() {
const panel = this;
panel.resizeObserver.unobserve(panel.$.container);
diff --git a/editor/inspector/assets/material.js b/editor/inspector/assets/material.js
index cb24671de7..65c6f93670 100644
--- a/editor/inspector/assets/material.js
+++ b/editor/inspector/assets/material.js
@@ -127,17 +127,17 @@ exports.methods = {
$container.$children = {};
}
- let i = 0;
- for (i; i < technique.passes.length; i++) {
+ for (let i = 0; i < technique.passes.length; i++) {
+ const pass = technique.passes[i];
// If the propertyIndex is not equal to the current pass index, then do not render
- if (technique.passes[i].propertyIndex !== undefined && technique.passes[i].propertyIndex.value !== i) {
+ if (pass.propertyIndex !== undefined && pass.propertyIndex.value !== i) {
continue;
}
// if asset is readonly
if (this.asset.readonly) {
- for (const key in technique.passes[i].value) {
- loopSetAssetDumpDataReadonly(technique.passes[i].value[key]);
+ for (const key in pass.value) {
+ loopSetAssetDumpDataReadonly(pass.value[key]);
}
}
@@ -145,7 +145,24 @@ exports.methods = {
$container.$children[i].setAttribute('type', 'dump');
$container.$children[i].setAttribute('fold', 'false');
$container.appendChild($container.$children[i]);
- $container.$children[i].render(technique.passes[i]);
+ $container.$children[i].render(pass);
+
+ // Add the checkbox given by the switch attribute
+ if (pass.switch && pass.switch.name) {
+ const $checkbox = document.createElement('ui-checkbox');
+ $checkbox.innerText = pass.switch.name;
+ $checkbox.setAttribute('slot', 'header');
+ $checkbox.addEventListener('change', (e) => {
+ pass.switch.value = e.target.value;
+ });
+ setReadonly(this.asset.readonly, $checkbox);
+
+ const $section = $container.$children[i].querySelector('ui-section');
+ $section.appendChild($checkbox);
+
+ const $label = $section.querySelector('ui-label');
+ $label.style.width = 'calc(var(--left-width) - 10px)';
+ }
$container.$children[i].querySelectorAll('ui-prop').forEach(($prop) => {
const dump = $prop.dump;
@@ -162,6 +179,10 @@ exports.methods = {
continue;
}
+ if (this.asset.readonly) {
+ loopSetAssetDumpDataReadonly(dump.childMap[childName]);
+ }
+
$prop.$children[childName] = document.createElement('ui-prop');
$prop.$children[childName].setAttribute('type', 'dump');
$prop.$children[childName].render(dump.childMap[childName]);
@@ -211,7 +232,8 @@ exports.methods = {
updateTechniqueOptions() {
let techniqueOption = '';
this.material.data.forEach((technique, index) => {
- techniqueOption += ``;
+ const name = technique.name ? `${index} - ${technique.name}` : index;
+ techniqueOption += ``;
});
this.$.technique.innerHTML = techniqueOption;
},
@@ -227,7 +249,7 @@ exports.methods = {
* @param assetList
* @param metaList
*/
-exports.update = async function (assetList, metaList) {
+exports.update = async function(assetList, metaList) {
this.assetList = assetList;
this.metaList = metaList;
this.asset = assetList[0];
@@ -243,6 +265,7 @@ exports.update = async function (assetList, metaList) {
}
this.material = await Editor.Message.request('scene', 'query-material', this.asset.uuid);
+ await Editor.Message.request('scene', 'preview-material', this.asset.uuid);
// effect