From a37b60f5a56cdfc5cd8623d18cf513e850f81884 Mon Sep 17 00:00:00 2001 From: Legonzaur Date: Tue, 24 Jan 2023 15:46:04 +0100 Subject: [PATCH] Catalog & Grab working --- Assets/Models/Simple table.prefab | 17 --- Assets/Models/chair.prefab | 16 -- Assets/Models/shelf_empty.prefab | 17 --- Assets/Scenes/FabLab/FabLab.unity | 235 ++++++++++++----------------- Assets/Scripts/Catalog.cs | 74 +++++++-- Assets/Scripts/CatalogElement.cs | 31 ++-- Assets/Scripts/FurnitureMover.cs | 28 +++- Assets/Scripts/MovableFurniture.cs | 29 +++- ProjectSettings/TagManager.asset | 3 +- 9 files changed, 219 insertions(+), 231 deletions(-) diff --git a/Assets/Models/Simple table.prefab b/Assets/Models/Simple table.prefab index e22e91e..32b60d1 100644 --- a/Assets/Models/Simple table.prefab +++ b/Assets/Models/Simple table.prefab @@ -197,7 +197,6 @@ GameObject: m_Component: - component: {fileID: 3674349604157782260} - component: {fileID: 7152506842566364840} - - component: {fileID: 5516512649396120673} m_Layer: 0 m_Name: Simple table m_TagString: Untagged @@ -240,22 +239,6 @@ MonoBehaviour: m_Center: {x: 0, y: 0, z: 0} m_Extent: {x: 0, y: 0, z: 0} wallMount: 0 ---- !u!54 &5516512649396120673 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4158574887593288270} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 --- !u!1 &6146061087085142095 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Models/chair.prefab b/Assets/Models/chair.prefab index 795761b..4d7db02 100644 --- a/Assets/Models/chair.prefab +++ b/Assets/Models/chair.prefab @@ -327,22 +327,6 @@ MonoBehaviour: m_Center: {x: 0, y: 0, z: 0} m_Extent: {x: 0, y: 0, z: 0} wallMount: 0 ---- !u!54 &5577736131529907943 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4774624094512517819} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 --- !u!4 &5035235579416466379 stripped Transform: m_CorrespondingSourceObject: {fileID: 820629935725706273, guid: 61dd8047e5e66dc4db5c150abe38beae, type: 3} diff --git a/Assets/Models/shelf_empty.prefab b/Assets/Models/shelf_empty.prefab index 361f2a8..4a6cfce 100644 --- a/Assets/Models/shelf_empty.prefab +++ b/Assets/Models/shelf_empty.prefab @@ -260,7 +260,6 @@ GameObject: - component: {fileID: 2996515769384266075} - component: {fileID: 2709258200819239477} - component: {fileID: 6645681851711596344} - - component: {fileID: 1547886741423616364} m_Layer: 0 m_Name: shelf_empty m_TagString: Untagged @@ -322,22 +321,6 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 2.017374, y: 1.4093293, z: 4.320848} m_Center: {x: -0.0065603256, y: 0.012041539, z: 2.1498158} ---- !u!54 &1547886741423616364 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2512467202128557025} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 --- !u!1 &2602268122132683364 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/FabLab/FabLab.unity b/Assets/Scenes/FabLab/FabLab.unity index 90f77a3..75054cc 100644 --- a/Assets/Scenes/FabLab/FabLab.unity +++ b/Assets/Scenes/FabLab/FabLab.unity @@ -2394,15 +2394,15 @@ Transform: m_Children: - {fileID: 1705480523} - {fileID: 808552922} + - {fileID: 146814758} + - {fileID: 896101879} + - {fileID: 1455652491} + - {fileID: 1672585692} - {fileID: 1329833008} - {fileID: 260182308} - {fileID: 765875807} - {fileID: 1290121936} - {fileID: 1527984575637916538} - - {fileID: 146814758} - - {fileID: 896101879} - - {fileID: 1455652491} - - {fileID: 1672585692} - {fileID: 435302310} - {fileID: 336078038} - {fileID: 1173886246} @@ -2432,7 +2432,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6694482510281237897, guid: f4664e62a3f09ce4894b51aeb60470bd, type: 3} propertyPath: m_RootOrder - value: 18 + value: 21 objectReference: {fileID: 0} - target: {fileID: 6694482510281237897, guid: f4664e62a3f09ce4894b51aeb60470bd, type: 3} propertyPath: m_LocalScale.x @@ -5760,7 +5760,7 @@ Transform: - {fileID: 899232842} - {fileID: 497015422} m_Father: {fileID: 45957245} - m_RootOrder: 7 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &175085081 PrefabInstance: @@ -5903,7 +5903,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_RootOrder - value: 3 + value: 2 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalScale.x @@ -5919,15 +5919,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.x - value: 1.6129999 + value: 0.3080759 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.y - value: -0.431 + value: 0.70722055 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.z - value: 0.705 + value: 0.284626 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalRotation.w @@ -6043,7 +6043,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 1888977164} + m_TransformParent: {fileID: 435302310} m_Modifications: - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_RootOrder @@ -6051,15 +6051,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalPosition.x - value: 0.0062946305 + value: 0.08329463 objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalPosition.y - value: 0.3921218 + value: -0.4288783 objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalPosition.z - value: 0.013928294 + value: 1.7049284 objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalRotation.w @@ -6170,7 +6170,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 475244, guid: 7a135b1a2cb9c8f488d4dd00c55ab283, type: 3} propertyPath: m_RootOrder - value: 3 + value: 7 objectReference: {fileID: 0} - target: {fileID: 475244, guid: 7a135b1a2cb9c8f488d4dd00c55ab283, type: 3} propertyPath: m_LocalPosition.x @@ -6261,7 +6261,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 15 + value: 19 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -7198,7 +7198,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6694482510281237897, guid: f4664e62a3f09ce4894b51aeb60470bd, type: 3} propertyPath: m_RootOrder - value: 20 + value: 23 objectReference: {fileID: 0} - target: {fileID: 6694482510281237897, guid: f4664e62a3f09ce4894b51aeb60470bd, type: 3} propertyPath: m_LocalScale.x @@ -7354,11 +7354,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.y - value: 1.4918169 + value: 0.32 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.z - value: -15.434761 + value: -9.03 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalRotation.w @@ -7504,7 +7504,11 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 1888977164} + - {fileID: 1288997560} + - {fileID: 132577122} + - {fileID: 472164268} + - {fileID: 802860442} + - {fileID: 242326303} m_Father: {fileID: 45957245} m_RootOrder: 11 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -8124,7 +8128,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 1888977164} + m_TransformParent: {fileID: 435302310} m_Modifications: - target: {fileID: 2048859290140646716, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_StaticEditorFlags @@ -8140,15 +8144,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.x - value: -0.0024496093 + value: 0.07455039 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.y - value: -0.33978105 + value: -1.1607809 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.z - value: -0.010123134 + value: 1.6808767 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalRotation.w @@ -8192,10 +8196,9 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7152506842566364840, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_Enabled - value: 0 + value: 1 objectReference: {fileID: 0} - m_RemovedComponents: - - {fileID: 7152506842566364840, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} + m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} --- !u!4 &472164268 stripped Transform: @@ -12113,7 +12116,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 19 + value: 22 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -13458,7 +13461,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 4 + value: 8 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -14638,7 +14641,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 1888977164} + m_TransformParent: {fileID: 435302310} m_Modifications: - target: {fileID: 4699182198977620406, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_Name @@ -14650,15 +14653,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.x - value: -1.6104125 + value: -1.5334125 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.y - value: -0.17465973 + value: -0.9956598 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.z - value: -0.014138341 + value: 1.6768618 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalRotation.w @@ -14996,6 +14999,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 808552922} + - component: {fileID: 808552923} m_Layer: 0 m_Name: Imprimantes 3D m_TagString: Untagged @@ -15011,17 +15015,33 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 808552921} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: -10.991924, y: 6.67572, z: -12.824374} + m_LocalPosition: {x: -9.687, y: 5.5375, z: -12.404} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 1317084064} - {fileID: 891532972} - {fileID: 2128333932} - {fileID: 197140882} + - {fileID: 1317084064} m_Father: {fileID: 45957245} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &808552923 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 808552921} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7310167259df75745b825087bf4c8de0, type: 3} + m_Name: + m_EditorClassIdentifier: + combinedBounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + wallMount: 0 --- !u!1001 &815680570 PrefabInstance: m_ObjectHideFlags: 0 @@ -16214,7 +16234,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_RootOrder - value: 1 + value: 0 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalScale.x @@ -16230,15 +16250,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.x - value: 1.613 + value: 0.3080759 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.y - value: -0.431 + value: 0.70722055 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.z - value: -0.304 + value: -0.7243738 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalRotation.w @@ -16349,7 +16369,7 @@ Transform: - {fileID: 193352390} - {fileID: 1967593823} m_Father: {fileID: 45957245} - m_RootOrder: 8 + m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &899232841 PrefabInstance: @@ -19445,7 +19465,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 1888977164} + m_TransformParent: {fileID: 435302310} m_Modifications: - target: {fileID: -4025371315460726001, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: showLeftPreview @@ -19461,23 +19481,23 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalScale.y - value: 0.20531806 + value: 0.20531808 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalScale.z - value: 0.20531791 + value: 0.20531793 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.x - value: 0.4568998 + value: 0.5338998 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.y - value: 0.37300003 + value: -0.44799995 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.z - value: -0.23510015 + value: 1.4559002 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalRotation.w @@ -19531,7 +19551,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 447954, guid: dc06161b6d97feb419f45f03b62e14b9, type: 3} propertyPath: m_RootOrder - value: 5 + value: 9 objectReference: {fileID: 0} - target: {fileID: 447954, guid: dc06161b6d97feb419f45f03b62e14b9, type: 3} propertyPath: m_LocalPosition.x @@ -19922,7 +19942,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_RootOrder - value: 0 + value: 3 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalScale.x @@ -19934,15 +19954,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.x - value: 1.3312488 + value: 0.026325226 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.y - value: -1.149927 + value: -0.011706829 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.z - value: 0.3568 + value: -0.06357384 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalRotation.w @@ -19984,7 +20004,12 @@ PrefabInstance: propertyPath: m_StaticEditorFlags value: 0 objectReference: {fileID: 0} - m_RemovedComponents: [] + - target: {fileID: 7152506842566364840, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} + propertyPath: m_Enabled + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: + - {fileID: 7152506842566364840, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} m_SourcePrefab: {fileID: 100100000, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} --- !u!4 &1317084064 stripped Transform: @@ -20000,7 +20025,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 2 + value: 6 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -21162,7 +21187,7 @@ Transform: - {fileID: 1620530528} - {fileID: 788326936} m_Father: {fileID: 45957245} - m_RootOrder: 9 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1481052597 PrefabInstance: @@ -22132,7 +22157,7 @@ MonoBehaviour: needsReinit: 0 AutoPlacementEnvironmentMask: serializedVersion: 2 - m_Bits: 256 + m_Bits: 1280 pointer: {fileID: 0} Grabbing: {fileID: 0} color: {r: 0, g: 0, b: 0, a: 0} @@ -22517,11 +22542,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 7304097665698855045, guid: 7520016a817d68f4685d157d457ebed1, type: 3} m_PrefabInstance: {fileID: 1569982188} m_PrefabAsset: {fileID: 0} ---- !u!1 &1573644873 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 2835658414891243653, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3} - m_PrefabInstance: {fileID: 1989420947} - m_PrefabAsset: {fileID: 0} --- !u!1001 &1582617698 PrefabInstance: m_ObjectHideFlags: 0 @@ -23658,7 +23678,7 @@ Transform: - {fileID: 815680571} - {fileID: 2061626855} m_Father: {fileID: 45957245} - m_RootOrder: 10 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1695254330 PrefabInstance: @@ -24029,7 +24049,7 @@ Transform: m_GameObject: {fileID: 1757592330} m_LocalRotation: {x: -0, y: -1, z: -0, w: 0.00000058114523} m_LocalPosition: {x: -6.057, y: -0.0029997826, z: -0} - m_LocalScale: {x: 0.12212861, y: 4.022701, z: 7.1114306} + m_LocalScale: {x: 0.14867938, y: 4.022701, z: 7.1114306} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 1173886246} @@ -26966,7 +26986,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 16 + value: 20 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -27307,7 +27327,7 @@ PrefabInstance: m_Modifications: - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_RootOrder - value: 14 + value: 18 objectReference: {fileID: 0} - target: {fileID: -8679921383154817045, guid: d8a039318f27391cdb025c7bd542c092, type: 3} propertyPath: m_LocalPosition.x @@ -28185,59 +28205,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} ---- !u!1 &1888977163 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1888977164} - - component: {fileID: 1888977165} - m_Layer: 0 - m_Name: Computer Rig - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &1888977164 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1888977163} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.077, y: -0.821, z: 1.691} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1288997560} - - {fileID: 132577122} - - {fileID: 472164268} - - {fileID: 802860442} - - {fileID: 242326303} - m_Father: {fileID: 435302310} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &1888977165 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1888977163} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 7310167259df75745b825087bf4c8de0, type: 3} - m_Name: - m_EditorClassIdentifier: - combinedBounds: - m_Center: {x: 0, y: 0, z: 0} - m_Extent: {x: 0, y: 0, z: 0} - wallMount: 0 --- !u!4 &1889890278 stripped Transform: m_CorrespondingSourceObject: {fileID: 5262755222010251265, guid: 481a02167edfebe44883f5868f8a27f9, type: 3} @@ -30194,22 +30161,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 589337997038399236, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3} m_PrefabInstance: {fileID: 1989420947} m_PrefabAsset: {fileID: 0} ---- !u!54 &1989420950 -Rigidbody: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1573644873} - serializedVersion: 2 - m_Mass: 1 - m_Drag: 0 - m_AngularDrag: 0.05 - m_UseGravity: 0 - m_IsKinematic: 1 - m_Interpolate: 0 - m_Constraints: 0 - m_CollisionDetection: 0 --- !u!1001 &2030655353 PrefabInstance: m_ObjectHideFlags: 0 @@ -33839,7 +33790,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_RootOrder - value: 2 + value: 1 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalScale.x @@ -33855,15 +33806,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.x - value: 1.6129999 + value: 0.3080759 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.y - value: -0.431 + value: 0.70722055 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalPosition.z - value: 0.211 + value: -0.20937347 objectReference: {fileID: 0} - target: {fileID: 5569992116628908473, guid: 3605d36a94a83634f940f71fad7f3930, type: 3} propertyPath: m_LocalRotation.w @@ -34005,7 +33956,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1527984575184472644, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3} propertyPath: m_RootOrder - value: 6 + value: 10 objectReference: {fileID: 0} - target: {fileID: 1527984575184472644, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3} propertyPath: m_LocalPosition.x @@ -34079,7 +34030,7 @@ PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: - m_TransformParent: {fileID: 1888977164} + m_TransformParent: {fileID: 435302310} m_Modifications: - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_RootOrder @@ -34087,15 +34038,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalPosition.x - value: -0.24544963 + value: -0.16844964 objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalPosition.y - value: 0.411 + value: -0.40999985 objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalPosition.z - value: -0.19400012 + value: 1.4969997 objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalRotation.w diff --git a/Assets/Scripts/Catalog.cs b/Assets/Scripts/Catalog.cs index 1fa43a6..fb2d5cc 100644 --- a/Assets/Scripts/Catalog.cs +++ b/Assets/Scripts/Catalog.cs @@ -1,12 +1,7 @@ -using JetBrains.Annotations; -using System; using System.Collections; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using UnityEditor; using UnityEngine; -using UnityEngine.ProBuilder.Shapes; -using UnityEngine.XR; +using Valve.VR; using Valve.VR.InteractionSystem; public class Catalog : MonoBehaviour @@ -22,6 +17,8 @@ public class Catalog : MonoBehaviour private GameObject currentSphere; public List Furnitures; private int maxShownObjects; + + private GameObject Trash; // Start is called before the first frame update void Start() { @@ -41,25 +38,68 @@ public class Catalog : MonoBehaviour // Update is called once per frame void Update() { + } + private void SpawnSphere(int index) + { + float radians = angle * Mathf.Deg2Rad; + float angleIncrement = radians / (maxShownObjects - 1); + if (index > Furnitures.Count - 1) + { + Debug.LogError("[Catalog] Sphere index out of bounds", this); + return; + } + var j = index * angleIncrement - radians / 2; + var sphere = Instantiate(spherePrefab); + sphere.transform.parent = transform; + sphere.transform.localScale = Vector3.one * objectScale; + sphere.transform.localPosition = new Vector3(Mathf.Sin(j), 0, Mathf.Cos(j)) * distance; + sphere.SetActive(true); + CatalogElement element = sphere.GetComponent(); + element.SetFurniture(Furnitures[index], objectScale); + element.index = index; + } + + public void SetTrash(MovableFurniture Grabbing) + { + Grabbing.gameObject.SetActive(false); + Trash.GetComponent().material.color = new Color(1, 0.5f, 0, 1); + } + + public void LeaveTrash(MovableFurniture Grabbing) + { + Grabbing.gameObject.SetActive(true); + CatalogElement element = Trash.GetComponent(); + element.ClearFurniture(); + Trash.GetComponent().material.color = new Color(1, 0, 0, 0.5f); + + } + private void SpawnTrash() + { + var sphere = Instantiate(spherePrefab); + sphere.transform.parent = transform; + sphere.transform.localScale = Vector3.one * objectScale; + sphere.transform.localPosition = new Vector3(0, 1, 1) * distance; + sphere.GetComponent().material.color = new Color(1, 0, 0, 0.5f); + sphere.GetComponent().enabled = false; + sphere.GetComponent().enabled = false; + sphere.SetActive(true); + sphere.tag = "Trash"; + sphere.layer = 10; + Trash = sphere; + } private void ShowCatalog() { gameObject.transform.SetParent(player.hands[0].transform); gameObject.transform.localPosition = Vector3.zero; - float radians = angle * Mathf.Deg2Rad; - float angleIncrement = radians / (maxShownObjects - 1); for (int i = 0; i < maxShownObjects; i++) { - var j = i * angleIncrement - radians / 2; - var sphere = Instantiate(spherePrefab); - sphere.transform.parent = transform; - sphere.transform.localScale = Vector3.one * objectScale; - sphere.transform.localPosition = new Vector3(Mathf.Sin(j), 0, Mathf.Cos(j)) * distance; - sphere.SetActive(true); - sphere.GetComponent().SetFurniture(Furnitures[i], objectScale); + SpawnSphere(i); } + SpawnTrash(); + StartCoroutine(CatalogCoroutine()); } @@ -107,18 +147,20 @@ public class Catalog : MonoBehaviour public void OnGrabSphere(CatalogElement sphere, Valve.VR.InteractionSystem.Hand hand) { + SpawnSphere(sphere.index); MovableFurniture grab = hand.GetComponent().Grabbing; if (grab != null) { return; } GameObject furniture = Instantiate(sphere.largeFurnitureModel); - MovableFurniture script = furniture.GetComponent() ; + MovableFurniture script = furniture.GetComponent(); if (!furniture.GetComponent()) { script = furniture.AddComponent(); } script.CalculateBounds(); + //script.OnPointerClickDown(); hand.GetComponent().Grabbing = script; } diff --git a/Assets/Scripts/CatalogElement.cs b/Assets/Scripts/CatalogElement.cs index 3ce80e6..2051730 100644 --- a/Assets/Scripts/CatalogElement.cs +++ b/Assets/Scripts/CatalogElement.cs @@ -1,13 +1,11 @@ using System.Collections; -using System.Collections.Generic; using UnityEngine; -using UnityEngine.Events; -using UnityEngine.ProBuilder.Shapes; using Valve.VR.InteractionSystem; public class CatalogElement : Throwable { public GameObject largeFurnitureModel; + public int index; private GameObject smallFurnitureModel; private Vector3 returnPosition; // Start is called before the first frame update @@ -19,7 +17,7 @@ public class CatalogElement : Throwable // Update is called once per frame void Update() { - + } protected override void OnAttachedToHand(Hand hand) @@ -42,7 +40,7 @@ public class CatalogElement : Throwable Catalog.Instance.OnGrabSphere(this, hand); //hand.GetComponent().Grabbing = largeFurnitureModel.GetComponent(); -} + } //------------------------------------------------- @@ -59,7 +57,7 @@ public class CatalogElement : Throwable Catalog.Instance.OnReleaseSphere(this, hand); Destroy(gameObject); } - + public void SetFurniture(GameObject furniture, float objectScale) { @@ -86,10 +84,16 @@ public class CatalogElement : Throwable }; float rescale = (objectScale / 1.4f) / objectBounds.combinedBounds.size.magnitude; smallFurnitureModel.transform.localScale *= rescale; - smallFurnitureModel.transform.localPosition = Vector3.down * 0.2f; + smallFurnitureModel.transform.localPosition = Vector3.down * 0.2f; StartCoroutine(KeepFurnitureAligned()); } + + public void ClearFurniture() + { + Destroy(smallFurnitureModel); + } + private IEnumerator ReturnSphere() { float time = 0; @@ -97,17 +101,24 @@ public class CatalogElement : Throwable while (time <= 1) { transform.localPosition = Vector3.Lerp(startPosition, returnPosition, time); - time += Time.deltaTime*4; + time += Time.deltaTime * 4; yield return null; } yield break; } - private IEnumerator KeepFurnitureAligned() { + private IEnumerator KeepFurnitureAligned() + { while (true) { - smallFurnitureModel.transform.eulerAngles = new Vector3(0, smallFurnitureModel.transform.eulerAngles.y-(20*Time.deltaTime), 0); + smallFurnitureModel.transform.eulerAngles = new Vector3(0, smallFurnitureModel.transform.eulerAngles.y - (20 * Time.deltaTime), 0); yield return null; } } + + + private void OnPointerEnter() + { + Debug.Log("enter"); + } } diff --git a/Assets/Scripts/FurnitureMover.cs b/Assets/Scripts/FurnitureMover.cs index fe5ea23..e78aa4c 100644 --- a/Assets/Scripts/FurnitureMover.cs +++ b/Assets/Scripts/FurnitureMover.cs @@ -25,6 +25,9 @@ public class FurnitureMover : MonoBehaviour private SnapTurn _snapturn; private Hand hand; + + public static FurnitureMover Instance; + private SnapTurn snapturn { get @@ -38,6 +41,7 @@ public class FurnitureMover : MonoBehaviour } private void Start() { + Instance = this; hand = GetComponent(); if (pose == null) pose = this.GetComponent(); @@ -77,16 +81,28 @@ public class FurnitureMover : MonoBehaviour Ray SnapRaycast = new Ray(transform.position, transform.forward); RaycastHit SnapHit; - //TODO Check if object is on walls - if (Grabbing.wallMount) - { - } + bool SnapbHit = Physics.Raycast(SnapRaycast, out SnapHit, 100f, AutoPlacementEnvironmentMask); if (SnapbHit && Grabbing != null) { - Grabbing.SnapTo(SnapHit.point, AutoPlacementEnvironmentMask, transform.forward); + //TODO Check if object is on walls + if (Grabbing.wallMount) + { + + } + if (SnapHit.collider.gameObject.tag == "Trash" && Grabbing.gameObject.activeInHierarchy) + { + Catalog.Instance.SetTrash(Grabbing); + } + else if (SnapHit.collider.gameObject.tag != "Trash") + { + Catalog.Instance.LeaveTrash(Grabbing); + Grabbing.gameObject.SetActive(true); + Grabbing.SnapTo(SnapHit.point, AutoPlacementEnvironmentMask, transform.forward); + } + } if (previousContact && previousContact != hit.transform) @@ -184,7 +200,7 @@ public class FurnitureMover : MonoBehaviour } private void OnPointerClickDown(object sender, PointerEventArgs e) { - if (Grabbing) + if (Grabbing != null) { return; } diff --git a/Assets/Scripts/MovableFurniture.cs b/Assets/Scripts/MovableFurniture.cs index c470e95..e1e3ba8 100644 --- a/Assets/Scripts/MovableFurniture.cs +++ b/Assets/Scripts/MovableFurniture.cs @@ -7,8 +7,8 @@ public class MovableFurniture : Furniture private List outlines; private Rigidbody _rigidbody; public bool wallMount; - private bool isColliding = false; + private bool isGrabbing = false; // Start is called before the first frame update new void Start() { @@ -38,17 +38,33 @@ public class MovableFurniture : Furniture public void OnPointerClickUp() { + isGrabbing = false; + foreach (ObjectOutline outline in outlines) + { + outline.enabled = false; + } if (_rigidbody != null) { _rigidbody.useGravity = true; + _rigidbody.isKinematic = false; } } + public void OnPointerClickDown() { + isGrabbing = true; + foreach (ObjectOutline outline in outlines) + { + outline.OutlineMode = ObjectOutline.Mode.OutlineAll; + outline.OutlineColor = Color.blue; + outline.OutlineWidth = 5f; + outline.enabled = true; + } if (_rigidbody != null) { _rigidbody.useGravity = false; + _rigidbody.isKinematic = true; } } @@ -57,18 +73,19 @@ public class MovableFurniture : Furniture { foreach (ObjectOutline outline in outlines) { - /*child.OutlineMode = ObjectOutline.Mode.OutlineAll; - child.OutlineColor = Color.yellow; - child.OutlineWidth = 5f;*/ - //outline.enabled = true; + outline.OutlineMode = ObjectOutline.Mode.OutlineAll; + outline.OutlineColor = Color.yellow; + outline.OutlineWidth = 5f; + outline.enabled = true; } } public void OnPointerExit() { + if (isGrabbing) { return; } foreach (ObjectOutline outline in outlines) { - //outline.enabled = false; + outline.enabled = false; } } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index d5f28ab..1001c23 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -8,6 +8,7 @@ TagManager: - projectile - FxTemporaire - FurnitureTrigger + - Trash layers: - Default - TransparentFX @@ -19,7 +20,7 @@ TagManager: - Teleport Area - Environment - FurnitureTrigger - - + - Trash - - -