Merge branch 'Scripting' into Assets

This commit is contained in:
Axel Galand 2023-01-26 09:53:53 +01:00
commit ef8f8d9f06
17 changed files with 416 additions and 74 deletions

View File

@ -11,6 +11,7 @@ Material:
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords:
- _PARALLAXMAP
- _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
@ -39,11 +40,11 @@ Material:
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 2000, y: 2000}
m_Scale: {x: 100, y: 100}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: b900361e13e6eaa44963cb851faf3ed3, type: 3}
m_Scale: {x: 2000, y: 2000}
m_Scale: {x: 100, y: 100}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
@ -63,14 +64,14 @@ Material:
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossMapScale: 0
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.08
- _SmoothnessTextureChannel: 0
- _SmoothnessTextureChannel: 1
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0

View File

@ -27,7 +27,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 999207089627997314}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: -0}
m_LocalPosition: {x: 0, y: 0.039, z: -0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -122,7 +122,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5022219494863929666}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 4.2239313, y: 1.046101, z: -0.024066806}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -146,6 +146,7 @@ MonoBehaviour:
combinedBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!1 &8294151951189356629
GameObject:
m_ObjectHideFlags: 0
@ -173,7 +174,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8294151951189356629}
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: -0}
m_LocalPosition: {x: 0, y: 0.039, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@ -25,7 +25,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6502689968648656832}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 3.9697971, y: 1.0193512, z: -1.9544978}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 1
m_Children:
@ -48,6 +48,7 @@ MonoBehaviour:
combinedBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!1001 &743310008199716879
PrefabInstance:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &392586589562003607
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6114432350300135443}
- component: {fileID: 8817835740557246532}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6114432350300135443
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 392586589562003607}
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: 3674349604157782260}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &8817835740557246532
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 392586589562003607}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 12.237078, y: 6.518132, z: 9.380431}
m_Center: {x: 0.1100985, y: 3.444804, z: -0.26158008}
--- !u!1 &1253093426770874476
GameObject:
m_ObjectHideFlags: 0
@ -72,8 +117,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2048859290140646716}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 5.0600014, y: 6.87, z: -3.75}
m_LocalScale: {x: 1, y: 0.94424, z: 1}
m_LocalPosition: {x: 5.0600014, y: 6.87, z: -3.9438}
m_LocalScale: {x: 1, y: 0.94424, z: 1.0554}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3674349604157782260}
@ -174,6 +219,7 @@ Transform:
- {fileID: 7846351332623750186}
- {fileID: 705425444331171642}
- {fileID: 5160726694365660193}
- {fileID: 6114432350300135443}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -189,6 +235,10 @@ MonoBehaviour:
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!1 &6146061087085142095
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3884115040606308642
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6821231163936271320}
- component: {fileID: 6695299937866651750}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6821231163936271320
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3884115040606308642}
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: 5262755222010251265}
m_RootOrder: 13
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &6695299937866651750
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3884115040606308642}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 4.568707, y: 7.746119, z: 5.480494}
m_Center: {x: -0.1474282, y: 4.3566036, z: -0.06824057}
--- !u!1 &8231086993610971755
GameObject:
m_ObjectHideFlags: 0
@ -278,6 +323,10 @@ MonoBehaviour:
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 &5035235579416466379 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 820629935725706273, guid: 61dd8047e5e66dc4db5c150abe38beae, type: 3}

View File

