52 lines
1.9 KiB
Markdown
52 lines
1.9 KiB
Markdown
# UIExtension UXController 数据驱动绑定模块手册
|
|
|
|
## 模块概述
|
|
`UXController` 与 `UXBinding` 组成 UI 状态驱动绑定系统,用于把控制器状态映射到 UI 属性值。
|
|
|
|
## 适用场景
|
|
- 页签状态切换。
|
|
- UI 主题或皮肤切换。
|
|
- 可见性、文本、颜色、尺寸等属性联动。
|
|
|
|
## 可调用 API
|
|
### 类型:`UXController`
|
|
源码:`Packages/com.alicizax.unity.ui.extension/Runtime/UXComponent/Controller/UXController.cs`
|
|
- 属性:`Controllers`、`Bindings`、`ControllerCount`
|
|
- `ControllerDefinition` 属性:`Id`、`Name`、`Length`、`Description`、`SelectedIndex`
|
|
- 方法:`TryGetControllerById(...)`、`TryGetControllerByName(...)`、`GetControllerByName(...)`、`GetControllerAt(...)`、`GetControllerIndex(...)`、`SetControllerIndex(...)`、`SetControllerIndexByName(...)`、`ResetAllControllers()`
|
|
|
|
### 类型:`UXBinding`
|
|
源码:`Packages/com.alicizax.unity.ui.extension/Runtime/UXComponent/Controller/UXBinding.cs`
|
|
- 属性:`Controller`、`Entries`
|
|
- 方法:`Initialize()`、`SetController(...)`、`CaptureDefaults()`、`ResetToDefaults()`、`PreviewEntry(...)`、`CaptureEntryValue(...)`、`CaptureEntryFallbackValue(...)`
|
|
- `BindingEntry` 属性:`ControllerId`、`ControllerIndex`、`Property`、`Value`、`FallbackMode`、`FallbackValue`、`HasCapturedDefault`
|
|
|
|
### 类型:`UXBindingValue`
|
|
- `BoolValue`
|
|
- `FloatValue`
|
|
- `StringValue`
|
|
- `ColorValue`
|
|
- `Vector2Value`
|
|
- `Vector3Value`
|
|
- `ObjectValue`
|
|
- `CopyFrom(UXBindingValue other)`
|
|
|
|
### 工具类:`UXBindingPropertyUtility`
|
|
源码:`Packages/com.alicizax.unity.ui.extension/Runtime/UXComponent/Controller/UXBindingPropertyUtility.cs`
|
|
- `AllMetadata`
|
|
- `GetMetadata(...)`
|
|
- `IsSupported(...)`
|
|
- `GetSupportedProperties(...)`
|
|
- `CaptureValue(...)`
|
|
- `ApplyValue(...)`
|
|
|
|
### 枚举
|
|
- `UXBindingFallbackMode`
|
|
- `UXBindingValueKind`
|
|
- `UXBindingProperty`
|
|
|
|
## 快速上手
|
|
```csharp
|
|
controller.SetControllerIndex("TabState", 1);
|
|
```
|