diff --git a/ShadowEditor.Web/src/component/MMDComponent.js b/ShadowEditor.Web/src/component/MMDComponent.js index 3648ac39..d54095b7 100644 --- a/ShadowEditor.Web/src/component/MMDComponent.js +++ b/ShadowEditor.Web/src/component/MMDComponent.js @@ -76,6 +76,25 @@ MMDComponent.prototype.render = function () { text: '选择', onClick: this.selectCameraAnimation.bind(this) }] + }, { + xtype: 'row', + children: [{ + xtype: 'label', + text: '音频' + }, { + xtype: 'input', + id: 'audio', + scope: this.id, + disabled: true, + style: { + width: '80px', + fontSize: '12px' + } + }, { + xtype: 'button', + text: '选择', + onClick: this.selectAudio.bind(this) + }] }] }; @@ -108,6 +127,7 @@ MMDComponent.prototype.updateUI = function () { var animation = UI.get('animation', this.id); var cameraAnimation = UI.get('cameraAnimation', this.id); + var audio = UI.get('audio', this.id); if (this.selected.userData.Animation) { animation.setValue(this.selected.userData.Animation.Name); @@ -120,6 +140,12 @@ MMDComponent.prototype.updateUI = function () { } else { cameraAnimation.setValue(''); } + + if (this.selected.userData.Audio) { + audio.setValue(this.selected.userData.Audio.Name); + } else { + audio.setValue(''); + } }; // ----------------------------- 模型动画 ------------------------------------------ @@ -162,4 +188,20 @@ MMDComponent.prototype.onSelectCameraAnimation = function (data) { this.updateUI(); }; +// ------------------------------ MMD音乐 -------------------------------------------- + +MMDComponent.prototype.selectAudio = function () { + this.app.call(`selectBottomPanel`, this, 'audio'); + UI.msg('请点击MMD动画对应的音频!'); + this.app.on(`selectAudio.${this.id}`, this.onSelectAudio.bind(this)); +}; + +MMDComponent.prototype.onSelectAudio = function (data) { + this.app.on(`selectAudio.${this.id}`, null); + + this.selected.userData.Audio = {}; + Object.assign(this.selected.userData.Audio, data); + this.updateUI(); +}; + export default MMDComponent; \ No newline at end of file