@ -24,7 +24,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4699182198977620406}
m_LocalRotation: {x: -0, y: -0, z: 0.70710576, w: 0.70710784}
m_LocalPosition: {x: -0.51733893, y: 1.621, z: -1.4194237}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@ -58,7 +58,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5078885061494400643}
m_LocalRotation: {x: -0.00000005960465, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.62495, z: -0.25492}
m_LocalPosition: {x: 0.168, y: 0.113, z: -0.229}
m_LocalScale: {x: -0.16656025, y: -0.16656025, z: -0.16656025}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@ -288,6 +288,7 @@ Transform:
- {fileID: 1696234186987782576}
- {fileID: 2781697966167280641}
- {fileID: 5613503160827514234}
- {fileID: 5878205338461874499}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
@ -306,6 +307,7 @@ MonoBehaviour:
combinedBounds:
m_Center: {x: 0, y: 0, z: 0}
m_Extent: {x: 0, y: 0, z: 0}
wallMount: 0
--- !u!65 &6645681851711596344
BoxCollider:
m_ObjectHideFlags: 0
@ -568,6 +570,51 @@ MeshRenderer:
m_SortingLayer: 0
m_SortingOrder: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!1 &4588887904168053738
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5878205338461874499}
- component: {fileID: 9184669346505142783}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5878205338461874499
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4588887904168053738}
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: 2996515769384266075}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &9184669346505142783
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4588887904168053738}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.9363493, y: 1.3597183, z: 4.2336807}
m_Center: {x: -0.016334474, y: 0.029815674, z: 2.1933994}
--- !u!1 &4983300697117577925
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,50 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &451019611259114879
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2833408188615038500}
- component: {fileID: 777966934955362417}
m_Layer: 9
m_Name: FurnitureTrigger
m_TagString: FurnitureTrigger
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2833408188615038500
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451019611259114879}
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: 589337997038399236}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!65 &777966934955362417
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 451019611259114879}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 40.602814, y: 20.834862, z: 1.929568}
m_Center: {x: 0.19675513, y: 8.908121, z: -1.2512306}
--- !u!1 &2835658414891243653
GameObject:
m_ObjectHideFlags: 0
@ -30,6 +75,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 6063464173187445548}
- {fileID: 2833408188615038500}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -86,7 +132,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4313268324301600403, guid: 5035aafbde1dd40458b242f88962c3d3, type: 3}
propertyPath: m_LocalPosition.z
value: 0
value: -1.36
objectReference: {fileID: 0}
- target: {fileID: 4313268324301600403, guid: 5035aafbde1dd40458b242f88962c3d3, type: 3}
propertyPath: m_LocalRotation.w

View File

@ -24,14 +24,14 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 726151543146820464}
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
m_LocalPosition: {x: 2.6100001, y: 1.8444445, z: -0.12111112}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.11111112, y: 0.11111112, z: 0.11111112}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 726151543547972459}
- {fileID: 726151544272545065}
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!1 &726151543547972456
GameObject:
@ -59,7 +59,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 726151543547972456}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalPosition: {x: 2.73, y: 7.08, z: -3.48}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@ -142,7 +142,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 726151544272545062}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 0, z: 0}
m_LocalPosition: {x: 2.73, y: 7.08, z: -3.48}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []

View File

@ -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<GameObject> 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("<b>[Catalog]</b> 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<CatalogElement>();
element.SetFurniture(Furnitures[index], objectScale);
element.index = index;
}
public void SetTrash(MovableFurniture Grabbing)
{
Grabbing.gameObject.SetActive(false);
Trash.GetComponent<MeshRenderer>().material.color = new Color(1, 0.5f, 0, 1);
}
public void LeaveTrash(MovableFurniture Grabbing)
{
Grabbing.gameObject.SetActive(true);
CatalogElement element = Trash.GetComponent<CatalogElement>();
element.ClearFurniture();
Trash.GetComponent<MeshRenderer>().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<MeshRenderer>().material.color = new Color(1, 0, 0, 0.5f);
sphere.GetComponent<Interactable>().enabled = false;
sphere.GetComponent<SteamVR_Skeleton_Poser>().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<CatalogElement>().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<FurnitureMover>().Grabbing;
if (grab != null)
{
return;
}
GameObject furniture = Instantiate(sphere.largeFurnitureModel);
MovableFurniture script = furniture.GetComponent<MovableFurniture>() ;
MovableFurniture script = furniture.GetComponent<MovableFurniture>();
if (!furniture.GetComponent<MovableFurniture>())
{
script = furniture.AddComponent<MovableFurniture>();
}
script.CalculateBounds();
//script.OnPointerClickDown();
hand.GetComponent<FurnitureMover>().Grabbing = script;
}

