diff --git a/Assets/Materials/Trash.mat b/Assets/Materials/Trash.mat new file mode 100644 index 0000000..ed45e4f --- /dev/null +++ b/Assets/Materials/Trash.mat @@ -0,0 +1,83 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Trash + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ValidKeywords: + - _ALPHAPREMULTIPLY_ON + - _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 10 + - _GlossMapScale: 0.5 + - _Glossiness: 0.737 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 3 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 1 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 0 + m_Colors: + - _Color: {r: 1, g: 0, b: 0.07366419, a: 0.42745098} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/Trash.mat.meta b/Assets/Materials/Trash.mat.meta new file mode 100644 index 0000000..610dcf1 --- /dev/null +++ b/Assets/Materials/Trash.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0e4be7523f64df641b9ac39f39093c91 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/FabLab/FabLab.unity b/Assets/Scenes/FabLab/FabLab.unity index b0b9f1f..07d28a3 100644 --- a/Assets/Scenes/FabLab/FabLab.unity +++ b/Assets/Scenes/FabLab/FabLab.unity @@ -6234,11 +6234,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalPosition.y - value: 0.3921218 + value: 0.7629217 objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalPosition.z - value: 0.013928294 + value: 0.013927817 objectReference: {fileID: 0} - target: {fileID: 8531222383232042004, guid: 0615df42b5cd5f1429cafa57731d1869, type: 3} propertyPath: m_LocalRotation.w @@ -6407,6 +6407,10 @@ PrefabInstance: propertyPath: pointVisibleMaterial value: objectReference: {fileID: 2100000, guid: 510c6e0b8b5c948458c2b4bc3de5a637, type: 2} + - target: {fileID: 11445746, guid: 7a135b1a2cb9c8f488d4dd00c55ab283, type: 3} + propertyPath: traceLayerMask.m_Bits + value: 384 + objectReference: {fileID: 0} - target: {fileID: 11445746, guid: 7a135b1a2cb9c8f488d4dd00c55ab283, type: 3} propertyPath: areaHighlightedMaterial value: @@ -8400,11 +8404,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.y - value: -0.33978105 + value: 0.031019092 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalPosition.z - value: -0.010123134 + value: -0.010122895 objectReference: {fileID: 0} - target: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} propertyPath: m_LocalRotation.w @@ -13768,11 +13772,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.y - value: -0.17465973 + value: 0.19614017 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalPosition.z - value: -0.014138341 + value: -0.014138818 objectReference: {fileID: 0} - target: {fileID: 5367457311287030540, guid: ab468a82ad445da4e9a084297505261f, type: 3} propertyPath: m_LocalRotation.w @@ -16734,6 +16738,120 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} +--- !u!1 &1104488937 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1104488938} + - component: {fileID: 1104488942} + - component: {fileID: 1104488941} + - component: {fileID: 1104488940} + - component: {fileID: 1104488939} + m_Layer: 10 + m_Name: Trash + m_TagString: Trash + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1104488938 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1104488937} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0.117, z: 0.2219} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} + m_ConstrainProportionsScale: 1 + m_Children: [] + m_Father: {fileID: 1527984575637916538} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!54 &1104488939 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1104488937} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 0 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 126 + m_CollisionDetection: 0 +--- !u!135 &1104488940 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1104488937} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &1104488941 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1104488937} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 0e4be7523f64df641b9ac39f39093c91, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &1104488942 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1104488937} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1119201756 GameObject: m_ObjectHideFlags: 0 @@ -16823,7 +16941,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh50740 + m_Name: pb_Mesh24816 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -18544,11 +18662,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalScale.y - value: 0.20531806 + value: 0.2053181 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalScale.z - value: 0.20531791 + value: 0.20531794 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.x @@ -18556,11 +18674,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.y - value: 0.37300003 + value: 0.74380004 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalPosition.z - value: -0.23510015 + value: -0.23510039 objectReference: {fileID: 0} - target: {fileID: 6291597597410968062, guid: fde4367ea6917fe43b9f69a154c145c1, type: 3} propertyPath: m_LocalRotation.w @@ -20247,6 +20365,68 @@ Transform: m_Father: {fileID: 45957245} m_RootOrder: 12 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1475892020 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1475892021} + - component: {fileID: 1475892022} + m_Layer: 26 + m_Name: FurnitureMover + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1475892021 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1475892020} + m_LocalRotation: {x: 0.1677507, y: -0.000000007450581, z: -0.000000004656613, w: 0.98582953} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1558616916} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 19.314, y: 0, z: 0} +--- !u!114 &1475892022 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1475892020} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 92e268c9230c939469a5d6b56877fb57, type: 3} + m_Name: + m_EditorClassIdentifier: + pose: {fileID: 0} + interactWithUI: + actionPath: /actions/default/in/InteractUI + needsReinit: 0 + snapLeftAction: + actionPath: /actions/default/in/SnapTurnLeft + needsReinit: 0 + snapRightAction: + actionPath: /actions/default/in/SnapTurnRight + needsReinit: 0 + AutoPlacementEnvironmentMask: + serializedVersion: 2 + m_Bits: 1280 + pointer: {fileID: 0} + Grabbing: {fileID: 0} + color: {r: 0, g: 0, b: 0, a: 0} + thickness: 0.002 + clickColor: {r: 0, g: 1, b: 0, a: 1} --- !u!1001 &1481052597 PrefabInstance: m_ObjectHideFlags: 0 @@ -21186,41 +21366,11 @@ Transform: m_Father: {fileID: 1173886246} m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &1558616909 stripped -GameObject: - m_CorrespondingSourceObject: {fileID: 160596, guid: dc06161b6d97feb419f45f03b62e14b9, type: 3} +--- !u!4 &1558616916 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 485514, guid: dc06161b6d97feb419f45f03b62e14b9, type: 3} m_PrefabInstance: {fileID: 1290121935} m_PrefabAsset: {fileID: 0} ---- !u!114 &1558616915 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1558616909} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 92e268c9230c939469a5d6b56877fb57, type: 3} - m_Name: - m_EditorClassIdentifier: - pose: {fileID: 0} - interactWithUI: - actionPath: /actions/default/in/InteractUI - needsReinit: 0 - snapLeftAction: - actionPath: /actions/default/in/SnapTurnLeft - needsReinit: 0 - snapRightAction: - actionPath: /actions/default/in/SnapTurnRight - needsReinit: 0 - AutoPlacementEnvironmentMask: - serializedVersion: 2 - m_Bits: 256 - pointer: {fileID: 0} - Grabbing: {fileID: 0} - color: {r: 0, g: 0, b: 0, a: 0} - thickness: 0.002 - clickColor: {r: 0, g: 1, b: 0, a: 1} --- !u!4 &1569489522 stripped Transform: m_CorrespondingSourceObject: {fileID: 3674349604157782260, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} @@ -27282,7 +27432,7 @@ Transform: 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.791} + m_LocalPosition: {x: 0.077, y: -1.1918, z: 1.791} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: @@ -33372,11 +33522,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalPosition.y - value: 0.411 + value: 0.78180015 objectReference: {fileID: 0} - target: {fileID: 7101811468694509626, guid: cbdff3e37c153cc48b95d4374a38eed9, type: 3} propertyPath: m_LocalPosition.z - value: -0.19400012 + value: -0.19399989 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 fb2d5cc..b9d0b7e 100644 --- a/Assets/Scripts/Catalog.cs +++ b/Assets/Scripts/Catalog.cs @@ -25,6 +25,7 @@ public class Catalog : MonoBehaviour Instance = this; maxShownObjects = Furnitures.Count; spherePrefab = transform.Find("Sphere").gameObject; + Trash = transform.Find("Trash").gameObject; player = Player.instance; if (player == null) { @@ -70,25 +71,26 @@ public class Catalog : MonoBehaviour public void LeaveTrash(MovableFurniture Grabbing) { Grabbing.gameObject.SetActive(true); - CatalogElement element = Trash.GetComponent(); - element.ClearFurniture(); + /*CatalogElement element = Trash.GetComponent(); + element.ClearFurniture();*/ Trash.GetComponent().material.color = new Color(1, 0, 0, 0.5f); } - private void SpawnTrash() + /*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; + Destroy(sphere.GetComponent()); + Destroy(sphere.GetComponent()); + sphere.AddComponent(); sphere.SetActive(true); sphere.tag = "Trash"; sphere.layer = 10; Trash = sphere; - } + }*/ private void ShowCatalog() { gameObject.transform.SetParent(player.hands[0].transform); @@ -98,7 +100,7 @@ public class Catalog : MonoBehaviour { SpawnSphere(i); } - SpawnTrash(); + //SpawnTrash(); StartCoroutine(CatalogCoroutine()); } @@ -145,10 +147,10 @@ public class Catalog : MonoBehaviour } } - public void OnGrabSphere(CatalogElement sphere, Valve.VR.InteractionSystem.Hand hand) + public void OnGrabSphere(CatalogElement sphere) { SpawnSphere(sphere.index); - MovableFurniture grab = hand.GetComponent().Grabbing; + MovableFurniture grab = FurnitureMover.Instance.Grabbing; if (grab != null) { return; @@ -161,12 +163,12 @@ public class Catalog : MonoBehaviour } script.CalculateBounds(); //script.OnPointerClickDown(); - hand.GetComponent().Grabbing = script; + FurnitureMover.Instance.Grabbing = script; } - public void OnReleaseSphere(CatalogElement sphere, Valve.VR.InteractionSystem.Hand hand) + public void OnReleaseSphere(CatalogElement sphere) { - hand.GetComponent().Grabbing = null; + FurnitureMover.Instance.Grabbing = null; } diff --git a/Assets/Scripts/CatalogElement.cs b/Assets/Scripts/CatalogElement.cs index 2051730..944d0c8 100644 --- a/Assets/Scripts/CatalogElement.cs +++ b/Assets/Scripts/CatalogElement.cs @@ -38,7 +38,7 @@ public class CatalogElement : Throwable attachPosition = transform.position; attachRotation = transform.rotation; - Catalog.Instance.OnGrabSphere(this, hand); + Catalog.Instance.OnGrabSphere(this); //hand.GetComponent().Grabbing = largeFurnitureModel.GetComponent(); } @@ -54,7 +54,7 @@ public class CatalogElement : Throwable rigidbody.interpolation = hadInterpolation; - Catalog.Instance.OnReleaseSphere(this, hand); + Catalog.Instance.OnReleaseSphere(this); Destroy(gameObject); } diff --git a/Assets/Scripts/FurnitureMover.cs b/Assets/Scripts/FurnitureMover.cs index e78aa4c..eabb306 100644 --- a/Assets/Scripts/FurnitureMover.cs +++ b/Assets/Scripts/FurnitureMover.cs @@ -42,9 +42,9 @@ public class FurnitureMover : MonoBehaviour private void Start() { Instance = this; - hand = GetComponent(); + hand = Player.instance.GetHand(1); ; if (pose == null) - pose = this.GetComponent(); + pose = hand.GetComponent(); if (pose == null) Debug.LogError("No SteamVR_Behaviour_Pose component found on this object", this); @@ -196,7 +196,7 @@ public class FurnitureMover : MonoBehaviour public void ReleaseFurniture(GameObject furniture) { - Catalog.Instance.ReleaseObject(furniture, gameObject.GetComponent()); + Catalog.Instance.ReleaseObject(furniture, hand); } private void OnPointerClickDown(object sender, PointerEventArgs e) { diff --git a/Assets/Scripts/Trash.cs b/Assets/Scripts/Trash.cs new file mode 100644 index 0000000..1db0638 --- /dev/null +++ b/Assets/Scripts/Trash.cs @@ -0,0 +1,87 @@ +using System.Collections; +using UnityEngine; +using Valve.VR.InteractionSystem; + +public class Trash : MonoBehaviour +{ + public GameObject largeFurnitureModel; + public int index; + private GameObject smallFurnitureModel; + private Vector3 returnPosition; + // Start is called before the first frame update + void Start() + { + returnPosition = transform.localPosition; + } + + // Update is called once per frame + void Update() + { + + } + + + + public void SetFurniture(GameObject furniture, float objectScale) + { + largeFurnitureModel = furniture; + smallFurnitureModel = Instantiate(furniture); + var throwables = smallFurnitureModel.GetComponentsInChildren(); + foreach (Throwable throwable in throwables) + { + Destroy(throwable); + }; + var rigidbodies = smallFurnitureModel.GetComponentsInChildren(); + foreach (Rigidbody rigidbody in rigidbodies) + { + Destroy(rigidbody); + }; + smallFurnitureModel.transform.parent = transform; + Destroy(smallFurnitureModel.GetComponent()); + Furniture objectBounds = smallFurnitureModel.AddComponent(); + objectBounds.CalculateBounds(); + var colldiers = smallFurnitureModel.GetComponentsInChildren(); + foreach (Collider collider in colldiers) + { + Destroy(collider); + }; + float rescale = (objectScale / 1.4f) / objectBounds.combinedBounds.size.magnitude; + smallFurnitureModel.transform.localScale *= rescale; + smallFurnitureModel.transform.localPosition = Vector3.down * 0.2f; + + StartCoroutine(KeepFurnitureAligned()); + } + + public void ClearFurniture() + { + Destroy(smallFurnitureModel); + } + + private IEnumerator ReturnSphere() + { + float time = 0; + Vector3 startPosition = transform.localPosition; + while (time <= 1) + { + transform.localPosition = Vector3.Lerp(startPosition, returnPosition, time); + time += Time.deltaTime * 4; + yield return null; + } + yield break; + } + + private IEnumerator KeepFurnitureAligned() + { + while (true) + { + 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/Trash.cs.meta b/Assets/Scripts/Trash.cs.meta new file mode 100644 index 0000000..92b3ef1 --- /dev/null +++ b/Assets/Scripts/Trash.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 274e05291e7b24c4e94f4be0000aee1e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: