diff --git a/Assets/Scenes/FabLab/FabLab.unity b/Assets/Scenes/FabLab/FabLab.unity index 4eaf795..bd2f6e4 100644 --- a/Assets/Scenes/FabLab/FabLab.unity +++ b/Assets/Scenes/FabLab/FabLab.unity @@ -12931,7 +12931,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 6275806258134515848, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3} propertyPath: m_IsActive - value: 1 + value: 0 objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3} diff --git a/Assets/Scripts/Catalog.cs b/Assets/Scripts/Catalog.cs index a8d88a5..0d5b7c4 100644 --- a/Assets/Scripts/Catalog.cs +++ b/Assets/Scripts/Catalog.cs @@ -8,7 +8,7 @@ using Valve.VR.InteractionSystem; public class Catalog : MonoBehaviour { private Player player = null; - public int maxShownObjects = 5; + private int maxShownObjects = 5; public int angle = 180; public float distance = .5f; public float objectScale = .1f; @@ -21,6 +21,7 @@ public class Catalog : MonoBehaviour // Start is called before the first frame update void Start() { + maxShownObjects = Furnitures.Count; spherePrefab = transform.Find("Sphere").gameObject; player = Player.instance; if (player == null) @@ -44,7 +45,7 @@ public class Catalog : MonoBehaviour float radians = angle * Mathf.Deg2Rad; float angleIncrement = radians / (maxShownObjects - 1); - for (float i = 0 / 2; i < maxShownObjects; i++) + for (int i = 0; i < maxShownObjects; i++) { var j = i * angleIncrement - radians / 2; var sphere = Instantiate(spherePrefab); @@ -52,8 +53,11 @@ public class Catalog : MonoBehaviour sphere.transform.localScale = Vector3.one * objectScale; sphere.transform.localPosition = new Vector3(Mathf.Sin(j), 0, Mathf.Cos(j)) * distance; sphere.SetActive(true); - } + GameObject furniture = Instantiate(Furnitures[i]); + furniture.transform.localScale*= objectScale; + + } StartCoroutine(CatalogCoroutine()); } diff --git a/Assets/Scripts/Catalog.cs.meta b/Assets/Scripts/Catalog.cs.meta index 0971651..1862333 100644 --- a/Assets/Scripts/Catalog.cs.meta +++ b/Assets/Scripts/Catalog.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6e448cbb02ada1545b6c4c79341232fc +guid: d4650b34090589b4782a7f67a297aeef MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Catalog.prefab b/Assets/Scripts/Catalog.prefab index e1fbcb1..de62c68 100644 --- a/Assets/Scripts/Catalog.prefab +++ b/Assets/Scripts/Catalog.prefab @@ -42,13 +42,16 @@ MonoBehaviour: m_GameObject: {fileID: 1527984575184472642} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 6e448cbb02ada1545b6c4c79341232fc, type: 3} + m_Script: {fileID: 11500000, guid: d4650b34090589b4782a7f67a297aeef, type: 3} m_Name: m_EditorClassIdentifier: - maxShownObjects: 6 - angle: 130 - distance: 0.17 - objectScale: 0.04 + angle: 180 + distance: 0.5 + objectScale: 0.1 + Furnitures: + - {fileID: 4774624094512517819, guid: 481a02167edfebe44883f5868f8a27f9, type: 3} + - {fileID: 4158574887593288270, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3} + - {fileID: 2835658414891243653, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3} --- !u!1 &6275806258134515848 GameObject: m_ObjectHideFlags: 0 @@ -352,4 +355,3 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6be44b6db6259b44aa167854e71e96f9, type: 3} m_Name: m_EditorClassIdentifier: - returnPosition: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/Furniture.cs b/Assets/Scripts/Furniture.cs new file mode 100644 index 0000000..38a46b0 --- /dev/null +++ b/Assets/Scripts/Furniture.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Furniture : MonoBehaviour +{ + protected Bounds combinedBounds; + protected Vector3 centerOffset; + protected void Start() + { + CalculateBounds(); + } + + // Update is called once per frame + void Update() + { + + } + + private void CalculateBounds() + { + if (GetComponent() != null) + { + combinedBounds = GetComponent().bounds; + } + else + { + combinedBounds = new Bounds(transform.position, Vector3.zero); + } + var renderers = GetComponentsInChildren(); + foreach (Collider child in renderers) + { + if (child != GetComponent()) + { + if (combinedBounds == null) + { + combinedBounds = child.bounds; + } + else + { + combinedBounds.Encapsulate(child.bounds); + } + } + } + //combinedBounds = renderers[0].bounds; + centerOffset = transform.position - combinedBounds.center; + } +} diff --git a/Assets/Scripts/Furniture.cs.meta b/Assets/Scripts/Furniture.cs.meta new file mode 100644 index 0000000..5851e9e --- /dev/null +++ b/Assets/Scripts/Furniture.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: abe917cf55ad57f4880d5fab1b8f5bd2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MovableFurniture.cs b/Assets/Scripts/MovableFurniture.cs index 5d94407..d7c4a23 100644 --- a/Assets/Scripts/MovableFurniture.cs +++ b/Assets/Scripts/MovableFurniture.cs @@ -1,17 +1,16 @@ using System.Collections.Generic; using UnityEngine; -public class MovableFurniture : MonoBehaviour +public class MovableFurniture : Furniture { private List children; private List outlines; private Rigidbody _rigidbody; - private Bounds combinedBounds; - private Vector3 centerOffset; // Start is called before the first frame update - void Start() + new void Start() { + base.Start(); _rigidbody = GetComponent(); children = new List(GetComponentsInChildren()); outlines = new List(); @@ -26,7 +25,6 @@ public class MovableFurniture : MonoBehaviour outline.OutlineWidth = 5f; outline.enabled = false; } - CalculateBounds(); } // Update is called once per frame @@ -110,32 +108,4 @@ public class MovableFurniture : MonoBehaviour Gizmos.DrawRay((transform.position - centerOffset) - (new Vector3(0, 0, combinedBounds.extents.z)), (new Vector3(0, 0, combinedBounds.size.z))); } - private void CalculateBounds() - { - if (GetComponent() != null) - { - combinedBounds = GetComponent().bounds; - } - else - { - combinedBounds = new Bounds(transform.position, Vector3.zero); - } - var renderers = GetComponentsInChildren(); - foreach (Collider child in renderers) - { - if (child != GetComponent()) - { - if (combinedBounds == null) - { - combinedBounds = child.bounds; - } - else - { - combinedBounds.Encapsulate(child.bounds); - } - } - } - //combinedBounds = renderers[0].bounds; - centerOffset = transform.position - combinedBounds.center; - } }