Removed TOTU 103
This commit is contained in:
8
Assets/Rendering/Prefabs.meta
Normal file
8
Assets/Rendering/Prefabs.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1439136ad9c372d4e9247073829fda2c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
556
Assets/Rendering/Prefabs/Canvas.prefab
Normal file
556
Assets/Rendering/Prefabs/Canvas.prefab
Normal file
@@ -0,0 +1,556 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &9026535830740058
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1596220658628776940}
|
||||
- component: {fileID: 6672458112312712712}
|
||||
- component: {fileID: 3081828165310011108}
|
||||
- component: {fileID: 5349664031701526150}
|
||||
- component: {fileID: 6474814586719468454}
|
||||
m_Layer: 5
|
||||
m_Name: Canvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1596220658628776940
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9026535830740058}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 0, y: 0, z: 0}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 3845743667891252539}
|
||||
- {fileID: 3201883731050491994}
|
||||
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: 0, y: 0}
|
||||
m_Pivot: {x: 0, y: 0}
|
||||
--- !u!223 &6672458112312712712
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9026535830740058}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
m_RenderMode: 0
|
||||
m_Camera: {fileID: 0}
|
||||
m_PlaneDistance: 100
|
||||
m_PixelPerfect: 0
|
||||
m_ReceivesEvents: 1
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 0
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!114 &3081828165310011108
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9026535830740058}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!114 &5349664031701526150
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9026535830740058}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &6474814586719468454
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9026535830740058}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 36e8da9d73937ba42b3ddc845bd232b3, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
extraMenu: {fileID: 1149286621614838598}
|
||||
--- !u!1 &1149286621614838598
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3201883731050491994}
|
||||
m_Layer: 5
|
||||
m_Name: ExtraMenu
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3201883731050491994
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1149286621614838598}
|
||||
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: 3149567034061518987}
|
||||
- {fileID: 6314127418420246373}
|
||||
m_Father: {fileID: 1596220658628776940}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 150, y: 550}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &1587833090545274988
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3149567034061518987}
|
||||
- component: {fileID: 1962965456032855317}
|
||||
- component: {fileID: 2167776298904264295}
|
||||
- component: {fileID: 949770743623128088}
|
||||
- component: {fileID: 4251386973041693939}
|
||||
m_Layer: 5
|
||||
m_Name: ScreenshotButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3149567034061518987
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1587833090545274988}
|
||||
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: 3201883731050491994}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 50, y: -50}
|
||||
m_SizeDelta: {x: 200, y: 200}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &1962965456032855317
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1587833090545274988}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2167776298904264295
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1587833090545274988}
|
||||
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: 451e45151aa33bb4f81acc0ff4921dcd, 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 &949770743623128088
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1587833090545274988}
|
||||
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: 2167776298904264295}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &4251386973041693939
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1587833090545274988}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: f58e0bbc8b9c1d8468a016efbd1539fb, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
screenshotButton: {fileID: 949770743623128088}
|
||||
--- !u!1 &2672113656551282264
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6314127418420246373}
|
||||
- component: {fileID: 9110153734344936014}
|
||||
- component: {fileID: 1543256943956527316}
|
||||
- component: {fileID: 393782669488423898}
|
||||
- component: {fileID: 2754441224872912904}
|
||||
m_Layer: 5
|
||||
m_Name: CancelButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &6314127418420246373
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2672113656551282264}
|
||||
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: 3201883731050491994}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 50, y: -300}
|
||||
m_SizeDelta: {x: 200, y: 200}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &9110153734344936014
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2672113656551282264}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1543256943956527316
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2672113656551282264}
|
||||
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: 897ac04d3fecfdb44b94aaf7b44d778a, 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 &393782669488423898
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2672113656551282264}
|
||||
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: 1543256943956527316}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &2754441224872912904
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2672113656551282264}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 36e8da9d73937ba42b3ddc845bd232b3, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
extraMenu: {fileID: 1149286621614838598}
|
||||
--- !u!1 &7489395641153028874
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3845743667891252539}
|
||||
- component: {fileID: 2253394871709186819}
|
||||
- component: {fileID: 2445253493489114219}
|
||||
- component: {fileID: 8904091200350269975}
|
||||
m_Layer: 5
|
||||
m_Name: MainButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3845743667891252539
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7489395641153028874}
|
||||
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: 1596220658628776940}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 150, y: -150}
|
||||
m_SizeDelta: {x: 200, y: 200}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &2253394871709186819
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7489395641153028874}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2445253493489114219
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7489395641153028874}
|
||||
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: ea898fea8091a62488b02c9772152d14, 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 &8904091200350269975
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7489395641153028874}
|
||||
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: 2445253493489114219}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 6474814586719468454}
|
||||
m_TargetAssemblyTypeName: AnimationsUI, Assembly-CSharp
|
||||
m_MethodName: ToggleExtraMenu
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
7
Assets/Rendering/Prefabs/Canvas.prefab.meta
Normal file
7
Assets/Rendering/Prefabs/Canvas.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef07377d741f8f940a5e798953a2a789
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
105
Assets/Rendering/Prefabs/Sofa.prefab
Normal file
105
Assets/Rendering/Prefabs/Sofa.prefab
Normal file
@@ -0,0 +1,105 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &564100530627430182
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalScale.x
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalScale.y
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalScale.z
|
||||
value: 20
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: -8679921383154817045, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_ConstrainProportionsScale
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 919132149155446097, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: Sofa
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 919132149155446097, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: -903021841371004655}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
--- !u!1 &798684835268098679 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 919132149155446097, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
m_PrefabInstance: {fileID: 564100530627430182}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!64 &-903021841371004655
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 798684835268098679}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 5
|
||||
m_Convex: 0
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -8089699231438940418, guid: 96d76ca61fc696f4d841082ad25c94be, type: 3}
|
||||
7
Assets/Rendering/Prefabs/Sofa.prefab.meta
Normal file
7
Assets/Rendering/Prefabs/Sofa.prefab.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e09b56ca981fc234fbec1acbe9c0bf48
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Rendering/Scripts.meta
Normal file
8
Assets/Rendering/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b87108f80fcd194cab99d35d188f288
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/Rendering/Scripts/BackButtonHandler.cs
Normal file
79
Assets/Rendering/Scripts/BackButtonHandler.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Assets.Resources.Scripts.Constants;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class BackButtonHandler : MonoBehaviour
|
||||
{
|
||||
private bool isExitPromptVisible = false;
|
||||
public GameObject exitPromptUI; // Una referencia a un panel de UI para confirmar la salida
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (exitPromptUI != null)
|
||||
{
|
||||
exitPromptUI.SetActive(false); // Desactivar el panel al inicio
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
// Detecta si el bot<6F>n "back" es presionado
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
HandleBackButton();
|
||||
}
|
||||
}
|
||||
|
||||
// M<>todo que maneja la l<>gica del bot<6F>n "back"
|
||||
void HandleBackButton()
|
||||
{
|
||||
string currentScene = SceneManager.GetActiveScene().name;
|
||||
|
||||
if (currentScene == ScreenNames.AR)
|
||||
{
|
||||
// Si estamos en la escena AR, cargar la escena principal
|
||||
SceneManager.LoadScene(ScreenNames.Main);
|
||||
}
|
||||
else if (currentScene == ScreenNames.Main)
|
||||
{
|
||||
// Si ya estamos en la escena principal, preguntar si quiere salir
|
||||
if (isExitPromptVisible)
|
||||
{
|
||||
// Si el cuadro de confirmaci<63>n ya est<73> visible, salir de la aplicaci<63>n
|
||||
Application.Quit();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mostrar el cuadro de confirmaci<63>n para salir
|
||||
ShowExitPrompt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mostrar el cuadro de confirmaci<63>n para salir
|
||||
private void ShowExitPrompt()
|
||||
{
|
||||
isExitPromptVisible = true;
|
||||
if (exitPromptUI != null)
|
||||
{
|
||||
exitPromptUI.SetActive(true); // Mostrar el panel de confirmaci<63>n
|
||||
}
|
||||
}
|
||||
|
||||
// Llamar a este m<>todo si el usuario confirma la salida
|
||||
public void ConfirmExit()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
// Llamar a este m<>todo si el usuario cancela la salida
|
||||
public void CancelExit()
|
||||
{
|
||||
isExitPromptVisible = false;
|
||||
if (exitPromptUI != null)
|
||||
{
|
||||
exitPromptUI.SetActive(false); // Ocultar el panel de confirmaci<63>n
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/BackButtonHandler.cs.meta
Normal file
11
Assets/Rendering/Scripts/BackButtonHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ce274ab6a871954cb0f52ec039d4f32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Rendering/Scripts/Constants.meta
Normal file
8
Assets/Rendering/Scripts/Constants.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eeade5e792a186a41888c159d0cb1110
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/Rendering/Scripts/Constants/ScreenNames.cs
Normal file
9
Assets/Rendering/Scripts/Constants/ScreenNames.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Assets.Resources.Scripts.Constants
|
||||
{
|
||||
public static class ScreenNames
|
||||
{
|
||||
public const string Main = "MainScreen";
|
||||
|
||||
public const string AR = "ARScreen";
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Constants/ScreenNames.cs.meta
Normal file
11
Assets/Rendering/Scripts/Constants/ScreenNames.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efa64e266c18eaa47aefc59f9dd1a3f9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Rendering/Scripts/DropdownMenu.cs
Normal file
16
Assets/Rendering/Scripts/DropdownMenu.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class DropdownMenu : MonoBehaviour
|
||||
{
|
||||
|
||||
public GameObject panel;
|
||||
|
||||
public void ToggleMenu()
|
||||
{
|
||||
panel.SetActive(!panel.activeSelf);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/DropdownMenu.cs.meta
Normal file
11
Assets/Rendering/Scripts/DropdownMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c60006937c555944697e0652023f3535
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Rendering/Scripts/Furniture.meta
Normal file
8
Assets/Rendering/Scripts/Furniture.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2d6bdbff63e9d541b72e1e566008ec8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Rendering/Scripts/Furniture/Furniture.cs
Normal file
13
Assets/Rendering/Scripts/Furniture/Furniture.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using JetBrains.Annotations;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class Furniture : MonoBehaviour
|
||||
{
|
||||
public void PlaceFurniture([CanBeNull] ARTrackable aRTrackable)
|
||||
{
|
||||
transform.SetParent(aRTrackable != null ? aRTrackable.transform : null);
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Furniture/Furniture.cs.meta
Normal file
11
Assets/Rendering/Scripts/Furniture/Furniture.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 17e788a765b8a8540a245deee922b393
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Rendering/Scripts/Furniture/FurnitureButton.cs
Normal file
19
Assets/Rendering/Scripts/Furniture/FurnitureButton.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Furniture
|
||||
{
|
||||
public class FurnitureButton : MonoBehaviour
|
||||
{
|
||||
public GameObject furniturePrefab;
|
||||
private FurnitureManager _furnitureManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_furnitureManager = FindFirstObjectByType<FurnitureManager>();
|
||||
|
||||
GetComponent<Button>().onClick.AddListener(() => _furnitureManager.SetSelectedFurniture(furniturePrefab));
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Furniture/FurnitureButton.cs.meta
Normal file
11
Assets/Rendering/Scripts/Furniture/FurnitureButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c4072d6f1c55d34bb1bcdd573b0db96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Assets/Rendering/Scripts/Furniture/FurnitureDragger.cs
Normal file
90
Assets/Rendering/Scripts/Furniture/FurnitureDragger.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
namespace Assets.Scripts.Furniture
|
||||
{
|
||||
public class FurnitureDragger : MonoBehaviour
|
||||
{
|
||||
private Camera _mainCamera;
|
||||
private ARRaycastManager _arRaycastManager;
|
||||
|
||||
private bool _isDragging;
|
||||
private bool _isRotating;
|
||||
private Vector2 _initialTouchPosition;
|
||||
private float _initialRotation;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_mainCamera = Camera.main;
|
||||
_arRaycastManager = FindFirstObjectByType<ARRaycastManager>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.touchCount == 1)
|
||||
{
|
||||
HandleDrag();
|
||||
}
|
||||
else if (Input.touchCount == 2)
|
||||
{
|
||||
HandleRotate();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleRotate()
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
Ray ray = _mainCamera.ScreenPointToRay(touch.position);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit) && hit.transform == transform)
|
||||
{
|
||||
_isDragging = true;
|
||||
}
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Moved && _isDragging)
|
||||
{
|
||||
List<ARRaycastHit> hits = new();
|
||||
if (_arRaycastManager.Raycast(touch.position, hits, TrackableType.PlaneWithinPolygon))
|
||||
{
|
||||
Pose hitPose = hits[0].pose;
|
||||
transform.position = hitPose.position;
|
||||
}
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { }
|
||||
{
|
||||
_isDragging = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDrag()
|
||||
{
|
||||
Touch touch1 = Input.GetTouch(0);
|
||||
Touch touch2 = Input.GetTouch(1);
|
||||
|
||||
if (touch1.phase == TouchPhase.Began || touch2.phase == TouchPhase.Began)
|
||||
{
|
||||
// Registrar el ángulo inicial para la rotación
|
||||
Vector2 initialVector = touch2.position - touch1.position;
|
||||
_initialRotation = Mathf.Atan2(initialVector.y, initialVector.x) * Mathf.Rad2Deg;
|
||||
}
|
||||
else if (touch1.phase == TouchPhase.Moved || touch2.phase == TouchPhase.Moved)
|
||||
{
|
||||
// Calcular el ángulo actual
|
||||
Vector2 currentVector = touch2.position - touch1.position;
|
||||
float currentRotation = Mathf.Atan2(currentVector.y, currentVector.x) * Mathf.Rad2Deg;
|
||||
|
||||
// Calcular la diferencia de ángulo y aplicar la rotación
|
||||
float deltaRotation = currentRotation - _initialRotation;
|
||||
transform.Rotate(Vector3.up, deltaRotation, Space.World);
|
||||
|
||||
// Actualizar el ángulo inicial
|
||||
_initialRotation = currentRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Furniture/FurnitureDragger.cs.meta
Normal file
11
Assets/Rendering/Scripts/Furniture/FurnitureDragger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f762d4bce59928241a92c04ffe468dfe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
94
Assets/Rendering/Scripts/Furniture/FurnitureManager.cs
Normal file
94
Assets/Rendering/Scripts/Furniture/FurnitureManager.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Assets.Scripts.Furniture;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class FurnitureManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ARRaycastManager arRaycastManager; // Para detectar superficies
|
||||
[SerializeField] private List<GameObject> furniturePrefabs; // Lista de prefabs de muebles
|
||||
[SerializeField] private GameObject furniturePreviewPrefab; // Prefab para previsualizaci<63>n
|
||||
|
||||
private GameObject _currentPreview;
|
||||
private GameObject _currentFurniturePrefab;
|
||||
private Vector3 _detectedPosition = Vector3.zero;
|
||||
private Quaternion _detectedRotation = Quaternion.identity;
|
||||
private bool _canAddFurniture = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Establece el primer mueble como predeterminado
|
||||
if (furniturePrefabs.Count > 0)
|
||||
{
|
||||
SetSelectedFurniture(furniturePrefabs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
DetectPlaneAndUpdatePreview();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// M<>todo para detectar planos y actualizar la posici<63>n de previsualizaci<63>n.
|
||||
/// </summary>
|
||||
private void DetectPlaneAndUpdatePreview()
|
||||
{
|
||||
if (_currentPreview == null) return;
|
||||
|
||||
var hits = new List<ARRaycastHit>();
|
||||
var middleScreen = new Vector2(Screen.width / 2, Screen.height / 2);
|
||||
|
||||
if (arRaycastManager.Raycast(middleScreen, hits, TrackableType.PlaneWithinPolygon))
|
||||
{
|
||||
_detectedPosition = hits[0].pose.position;
|
||||
_detectedRotation = hits[0].pose.rotation;
|
||||
|
||||
_currentPreview.transform.SetPositionAndRotation(_detectedPosition, _detectedRotation);
|
||||
_currentPreview.SetActive(true);
|
||||
|
||||
_canAddFurniture = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentPreview.SetActive(false);
|
||||
_canAddFurniture = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// M<>todo para colocar un mueble en la posici<63>n detectada.
|
||||
/// </summary>
|
||||
public void PlaceFurniture()
|
||||
{
|
||||
if (!_canAddFurniture || _currentFurniturePrefab == null) return;
|
||||
|
||||
var newFurniture = Instantiate(_currentFurniturePrefab);
|
||||
newFurniture.transform.SetPositionAndRotation(_detectedPosition, _detectedRotation);
|
||||
|
||||
// A<>adir funcionalidad de manipulaci<63>n (rotar, mover, etc.)
|
||||
newFurniture.AddComponent<FurnitureDragger>();
|
||||
|
||||
Debug.Log("Mueble colocado en la posici<63>n detectada.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cambiar el prefab del mueble seleccionado.
|
||||
/// </summary>
|
||||
/// <param name="furniturePrefab">Prefab del mueble seleccionado.</param>
|
||||
public void SetSelectedFurniture(GameObject furniturePrefab)
|
||||
{
|
||||
_currentFurniturePrefab = furniturePrefab;
|
||||
|
||||
// Actualizar el preview
|
||||
if (_currentPreview != null)
|
||||
{
|
||||
Destroy(_currentPreview);
|
||||
}
|
||||
|
||||
_currentPreview = Instantiate(furniturePreviewPrefab ?? furniturePrefab);
|
||||
_currentPreview.SetActive(false);
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Furniture/FurnitureManager.cs.meta
Normal file
11
Assets/Rendering/Scripts/Furniture/FurnitureManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4754f676fdfa9f0418689553f7af213f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
63
Assets/Rendering/Scripts/Furniture/FurnitureSpawner.cs
Normal file
63
Assets/Rendering/Scripts/Furniture/FurnitureSpawner.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class FurnitureSpawner : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private ARRaycastManager arRaycastManager;
|
||||
[SerializeField] private GameObject furniturePrefab;
|
||||
|
||||
private bool _canAddFurniture;
|
||||
private GameObject _furniturePreview;
|
||||
private Vector3 _detectedPosition = new();
|
||||
private Quaternion _detectedRotation = Quaternion.identity;
|
||||
private ARTrackable _currentTrackable = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
InputHandler.OnTap += SpawnFurniture;
|
||||
_furniturePreview = Instantiate(furniturePrefab);
|
||||
SetCanAddFurniture(true);
|
||||
}
|
||||
|
||||
private void SpawnFurniture()
|
||||
{
|
||||
if (!_canAddFurniture) return;
|
||||
|
||||
var furniture = Instantiate(furniturePrefab);
|
||||
|
||||
furniture.GetComponent<Furniture>().PlaceFurniture(_currentTrackable);
|
||||
furniture.transform.SetPositionAndRotation(_detectedPosition, _detectedRotation);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
// Detect a position and rotation over the detected surface
|
||||
GetRaycastHitTransform();
|
||||
}
|
||||
|
||||
private void GetRaycastHitTransform()
|
||||
{
|
||||
var hits = new List<ARRaycastHit>();
|
||||
var middleScreen = new Vector2(Screen.width / 2, Screen.height / 2);
|
||||
if (arRaycastManager.Raycast(middleScreen, hits, TrackableType.PlaneWithinPolygon))
|
||||
{
|
||||
_detectedPosition = hits[0].pose.position;
|
||||
_detectedRotation = hits[0].pose.rotation;
|
||||
_furniturePreview.transform.SetPositionAndRotation(_detectedPosition, _detectedRotation);
|
||||
_currentTrackable = hits[0].trackable;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
InputHandler.OnTap -= SpawnFurniture;
|
||||
}
|
||||
|
||||
private void SetCanAddFurniture(bool canAddFurniture)
|
||||
{
|
||||
_canAddFurniture = canAddFurniture;
|
||||
_furniturePreview.SetActive(canAddFurniture);
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Furniture/FurnitureSpawner.cs.meta
Normal file
11
Assets/Rendering/Scripts/Furniture/FurnitureSpawner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc7cde5cab4e5c6409f75a3825da5fa5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Rendering/Scripts/Input.meta
Normal file
8
Assets/Rendering/Scripts/Input.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7693a63861599743b8f69ecdce9bd68
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Rendering/Scripts/Input/AnimationsUI.cs
Normal file
48
Assets/Rendering/Scripts/Input/AnimationsUI.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class AnimationsUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject extraMenu;
|
||||
private bool isMenuActive = false;
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Asegurarse de que el men<65> est<73> en la posici<63>n fuera de la pantalla al inicio
|
||||
extraMenu.GetComponent<RectTransform>().anchoredPosition = new Vector2(extraMenu.GetComponent<RectTransform>().anchoredPosition.x, 550);
|
||||
extraMenu.SetActive(false); // El men<65> empieza desactivado
|
||||
}
|
||||
|
||||
public void ToggleExtraMenu()
|
||||
{
|
||||
if (isMenuActive)
|
||||
{
|
||||
DeactivateExtraMenu();
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivateExtraMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public void ActivateExtraMenu()
|
||||
{
|
||||
// Colocar el men<65> en la posici<63>n fuera de la vista antes de activarlo
|
||||
extraMenu.GetComponent<RectTransform>().anchoredPosition = new Vector2(extraMenu.GetComponent<RectTransform>().anchoredPosition.x, 550);
|
||||
extraMenu.SetActive(true); // Activar el men<65> inmediatamente
|
||||
LeanTween.moveY(extraMenu.GetComponent<RectTransform>(), -400, 0.5f) // Reducir tiempo de animaci<63>n
|
||||
.setEase(LeanTweenType.easeOutExpo)
|
||||
.setOnComplete(() => isMenuActive = true); // Cambiar el estado del men<65>
|
||||
}
|
||||
|
||||
public void DeactivateExtraMenu()
|
||||
{
|
||||
// Animar el men<65> para ocultarlo y desactivarlo al terminar la animaci<63>n
|
||||
LeanTween.moveY(extraMenu.GetComponent<RectTransform>(), 550, 0.5f) // Reducir tiempo de animaci<63>n
|
||||
.setEase(LeanTweenType.easeInExpo)
|
||||
.setOnComplete(() =>
|
||||
{
|
||||
extraMenu.SetActive(false); // Desactivar el men<65> despu<70>s de la animaci<63>n
|
||||
isMenuActive = false; // Cambiar el estado del men<65>
|
||||
});
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Input/AnimationsUI.cs.meta
Normal file
11
Assets/Rendering/Scripts/Input/AnimationsUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d34713073cfff8e449751aa3cdb33704
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Assets/Rendering/Scripts/Input/InputHandler.cs
Normal file
31
Assets/Rendering/Scripts/Input/InputHandler.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InputHandler : MonoBehaviour
|
||||
{
|
||||
public static event Action OnTap;
|
||||
private UserInput _userInput;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_userInput = new UserInput();
|
||||
_userInput.Enable();
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_userInput.MobileTouch.Tap.performed += OnTapPerformed;
|
||||
}
|
||||
|
||||
private void OnTapPerformed(InputAction.CallbackContext context)
|
||||
{
|
||||
OnTap?.Invoke();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_userInput.MobileTouch.Tap.performed -= OnTapPerformed;
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Input/InputHandler.cs.meta
Normal file
11
Assets/Rendering/Scripts/Input/InputHandler.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e43702aefc12384a940b0cc2439dcb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
183
Assets/Rendering/Scripts/Input/UserInput.cs
Normal file
183
Assets/Rendering/Scripts/Input/UserInput.cs
Normal file
@@ -0,0 +1,183 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
|
||||
// version 1.11.0
|
||||
// from Assets/Rendering/Scripts/Input/UserInput.inputactions
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.Utilities;
|
||||
|
||||
public partial class @UserInput: IInputActionCollection2, IDisposable
|
||||
{
|
||||
public InputActionAsset asset { get; }
|
||||
public @UserInput()
|
||||
{
|
||||
asset = InputActionAsset.FromJson(@"{
|
||||
""name"": ""UserInput"",
|
||||
""maps"": [
|
||||
{
|
||||
""name"": ""MobileTouch"",
|
||||
""id"": ""61b9d527-e568-4d9a-b29c-76c81e318c30"",
|
||||
""actions"": [
|
||||
{
|
||||
""name"": ""Tap"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""cc2f4409-7610-4448-8159-a64fcf617dcc"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""77adbad9-9a21-48ad-b3ed-9c05bb6b8080"",
|
||||
""path"": ""<Touchscreen>/primaryTouch/tap"",
|
||||
""interactions"": ""Tap"",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Tap"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""d2bc1807-065d-4e50-bb15-4c59d514aee2"",
|
||||
""path"": ""<Mouse>/leftButton"",
|
||||
""interactions"": ""Tap"",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Tap"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
""controlSchemes"": []
|
||||
}");
|
||||
// MobileTouch
|
||||
m_MobileTouch = asset.FindActionMap("MobileTouch", throwIfNotFound: true);
|
||||
m_MobileTouch_Tap = m_MobileTouch.FindAction("Tap", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@UserInput()
|
||||
{
|
||||
UnityEngine.Debug.Assert(!m_MobileTouch.enabled, "This will cause a leak and performance issues, UserInput.MobileTouch.Disable() has not been called.");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Object.Destroy(asset);
|
||||
}
|
||||
|
||||
public InputBinding? bindingMask
|
||||
{
|
||||
get => asset.bindingMask;
|
||||
set => asset.bindingMask = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputDevice>? devices
|
||||
{
|
||||
get => asset.devices;
|
||||
set => asset.devices = value;
|
||||
}
|
||||
|
||||
public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
|
||||
|
||||
public bool Contains(InputAction action)
|
||||
{
|
||||
return asset.Contains(action);
|
||||
}
|
||||
|
||||
public IEnumerator<InputAction> GetEnumerator()
|
||||
{
|
||||
return asset.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
asset.Enable();
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
{
|
||||
asset.Disable();
|
||||
}
|
||||
|
||||
public IEnumerable<InputBinding> bindings => asset.bindings;
|
||||
|
||||
public InputAction FindAction(string actionNameOrId, bool throwIfNotFound = false)
|
||||
{
|
||||
return asset.FindAction(actionNameOrId, throwIfNotFound);
|
||||
}
|
||||
|
||||
public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
{
|
||||
return asset.FindBinding(bindingMask, out action);
|
||||
}
|
||||
|
||||
// MobileTouch
|
||||
private readonly InputActionMap m_MobileTouch;
|
||||
private List<IMobileTouchActions> m_MobileTouchActionsCallbackInterfaces = new List<IMobileTouchActions>();
|
||||
private readonly InputAction m_MobileTouch_Tap;
|
||||
public struct MobileTouchActions
|
||||
{
|
||||
private @UserInput m_Wrapper;
|
||||
public MobileTouchActions(@UserInput wrapper) { m_Wrapper = wrapper; }
|
||||
public InputAction @Tap => m_Wrapper.m_MobileTouch_Tap;
|
||||
public InputActionMap Get() { return m_Wrapper.m_MobileTouch; }
|
||||
public void Enable() { Get().Enable(); }
|
||||
public void Disable() { Get().Disable(); }
|
||||
public bool enabled => Get().enabled;
|
||||
public static implicit operator InputActionMap(MobileTouchActions set) { return set.Get(); }
|
||||
public void AddCallbacks(IMobileTouchActions instance)
|
||||
{
|
||||
if (instance == null || m_Wrapper.m_MobileTouchActionsCallbackInterfaces.Contains(instance)) return;
|
||||
m_Wrapper.m_MobileTouchActionsCallbackInterfaces.Add(instance);
|
||||
@Tap.started += instance.OnTap;
|
||||
@Tap.performed += instance.OnTap;
|
||||
@Tap.canceled += instance.OnTap;
|
||||
}
|
||||
|
||||
private void UnregisterCallbacks(IMobileTouchActions instance)
|
||||
{
|
||||
@Tap.started -= instance.OnTap;
|
||||
@Tap.performed -= instance.OnTap;
|
||||
@Tap.canceled -= instance.OnTap;
|
||||
}
|
||||
|
||||
public void RemoveCallbacks(IMobileTouchActions instance)
|
||||
{
|
||||
if (m_Wrapper.m_MobileTouchActionsCallbackInterfaces.Remove(instance))
|
||||
UnregisterCallbacks(instance);
|
||||
}
|
||||
|
||||
public void SetCallbacks(IMobileTouchActions instance)
|
||||
{
|
||||
foreach (var item in m_Wrapper.m_MobileTouchActionsCallbackInterfaces)
|
||||
UnregisterCallbacks(item);
|
||||
m_Wrapper.m_MobileTouchActionsCallbackInterfaces.Clear();
|
||||
AddCallbacks(instance);
|
||||
}
|
||||
}
|
||||
public MobileTouchActions @MobileTouch => new MobileTouchActions(this);
|
||||
public interface IMobileTouchActions
|
||||
{
|
||||
void OnTap(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/Input/UserInput.cs.meta
Normal file
11
Assets/Rendering/Scripts/Input/UserInput.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6fdf824f953584842baff9a570fcfea8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/Rendering/Scripts/Input/UserInput.inputactions
Normal file
45
Assets/Rendering/Scripts/Input/UserInput.inputactions
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "UserInput",
|
||||
"maps": [
|
||||
{
|
||||
"name": "MobileTouch",
|
||||
"id": "61b9d527-e568-4d9a-b29c-76c81e318c30",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Tap",
|
||||
"type": "Button",
|
||||
"id": "cc2f4409-7610-4448-8159-a64fcf617dcc",
|
||||
"expectedControlType": "",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"name": "",
|
||||
"id": "77adbad9-9a21-48ad-b3ed-9c05bb6b8080",
|
||||
"path": "<Touchscreen>/primaryTouch/tap",
|
||||
"interactions": "Tap",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Tap",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"id": "d2bc1807-065d-4e50-bb15-4c59d514aee2",
|
||||
"path": "<Mouse>/leftButton",
|
||||
"interactions": "Tap",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Tap",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"controlSchemes": []
|
||||
}
|
||||
14
Assets/Rendering/Scripts/Input/UserInput.inputactions.meta
Normal file
14
Assets/Rendering/Scripts/Input/UserInput.inputactions.meta
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 116a31151feae794ab271c090458bf17
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||
generateWrapperCode: 1
|
||||
wrapperCodePath:
|
||||
wrapperClassName:
|
||||
wrapperCodeNamespace:
|
||||
8
Assets/Rendering/Scripts/New.meta
Normal file
8
Assets/Rendering/Scripts/New.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f73149bbc806c74486060c2a88d9572
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
79
Assets/Rendering/Scripts/New/DragAndDropManager.cs
Normal file
79
Assets/Rendering/Scripts/New/DragAndDropManager.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class DragAndDropManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public GameObject prefabToInstance;
|
||||
|
||||
private ARRaycastManager arRaycastManager; // Asignable din<69>micamente
|
||||
private Camera arCamera; // Asignable din<69>micamente
|
||||
private GameObject draggedObject;
|
||||
|
||||
// M<>todo para asignar la c<>mara desde MeasuringSystem
|
||||
public void SetCamera(Camera camera)
|
||||
{
|
||||
if (camera == null)
|
||||
{
|
||||
Debug.LogError("C<>mara proporcionada es nula.");
|
||||
return;
|
||||
}
|
||||
arCamera = camera;
|
||||
Debug.Log($"C<>mara asignada: {arCamera.name}");
|
||||
}
|
||||
|
||||
// M<>todo para asignar el ARRaycastManager desde MeasuringSystem
|
||||
public void SetARRaycastManager(ARRaycastManager raycastManager)
|
||||
{
|
||||
if (raycastManager == null)
|
||||
{
|
||||
Debug.LogError("ARRaycastManager proporcionado es nulo.");
|
||||
return;
|
||||
}
|
||||
arRaycastManager = raycastManager;
|
||||
Debug.Log($"ARRaycastManager asignado: {arRaycastManager.name}");
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
if (prefabToInstance != null)
|
||||
{
|
||||
draggedObject = Instantiate(prefabToInstance);
|
||||
draggedObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
if (draggedObject != null)
|
||||
{
|
||||
if (arRaycastManager == null || arCamera == null)
|
||||
{
|
||||
Debug.LogWarning("ARRaycastManager o c<>mara no asignados. No se puede realizar el raycast.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<ARRaycastHit> hits = new List<ARRaycastHit>();
|
||||
if (arRaycastManager.Raycast(eventData.position, hits, TrackableType.Planes))
|
||||
{
|
||||
var hitPose = hits[0].pose;
|
||||
|
||||
// Colocar el objeto en la posici<63>n AR detectada
|
||||
draggedObject.transform.position = hitPose.position;
|
||||
draggedObject.transform.rotation = hitPose.rotation;
|
||||
draggedObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
if (draggedObject != null)
|
||||
{
|
||||
draggedObject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/New/DragAndDropManager.cs.meta
Normal file
11
Assets/Rendering/Scripts/New/DragAndDropManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bcac7e483a825d48bb0e327d618f0ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
215
Assets/Rendering/Scripts/New/ObjectSelector.cs
Normal file
215
Assets/Rendering/Scripts/New/ObjectSelector.cs
Normal file
@@ -0,0 +1,215 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.ARFoundation;
|
||||
using UnityEngine.XR.ARSubsystems;
|
||||
|
||||
public class ObjectSelector : MonoBehaviour
|
||||
{
|
||||
public LayerMask interactableLayer;
|
||||
|
||||
private ARRaycastManager arRaycastManager; // Asignable din<69>micamente
|
||||
private Camera arCamera; // Asignable din<69>micamente
|
||||
private GameObject selectedObject;
|
||||
|
||||
private readonly float longTapTreshold = 1f;
|
||||
private readonly float doubleTapMaxDelay = 0.5f;
|
||||
private float tapTimer = 0f;
|
||||
private float lastTapTime = 0f;
|
||||
private bool isRelocating = false;
|
||||
|
||||
// M<>todo para asignar la c<>mara desde MeasuringSystem
|
||||
public void SetCamera(Camera camera)
|
||||
{
|
||||
arCamera = camera;
|
||||
Debug.Log($"C<>mara asignada: {arCamera.name}");
|
||||
}
|
||||
|
||||
// M<>todo para asignar el ARRaycastManager desde MeasuringSystem
|
||||
public void SetARRaycastManager(ARRaycastManager raycastManager)
|
||||
{
|
||||
arRaycastManager = raycastManager;
|
||||
Debug.Log($"ARRaycastManager asignado: {arRaycastManager.name}");
|
||||
FindObjectOfType<DebugLoggerUI>().AddMessage($"ARRaycastManager asignado: {arRaycastManager.name}");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (arCamera == null || arRaycastManager == null)
|
||||
{
|
||||
Debug.LogWarning("La c<>mara o el ARRaycastManager no han sido asignados.");
|
||||
FindObjectOfType<DebugLoggerUI>().AddMessage("La c<>mara o el ARRaycastManager no han sido asignados.");
|
||||
return;
|
||||
}
|
||||
|
||||
HandleTouchInput();
|
||||
HandleRotation();
|
||||
UpdateOutline();
|
||||
}
|
||||
|
||||
private void HandleTouchInput()
|
||||
{
|
||||
if (Input.touchCount == 1)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
Ray ray = arCamera.ScreenPointToRay(touch.position);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity, interactableLayer))
|
||||
{
|
||||
if (selectedObject == hit.collider.gameObject)
|
||||
{
|
||||
if (Time.time - lastTapTime <= doubleTapMaxDelay)
|
||||
{
|
||||
DeleteObject();
|
||||
lastTapTime = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastTapTime = Time.time;
|
||||
StartCoroutine(CheckLongTap());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectObject(hit.collider.gameObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DeselectObject();
|
||||
}
|
||||
}
|
||||
|
||||
if (touch.phase == TouchPhase.Moved && isRelocating)
|
||||
{
|
||||
RelocateObject(touch.position);
|
||||
}
|
||||
|
||||
if (touch.phase == TouchPhase.Ended)
|
||||
{
|
||||
isRelocating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator CheckLongTap()
|
||||
{
|
||||
tapTimer = 0f;
|
||||
while (tapTimer < longTapTreshold)
|
||||
{
|
||||
if (Input.touchCount == 0 || Input.GetTouch(0).phase == TouchPhase.Ended)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
tapTimer += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
isRelocating = true;
|
||||
}
|
||||
|
||||
private void RelocateObject(Vector2 screenPosition)
|
||||
{
|
||||
if (selectedObject != null)
|
||||
{
|
||||
List<ARRaycastHit> hits = new();
|
||||
if (arRaycastManager.Raycast(screenPosition, hits, TrackableType.Planes))
|
||||
{
|
||||
Pose hitPose = hits[0].pose;
|
||||
|
||||
selectedObject.transform.SetPositionAndRotation(Vector3.Lerp(
|
||||
selectedObject.transform.position,
|
||||
hitPose.position,
|
||||
Time.deltaTime * 10f
|
||||
), Quaternion.Lerp(
|
||||
selectedObject.transform.rotation,
|
||||
selectedObject.transform.rotation,
|
||||
Time.deltaTime * 10f
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleRotation()
|
||||
{
|
||||
if (selectedObject != null && Input.touchCount == 1)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
if (touch.phase == TouchPhase.Moved)
|
||||
{
|
||||
Vector2 touchDelta = touch.deltaPosition;
|
||||
float rotationAmount = touchDelta.x * 0.1f;
|
||||
|
||||
selectedObject.transform.Rotate(0, -rotationAmount, 0, Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SelectObject(GameObject gameObject)
|
||||
{
|
||||
if (selectedObject != null)
|
||||
{
|
||||
DeselectObject();
|
||||
}
|
||||
|
||||
selectedObject = gameObject;
|
||||
|
||||
if (selectedObject != null)
|
||||
{
|
||||
EnableOutline(selectedObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeselectObject()
|
||||
{
|
||||
if (selectedObject != null)
|
||||
{
|
||||
DisableOutline(selectedObject);
|
||||
}
|
||||
|
||||
selectedObject = null;
|
||||
}
|
||||
|
||||
private void DeleteObject()
|
||||
{
|
||||
if (selectedObject != null)
|
||||
{
|
||||
Destroy(selectedObject);
|
||||
selectedObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableOutline(GameObject obj)
|
||||
{
|
||||
if (obj.TryGetComponent<Outline>(out var outline))
|
||||
{
|
||||
outline.enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newOutline = obj.AddComponent<Outline>();
|
||||
newOutline.OutlineColor = Color.cyan;
|
||||
newOutline.OutlineWidth = 10f;
|
||||
}
|
||||
}
|
||||
|
||||
private void DisableOutline(GameObject obj)
|
||||
{
|
||||
if (obj.TryGetComponent<Outline>(out var outline))
|
||||
{
|
||||
outline.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateOutline()
|
||||
{
|
||||
if (selectedObject != null)
|
||||
{
|
||||
EnableOutline(selectedObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Rendering/Scripts/New/ObjectSelector.cs.meta
Normal file
12
Assets/Rendering/Scripts/New/ObjectSelector.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ec9fc900a2729c041a9c5a00765afc67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- selectionIndicatorPrefab: {instanceID: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/Rendering/Scripts/RotateAndMoveObject.cs
Normal file
88
Assets/Rendering/Scripts/RotateAndMoveObject.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class RotateAndMoveObjectAR : MonoBehaviour
|
||||
{
|
||||
public GameObject furniture;
|
||||
public Camera arCamera;
|
||||
public float rotationSpeed = 100f;
|
||||
public float moveSpeed = 0.01f;
|
||||
|
||||
private bool isRotating;
|
||||
private bool isMoving;
|
||||
private Vector2 lastTouchPosition;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
HandleRotation();
|
||||
HandleMovement();
|
||||
}
|
||||
|
||||
void HandleRotation()
|
||||
{
|
||||
// Comprobar si hay un segundo dedo en la pantalla (para rotaci<63>n)
|
||||
if (Input.touchCount == 1)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
lastTouchPosition = touch.position;
|
||||
isRotating = true;
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Moved && isRotating)
|
||||
{
|
||||
Vector2 touchDelta = touch.position - lastTouchPosition;
|
||||
float rotationAmount = touchDelta.x * rotationSpeed * Time.deltaTime;
|
||||
|
||||
// Rotar el objeto sobre el eje Y
|
||||
furniture.transform.Rotate(0, -rotationAmount, 0);
|
||||
|
||||
lastTouchPosition = touch.position;
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
|
||||
{
|
||||
isRotating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandleMovement()
|
||||
{
|
||||
// Comprobar si hay un toque en la pantalla para mover el objeto
|
||||
if (Input.touchCount == 1)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
Ray ray = arCamera.ScreenPointToRay(touch.position);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit))
|
||||
{
|
||||
if (hit.collider.gameObject == furniture)
|
||||
{
|
||||
isMoving = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Moved && isMoving)
|
||||
{
|
||||
// Calcular la nueva posici<63>n en el mundo
|
||||
Ray ray = arCamera.ScreenPointToRay(touch.position);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit))
|
||||
{
|
||||
// Mueve el mueble al punto donde toca el rayo
|
||||
furniture.transform.position = Vector3.Lerp(
|
||||
furniture.transform.position,
|
||||
hit.point,
|
||||
moveSpeed
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
|
||||
{
|
||||
isMoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/RotateAndMoveObject.cs.meta
Normal file
11
Assets/Rendering/Scripts/RotateAndMoveObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19f18e429efebeb419ca31e26c506bb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/Rendering/Scripts/ScalateAndRotateObjectAR.cs
Normal file
49
Assets/Rendering/Scripts/ScalateAndRotateObjectAR.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ScalateAndRotateObjectAR : MonoBehaviour
|
||||
{
|
||||
public GameObject furniture;
|
||||
public Camera arCamera;
|
||||
public float rotationSpeed = 100f;
|
||||
|
||||
private bool isRotating;
|
||||
private Vector2 lastTouchPosition;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
HandleRotation();
|
||||
}
|
||||
|
||||
void HandleRotation()
|
||||
{
|
||||
// Comprobar si hay un toque en la pantalla
|
||||
if (Input.touchCount > 0)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
|
||||
// Si el toque ha comenzado
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
{
|
||||
lastTouchPosition = touch.position;
|
||||
isRotating = true;
|
||||
}
|
||||
// Mientras se arrastra el dedo en la pantalla
|
||||
else if (touch.phase == TouchPhase.Moved && isRotating)
|
||||
{
|
||||
Vector2 touchDelta = touch.position - lastTouchPosition;
|
||||
float rotatiorAmount = touchDelta.x * rotationSpeed * Time.deltaTime;
|
||||
|
||||
// Rotar el mueble sobre el eje Y
|
||||
furniture.transform.Rotate(0, -rotatiorAmount, 0);
|
||||
|
||||
lastTouchPosition = touch.position;
|
||||
}
|
||||
// Cuando el toque termina
|
||||
else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled)
|
||||
{
|
||||
isRotating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/ScalateAndRotateObjectAR.cs.meta
Normal file
11
Assets/Rendering/Scripts/ScalateAndRotateObjectAR.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 20102c103a6368046b860b5b8d1f7769
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Rendering/Scripts/SceneSwitcher.cs
Normal file
17
Assets/Rendering/Scripts/SceneSwitcher.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class SceneSwitcher : MonoBehaviour
|
||||
{
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("El nombre de la escena no ha sido proporcionado.");
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/SceneSwitcher.cs.meta
Normal file
11
Assets/Rendering/Scripts/SceneSwitcher.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a76adfc926dfcd4418ce1de84fc6848f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
196
Assets/Rendering/Scripts/ShareScreenshotButton.cs
Normal file
196
Assets/Rendering/Scripts/ShareScreenshotButton.cs
Normal file
@@ -0,0 +1,196 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Android;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ShareScreenshotButton : MonoBehaviour
|
||||
{
|
||||
public Button screenshotButton;
|
||||
private string fileName;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
if (!AndroidVersionIs11OrAbove() && !Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
|
||||
{
|
||||
// Si no tiene permisos, solicitarlos
|
||||
Permission.RequestUserPermission(Permission.ExternalStorageWrite);
|
||||
}
|
||||
|
||||
// Asignar la funci<63>n al evento onClick del bot<6F>n
|
||||
screenshotButton.onClick.AddListener(TakeScreenshotAndShare);
|
||||
}
|
||||
|
||||
public void CheckPermissions()
|
||||
{
|
||||
// Este m<>todo puede ser llamado en cualquier momento para verificar permisos
|
||||
if (Permission.HasUserAuthorizedPermission(Permission.ExternalStorageWrite))
|
||||
{
|
||||
Debug.Log("Permiso concedido para escribir en almacenamiento.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Permiso denegado para escribir en almacenamiento.");
|
||||
}
|
||||
}
|
||||
|
||||
public void TakeScreenshotAndShare()
|
||||
{
|
||||
fileName = "Screenshot_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".png";
|
||||
// Iniciar la rutina para capturar y compartir la pantalla
|
||||
StartCoroutine(CaptureAndShareScreenshot());
|
||||
}
|
||||
|
||||
private IEnumerator CaptureAndShareScreenshot()
|
||||
{
|
||||
// Esperar al final del frame para asegurarse de que todo est<73> dibujado
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
// Tomar la captura de pantalla y guardarla en la carpeta temporal del dispositivo
|
||||
Texture2D screenshot = new(Screen.width, Screen.height, TextureFormat.RGB24, false);
|
||||
screenshot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
screenshot.Apply();
|
||||
|
||||
byte[] imageBytes = screenshot.EncodeToPNG();
|
||||
|
||||
if (AndroidVersionIs11OrAbove())
|
||||
{
|
||||
SaveImageToGalleryAndShare(imageBytes, fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
SaveImageToExternalStorageAndShare(imageBytes, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private bool AndroidVersionIs11OrAbove()
|
||||
{
|
||||
return (Application.platform == RuntimePlatform.Android && SystemInfo.operatingSystem.StartsWith("Android OS") && int.Parse(SystemInfo.operatingSystem.Split(' ')[2]) >= 11);
|
||||
}
|
||||
|
||||
// Guardar en MediaStore (Android 11 o superior) y compartir
|
||||
private void SaveImageToGalleryAndShare(byte[] imageBytes, string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
AndroidJavaClass mediaStoreClass = new("android.provider.MediaStore$Images$Media");
|
||||
AndroidJavaObject contentResolver = GetContentResolver();
|
||||
AndroidJavaObject contentValues = new("android.content.ContentValues");
|
||||
|
||||
contentValues.Call("put", "title", fileName);
|
||||
contentValues.Call("put", "mime_type", "image/png");
|
||||
contentValues.Call("put", "relative_path", "Pictures/Screenshots");
|
||||
|
||||
AndroidJavaObject uri = contentResolver.Call<AndroidJavaObject>("insert", mediaStoreClass.GetStatic<AndroidJavaObject>("EXTERNAL_CONTENT_URI"), contentValues);
|
||||
if (uri != null)
|
||||
{
|
||||
AndroidJavaObject outputStream = contentResolver.Call<AndroidJavaObject>("openOutputStream", uri);
|
||||
outputStream.Call("write", imageBytes);
|
||||
outputStream.Call("flush");
|
||||
outputStream.Call("close");
|
||||
|
||||
Debug.Log("Captura guardada en la galer<65>a.");
|
||||
ShareScreenshot(uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("No se pudo guardar la imagen en MediaStore.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError("Error al guardar la captura en MediaStore: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Guardar en almacenamiento externo (para Android 8 a 10) y compartir
|
||||
private void SaveImageToExternalStorageAndShare(byte[] imageBytes, string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
string directory = GetExternalStorageDirectory();
|
||||
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
string filePath = Path.Combine(directory, fileName);
|
||||
File.WriteAllBytes(filePath, imageBytes);
|
||||
Debug.Log("Captura guardada en: " + filePath);
|
||||
|
||||
ShareScreenshot(new AndroidJavaObject("java.io.File", filePath));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError("Error al guardar la captura: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// M<>todo para obtener la ruta del almacenamiento externo
|
||||
private string GetExternalStorageDirectory()
|
||||
{
|
||||
AndroidJavaClass environment = new("android.os.Environment");
|
||||
string directory = environment.CallStatic<AndroidJavaObject>("getExternalStoragePublicDirectory", environment.GetStatic<string>("DIRECTORY_PICTURES")).Call<string>("getAbsolutePath");
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
// Compartir la captura de pantalla
|
||||
private void ShareScreenshot(AndroidJavaObject fileOrUri)
|
||||
{
|
||||
try
|
||||
{
|
||||
AndroidJavaClass intentClass = new("android.content.Intent");
|
||||
AndroidJavaObject intentObject = new("android.content.Intent");
|
||||
|
||||
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
|
||||
intentObject.Call<AndroidJavaObject>("setType", "image/png");
|
||||
|
||||
// Obtener el contexto de Unity
|
||||
AndroidJavaClass unityPlayer = new("com.unity3d.player.UnityPlayer");
|
||||
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
|
||||
// Si es Android 11 o superior, usa el URI; si es anterior, usa FileProvider
|
||||
if (AndroidVersionIs11OrAbove())
|
||||
{
|
||||
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), fileOrUri);
|
||||
intentObject.Call<AndroidJavaObject>("addFlags", 1 << 1); // FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
else
|
||||
{
|
||||
AndroidJavaClass fileProviderClass = new AndroidJavaClass("androidx.core.content.FileProvider");
|
||||
|
||||
AndroidJavaObject uri = fileProviderClass.CallStatic<AndroidJavaObject>(
|
||||
"getUriForFile",
|
||||
currentActivity,
|
||||
currentActivity.Call<string>("getPackageName") + ".fileprovider",
|
||||
fileOrUri
|
||||
);
|
||||
|
||||
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uri);
|
||||
intentObject.Call("addFlags", intentClass.GetStatic<int>("FLAG_GRANT_READ_URI_PERMISSION"));
|
||||
//intentObject.Call<AndroidJavaObject>("addFlags", 1 << 1); // FLAG_GRANT_READ_URI_PERMISSION
|
||||
}
|
||||
|
||||
AndroidJavaObject chooser = intentClass.CallStatic<AndroidJavaObject>("createChooser", intentObject, "Share Screenshot");
|
||||
currentActivity.Call("startActivity", chooser);
|
||||
|
||||
Debug.Log("Cuadro de di<64>logo de compartir lanzado.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError("Error al compartir la captura: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Obtener ContentResolver para Android
|
||||
private AndroidJavaObject GetContentResolver()
|
||||
{
|
||||
AndroidJavaClass unityPlayer = new("com.unity3d.player.UnityPlayer");
|
||||
AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
return currentActivity.Call<AndroidJavaObject>("getContentResolver");
|
||||
}
|
||||
}
|
||||
11
Assets/Rendering/Scripts/ShareScreenshotButton.cs.meta
Normal file
11
Assets/Rendering/Scripts/ShareScreenshotButton.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db859f4c6b3759c48bfa5e7bed44ccd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user