View File

@ -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<FurnitureMover>().Grabbing = largeFurnitureModel.GetComponent<MovableFurniture>();
}
}
//-------------------------------------------------
@ -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");
}
}

View File

@ -1,6 +1,4 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using Valve.VR;
using Valve.VR.Extras;
using Valve.VR.InteractionSystem;
@ -27,6 +25,9 @@ public class FurnitureMover : MonoBehaviour
private SnapTurn _snapturn;
private Hand hand;
public static FurnitureMover Instance;
private SnapTurn snapturn
{
get
@ -40,6 +41,7 @@ public class FurnitureMover : MonoBehaviour
}
private void Start()
{
Instance = this;
hand = GetComponent<Hand>();
if (pose == null)
pose = this.GetComponent<SteamVR_Behaviour_Pose>();
@ -79,13 +81,30 @@ public class FurnitureMover : MonoBehaviour
Ray SnapRaycast = new Ray(transform.position, transform.forward);
RaycastHit SnapHit;
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)
{
PointerEventArgs args = new PointerEventArgs();
@ -145,12 +164,9 @@ public class FurnitureMover : MonoBehaviour
}
pointer.transform.localPosition = new Vector3(0f, 0f, dist / 2f);
if(Grabbing != null && snapLeftAction != null && snapRightAction != null && snapLeftAction.activeBinding && snapRightAction.activeBinding)
//Rotate Logic
if (Grabbing != null && snapLeftAction != null && snapRightAction != null && snapLeftAction.activeBinding && snapRightAction.activeBinding)
{
bool leftHandTurnLeft = snapLeftAction.GetStateDown(hand.handType);
bool rightHandTurnLeft = snapLeftAction.GetStateDown(hand.otherHand.handType);
@ -184,7 +200,7 @@ public class FurnitureMover : MonoBehaviour
}
private void OnPointerClickDown(object sender, PointerEventArgs e)
{
if (Grabbing)
if (Grabbing != null)
{
return;
}
@ -198,7 +214,7 @@ public class FurnitureMover : MonoBehaviour
GrabFurniture(Grabbing.gameObject);
/*Grabbing.transform.SetParent(this.transform);*/
}
public void SetGrabbing(MovableFurniture furniture)
{
Grabbing = furniture;
@ -234,13 +250,13 @@ public class FurnitureMover : MonoBehaviour
private void OnPointerIn(object sender, PointerEventArgs e)
{
if (Grabbing != null) return;
MovableFurniturePart pointerEnterHandler = e.target.GetComponent<MovableFurniturePart>();
if (pointerEnterHandler == null)
{
return;
}
pointerEnterHandler.OnPointerEnter();
}
}

View File

