完善3D解剖功能
This commit is contained in:
parent
d101ab8565
commit
f258ad09ab
@ -1080,11 +1080,150 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
BodyContent: {fileID: 5601864313735818432}
|
||||
LeftContent: {fileID: 3644811849542302248}
|
||||
DragBtn: {fileID: 4284720363514511568}
|
||||
DragBack: {fileID: 540967449707403434}
|
||||
ResetBtn: {fileID: 1164260856681727312}
|
||||
ActiveBtn: {fileID: 6692543268377793545}
|
||||
ActiveBack: {fileID: 3554365675561402507}
|
||||
DragBtn: {fileID: 4284720363514511568}
|
||||
DragBack: {fileID: 540967449707403434}
|
||||
BodyItem: {fileID: 1682419669064365991}
|
||||
--- !u!1 &4437185578165757201
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3959195348148526699}
|
||||
- component: {fileID: 6893419802133694656}
|
||||
- component: {fileID: 4072128863539031069}
|
||||
- component: {fileID: 6573736067503725872}
|
||||
- component: {fileID: 1164260856681727312}
|
||||
m_Layer: 5
|
||||
m_Name: ResetBtn
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3959195348148526699
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4437185578165757201}
|
||||
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: 4205592421312639835}
|
||||
m_Father: {fileID: 3644811849542302248}
|
||||
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: 102, y: 34}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &6893419802133694656
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4437185578165757201}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &4072128863539031069
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4437185578165757201}
|
||||
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: 8c77a2052664d0d4e9be892444deddd1, 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!114 &6573736067503725872
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4437185578165757201}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0d51f3a7c41ab0346b49ae50d456bece, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
MarkType: 0
|
||||
CustomComponentName: BtnPrefab
|
||||
CustomComment:
|
||||
mComponentName: UnityEngine.UI.Button
|
||||
--- !u!114 &1164260856681727312
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4437185578165757201}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 4072128863539031069}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &5049956726037078213
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1589,8 +1728,9 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 7134505307210740835}
|
||||
- {fileID: 3959195348148526699}
|
||||
- {fileID: 165414428222451636}
|
||||
- {fileID: 7134505307210740835}
|
||||
m_Father: {fileID: 1062102287437619772}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
@ -1850,6 +1990,140 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!1 &7499310447612568881
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4205592421312639835}
|
||||
- component: {fileID: 1855204455405537204}
|
||||
- component: {fileID: 2739947805228490611}
|
||||
m_Layer: 5
|
||||
m_Name: Label
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &4205592421312639835
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7499310447612568881}
|
||||
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: 3959195348148526699}
|
||||
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 &1855204455405537204
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7499310447612568881}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2739947805228490611
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7499310447612568881}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, 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_text: "\u590D\u4F4D"
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 97936a7b3a86809479ac89371e95b079, type: 2}
|
||||
m_sharedMaterial: {fileID: 168401102475399263, guid: 97936a7b3a86809479ac89371e95b079, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
topLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
topRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
|
||||
bottomRight: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_fontColorGradientPreset: {fileID: 0}
|
||||
m_spriteAsset: {fileID: 0}
|
||||
m_tintAllSprites: 0
|
||||
m_StyleSheet: {fileID: 0}
|
||||
m_TextStyleHashCode: -1183493901
|
||||
m_overrideHtmlColors: 0
|
||||
m_faceColor:
|
||||
serializedVersion: 2
|
||||
rgba: 4294967295
|
||||
m_fontSize: 16
|
||||
m_fontSizeBase: 16
|
||||
m_fontWeight: 400
|
||||
m_enableAutoSizing: 0
|
||||
m_fontSizeMin: 18
|
||||
m_fontSizeMax: 72
|
||||
m_fontStyle: 0
|
||||
m_HorizontalAlignment: 2
|
||||
m_VerticalAlignment: 512
|
||||
m_textAlignment: 65535
|
||||
m_characterSpacing: 0
|
||||
m_wordSpacing: 0
|
||||
m_lineSpacing: 0
|
||||
m_lineSpacingMax: 0
|
||||
m_paragraphSpacing: 0
|
||||
m_charWidthMaxAdj: 0
|
||||
m_enableWordWrapping: 1
|
||||
m_wordWrappingRatios: 0.4
|
||||
m_overflowMode: 0
|
||||
m_linkedTextComponent: {fileID: 0}
|
||||
parentLinkedComponent: {fileID: 0}
|
||||
m_enableKerning: 1
|
||||
m_enableExtraPadding: 0
|
||||
checkPaddingRequired: 0
|
||||
m_isRichText: 1
|
||||
m_parseCtrlCharacters: 1
|
||||
m_isOrthographic: 1
|
||||
m_isCullingEnabled: 0
|
||||
m_horizontalMapping: 0
|
||||
m_verticalMapping: 0
|
||||
m_uvLineOffset: 0
|
||||
m_geometrySortingOrder: 0
|
||||
m_IsTextObjectScaleStatic: 0
|
||||
m_VertexBufferAutoSizeReduction: 0
|
||||
m_useMaxVisibleDescender: 1
|
||||
m_pageToDisplay: 1
|
||||
m_margin: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_isUsingLegacyAnimationComponent: 0
|
||||
m_isVolumetricText: 0
|
||||
m_hasFontAssetChanged: 0
|
||||
m_baseMaterial: {fileID: 0}
|
||||
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
|
||||
--- !u!1 &8568279820254546874
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -323,7 +323,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 51, y: -7.184}
|
||||
m_AnchoredPosition: {x: 51, y: -7.1839905}
|
||||
m_SizeDelta: {x: 102, y: 34}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!222 &4075577543603496310
|
||||
@ -1053,6 +1053,8 @@ GameObject:
|
||||
- component: {fileID: 6827284989092321893}
|
||||
- component: {fileID: 4497957665814808150}
|
||||
- component: {fileID: 5775295014847080228}
|
||||
- component: {fileID: 3534695522984393869}
|
||||
- component: {fileID: 2319114503345784786}
|
||||
m_Layer: 0
|
||||
m_Name: bg
|
||||
m_TagString: Untagged
|
||||
@ -1079,7 +1081,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 1010, y: 590}
|
||||
m_SizeDelta: {x: 1010, y: 0}
|
||||
m_Pivot: {x: 0.99999994, y: -0.00000004284084}
|
||||
--- !u!222 &4497957665814808150
|
||||
CanvasRenderer:
|
||||
@ -1119,6 +1121,46 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &3534695522984393869
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4630449187609202247}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Padding:
|
||||
m_Left: 0
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 7
|
||||
m_Spacing: 0
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
m_ChildControlWidth: 1
|
||||
m_ChildControlHeight: 1
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &2319114503345784786
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4630449187609202247}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 0
|
||||
m_VerticalFit: 2
|
||||
--- !u!1 &5243978266746649525
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2019,10 +2061,10 @@ RectTransform:
|
||||
- {fileID: 8846071839557483914}
|
||||
m_Father: {fileID: 6827284989092321893}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -24.18396}
|
||||
m_SizeDelta: {x: 0, y: 48.36798}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &8897071683313985438
|
||||
MonoBehaviour:
|
||||
@ -2087,9 +2129,9 @@ RectTransform:
|
||||
m_Father: {fileID: 6827284989092321893}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 24.183985}
|
||||
m_SizeDelta: {x: 0, y: 48.368}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &6142069136662953391
|
||||
MonoBehaviour:
|
||||
|
||||
@ -30,6 +30,7 @@ public class Body3DController : MonoSingleton<Body3DController>
|
||||
private Vector2 mouseDownPosition; // 记录鼠标按下时的位置
|
||||
|
||||
Stack<GameObject> activeObjs = new Stack<GameObject>();
|
||||
Stack<GameObject> moveObjs = new Stack<GameObject>();
|
||||
public override void OnSingletonInit()
|
||||
{
|
||||
base.OnSingletonInit();
|
||||
@ -86,7 +87,8 @@ public class Body3DController : MonoSingleton<Body3DController>
|
||||
}
|
||||
else
|
||||
{
|
||||
this.status &= status;
|
||||
// ɾ³ý״̬
|
||||
this.status &= ~status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +113,25 @@ public class Body3DController : MonoSingleton<Body3DController>
|
||||
}
|
||||
}
|
||||
|
||||
public void AddMoveObj(GameObject obj)
|
||||
{
|
||||
if (moveObjs.Contains(obj)==false)
|
||||
{
|
||||
moveObjs.Push(obj);
|
||||
}
|
||||
}
|
||||
public GameObject PopMoveObj()
|
||||
{
|
||||
if (moveObjs.Count > 0)
|
||||
{
|
||||
return moveObjs.Pop();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Active(bool isActive)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
|
||||
@ -12,6 +12,10 @@ public class Body3DOjbItem : MonoBehaviour
|
||||
|
||||
ObjectToggle objToggle;
|
||||
ObjDrag objDrag;
|
||||
// 记录上一次鼠标按下的时间
|
||||
private float lastClickTime;
|
||||
// 双击的时间间隔阈值
|
||||
private const float doubleClickTimeThreshold = 0.3f;
|
||||
private void Awake()
|
||||
{
|
||||
}
|
||||
@ -46,6 +50,10 @@ public class Body3DOjbItem : MonoBehaviour
|
||||
{
|
||||
colorToggle?.SetColor(isOn);
|
||||
objDrag = gameObject.GetOrAddComponent<ObjDrag>();
|
||||
objDrag.OnDragEnd.AddListener(obj =>
|
||||
{
|
||||
Body3DController.Instance.AddMoveObj(gameObject);
|
||||
});
|
||||
RefreshDrag();
|
||||
TypeEventSystem.Global.Send<OnBody3DSelected>(new OnBody3DSelected() { isOn = isOn, obj = gameObject });
|
||||
if (isOn)
|
||||
@ -63,6 +71,43 @@ public class Body3DOjbItem : MonoBehaviour
|
||||
|
||||
}
|
||||
}
|
||||
private void OnMouseDown()
|
||||
{
|
||||
// 计算当前时间与上一次点击时间的间隔
|
||||
float currentTime = Time.time;
|
||||
if (currentTime - lastClickTime < doubleClickTimeThreshold)
|
||||
{
|
||||
// 触发双击事件
|
||||
OnDoubleClick();
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void OnDoubleClick()
|
||||
{
|
||||
if (Body3DController.Instance.CheckStatus(Body3DController.Status.Drag))
|
||||
{
|
||||
var drag = gameObject.GetComponent<ObjDrag>();
|
||||
if (drag != null)
|
||||
{
|
||||
drag.OnDoubleClick();
|
||||
}
|
||||
}
|
||||
else if (Body3DController.Instance.CheckStatus(Body3DController.Status.Active) == false)
|
||||
{
|
||||
float distance = 1;
|
||||
if (float.TryParse(body.FocusDistance, out distance))
|
||||
{
|
||||
Show3DCamera.instance.FocusObj(gameObject.transform.position, distance);
|
||||
}
|
||||
else
|
||||
{
|
||||
Show3DCamera.instance.FocusObj(gameObject.transform.position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBody3DDragHandler(OnBody3DDragChanged drag)
|
||||
{
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using DG.Tweening;
|
||||
using QFramework;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class ObjDrag : MonoBehaviour
|
||||
{
|
||||
@ -9,11 +11,7 @@ public class ObjDrag : MonoBehaviour
|
||||
|
||||
Vector3 startPosition;
|
||||
|
||||
// 记录上一次鼠标按下的时间
|
||||
private float lastClickTime;
|
||||
// 双击的时间间隔阈值
|
||||
private const float doubleClickTimeThreshold = 0.3f;
|
||||
|
||||
public UnityEvent<GameObject> OnDragEnd = new UnityEvent<GameObject>();
|
||||
void Start()
|
||||
{
|
||||
startPosition = gameObject.transform.position;
|
||||
@ -24,6 +22,7 @@ public class ObjDrag : MonoBehaviour
|
||||
if (isOn)
|
||||
{
|
||||
Show3DCamera.instance.lockMove = false;
|
||||
OnDragEnd?.Invoke(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,15 +30,6 @@ public class ObjDrag : MonoBehaviour
|
||||
{
|
||||
if (isOn)
|
||||
{
|
||||
// 计算当前时间与上一次点击时间的间隔
|
||||
float currentTime = Time.time;
|
||||
if (currentTime - lastClickTime < doubleClickTimeThreshold)
|
||||
{
|
||||
// 触发双击事件
|
||||
OnDoubleClick();
|
||||
}
|
||||
lastClickTime = currentTime;
|
||||
|
||||
// 获取鼠标在相机视角平面上的世界坐标
|
||||
Vector3 mouseWorldPos = GetMouseWorldPositionOnPlane();
|
||||
// 计算物体位置与鼠标点击点在世界坐标中的偏移量
|
||||
@ -89,7 +79,7 @@ public class ObjDrag : MonoBehaviour
|
||||
}
|
||||
|
||||
// 双击事件处理函数
|
||||
private void OnDoubleClick()
|
||||
public void OnDoubleClick()
|
||||
{
|
||||
// 在这里可以添加你想要执行的双击逻辑
|
||||
// 例如,将物体重置到起始位置
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using DG.Tweening;
|
||||
using GCSeries.Core;
|
||||
using System;
|
||||
using Unity.Burst.CompilerServices;
|
||||
@ -29,6 +30,10 @@ public class Show3DCamera : MonoBehaviour
|
||||
|
||||
public RenderTexture texture;
|
||||
public bool lockMove = false;
|
||||
|
||||
|
||||
private Vector2 mouseDownPosition; // 记录鼠标按下时的位置
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
@ -38,7 +43,7 @@ public class Show3DCamera : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
public void Set(Transform target, float rotateSpeed = 10, float moveSpeed = 0.1f, float distance = 0.1f, float pitchMin = -20, float pitchMax = 80, float distanceMin = 0.2f, float distanceMax = 20f, RectTransform inputRect = null, bool isRenderTexture = true)
|
||||
public void Set(Transform target, float rotateSpeed = 10, float moveSpeed = 0.1f, float distance = 0.1f, float pitchMin = -20, float pitchMax = 80, float distanceMin = 0.2f, float distanceMax = 20f, RectTransform inputRect = null, bool isRenderTexture = true, float moveTime = -1)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
@ -67,20 +72,31 @@ public class Show3DCamera : MonoBehaviour
|
||||
{
|
||||
self.targetTexture = null;
|
||||
}
|
||||
UpdateCameraPosition();
|
||||
UpdateCameraPosition(moveTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (targetPos != null && lockMove == false)
|
||||
if (targetPos != null && lockMove == false && EventSystem.current.IsPointerOverGameObject() == false)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
// 记录鼠标按下时的位置
|
||||
mouseDownPosition = Input.mousePosition;
|
||||
}
|
||||
|
||||
// 按住鼠标左键时旋转相机
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
// 计算鼠标按下和抬起位置之间的距离
|
||||
float distance = Vector2.Distance(mouseDownPosition, Input.mousePosition);
|
||||
if (distance > 1f)
|
||||
{
|
||||
RotateCamera();
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标滚轮缩放
|
||||
float scroll = Input.GetAxis("Mouse ScrollWheel");
|
||||
@ -147,6 +163,21 @@ public class Show3DCamera : MonoBehaviour
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 聚焦某个物体
|
||||
/// </summary>
|
||||
public void FocusObj(Vector3 target, float distance = 1f)
|
||||
{
|
||||
// 计算相机前方一定距离的位置,作为Cube的目标位置
|
||||
// 可以根据需要调整这个距离
|
||||
Vector3 cameraPos = target - transform.forward * distance;
|
||||
|
||||
targetPos = target;
|
||||
this.distance = distance;
|
||||
offset = new Vector3(0, 0, -distance);
|
||||
transform.position = cameraPos;
|
||||
}
|
||||
|
||||
public void OnMouseEnterObj(GameObject obj)
|
||||
{
|
||||
TipItem tip = obj.GetComponent<TipItem>();
|
||||
@ -200,18 +231,26 @@ public class Show3DCamera : MonoBehaviour
|
||||
}
|
||||
|
||||
// 更新相机位置和朝向
|
||||
private void UpdateCameraPosition()
|
||||
private void UpdateCameraPosition(float moveTime = -1)
|
||||
{
|
||||
// 计算旋转后的偏移量
|
||||
Quaternion rotation = Quaternion.Euler(pitch, yaw, 0);
|
||||
Vector3 rotatedOffset = rotation * offset;
|
||||
|
||||
// 更新相机位置
|
||||
transform.position = targetPos + rotatedOffset;
|
||||
|
||||
if (moveTime != -1)
|
||||
{
|
||||
transform.DOMove(targetPos + rotatedOffset, moveTime).onUpdate = () =>
|
||||
// 相机始终朝向目标点
|
||||
transform.LookAt(targetPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = targetPos + rotatedOffset;
|
||||
// 相机始终朝向目标点
|
||||
transform.LookAt(targetPos);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
15
Assets/Scripts/UI/UIBody3D.Designer.cs
generated
15
Assets/Scripts/UI/UIBody3D.Designer.cs
generated
@ -5,7 +5,7 @@ using QFramework;
|
||||
|
||||
namespace QFramework.Example
|
||||
{
|
||||
// Generate Id:54cc185d-5dba-4a35-a35c-f7ccce574623
|
||||
// Generate Id:517b031d-7fb8-4418-aa63-70787d47d5ff
|
||||
public partial class UIBody3D
|
||||
{
|
||||
public const string Name = "UIBody3D";
|
||||
@ -15,14 +15,16 @@ namespace QFramework.Example
|
||||
[SerializeField]
|
||||
public RectTransform LeftContent;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Toggle DragBtn;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Button DragBack;
|
||||
public UnityEngine.UI.Button ResetBtn;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Toggle ActiveBtn;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Button ActiveBack;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Toggle DragBtn;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Button DragBack;
|
||||
[SerializeField]
|
||||
public UnityEngine.UI.Toggle BodyItem;
|
||||
|
||||
private UIBody3DData mPrivateData = null;
|
||||
@ -31,10 +33,11 @@ namespace QFramework.Example
|
||||
{
|
||||
BodyContent = null;
|
||||
LeftContent = null;
|
||||
DragBtn = null;
|
||||
DragBack = null;
|
||||
ResetBtn = null;
|
||||
ActiveBtn = null;
|
||||
ActiveBack = null;
|
||||
DragBtn = null;
|
||||
DragBack = null;
|
||||
BodyItem = null;
|
||||
|
||||
mData = null;
|
||||
|
||||
@ -11,6 +11,7 @@ namespace QFramework.Example
|
||||
}
|
||||
public partial class UIBody3D : UIPanel
|
||||
{
|
||||
GameObject root;
|
||||
protected override void OnInit(IUIData uiData = null)
|
||||
{
|
||||
DragBtn.onValueChanged.AddListener(isOn =>
|
||||
@ -22,7 +23,11 @@ namespace QFramework.Example
|
||||
});
|
||||
DragBack.onClick.AddListener(() =>
|
||||
{
|
||||
DragBtn.isOn = false;
|
||||
GameObject obj = Body3DController.Instance.PopMoveObj();
|
||||
if (obj != null)
|
||||
{
|
||||
obj.GetComponent<ObjDrag>().OnDoubleClick();
|
||||
}
|
||||
});
|
||||
|
||||
ActiveBtn.onValueChanged.AddListener(isOn =>
|
||||
@ -35,13 +40,18 @@ namespace QFramework.Example
|
||||
{
|
||||
Body3DController.Instance.PopActiveObj()?.gameObject.SetActive(true);
|
||||
});
|
||||
ResetBtn.onClick.AddListener(() =>
|
||||
{
|
||||
ResetCamera(0.5f);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected override void OnOpen(IUIData uiData = null)
|
||||
{
|
||||
mData = uiData as UIBody3DData ?? new UIBody3DData();
|
||||
BodyContent.RemoveAllChildren();
|
||||
GameObject root = Utility.FindObj(mData.body.Path);
|
||||
root = Utility.FindObj(mData.body.Path);
|
||||
root.SetActive(true);
|
||||
foreach (var bodyData in mData.body.subBody)
|
||||
{
|
||||
@ -59,11 +69,16 @@ namespace QFramework.Example
|
||||
}
|
||||
FreeCameraController.instance.gameObject.SetActive(false);
|
||||
Show3DCamera.instance.gameObject.SetActive(true);
|
||||
Show3DCamera.instance.Set(root.transform, distance: 5, isRenderTexture: false);
|
||||
ResetCamera(-1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ResetCamera(float moveTime)
|
||||
{
|
||||
Show3DCamera.instance.Set(root.transform, distance: 5, isRenderTexture: false, moveTime: moveTime);
|
||||
}
|
||||
|
||||
protected override void OnShow()
|
||||
{
|
||||
}
|
||||
|
||||
@ -173,6 +173,8 @@ namespace XMLTool
|
||||
|
||||
public string Audio { get; set; }
|
||||
|
||||
public string FocusDistance { get; set; }
|
||||
|
||||
public bool isShow = false;
|
||||
|
||||
public ObjectToggle toggle;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user