@eva/plugin-renderer-text 2.0.1-beta.22 → 2.0.1-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -126,6 +126,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
126
126
|
} else {
|
|
127
127
|
yield this.addHTMLTextComponent(changed);
|
|
128
128
|
}
|
|
129
|
+
this.setSize(changed);
|
|
129
130
|
} else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
130
131
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
131
132
|
this.texts[changed.gameObject.id].text.destroy({
|
|
@@ -134,7 +135,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
134
135
|
delete this.texts[changed.gameObject.id];
|
|
135
136
|
} else {
|
|
136
137
|
this.change(changed);
|
|
137
|
-
this.setSize(changed);
|
|
138
138
|
const component = changed.component;
|
|
139
139
|
if (changed.prop.prop[0] === 'style' && component.style && component.style.fontFamily) {
|
|
140
140
|
const {
|
|
@@ -142,6 +142,7 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
142
142
|
} = this.texts[changed.gameObject.id];
|
|
143
143
|
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
144
144
|
}
|
|
145
|
+
this.setSize(changed);
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
148
|
}
|
|
@@ -158,7 +159,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
158
159
|
text,
|
|
159
160
|
component
|
|
160
161
|
};
|
|
161
|
-
this.setSize(changed);
|
|
162
162
|
if (fontFamily) {
|
|
163
163
|
yield this.waitForFontResource(text, changed, fontFamily);
|
|
164
164
|
}
|
|
@@ -182,7 +182,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
182
182
|
text: htmlText,
|
|
183
183
|
component
|
|
184
184
|
};
|
|
185
|
-
this.setSize(changed);
|
|
186
185
|
if (fontFamily) {
|
|
187
186
|
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
188
187
|
}
|
|
@@ -201,7 +200,6 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
201
200
|
const component = this.texts[changed.gameObject.id].component;
|
|
202
201
|
text.style.fontFamily = fontFamily;
|
|
203
202
|
text.text = component.text;
|
|
204
|
-
this.setSize(changed);
|
|
205
203
|
} catch (error) {
|
|
206
204
|
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
207
205
|
}
|
|
@@ -239,8 +237,12 @@ var _EVA_IIFE_text = function (exports, pixi_js, eva_js, pluginRenderer, rendere
|
|
|
239
237
|
transform
|
|
240
238
|
} = changed.gameObject;
|
|
241
239
|
if (!transform) return;
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
const {
|
|
241
|
+
text
|
|
242
|
+
} = this.texts[changed.gameObject.id];
|
|
243
|
+
const size = text.getSize();
|
|
244
|
+
transform.size.width = size.width;
|
|
245
|
+
transform.size.height = size.height;
|
|
244
246
|
}
|
|
245
247
|
};
|
|
246
248
|
Text.systemName = 'Text';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,i,o){"use strict";function s(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function r(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function c(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,c)}l((i=i.apply(t,e||[])).next())}))}function c(t){return function(e,n){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);i.key=n,i.type=t}}class l extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),i={};for(const t in n)0===t.indexOf("_")&&(i[t.substring(1)]=n[t]);delete i.styleKey,this.style=i,t&&(this.text=t.text,_extends(this.style,t.style))}}l.componentName="Text",s([c("string")],l.prototype,"text",void 0);class a extends n.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}a.componentName="HTMLText",s([c("string")],a.prototype,"text",void 0);let d=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return r(this,void 0,void 0,(function*(){const e="Text"===t.componentName,i="HTMLText"===t.componentName;if(e||i)if(t.type===n.OBSERVER_TYPE.ADD)e?yield this.addTextComponent(t):yield this.addHTMLTextComponent(t);else if(t.type===n.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(t.gameObject.id).removeChild(this.texts[t.gameObject.id].text),this.texts[t.gameObject.id].text.destroy({children:!0}),delete this.texts[t.gameObject.id];else{this.change(t)
|
|
1
|
+
function _extends(){return _extends=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)({}).hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},_extends.apply(null,arguments)}globalThis.EVA=globalThis.EVA||{},globalThis.EVA.plugin=globalThis.EVA.plugin||{},globalThis.EVA.plugin.renderer=globalThis.EVA.plugin.renderer||{};var _EVA_IIFE_text=function(t,e,n,i,o){"use strict";function s(t,e,n,i){var o,s=arguments.length,r=s<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(r=(s<3?o(r):s>3?o(e,n,r):o(e,n))||r);return s>3&&r&&Object.defineProperty(e,n,r),r}function r(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{l(i.next(t))}catch(t){s(t)}}function c(t){try{l(i.throw(t))}catch(t){s(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,c)}l((i=i.apply(t,e||[])).next())}))}function c(t){return function(e,n){var i=function(t,e){return t.constructor.IDEProps||(t.constructor.IDEProps={}),t.constructor.IDEProps[e]||(t.constructor.IDEProps[e]={}),t.constructor.IDEProps[e]}(e,n);i.key=n,i.type=t}}class l extends n.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),i={};for(const t in n)0===t.indexOf("_")&&(i[t.substring(1)]=n[t]);delete i.styleKey,this.style=i,t&&(this.text=t.text,_extends(this.style,t.style))}}l.componentName="Text",s([c("string")],l.prototype,"text",void 0);class a extends n.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(t){this.style=_extends({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==t?void 0:t.style),this.textureStyle=_extends({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==t?void 0:t.textureStyle),t&&(this.text=t.text)}}a.componentName="HTMLText",s([c("string")],a.prototype,"text",void 0);let d=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(t){return r(this,void 0,void 0,(function*(){const e="Text"===t.componentName,i="HTMLText"===t.componentName;if(e||i)if(t.type===n.OBSERVER_TYPE.ADD)e?yield this.addTextComponent(t):yield this.addHTMLTextComponent(t),this.setSize(t);else if(t.type===n.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(t.gameObject.id).removeChild(this.texts[t.gameObject.id].text),this.texts[t.gameObject.id].text.destroy({children:!0}),delete this.texts[t.gameObject.id];else{this.change(t);const e=t.component;if("style"===t.prop.prop[0]&&e.style&&e.style.fontFamily){const{text:n}=this.texts[t.gameObject.id];yield this.waitForFontResource(n,t,e.style.fontFamily)}this.setSize(t)}}))}addTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),i=n.fontFamily;delete n.fontFamily;const s=i?"":e.text,r=new o.Text(s,n);this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},i&&(yield this.waitForFontResource(r,t,i))}))}addHTMLTextComponent(t){return r(this,void 0,void 0,(function*(){const e=t.component,n=_extends({},e.style),i=n.fontFamily;delete n.fontFamily;const s=i?"":e.text,r=new o.HTMLText(_extends({text:s,style:n},e.textureStyle&&{textureStyle:e.textureStyle}));this.containerManager.getContainer(t.gameObject.id).addChildAt(r,0),this.texts[t.gameObject.id]={text:r,component:e},i&&(yield this.waitForFontResource(r,t,i))}))}waitForFontResource(t,e,i){return r(this,void 0,void 0,(function*(){if(i)try{const o=Array.isArray(i)?i[0]:i,s=this.increaseAsyncId(e.gameObject.id);if(yield n.resource.getResource(o),!this.validateAsyncId(e.gameObject.id,s))return;const r=this.texts[e.gameObject.id].component;t.style.fontFamily=i,t.text=r.text}catch(t){console.warn(`字体资源 ${i} 加载失败:`,t)}}))}change(t){const{text:e,component:n}=this.texts[t.gameObject.id],i="HTMLText"===t.componentName;if("text"===t.prop.prop[0])e.text=n.text;else if("style"===t.prop.prop[0])_extends(e.style,n.style);else if("textureStyle"===t.prop.prop[0]&&i){const i=n,s=this.containerManager.getContainer(t.gameObject.id),r=s.getChildIndex(e);s.removeChild(e),e.destroy({children:!0});const c=new o.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});s.addChildAt(c,r),this.texts[t.gameObject.id].text=c}}setSize(t){const{transform:e}=t.gameObject;if(!e)return;const{text:n}=this.texts[t.gameObject.id],i=n.getSize();e.size.width=i.width,e.size.height=i.height}};d.systemName="Text",d=s([n.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],d);var x=d;return t.HTMLText=a,t.Text=l,t.TextSystem=x,Object.defineProperty(t,"__esModule",{value:!0}),t}({},PIXI,EVA,EVA.plugin.renderer,EVA.rendererAdapter);globalThis.EVA.plugin.renderer.text=globalThis.EVA.plugin.renderer.text||_EVA_IIFE_text;
|
|
@@ -111,6 +111,7 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
111
111
|
else {
|
|
112
112
|
yield this.addHTMLTextComponent(changed);
|
|
113
113
|
}
|
|
114
|
+
this.setSize(changed);
|
|
114
115
|
}
|
|
115
116
|
else if (changed.type === eva_js.OBSERVER_TYPE.REMOVE) {
|
|
116
117
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
@@ -119,12 +120,12 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
119
120
|
}
|
|
120
121
|
else {
|
|
121
122
|
this.change(changed);
|
|
122
|
-
this.setSize(changed);
|
|
123
123
|
const component = changed.component;
|
|
124
124
|
if (changed.prop.prop[0] === 'style' && component.style && component.style.fontFamily) {
|
|
125
125
|
const { text } = this.texts[changed.gameObject.id];
|
|
126
126
|
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
127
127
|
}
|
|
128
|
+
this.setSize(changed);
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
131
|
}
|
|
@@ -141,7 +142,6 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
141
142
|
text,
|
|
142
143
|
component,
|
|
143
144
|
};
|
|
144
|
-
this.setSize(changed);
|
|
145
145
|
if (fontFamily) {
|
|
146
146
|
yield this.waitForFontResource(text, changed, fontFamily);
|
|
147
147
|
}
|
|
@@ -160,7 +160,6 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
160
160
|
text: htmlText,
|
|
161
161
|
component,
|
|
162
162
|
};
|
|
163
|
-
this.setSize(changed);
|
|
164
163
|
if (fontFamily) {
|
|
165
164
|
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
166
165
|
}
|
|
@@ -180,7 +179,6 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
180
179
|
const component = this.texts[changed.gameObject.id].component;
|
|
181
180
|
text.style.fontFamily = fontFamily;
|
|
182
181
|
text.text = component.text;
|
|
183
|
-
this.setSize(changed);
|
|
184
182
|
}
|
|
185
183
|
catch (error) {
|
|
186
184
|
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
@@ -215,8 +213,10 @@ let Text = class Text extends pluginRenderer.Renderer {
|
|
|
215
213
|
const { transform } = changed.gameObject;
|
|
216
214
|
if (!transform)
|
|
217
215
|
return;
|
|
218
|
-
|
|
219
|
-
|
|
216
|
+
const { text } = this.texts[changed.gameObject.id];
|
|
217
|
+
const size = text.getSize();
|
|
218
|
+
transform.size.width = size.width;
|
|
219
|
+
transform.size.height = size.height;
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
Text.systemName = 'Text';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("pixi.js"),t=require("@eva/eva.js"),n=require("@eva/inspector-decorator"),i=require("@eva/plugin-renderer"),s=require("@eva/renderer-adapter");
|
|
2
2
|
/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -13,4 +13,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
13
13
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
14
14
|
and limitations under the License.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
function o(e,t,i
|
|
16
|
+
function o(e,t,n,i){var s,o=arguments.length,r=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,i);else for(var c=e.length-1;c>=0;c--)(s=e[c])&&(r=(o<3?s(r):o>3?s(t,n,r):s(t,n))||r);return o>3&&r&&Object.defineProperty(t,n,r),r}function r(e,t,n,i){return new(n||(n=Promise))((function(s,o){function r(e){try{a(i.next(e))}catch(e){o(e)}}function c(e){try{a(i.throw(e))}catch(e){o(e)}}function a(e){e.done?s(e.value):new n((function(t){t(e.value)})).then(r,c)}a((i=i.apply(e,t||[])).next())}))}class c extends t.Component{constructor(){super(...arguments),this.text="",this.style={}}init(t){const n=new e.TextStyle({fontSize:20}),i={};for(const e in n)0===e.indexOf("_")&&(i[e.substring(1)]=n[e]);delete i.styleKey,this.style=i,t&&(this.text=t.text,Object.assign(this.style,t.style))}}c.componentName="Text",o([n.type("string")],c.prototype,"text",void 0);class a extends t.Component{constructor(){super(...arguments),this.text="",this.style={},this.textureStyle={}}init(e){this.style=Object.assign({fontSize:24,fill:"#000000",fontFamily:"Arial"},null==e?void 0:e.style),this.textureStyle=Object.assign({scaleMode:"linear",resolution:window.devicePixelRatio||1},null==e?void 0:e.textureStyle),e&&(this.text=e.text)}}a.componentName="HTMLText",o([n.type("string")],a.prototype,"text",void 0);let d=class extends i.Renderer{constructor(){super(...arguments),this.name="Text",this.texts={}}init(){this.renderSystem=this.game.getSystem(i.RendererSystem),this.renderSystem.rendererManager.register(this)}componentChanged(e){return r(this,void 0,void 0,(function*(){const n="Text"===e.componentName,i="HTMLText"===e.componentName;if(n||i)if(e.type===t.OBSERVER_TYPE.ADD)n?yield this.addTextComponent(e):yield this.addHTMLTextComponent(e),this.setSize(e);else if(e.type===t.OBSERVER_TYPE.REMOVE)this.containerManager.getContainer(e.gameObject.id).removeChild(this.texts[e.gameObject.id].text),this.texts[e.gameObject.id].text.destroy({children:!0}),delete this.texts[e.gameObject.id];else{this.change(e);const t=e.component;if("style"===e.prop.prop[0]&&t.style&&t.style.fontFamily){const{text:n}=this.texts[e.gameObject.id];yield this.waitForFontResource(n,e,t.style.fontFamily)}this.setSize(e)}}))}addTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,n=Object.assign({},t.style),i=n.fontFamily;delete n.fontFamily;const o=i?"":t.text,r=new s.Text(o,n);this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},i&&(yield this.waitForFontResource(r,e,i))}))}addHTMLTextComponent(e){return r(this,void 0,void 0,(function*(){const t=e.component,n=Object.assign({},t.style),i=n.fontFamily;delete n.fontFamily;const o=i?"":t.text,r=new s.HTMLText(Object.assign({text:o,style:n},t.textureStyle&&{textureStyle:t.textureStyle}));this.containerManager.getContainer(e.gameObject.id).addChildAt(r,0),this.texts[e.gameObject.id]={text:r,component:t},i&&(yield this.waitForFontResource(r,e,i))}))}waitForFontResource(e,n,i){return r(this,void 0,void 0,(function*(){if(i)try{const s=Array.isArray(i)?i[0]:i,o=this.increaseAsyncId(n.gameObject.id);if(yield t.resource.getResource(s),!this.validateAsyncId(n.gameObject.id,o))return;const r=this.texts[n.gameObject.id].component;e.style.fontFamily=i,e.text=r.text}catch(e){console.warn(`字体资源 ${i} 加载失败:`,e)}}))}change(e){const{text:t,component:n}=this.texts[e.gameObject.id],i="HTMLText"===e.componentName;if("text"===e.prop.prop[0])t.text=n.text;else if("style"===e.prop.prop[0])Object.assign(t.style,n.style);else if("textureStyle"===e.prop.prop[0]&&i){const i=n,o=this.containerManager.getContainer(e.gameObject.id),r=o.getChildIndex(t);o.removeChild(t),t.destroy({children:!0});const c=new s.HTMLText({text:i.text,style:i.style,textureStyle:i.textureStyle});o.addChildAt(c,r),this.texts[e.gameObject.id].text=c}}setSize(e){const{transform:t}=e.gameObject;if(!t)return;const{text:n}=this.texts[e.gameObject.id],i=n.getSize();t.size.width=i.width,t.size.height=i.height}};d.systemName="Text",d=o([t.decorators.componentObserver({Text:["text",{prop:["style"],deep:!0}],HTMLText:["text",{prop:["style"],deep:!0},{prop:["textureStyle"],deep:!0}]})],d);var l=d;exports.HTMLText=a,exports.Text=c,exports.TextSystem=l;
|
|
@@ -107,6 +107,7 @@ let Text = class Text extends Renderer {
|
|
|
107
107
|
else {
|
|
108
108
|
yield this.addHTMLTextComponent(changed);
|
|
109
109
|
}
|
|
110
|
+
this.setSize(changed);
|
|
110
111
|
}
|
|
111
112
|
else if (changed.type === OBSERVER_TYPE.REMOVE) {
|
|
112
113
|
this.containerManager.getContainer(changed.gameObject.id).removeChild(this.texts[changed.gameObject.id].text);
|
|
@@ -115,12 +116,12 @@ let Text = class Text extends Renderer {
|
|
|
115
116
|
}
|
|
116
117
|
else {
|
|
117
118
|
this.change(changed);
|
|
118
|
-
this.setSize(changed);
|
|
119
119
|
const component = changed.component;
|
|
120
120
|
if (changed.prop.prop[0] === 'style' && component.style && component.style.fontFamily) {
|
|
121
121
|
const { text } = this.texts[changed.gameObject.id];
|
|
122
122
|
yield this.waitForFontResource(text, changed, component.style.fontFamily);
|
|
123
123
|
}
|
|
124
|
+
this.setSize(changed);
|
|
124
125
|
}
|
|
125
126
|
});
|
|
126
127
|
}
|
|
@@ -137,7 +138,6 @@ let Text = class Text extends Renderer {
|
|
|
137
138
|
text,
|
|
138
139
|
component,
|
|
139
140
|
};
|
|
140
|
-
this.setSize(changed);
|
|
141
141
|
if (fontFamily) {
|
|
142
142
|
yield this.waitForFontResource(text, changed, fontFamily);
|
|
143
143
|
}
|
|
@@ -156,7 +156,6 @@ let Text = class Text extends Renderer {
|
|
|
156
156
|
text: htmlText,
|
|
157
157
|
component,
|
|
158
158
|
};
|
|
159
|
-
this.setSize(changed);
|
|
160
159
|
if (fontFamily) {
|
|
161
160
|
yield this.waitForFontResource(htmlText, changed, fontFamily);
|
|
162
161
|
}
|
|
@@ -176,7 +175,6 @@ let Text = class Text extends Renderer {
|
|
|
176
175
|
const component = this.texts[changed.gameObject.id].component;
|
|
177
176
|
text.style.fontFamily = fontFamily;
|
|
178
177
|
text.text = component.text;
|
|
179
|
-
this.setSize(changed);
|
|
180
178
|
}
|
|
181
179
|
catch (error) {
|
|
182
180
|
console.warn(`字体资源 ${fontFamily} 加载失败:`, error);
|
|
@@ -211,8 +209,10 @@ let Text = class Text extends Renderer {
|
|
|
211
209
|
const { transform } = changed.gameObject;
|
|
212
210
|
if (!transform)
|
|
213
211
|
return;
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
const { text } = this.texts[changed.gameObject.id];
|
|
213
|
+
const size = text.getSize();
|
|
214
|
+
transform.size.width = size.width;
|
|
215
|
+
transform.size.height = size.height;
|
|
216
216
|
}
|
|
217
217
|
};
|
|
218
218
|
Text.systemName = 'Text';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eva/plugin-renderer-text",
|
|
3
|
-
"version": "2.0.1-beta.
|
|
3
|
+
"version": "2.0.1-beta.23",
|
|
4
4
|
"description": "@eva/plugin-renderer-text",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/plugin-renderer-text.esm.js",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"homepage": "https://eva.js.org",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@eva/inspector-decorator": "^0.0.5",
|
|
22
|
-
"@eva/plugin-renderer": "2.0.1-beta.
|
|
23
|
-
"@eva/renderer-adapter": "2.0.1-beta.
|
|
24
|
-
"@eva/eva.js": "2.0.1-beta.
|
|
22
|
+
"@eva/plugin-renderer": "2.0.1-beta.23",
|
|
23
|
+
"@eva/renderer-adapter": "2.0.1-beta.23",
|
|
24
|
+
"@eva/eva.js": "2.0.1-beta.23",
|
|
25
25
|
"pixi.js": "^8.8.1"
|
|
26
26
|
}
|
|
27
27
|
}
|