@ -7,7 +7,8 @@ public class MovableFurniture : Furniture
private List<ObjectOutline> 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()
{
@ -22,7 +23,7 @@ public class MovableFurniture : Furniture
var outline = child.gameObject.AddComponent<ObjectOutline>();
if (!outline) continue;
outlines.Add(outline);
outline.OutlineMode = ObjectOutline.Mode.OutlineAll;
outline.OutlineMode = ObjectOutline.Mode.OutlineVisible;
outline.OutlineColor = Color.yellow;
outline.OutlineWidth = 5f;
outline.enabled = false;
@ -37,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;
}
}
@ -56,15 +73,16 @@ public class MovableFurniture : Furniture
{
foreach (ObjectOutline outline in outlines)
{
/*child.OutlineMode = ObjectOutline.Mode.OutlineAll;
child.OutlineColor = Color.yellow;
child.OutlineWidth = 5f;*/
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;
@ -96,6 +114,9 @@ public class MovableFurniture : Furniture
{
Vector3 previousPosition = transform.position;
Vector3 offset = Vector3.zero;
//if (isColliding) { return; }
transform.position = position;
return;
if (wallMount)
{
transform.position = position;
@ -149,21 +170,54 @@ public class MovableFurniture : Furniture
void OnDrawGizmos()
{
// Draw a yellow sphere at the transform's position
Gizmos.color = Color.red;
/*Gizmos.color = Color.red;
Gizmos.DrawWireCube(transform.position - centerOffset, combinedBounds.size);
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 OnDisable()
{
if(outlines != null && outlines.Count > 0)
if (outlines != null && outlines.Count > 0)
{
foreach (ObjectOutline outline in outlines)
{
outline.enabled = false;
}
}
}
//Check if collision before moving an object
public void OnFurnitureCollisionEnter(Collider other)
{
/*foreach (ObjectOutline outline in outlines)
{
outline.OutlineColor = Color.red;
outline.enabled = true;
}
isColliding = true;*/
}
public void OnFurnitureCollisionStay(Collider other)
{
//isColliding = true;
}
public void OnFurnitureCollisionExit(Collider other)
{
//Run CheckFurnitureCollisions on next FixedUpdate loop. If no object is truly colliding, isColliding should be false inside CheckFurnitureCollisions
/*Invoke("CheckFurnitureCollisions", Time.fixedTime * 2);
isColliding = false;*/
}
private void CheckFurnitureCollisions()
{
if (isColliding == true) return;
foreach (ObjectOutline outline in outlines)
{
outline.OutlineColor = Color.yellow;
outline.enabled = false;
}
}
}

View File

@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MovableFurniturePart : MonoBehaviour
{
@ -9,13 +6,13 @@ public class MovableFurniturePart : MonoBehaviour
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnPointerClickDown()
@ -32,4 +29,19 @@ public class MovableFurniturePart : MonoBehaviour
{
parent.OnPointerExit();
}
private void OnTriggerEnter(Collider other)
{
parent.OnFurnitureCollisionEnter(other);
}
private void OnTriggerExit(Collider other)
{
parent.OnFurnitureCollisionExit(other);
}
private void OnTriggerStay(Collider other)
{
parent.OnFurnitureCollisionStay(other);
}
}

View File

@ -18,7 +18,7 @@ PhysicsManager:
m_ClothInterCollisionDistance: 0
m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: 7fffffff7fffffff7fffffffffffffff7fffffff7fffffff7fffffff88ffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffff
m_LayerCollisionMatrix: 7ffdffff7ffdffff7ffdffffffffffff7ffdffff7ffdffff7ffdffff88fdff7fffffffff08ffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7ffdffff
m_AutoSimulation: 1
m_AutoSyncTransforms: 0
m_ReuseCollisionCallbacks: 1

View File

@ -98,6 +98,11 @@
"key": "log.path",
"value": "{\"m_Value\":\"ProBuilderLog.txt\"}"
},
{
"type": "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.materialPalettePath",
"value": "{\"m_Value\":\"Assets/ProBuilder Data/Default Material Palette.asset\"}"
},
{
"type": "UnityEngine.ProBuilder.SemVer, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "about.identifier",
@ -126,7 +131,7 @@
{
"type": "UnityEngine.ProBuilder.SelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.lastMeshSelectMode",
"value": "{\"m_Value\":4}"
"value": "{\"m_Value\":8}"
},
{
"type": "UnityEngine.Rendering.ShadowCastingMode, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
@ -187,6 +192,11 @@
"type": "UnityEngine.Quaternion, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastRotation",
"value": "{\"m_Value\":{\"x\":0.0,\"y\":0.0,\"z\":0.0,\"w\":1.0}}"
},
{
"type": "UnityEngine.ProBuilder.ExtrudeMethod, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.extrudeMethod",
"value": "{\"m_Value\":2}"
}
]
}

View File

@ -7,6 +7,8 @@ TagManager:
- SamplesInfoPanel
- projectile
- FxTemporaire
- FurnitureTrigger
- Trash
layers:
- Default
- TransparentFX
@ -17,8 +19,8 @@ TagManager:
- Static Lighting
- Teleport Area
- Environment
-
-
- FurnitureTrigger
- Trash
-
-
-