Skip to content

Commit

Permalink
feat: add button
Browse files Browse the repository at this point in the history
  • Loading branch information
cptbtptpbcptdtptp committed Nov 5, 2024
2 parents 4d930f2 + 15b8e6c commit 72be260
Show file tree
Hide file tree
Showing 6 changed files with 663 additions and 10 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/2d/text/TextUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Vector2 } from "@galacean/engine-math";
import { Engine } from "../../Engine";
import { UIText } from "../../ui";
import { FontStyle } from "../enums/FontStyle";
import { OverflowMode } from "../enums/TextOverflow";
import { CharInfo } from "./CharInfo";
Expand Down Expand Up @@ -96,7 +97,7 @@ export class TextUtils {
return <CharInfo>TextUtils._measureFontOrChar(fontString, char, true);
}

static measureTextWithWrap(renderer: TextRenderer): TextMetrics {
static measureTextWithWrap(renderer: TextRenderer | UIText): TextMetrics {
const subFont = renderer._getSubFont();
const fontString = subFont.nativeFontString;
const fontSizeInfo = TextUtils.measureFont(fontString);
Expand Down Expand Up @@ -270,7 +271,7 @@ export class TextUtils {
};
}

static measureTextWithoutWrap(renderer: TextRenderer): TextMetrics {
static measureTextWithoutWrap(renderer: TextRenderer | UIText): TextMetrics {
const subFont = renderer._getSubFont();
const fontString = subFont.nativeFontString;
const fontSizeInfo = TextUtils.measureFont(fontString);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/ui/UIImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ export class UIImage extends UIRenderer implements ISpriteRenderer {
this.drawMode = SpriteDrawMode.Simple;
this.setMaterial(this._engine._basicResources.uiDefaultMaterial);
this._onSpriteChange = this._onSpriteChange.bind(this);
//@ts-ignore
this._color._onValueChanged = this._onColorChange.bind(this);
}

protected override _hitTest(localPosition: Vector3): boolean {
Expand Down
Loading

0 comments on commit 72be260

Please sign in to comment.