UI框架开发中

This commit is contained in:
2025-09-29 07:45:07 +08:00
parent 423ad80303
commit 71edbb6088
39 changed files with 1191 additions and 397 deletions

View File

@@ -122,133 +122,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1001 &182059024
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 1993296955}
m_Modifications:
- target: {fileID: 1613174875475300, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
propertyPath: m_Name
value: LeftStick
objectReference: {fileID: 0}
- target: {fileID: 114480945186419424, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_Behaviour
value: 2
objectReference: {fileID: 0}
- target: {fileID: 114480945186419424, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_MovementRange
value: 300
objectReference: {fileID: 0}
- target: {fileID: 114480945186419424, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_DynamicOriginRange
value: 300
objectReference: {fileID: 0}
- target: {fileID: 114480945186419424, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_DynamicOriginClickable
value:
objectReference: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_Pivot.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_Pivot.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_RootOrder
value: 4
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchorMax.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchorMax.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchorMin.x
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchorMin.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_SizeDelta.x
value: 100
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_SizeDelta.y
value: 100
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchoredPosition.x
value: -161
objectReference: {fileID: 0}
- target: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
propertyPath: m_AnchoredPosition.y
value: -129
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: f77f88b14a477764bb65a49d28c02d33, type: 3}
--- !u!1001 &213445084
PrefabInstance:
m_ObjectHideFlags: 0
@@ -366,12 +239,6 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 05f32eddd3e41fd4597ada617b785928, type: 3}
--- !u!224 &223523015 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 224091927000801720, guid: f77f88b14a477764bb65a49d28c02d33,
type: 3}
m_PrefabInstance: {fileID: 182059024}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &334844325
PrefabInstance:
m_ObjectHideFlags: 0
@@ -1161,8 +1028,8 @@ RectTransform:
- {fileID: 827737258}
- {fileID: 1467932573}
- {fileID: 334844326}
- {fileID: 223523015}
- {fileID: 1763776551}
- {fileID: 2963455855290732268}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
@@ -1184,6 +1051,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
inputAction: {fileID: 2145626033925996126, guid: efc74d62e0aa605438ae41c388786ef8,
type: 3}
ParentObj: {fileID: 713718991246645364}
onScreenStick: {fileID: 8904126831151913604}
--- !u!850595691 &2075976824
LightingSettings:
m_ObjectHideFlags: 0
@@ -1248,6 +1117,385 @@ LightingSettings:
m_PVRTiledBaking: 0
m_NumRaysToShootPerTexel: -1
m_RespectSceneVisibilityWhenBakingGI: 0
--- !u!1 &432402199150701803
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4384745167881809789}
- component: {fileID: 2540828120232935279}
- component: {fileID: 4825629831811530760}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &713718991246645364
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8376355588769731086}
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: 4384745167881809789}
m_Father: {fileID: 2963455855290732268}
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: -589.99994, y: -128.99998}
m_SizeDelta: {x: 300, y: 300}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &737919063412850879
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8376355588769731086}
m_CullTransparentMesh: 1
--- !u!222 &927724787126069688
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5145362127522282297}
m_CullTransparentMesh: 0
--- !u!224 &1783108751789781873
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5145362127522282297}
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: 3657818702438058884}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 2, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2540828120232935279
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 432402199150701803}
m_CullTransparentMesh: 1
--- !u!224 &2963455855290732268
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6937528586866629539}
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: 713718991246645364}
- {fileID: 3657818702438058884}
m_Father: {fileID: 1993296955}
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 &3007171117402795681
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5145362127522282297}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Left Stick
--- !u!222 &3354833319183544138
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7282532954179545991}
m_CullTransparentMesh: 0
--- !u!224 &3657818702438058884
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7282532954179545991}
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: 1783108751789781873}
m_Father: {fileID: 2963455855290732268}
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: -590, y: -129}
m_SizeDelta: {x: 300, y: 300}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &3703355205647292765
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7282532954179545991}
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: 1}
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: 21300000, guid: 8bd30333489082143a978bd2d0fc8634, type: 3}
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!224 &4384745167881809789
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 432402199150701803}
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: 713718991246645364}
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: 0}
m_SizeDelta: {x: 300, y: 300}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &4825629831811530760
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 432402199150701803}
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: 1}
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: 21300000, guid: 838794475e7fe2e419eec0bcf8f8701b, type: 3}
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 &5145362127522282297
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1783108751789781873}
- component: {fileID: 927724787126069688}
- component: {fileID: 3007171117402795681}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &6707519295810528578
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8376355588769731086}
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: 1}
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: 21300000, guid: 894062b635dc9a54bb9df1c208d32c79, type: 3}
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 &6937528586866629539
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2963455855290732268}
m_Layer: 5
m_Name: MoveCtrlPanel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &7282532954179545991
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3657818702438058884}
- component: {fileID: 3354833319183544138}
- component: {fileID: 3703355205647292765}
- component: {fileID: 8904126831151913604}
m_Layer: 5
m_Name: LeftStick
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &8376355588769731086
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 713718991246645364}
- component: {fileID: 737919063412850879}
- component: {fileID: 6707519295810528578}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &8904126831151913604
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7282532954179545991}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e9d677f1681015749b15c436eec6d880, type: 3}
m_Name:
m_EditorClassIdentifier:
m_MovementRange: 150
m_DynamicOriginRange: 300
m_ControlPath: /<GamePad>/LeftStick
m_Behaviour: 2
m_UseIsolatedInputActions: 0
m_PointerDownAction:
m_Name:
m_Type: 0
m_ExpectedControlType:
m_Id: 4b7f3134-e9d7-4cf1-af13-b4c50eba83ce
m_Processors:
m_Interactions:
m_SingletonActionBindings: []
m_Flags: 0
m_PointerMoveAction:
m_Name:
m_Type: 0
m_ExpectedControlType:
m_Id: 6e5ab135-fb47-4df0-8482-ed75002e2267
m_Processors:
m_Interactions:
m_SingletonActionBindings: []
m_Flags: 0
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0

View File

@@ -2,14 +2,27 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.OnScreen;
public class ScreenTest : MonoBehaviour
{
public InputActionReference inputAction;
public RectTransform ParentObj;
public OnScreenStick onScreenStick;
Vector2 startPos;
// Start is called before the first frame update
void Start()
{
startPos = ParentObj.anchoredPosition;
inputAction.action.Enable();
inputAction.action.performed += ScreenTouchTest;
onScreenStick.onPointerDown += () =>
{
ParentObj.anchoredPosition = onScreenStick.PointerDownPos;
};
onScreenStick.onPointerUp += () =>
{
ParentObj.anchoredPosition = startPos;
};
}
private void ScreenTouchTest(InputAction.CallbackContext obj)