A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: add TextInput component and plugin
esengine0fe56b8faac5
diff --git a/editor/src/panels/inspector/InspectorHelpers.ts b/editor/src/panels/inspector/InspectorHelpers.tsindex fc3143341..e11a7355c 100644--- a/editor/src/panels/inspector/InspectorHelpers.ts+++ b/editor/src/panels/inspector/InspectorHelpers.ts@@ -139,6 +139,7 @@ export function getComponentIcon(type: string): string {case 'Camera':return icons.camera(14);case 'Text':+ case 'TextInput':return icons.type(14);default:return icons.settings(14);diff --git a/sdk/src/app.ts b/sdk/src/app.tsindex 98ff2898d..9fa8c15a0 100644--- a/sdk/src/app.ts+++ b/sdk/src/app.ts@@ -11,6 +11,7 @@ import { textPlugin } from './ui/TextPlugin';import { uiMaskPlugin } from './ui/UIMaskPlugin';import { uiInteractionPlugin } from './ui/UIInteractionPlugin';import { uiLayoutPlugin } from './ui/UILayoutPlugin';+import { textInputPlugin } from './ui/TextInputPlugin';import { UICameraInfo } from './ui/UICameraInfo';import { inputPlugin } from './input';import { assetPlugin } from './asset';@@ -378,6 +379,7 @@ export function createWebApp(module: ESEngineModule, options?: WebAppOptions): Aapp.addPlugin(uiMaskPlugin);app.addPlugin(uiLayoutPlugin);app.addPlugin(uiInteractionPlugin);+ app.addPlugin(textInputPlugin);return app;}diff --git a/sdk/src/core.ts b/sdk/src/core.tsindex 17c2bf35e..1563c5534 100644--- a/sdk/src/core.ts+++ b/sdk/src/core.ts@@ -200,6 +200,9 @@ export {uiLayoutPlugin,UIInteractionPlugin,uiInteractionPlugin,+ TextInput,+ TextInputPlugin,+ textInputPlugin,type TextData,type UIRectData,type UIMaskData,@@ -214,6 +217,7 @@ export {type UICameraData,type LayoutRect,type LayoutResult,+ type TextInputData,} from './ui';// =============================================================================diff --git a/sdk/src/ui/TextInput.ts b/sdk/src/ui/TextInput.tsnew file mode 100644index 000000000..38c52ce3f--- /dev/null+++ b/sdk/src/ui/TextInput.ts@@ -0,0 +1,38 @@+import { defineComponent } from '../component';+import type { Color } from '../types';++export interface TextInputData {+ value: string;+ placeholder: string;+ placeholderColor: Color;+ fontFamily: string;+ fontSize: number;+ color: Color;+ backgroundColor: Color;+ padding: number;+ maxLength: number;+ multiline: boolean;+ password: boolean;+ readOnly: boolean;+ focused: boolean;+ cursorPos: number;+ dirty: boolean;+}++export const TextInput = defineComponent<TextInputData>('TextInput', {+ value: '',+ placeholder: '',+ placeholderColor: { r: 0.6, g: 0.6, b: 0.6, a: 1 },+ fontFamily: 'Arial',+ fontSize: 16,+ color: { r: 1, g: 1, b: 1, a: 1 },+ backgroundColor: { r: 0.15, g: 0.15, b: 0.15, a: 1 },+ padding: 6,+ maxLength: 0,+ multiline: false,+ password: false,+ readOnly: false,+ focused: false,+ cursorPos: 0,+ dirty: true,+});diff --git a/sdk/src/ui/UIEvents.ts b/sdk/src/ui/UIEvents.tsindex 8cb4a2c1a..0541ac542 100644--- a/sdk/src/ui/UIEvents.ts+++ b/sdk/src/ui/UIEvents.ts@@ -1,7 +1,7 @@import { defineResource } from '../resource';import type { Entity } from '../types';-export type UIEventType = 'click' | 'press' | 'release' | 'hover_enter' | 'hover_exit';+export type UIEventType = 'click' | 'press' | 'release' | 'hover_enter' | 'hover_exit' | 'submit' | 'change';export interface UIEvent {entity: Entity;diff --git a/sdk/src/ui/index.ts b/sdk/src/ui/index.tsindex 9749c2e0a..eabfb7f40 100644--- a/sdk/src/ui/index.ts+++ b/sdk/src/ui/index.ts@@ -110,3 +110,15 @@ export {UIInteractionPlugin,uiInteractionPlugin,} from './UIInteractionPlugin';++// TextInput Component+export {+ TextInput,+ type TextInputData,+} from './TextInput';++// TextInput Plugin+export {+ TextInputPlugin,+ textInputPlugin,+} from './TextInputPlugin';