diff --git a/Assets/InteractionEngine/ShinyThings.cs b/Assets/InteractionEngine/ShinyThings.cs index 1d7c05a03e41ff3b35ffcb78a5420987002f7f45..11abf720c3298584c8444915bbf2f1fee4e81876 100644 --- a/Assets/InteractionEngine/ShinyThings.cs +++ b/Assets/InteractionEngine/ShinyThings.cs @@ -3,6 +3,7 @@ using UnityEngine; using UnityEditor; using static CommunicationEvents; +using System; public class ShinyThings : MonoBehaviour { @@ -45,16 +46,43 @@ public void Update() RaycastHit Hit = Cursor.Hit; - if (Hit.transform != null) + Highlighting(Hit); + + + //LineRendering-Part + + //@John before: hit.point + + Debug.Log(this.transform.position); + + if (this.lineDrawingActivated) + UpdateLineDrawing(this.transform.position); + else if (this.curveDrawingActivated) + UpdateCurveDrawing(this.transform.position); + + + + } + + private void Highlighting(RaycastHit hit) + { + if (hit.transform != null) { - Transform selection = Hit.transform; + Transform selection = hit.transform; + + //only do stuff if selection changes + //Set the last Fact unselected if (this.lastFactSelection != null) { + if (selection == this.lastFactSelection) return; //Invoke the EndHighlightEvent that will be handled in FactSpawner // CommunicationEvents.EndHighlightEvent.Invoke(this.lastFactSelection); - OnMouseOverFactEnd(lastFactSelection); + if (this.lastFactSelection.CompareTag(selectableTag)) + OnMouseOverFactEnd(lastFactSelection); + else + OnMouseOverSnapZoneEnd(lastFactSelection); this.lastFactSelection = null; } @@ -66,16 +94,52 @@ public void Update() //CommunicationEvents.HighlightEvent.Invoke(selection); OnMouseOverFact(lastFactSelection); } - //SELECTION-HIGHLIGHTING-PART-END + else if (selection.CompareTag("SnapZone")) + { + this.lastFactSelection = selection; + OnMouseOverSnapZone(lastFactSelection); - //LineRendering-Part - if (this.lineDrawingActivated) - UpdateLineDrawing(Hit.point); - else if (this.curveDrawingActivated) - UpdateCurveDrawing(Hit.point); + } } + //SELECTION-HIGHLIGHTING-PART-END + } + + private void OnMouseOverSnapZoneEnd(Transform selection) + { + Renderer selectionRenderer; + + if (selection != null) + { + selectionRenderer = selection.GetComponent<Renderer>(); + if (selectionRenderer != null) + { + //Add transparency + var oldCol = selectionRenderer.material.color; + oldCol.a = .25f; + selectionRenderer.material.color = oldCol; + //Unhide Mouse cursor + UnityEngine.Cursor.visible = true; + } + } + } + + private void OnMouseOverSnapZone(Transform selection) + { + Renderer selectionRenderer; + selectionRenderer = selection.GetComponent<Renderer>(); + if (selectionRenderer != null) + { + //Remove transparency + var oldCol = selectionRenderer.material.color; + oldCol.a = 1; + selectionRenderer.material.color = oldCol; + + //Hide Mouse cursor + UnityEngine.Cursor.visible = false; + + } } public void OnMouseOverFact(Transform selection) diff --git a/Assets/InteractionEngine/WorldCursor.cs b/Assets/InteractionEngine/WorldCursor.cs index e777c5109e632c23f63d96b7f2008ebeea0561d7..022cf569843afb6311e37cc685375164fcce8c4c 100644 --- a/Assets/InteractionEngine/WorldCursor.cs +++ b/Assets/InteractionEngine/WorldCursor.cs @@ -39,8 +39,9 @@ void Update() { Hit.point = Hit.collider.transform.position; Hit.normal = Vector3.up; - Debug.Log("boom"); CheckMouseButtons(true); + transform.position = Hit.point; + transform.up = Hit.normal; } else @@ -57,7 +58,10 @@ void Update() } else { - transform.position = Cam.ScreenToWorldPoint(Input.mousePosition); + var dist = 10f; + if (Hit.transform!=null) + dist = (Camera.main.transform.position - Hit.transform.position).magnitude; + transform.position = Cam.ScreenToWorldPoint(Input.mousePosition + new Vector3(0,0,1) *dist); transform.up = -Cam.transform.forward; } diff --git a/Assets/Materials/CursorMaterial.mat b/Assets/Materials/CursorMaterial.mat index 8322c751b7c2afadfc391873958ad3031e04845f..7ae403b6d2c47e488a4a5a4a7d71b7f0459d4ce7 100644 --- a/Assets/Materials/CursorMaterial.mat +++ b/Assets/Materials/CursorMaterial.mat @@ -8,7 +8,7 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: CursorMaterial - m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} + m_Shader: {fileID: 4800000, guid: 2649b895a4c22d649852a0ca4c825c74, type: 3} m_ShaderKeywords: m_LightmapFlags: 4 m_EnableInstancingVariants: 0 @@ -57,6 +57,7 @@ Material: m_Offset: {x: 0, y: 0} m_Floats: - _BumpScale: 1 + - _ColorMask: 15 - _Cutoff: 0.5 - _DetailNormalMapScale: 1 - _DstBlend: 0 @@ -70,6 +71,11 @@ Material: - _SmoothnessTextureChannel: 0 - _SpecularHighlights: 1 - _SrcBlend: 1 + - _Stencil: 0 + - _StencilComp: 8 + - _StencilOp: 0 + - _StencilReadMask: 255 + - _StencilWriteMask: 255 - _UVSec: 0 - _ZWrite: 1 m_Colors: diff --git a/Assets/Materials/SeeThrough 1.mat b/Assets/Materials/SeeThrough 1.mat index 012caa9b44566e416d043c154506a93462b66801..01070b4ea2d1cd9514e8578179902a7b5cd8e47a 100644 --- a/Assets/Materials/SeeThrough 1.mat +++ b/Assets/Materials/SeeThrough 1.mat @@ -8,7 +8,7 @@ Material: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_Name: SeeThrough 1 - m_Shader: {fileID: 4800000, guid: 2649b895a4c22d649852a0ca4c825c74, type: 3} + m_Shader: {fileID: 10760, guid: 0000000000000000f000000000000000, type: 0} m_ShaderKeywords: _ALPHAPREMULTIPLY_ON m_LightmapFlags: 4 m_EnableInstancingVariants: 0 @@ -80,5 +80,5 @@ Material: - _UseUIAlphaClip: 0 - _ZWrite: 0 m_Colors: - - _Color: {r: 0.972549, g: 0.30369413, b: 0, a: 0.11372549} + - _Color: {r: 0.972549, g: 0.30369413, b: 0, a: 0.2509804} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/TreeWorld.unity b/Assets/TreeWorld.unity index fd6ad34ef6eb842cfb923f4ccb3cd5afcd9e7ca7..721d54aae1196ec8a2d14719167c6ba0f6a31077 100644 --- a/Assets/TreeWorld.unity +++ b/Assets/TreeWorld.unity @@ -157,7 +157,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3} propertyPath: m_RootOrder - value: 1 + value: 3 objectReference: {fileID: 0} - target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -272,7 +272,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 45.118004, y: 115.065, z: 146.117} --- !u!1 &144550594 GameObject: @@ -320,7 +320,7 @@ RectTransform: m_Children: - {fileID: 1920747393} m_Father: {fileID: 0} - m_RootOrder: 8 + m_RootOrder: 10 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} @@ -396,7 +396,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} propertyPath: m_LocalPosition.y - value: 0.08 + value: -0.045 objectReference: {fileID: 0} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} propertyPath: m_LocalPosition.z @@ -420,7 +420,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} propertyPath: m_RootOrder - value: 0 + value: 2 objectReference: {fileID: 0} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -707,7 +707,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &422404977 GameObject: @@ -864,7 +864,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &535944724 GameObject: @@ -1047,7 +1047,7 @@ Transform: m_LocalScale: {x: 1, y: 4, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 5 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &684756691 GameObject: @@ -1079,7 +1079,7 @@ Transform: - {fileID: 1675643438} - {fileID: 1451305264} m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &866436393 GameObject: @@ -1488,12 +1488,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1009368148} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0.48, z: 0} - m_LocalScale: {x: 3, y: 3, z: 3} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 2.6310663, y: 0, z: 2.165048} + m_LocalScale: {x: 1.5, y: 1.5, z: 1.5} m_Children: [] - m_Father: {fileID: 1347135377} - m_RootOrder: 17 + m_Father: {fileID: 0} + m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!135 &1009368150 SphereCollider: @@ -1841,7 +1841,7 @@ PrefabInstance: - target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f, type: 3} propertyPath: m_RootOrder - value: 3 + value: 5 objectReference: {fileID: 0} - target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f, type: 3} @@ -1955,12 +1955,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 38927f5b66d24cc428e39ffa454b0bfb, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!4 &1347135377 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, - type: 3} - m_PrefabInstance: {fileID: 154206643} - m_PrefabAsset: {fileID: 0} --- !u!1 &1351049950 GameObject: m_ObjectHideFlags: 0 @@ -2094,12 +2088,12 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1563243733} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 16.97, z: 0} - m_LocalScale: {x: 3, y: 3, z: 3} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 2.6310663, y: 8.44, z: 2.165048} + m_LocalScale: {x: 1.5, y: 1.5, z: 1.5} m_Children: [] - m_Father: {fileID: 1347135377} - m_RootOrder: 18 + m_Father: {fileID: 0} + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!23 &1563243735 MeshRenderer: @@ -2409,7 +2403,7 @@ Transform: m_GameObject: {fileID: 1675643434} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 20, y: 0.5, z: 20} + m_LocalScale: {x: 20, y: 0.00001, z: 20} m_Children: [] m_Father: {fileID: 684756692} m_RootOrder: 0