refactor(ui): 重构 SelectItem 与 SliderItem 适配 Terminal 设置页

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-01 19:02:49 +08:00
co-authored by Cursor
parent 603dc9dad3
commit 4deb565882
7 changed files with 688 additions and 172 deletions
@@ -444,14 +444,14 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 27177156846382951}
- {fileID: 2806314693394340526}
- {fileID: 8177162145044828877}
- {fileID: 7791053714247626159}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_SizeDelta: {x: 1000, y: 60}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4099831927643554877
MonoBehaviour:
@@ -465,18 +465,25 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: ef1de16c90b849ef86a4360768fc55f6, type: 3}
m_Name:
m_EditorClassIdentifier:
prop: WindowMode
label: setting_window
OnValueChanged:
m_PersistentCalls:
m_Calls: []
options:
- prop: Windowed
label: setting_window_windowed
- prop: FullScreen
label: setting_window_fullscreen
- prop: MaximizedWindow
label: setting_window_maximizedWindow
labelText: {fileID: 5006247552854995519}
labelLocalize: {fileID: 1032211294988139403}
showText: {fileID: 3938852416590497403}
showLocalize: {fileID: 8147536583624643951}
leftBtn: {fileID: 2370438686613021399}
rightBtn: {fileID: 1377516604571534447}
selectionBar: {fileID: 7311972616869413698}
selectionBarHiddenAlpha: 0
selectionBarVisibleAlpha: 1
normalTextColor: {r: 1, g: 1, b: 1, a: 1}
hoveredTextColor: {r: 0.02, g: 0.02, b: 0.04, a: 1}
lightRowButtonColors:
m_NormalColor: {r: 0.02, g: 0.02, b: 0.04, a: 1}
m_HighlightedColor: {r: 0.35, g: 0.35, b: 0.4, a: 1}
m_PressedColor: {r: 0.55, g: 0.55, b: 0.6, a: 1}
m_SelectedColor: {r: 0.02, g: 0.02, b: 0.04, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
--- !u!1 &5824775690649857626
GameObject:
m_ObjectHideFlags: 0
@@ -500,7 +507,7 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5824775690649857626}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
@@ -508,13 +515,77 @@ RectTransform:
- {fileID: 4457764961296169826}
- {fileID: 2270652969785232746}
- {fileID: 5685853180135426375}
m_Father: {fileID: 7791053714247626159}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7677408382091391569
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7791053714247626159}
- component: {fileID: 8174150631162951626}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &7791053714247626159
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7677408382091391569}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 27177156846382951}
- {fileID: 2806314693394340526}
m_Father: {fileID: 5824597425683931436}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 100, y: 0}
m_SizeDelta: {x: 100, y: 50}
m_Pivot: {x: -0.2, y: 0.5}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 50, y: -30}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &8174150631162951626
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7677408382091391569}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 15
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 3
m_Spacing: 10
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &7841004607171630674
GameObject:
m_ObjectHideFlags: 0
@@ -541,17 +612,17 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7841004607171630674}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5824597425683931436}
m_Father: {fileID: 7791053714247626159}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -10, y: 0}
m_SizeDelta: {x: 120, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 320, y: 50}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &85167933423521209
CanvasRenderer:
@@ -608,8 +679,8 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 40
m_fontSizeBase: 40
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@@ -690,3 +761,78 @@ MonoBehaviour:
references:
version: 2
RefIds: []
--- !u!1 &8907748743948171428
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8177162145044828877}
- component: {fileID: 8091024215010370130}
- component: {fileID: 7311972616869413698}
m_Layer: 0
m_Name: Selection Bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8177162145044828877
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8907748743948171428}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 5824597425683931436}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8091024215010370130
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8907748743948171428}
m_CullTransparentMesh: 1
--- !u!114 &7311972616869413698
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8907748743948171428}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
@@ -176,17 +176,17 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2721427419101969262}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 305064715333190683}
m_Father: {fileID: 2010492998072573150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -10, y: 0}
m_SizeDelta: {x: 120, y: 50}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 320, y: 50}
m_Pivot: {x: 1, y: 0.5}
--- !u!222 &7616446508434232365
CanvasRenderer:
@@ -243,8 +243,8 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontSize: 40
m_fontSizeBase: 40
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@@ -354,14 +354,14 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1163567057521848681}
- {fileID: 6732691262169134867}
- {fileID: 2800936835720725662}
- {fileID: 2010492998072573150}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 50}
m_SizeDelta: {x: 1000, y: 60}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &6885231114081803451
MonoBehaviour:
@@ -375,11 +375,15 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6cb985d5e95047f88ddec878de7972a2, type: 3}
m_Name:
m_EditorClassIdentifier:
prop: Volume
label: setting_volume
OnValueChanged:
m_PersistentCalls:
m_Calls: []
slider: {fileID: 3553234827604121308}
labelText: {fileID: 6338673825785440556}
labelLocalize: {fileID: 6550843177228825060}
sliderText: {fileID: 3656877915088725050}
selectionBar: {fileID: 5811921145249754562}
selectionBarHiddenAlpha: 0
selectionBarVisibleAlpha: 1
normalTextColor: {r: 1, g: 1, b: 1, a: 1}
hoveredTextColor: {r: 0.02, g: 0.02, b: 0.04, a: 1}
--- !u!1 &3171587862189739335
GameObject:
m_ObjectHideFlags: 0
@@ -514,19 +518,159 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6131397560991339167}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 7791647524598842268}
m_Father: {fileID: 2010492998072573150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 400, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &7023726294702313920
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2800936835720725662}
- component: {fileID: 6984066744764525887}
- component: {fileID: 5811921145249754562}
m_Layer: 0
m_Name: Selection Bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2800936835720725662
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7023726294702313920}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 305064715333190683}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 50}
m_Pivot: {x: -0.2, y: 0.5}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &6984066744764525887
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7023726294702313920}
m_CullTransparentMesh: 1
--- !u!114 &5811921145249754562
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7023726294702313920}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &8328470145810067769
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2010492998072573150}
- component: {fileID: 4034804984428078857}
m_Layer: 5
m_Name: Content
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2010492998072573150
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8328470145810067769}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1163567057521848681}
- {fileID: 5952270497693892333}
- {fileID: 6732691262169134867}
m_Father: {fileID: 305064715333190683}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4034804984428078857
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8328470145810067769}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 30649d3a9faa99c48a7b1166b86bf2a0, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Padding:
m_Left: 15
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 3
m_Spacing: 0
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 1
m_ChildControlWidth: 0
m_ChildControlHeight: 0
m_ChildScaleWidth: 0
m_ChildScaleHeight: 0
m_ReverseArrangement: 0
--- !u!1 &8845553095916225345
GameObject:
m_ObjectHideFlags: 0
@@ -559,13 +703,12 @@ RectTransform:
- {fileID: 4316814271319446306}
- {fileID: 4371280193830370112}
- {fileID: 7079245237346467699}
- {fileID: 5952270497693892333}
m_Father: {fileID: 6732691262169134867}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 20, y: 0}
m_SizeDelta: {x: 200, y: 20}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 400, y: 20}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &3553234827604121308
MonoBehaviour:
@@ -629,7 +772,6 @@ GameObject:
- component: {fileID: 5952270497693892333}
- component: {fileID: 7230026334986147505}
- component: {fileID: 3656877915088725050}
- component: {fileID: 7954288208286476696}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
@@ -644,17 +786,17 @@ RectTransform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8891862477470894644}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 7791647524598842268}
m_Father: {fileID: 2010492998072573150}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 15.000001}
m_SizeDelta: {x: 0, y: 20}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 200, y: 32.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7230026334986147505
CanvasRenderer:
@@ -684,7 +826,7 @@ MonoBehaviour:
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: 50
m_text: 50/100
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
m_sharedMaterial: {fileID: -6659093157667844055, guid: f242fb3dde1933640859f1c54591c9c8, type: 2}
@@ -711,8 +853,8 @@ MonoBehaviour:
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 20
m_fontSizeBase: 20
m_fontSize: 32
m_fontSizeBase: 32
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
@@ -753,20 +895,6 @@ MonoBehaviour:
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &7954288208286476696
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8891862477470894644}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 2
m_VerticalFit: 0
--- !u!1 &8893160790744753639
GameObject:
m_ObjectHideFlags: 0
@@ -28,9 +28,9 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 280114235428445390}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -101,10 +101,10 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8394664858893978607}
m_Father: {fileID: 8061307773979316499}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -139,9 +139,9 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3516029471209091175}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -179,7 +179,7 @@ MonoBehaviour:
m_text: 0 / 0
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_sharedMaterial: {fileID: -3469992342024533900, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_sharedMaterial: {fileID: 2810396569639620041, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@@ -272,6 +272,7 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2270854945082478967}
- {fileID: 280114235428445390}
@@ -279,7 +280,6 @@ RectTransform:
- {fileID: 78859839904637773}
- {fileID: 3516029471209091175}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@@ -303,7 +303,7 @@ MonoBehaviour:
imageCurrent: {fileID: 370020824947925516}
textCurrent: {fileID: -7679067700714320573}
loop: 1
hasIndicator: 1
hasIndicator: 0
indicator: {fileID: 1734375169921074298}
indicatorRect: {fileID: 3516029471209091175}
startIndex: 0
@@ -344,11 +344,11 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3234711045948957830}
- {fileID: 4244637489626655452}
m_Father: {fileID: 78859839904637773}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -395,9 +395,9 @@ RectTransform:
m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4139001676869347502}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -470,10 +470,10 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5474023296842850581}
m_Father: {fileID: 8061307773979316499}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
@@ -560,9 +560,9 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8061307773979316499}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -635,9 +635,9 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8394664858893978607}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
@@ -675,7 +675,7 @@ MonoBehaviour:
m_text: Option 1
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_sharedMaterial: {fileID: -3469992342024533900, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_sharedMaterial: {fileID: 2810396569639620041, guid: 0e7e80bfdc54f454a8949cf216f589ab, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
@@ -757,7 +757,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &3516029471209091175
RectTransform:
m_ObjectHideFlags: 0
@@ -768,10 +768,10 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1405096709158585679}
m_Father: {fileID: 8061307773979316499}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@@ -818,10 +818,10 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1024366000720371455}
m_Father: {fileID: 8061307773979316499}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
@@ -908,9 +908,9 @@ RectTransform:
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8394664858893978607}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5}
+184 -45
View File
@@ -1,70 +1,209 @@
using System;
using System;
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Components;
using UnityEngine.UI;
namespace AibisDream
{
public class SelectItem : AbsFormItem
public class SelectItem : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public override FieldType FieldType => FieldType.Select;
[SerializeField] private TMP_Text labelText;
[SerializeField] private LocalizeStringEvent labelLocalize;
[SerializeField] private TMP_Text showText;
[SerializeField] private LocalizeStringEvent showLocalize;
[SerializeField] private Button leftBtn;
[SerializeField] private Button rightBtn;
[SerializeField] private Image selectionBar;
[SerializeField] private float selectionBarHiddenAlpha;
[SerializeField] private float selectionBarVisibleAlpha = 1f;
[SerializeField] private Color normalTextColor = Color.white;
[SerializeField] private Color hoveredTextColor = new Color(0.02f, 0.02f, 0.04f);
[SerializeField] private ColorBlock lightRowButtonColors = new ColorBlock
{
normalColor = new Color(0.02f, 0.02f, 0.04f, 1f),
highlightedColor = new Color(0.35f, 0.35f, 0.4f, 1f),
pressedColor = new Color(0.55f, 0.55f, 0.6f, 1f),
selectedColor = new Color(0.02f, 0.02f, 0.04f, 1f),
disabledColor = new Color(0.78431374f, 0.78431374f, 0.78431374f, 0.5019608f),
colorMultiplier = 1f,
fadeDuration = 0.1f
};
#region
private LocalizeStringEvent _showText;
private Button _leftBtn;
private Button _rightBtn;
#endregion
#region
[Header("可选项")]
public UIFormOption[] options;
private string _propName;
private UIFormOption[] _options = Array.Empty<UIFormOption>();
private int _curIdx;
private Action<string, string> _onValueChanged;
private bool _isListening;
private ColorBlock _darkRowButtonColors;
#endregion
protected override void InitField()
private void Awake()
{
var field = transform.Find("Field");
_showText = field.Find("ShowText").GetComponent<LocalizeStringEvent>();
_leftBtn = field.Find("Left Btn").GetComponent<Button>();
_rightBtn = field.Find("Right Btn").GetComponent<Button>();
_leftBtn.onClick.AddListener(LeftRoll);
_rightBtn.onClick.AddListener(RightRoll);
}
public override void SetValue(string value)
{
var idx = Array.FindIndex(options, item => item.prop == value);
if (idx < 0)
if (leftBtn != null)
{
Debug.LogError($"{prop} setting value error");
_darkRowButtonColors = leftBtn.colors;
}
_curIdx = idx;
_showText.SetEntry(options[idx].label);
SetHovered(false);
if (!_isListening)
{
leftBtn?.onClick.AddListener(LeftRoll);
rightBtn?.onClick.AddListener(RightRoll);
_isListening = leftBtn != null || rightBtn != null;
}
}
public void OnPointerEnter(PointerEventData eventData)
{
SetHovered(true);
}
public void OnPointerExit(PointerEventData eventData)
{
SetHovered(false);
}
private void SetHovered(bool hovered)
{
SetSelectionBarAlpha(hovered ? selectionBarVisibleAlpha : selectionBarHiddenAlpha);
var textColor = hovered ? hoveredTextColor : normalTextColor;
SetTextColor(labelText, textColor);
SetTextColor(showText, textColor);
var buttonColors = hovered ? lightRowButtonColors : _darkRowButtonColors;
ApplyButtonColors(leftBtn, buttonColors);
ApplyButtonColors(rightBtn, buttonColors);
}
private static void SetTextColor(TMP_Text text, Color color)
{
if (text != null)
{
text.color = color;
}
}
private static void ApplyButtonColors(Button button, ColorBlock colors)
{
if (button != null)
{
button.colors = colors;
}
}
private void SetSelectionBarAlpha(float alpha)
{
if (selectionBar == null)
{
return;
}
var color = selectionBar.color;
color.a = alpha;
selectionBar.color = color;
}
private void OnDestroy()
{
if (!_isListening)
{
return;
}
leftBtn?.onClick.RemoveListener(LeftRoll);
rightBtn?.onClick.RemoveListener(RightRoll);
_isListening = false;
}
public void Init(string propName, string label, UIFormOption[] options, Action<string, string> onValueChanged)
{
_propName = propName;
_options = options ?? Array.Empty<UIFormOption>();
_onValueChanged = onValueChanged;
if (leftBtn == null || rightBtn == null)
{
Debug.LogError($"[SelectItem] Buttons not assigned on {name}.", this);
}
SetDisplayText(labelText, labelLocalize, label);
RefreshValue();
}
public void SetValue(string value)
{
var idx = Array.FindIndex(_options, item => item.prop == value);
if (idx < 0)
{
Debug.LogWarning($"[SelectItem] {_propName} value '{value}' not found on {name}; fallback to first option.");
idx = 0;
}
_curIdx = Mathf.Clamp(idx, 0, Mathf.Max(0, _options.Length - 1));
RefreshValue();
}
private void LeftRoll()
{
_curIdx = CommonUtil.LoopStep(_curIdx, 0, options.Length - 1);
_showText.SetEntry(options[_curIdx].label);
OnValueChanged?.Invoke(prop, options[_curIdx].prop);
Step(1);
}
private void RightRoll()
{
_curIdx = CommonUtil.LoopStep(_curIdx, 0, options.Length - 1, -1);
_showText.SetEntry(options[_curIdx].label);
OnValueChanged?.Invoke(prop, options[_curIdx].prop);
Step(-1);
}
private void Step(int offset)
{
if (_options.Length == 0)
{
return;
}
_curIdx = CommonUtil.LoopStep(_curIdx, 0, _options.Length - 1, offset);
RefreshValue();
_onValueChanged?.Invoke(_propName, _options[_curIdx].prop);
}
private void RefreshValue()
{
if (_options.Length == 0)
{
SetDisplayText(showText, showLocalize, string.Empty);
return;
}
SetDisplayText(showText, showLocalize, _options[_curIdx].label);
}
private static void SetDisplayText(TMP_Text text, LocalizeStringEvent localize, string value)
{
if (localize != null && IsLocalizationKey(value))
{
localize.enabled = true;
localize.SetTable(ConstRef.UITextTable);
localize.SetEntry(value);
return;
}
if (localize != null)
{
localize.enabled = false;
}
if (text != null)
{
text.text = value;
}
}
private static bool IsLocalizationKey(string value)
{
return !string.IsNullOrEmpty(value) && value.StartsWith("setting_", StringComparison.Ordinal);
}
}
}
}
+137 -27
View File
@@ -1,50 +1,160 @@
using System;
using System.Globalization;
using AibisDream.Utility;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Localization.Components;
using UnityEngine.UI;
namespace AibisDream
{
public class SliderItem : AbsFormItem
public class SliderItem : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public override FieldType FieldType => FieldType.Slider;
[SerializeField] private Slider slider;
[SerializeField] private TMP_Text labelText;
[SerializeField] private LocalizeStringEvent labelLocalize;
[SerializeField] private TMP_Text sliderText;
[SerializeField] private Image selectionBar;
[SerializeField] private float selectionBarHiddenAlpha;
[SerializeField] private float selectionBarVisibleAlpha = 1f;
[SerializeField] private Color normalTextColor = Color.white;
[SerializeField] private Color hoveredTextColor = new Color(0.02f, 0.02f, 0.04f);
#region
private string _propName;
private Action<string, string> _onValueChanged;
private bool _isListening;
private Slider _slider;
private TMP_Text _sliderText;
#endregion
protected override void InitField()
private void Awake()
{
// 初始化索引
_slider = GetComponentInChildren<Slider>();
_sliderText = _slider.GetComponentInChildren<TMP_Text>(true);
// 绑定事件
_slider.onValueChanged.AddListener(OnSliderChanged);
SetHovered(false);
if (slider != null && !_isListening)
{
slider.onValueChanged.AddListener(OnSliderChanged);
_isListening = true;
}
}
public void OnPointerEnter(PointerEventData eventData)
{
SetHovered(true);
}
public void OnPointerExit(PointerEventData eventData)
{
SetHovered(false);
}
private void SetHovered(bool hovered)
{
SetSelectionBarAlpha(hovered ? selectionBarVisibleAlpha : selectionBarHiddenAlpha);
var color = hovered ? hoveredTextColor : normalTextColor;
SetTextColor(labelText, color);
SetTextColor(sliderText, color);
}
private void SetSelectionBarAlpha(float alpha)
{
if (selectionBar == null)
{
return;
}
var color = selectionBar.color;
color.a = alpha;
selectionBar.color = color;
}
private static void SetTextColor(TMP_Text text, Color color)
{
if (text != null)
{
text.color = color;
}
}
private void OnDestroy()
{
if (slider != null && _isListening)
{
slider.onValueChanged.RemoveListener(OnSliderChanged);
_isListening = false;
}
}
public void Init(string propName, string label, float minValue, float maxValue, Action<string, string> onValueChanged)
{
_propName = propName;
_onValueChanged = onValueChanged;
SetDisplayText(labelText, labelLocalize, label);
if (slider == null)
{
Debug.LogError($"[SliderItem] Slider not assigned on {name}.", this);
return;
}
slider.minValue = minValue;
slider.maxValue = maxValue;
}
public void SetValue(string value)
{
if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var floatValue))
{
Debug.LogError($"SliderItem: 解析数值{value}失败");
return;
}
if (slider != null)
{
slider.SetValueWithoutNotify(floatValue);
}
RefreshValue(floatValue);
}
private void OnSliderChanged(float value)
{
// 更新数字显示
_sliderText.text = Mathf.RoundToInt(value * 100).ToString();
// 触发修改事件
OnValueChanged.Invoke(prop, value.ToString("F2"));
RefreshValue(value);
_onValueChanged?.Invoke(_propName, value.ToString("0.##", CultureInfo.InvariantCulture));
}
public override void SetValue(string value)
private void RefreshValue(float value)
{
if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var floatValue))
if (sliderText != null)
{
_slider.value = floatValue;
_sliderText.text = Mathf.RoundToInt(floatValue * 100).ToString();
}
else
{
Debug.LogError($"SliderItem: 解析数值{value}失败");
var curVolume = Mathf.RoundToInt(value * 100).ToString(CultureInfo.InvariantCulture);
sliderText.text = $"{curVolume}/100";
}
}
private static void SetDisplayText(TMP_Text text, LocalizeStringEvent localize, string value)
{
if (localize != null && IsLocalizationKey(value))
{
localize.enabled = true;
localize.SetTable(ConstRef.UITextTable);
localize.SetEntry(value);
return;
}
if (localize != null)
{
localize.enabled = false;
}
if (text != null)
{
text.text = value;
}
}
private static bool IsLocalizationKey(string value)
{
return !string.IsNullOrEmpty(value) && value.StartsWith("setting_", StringComparison.Ordinal);
}
}
}
}
@@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 2c1bcc3613815c74fb44cc1db21f524e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: