generated from VR-Sexe/Unity3DTemplate
Add furniture class and heritage
This commit is contained in:
parent
ac3c539569
commit
162b973bc2
@ -12931,7 +12931,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 6275806258134515848, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3}
|
- target: {fileID: 6275806258134515848, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3}
|
||||||
propertyPath: m_IsActive
|
propertyPath: m_IsActive
|
||||||
value: 1
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 1805c511e7b7f0e49afb0651e27725b4, type: 3}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Valve.VR.InteractionSystem;
|
|||||||
public class Catalog : MonoBehaviour
|
public class Catalog : MonoBehaviour
|
||||||
{
|
{
|
||||||
private Player player = null;
|
private Player player = null;
|
||||||
public int maxShownObjects = 5;
|
private int maxShownObjects = 5;
|
||||||
public int angle = 180;
|
public int angle = 180;
|
||||||
public float distance = .5f;
|
public float distance = .5f;
|
||||||
public float objectScale = .1f;
|
public float objectScale = .1f;
|
||||||
@ -21,6 +21,7 @@ public class Catalog : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
maxShownObjects = Furnitures.Count;
|
||||||
spherePrefab = transform.Find("Sphere").gameObject;
|
spherePrefab = transform.Find("Sphere").gameObject;
|
||||||
player = Player.instance;
|
player = Player.instance;
|
||||||
if (player == null)
|
if (player == null)
|
||||||
@ -44,7 +45,7 @@ public class Catalog : MonoBehaviour
|
|||||||
float radians = angle * Mathf.Deg2Rad;
|
float radians = angle * Mathf.Deg2Rad;
|
||||||
float angleIncrement = radians / (maxShownObjects - 1);
|
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 j = i * angleIncrement - radians / 2;
|
||||||
var sphere = Instantiate(spherePrefab);
|
var sphere = Instantiate(spherePrefab);
|
||||||
@ -52,8 +53,11 @@ public class Catalog : MonoBehaviour
|
|||||||
sphere.transform.localScale = Vector3.one * objectScale;
|
sphere.transform.localScale = Vector3.one * objectScale;
|
||||||
sphere.transform.localPosition = new Vector3(Mathf.Sin(j), 0, Mathf.Cos(j)) * distance;
|
sphere.transform.localPosition = new Vector3(Mathf.Sin(j), 0, Mathf.Cos(j)) * distance;
|
||||||
sphere.SetActive(true);
|
sphere.SetActive(true);
|
||||||
}
|
|
||||||
|
|
||||||
|
GameObject furniture = Instantiate(Furnitures[i]);
|
||||||
|
furniture.transform.localScale*= objectScale;
|
||||||
|
|
||||||
|
}
|
||||||
StartCoroutine(CatalogCoroutine());
|
StartCoroutine(CatalogCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6e448cbb02ada1545b6c4c79341232fc
|
guid: d4650b34090589b4782a7f67a297aeef
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|||||||
@ -42,13 +42,16 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 1527984575184472642}
|
m_GameObject: {fileID: 1527984575184472642}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 6e448cbb02ada1545b6c4c79341232fc, type: 3}
|
m_Script: {fileID: 11500000, guid: d4650b34090589b4782a7f67a297aeef, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
maxShownObjects: 6
|
angle: 180
|
||||||
angle: 130
|
distance: 0.5
|
||||||
distance: 0.17
|
objectScale: 0.1
|
||||||
objectScale: 0.04
|
Furnitures:
|
||||||
|
- {fileID: 4774624094512517819, guid: 481a02167edfebe44883f5868f8a27f9, type: 3}
|
||||||
|
- {fileID: 4158574887593288270, guid: b4f1c52a4d9acc94da08e9006d9fd5e0, type: 3}
|
||||||
|
- {fileID: 2835658414891243653, guid: ec717aa9a84ac1849bec0aa4f4b89314, type: 3}
|
||||||
--- !u!1 &6275806258134515848
|
--- !u!1 &6275806258134515848
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -352,4 +355,3 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 6be44b6db6259b44aa167854e71e96f9, type: 3}
|
m_Script: {fileID: 11500000, guid: 6be44b6db6259b44aa167854e71e96f9, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
returnPosition: {x: 0, y: 0, z: 0}
|
|
||||||
|
|||||||
48
Assets/Scripts/Furniture.cs
Normal file
48
Assets/Scripts/Furniture.cs
Normal file
@ -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<Renderer>() != null)
|
||||||
|
{
|
||||||
|
combinedBounds = GetComponent<Renderer>().bounds;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
combinedBounds = new Bounds(transform.position, Vector3.zero);
|
||||||
|
}
|
||||||
|
var renderers = GetComponentsInChildren<Collider>();
|
||||||
|
foreach (Collider child in renderers)
|
||||||
|
{
|
||||||
|
if (child != GetComponent<Renderer>())
|
||||||
|
{
|
||||||
|
if (combinedBounds == null)
|
||||||
|
{
|
||||||
|
combinedBounds = child.bounds;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
combinedBounds.Encapsulate(child.bounds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//combinedBounds = renderers[0].bounds;
|
||||||
|
centerOffset = transform.position - combinedBounds.center;
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Furniture.cs.meta
Normal file
11
Assets/Scripts/Furniture.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: abe917cf55ad57f4880d5fab1b8f5bd2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,17 +1,16 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class MovableFurniture : MonoBehaviour
|
public class MovableFurniture : Furniture
|
||||||
{
|
{
|
||||||
private List<Transform> children;
|
private List<Transform> children;
|
||||||
private List<ObjectOutline> outlines;
|
private List<ObjectOutline> outlines;
|
||||||
private Rigidbody _rigidbody;
|
private Rigidbody _rigidbody;
|
||||||
|
|
||||||
private Bounds combinedBounds;
|
|
||||||
private Vector3 centerOffset;
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
new void Start()
|
||||||
{
|
{
|
||||||
|
base.Start();
|
||||||
_rigidbody = GetComponent<Rigidbody>();
|
_rigidbody = GetComponent<Rigidbody>();
|
||||||
children = new List<Transform>(GetComponentsInChildren<Transform>());
|
children = new List<Transform>(GetComponentsInChildren<Transform>());
|
||||||
outlines = new List<ObjectOutline>();
|
outlines = new List<ObjectOutline>();
|
||||||
@ -26,7 +25,6 @@ public class MovableFurniture : MonoBehaviour
|
|||||||
outline.OutlineWidth = 5f;
|
outline.OutlineWidth = 5f;
|
||||||
outline.enabled = false;
|
outline.enabled = false;
|
||||||
}
|
}
|
||||||
CalculateBounds();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// 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)));
|
Gizmos.DrawRay((transform.position - centerOffset) - (new Vector3(0, 0, combinedBounds.extents.z)), (new Vector3(0, 0, combinedBounds.size.z)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CalculateBounds()
|
|
||||||
{
|
|
||||||
if (GetComponent<Renderer>() != null)
|
|
||||||
{
|
|
||||||
combinedBounds = GetComponent<Renderer>().bounds;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
combinedBounds = new Bounds(transform.position, Vector3.zero);
|
|
||||||
}
|
|
||||||
var renderers = GetComponentsInChildren<Collider>();
|
|
||||||
foreach (Collider child in renderers)
|
|
||||||
{
|
|
||||||
if (child != GetComponent<Renderer>())
|
|
||||||
{
|
|
||||||
if (combinedBounds == null)
|
|
||||||
{
|
|
||||||
combinedBounds = child.bounds;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
combinedBounds.Encapsulate(child.bounds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//combinedBounds = renderers[0].bounds;
|
|
||||||
centerOffset = transform.position - combinedBounds.center;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user