Skip to content
Snippets Groups Projects
Commit 8b8783ec authored by Richard Marcus's avatar Richard Marcus
Browse files

Snapzone and Cursor Updates

parent 599e6f4e
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using static CommunicationEvents; using static CommunicationEvents;
using System;
public class ShinyThings : MonoBehaviour public class ShinyThings : MonoBehaviour
{ {
...@@ -45,16 +46,43 @@ public void Update() ...@@ -45,16 +46,43 @@ public void Update()
RaycastHit Hit = Cursor.Hit; 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 //Set the last Fact unselected
if (this.lastFactSelection != null) if (this.lastFactSelection != null)
{ {
if (selection == this.lastFactSelection) return;
//Invoke the EndHighlightEvent that will be handled in FactSpawner //Invoke the EndHighlightEvent that will be handled in FactSpawner
// CommunicationEvents.EndHighlightEvent.Invoke(this.lastFactSelection); // CommunicationEvents.EndHighlightEvent.Invoke(this.lastFactSelection);
if (this.lastFactSelection.CompareTag(selectableTag))
OnMouseOverFactEnd(lastFactSelection); OnMouseOverFactEnd(lastFactSelection);
else
OnMouseOverSnapZoneEnd(lastFactSelection);
this.lastFactSelection = null; this.lastFactSelection = null;
} }
...@@ -66,16 +94,52 @@ public void Update() ...@@ -66,16 +94,52 @@ public void Update()
//CommunicationEvents.HighlightEvent.Invoke(selection); //CommunicationEvents.HighlightEvent.Invoke(selection);
OnMouseOverFact(lastFactSelection); OnMouseOverFact(lastFactSelection);
} }
else if (selection.CompareTag("SnapZone"))
{
this.lastFactSelection = selection;
OnMouseOverSnapZone(lastFactSelection);
}
}
//SELECTION-HIGHLIGHTING-PART-END //SELECTION-HIGHLIGHTING-PART-END
}
//LineRendering-Part private void OnMouseOverSnapZoneEnd(Transform selection)
if (this.lineDrawingActivated) {
UpdateLineDrawing(Hit.point); Renderer selectionRenderer;
else if (this.curveDrawingActivated)
UpdateCurveDrawing(Hit.point); 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) public void OnMouseOverFact(Transform selection)
......
...@@ -39,8 +39,9 @@ void Update() ...@@ -39,8 +39,9 @@ void Update()
{ {
Hit.point = Hit.collider.transform.position; Hit.point = Hit.collider.transform.position;
Hit.normal = Vector3.up; Hit.normal = Vector3.up;
Debug.Log("boom");
CheckMouseButtons(true); CheckMouseButtons(true);
transform.position = Hit.point;
transform.up = Hit.normal;
} }
else else
...@@ -57,7 +58,10 @@ void Update() ...@@ -57,7 +58,10 @@ void Update()
} }
else 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; transform.up = -Cam.transform.forward;
} }
......
...@@ -8,7 +8,7 @@ Material: ...@@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: CursorMaterial m_Name: CursorMaterial
m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 4800000, guid: 2649b895a4c22d649852a0ca4c825c74, type: 3}
m_ShaderKeywords: m_ShaderKeywords:
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
...@@ -57,6 +57,7 @@ Material: ...@@ -57,6 +57,7 @@ Material:
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Floats: m_Floats:
- _BumpScale: 1 - _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
...@@ -70,6 +71,11 @@ Material: ...@@ -70,6 +71,11 @@ Material:
- _SmoothnessTextureChannel: 0 - _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1 - _SpecularHighlights: 1
- _SrcBlend: 1 - _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0 - _UVSec: 0
- _ZWrite: 1 - _ZWrite: 1
m_Colors: m_Colors:
......
...@@ -8,7 +8,7 @@ Material: ...@@ -8,7 +8,7 @@ Material:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: SeeThrough 1 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_ShaderKeywords: _ALPHAPREMULTIPLY_ON
m_LightmapFlags: 4 m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
...@@ -80,5 +80,5 @@ Material: ...@@ -80,5 +80,5 @@ Material:
- _UseUIAlphaClip: 0 - _UseUIAlphaClip: 0
- _ZWrite: 0 - _ZWrite: 0
m_Colors: 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} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
...@@ -157,7 +157,7 @@ PrefabInstance: ...@@ -157,7 +157,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3} - target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 1 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3} - target: {fileID: 400000, guid: 5e9e851c0e142814dac026a256ba2ac0, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
...@@ -272,7 +272,7 @@ Transform: ...@@ -272,7 +272,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 2 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 45.118004, y: 115.065, z: 146.117} m_LocalEulerAnglesHint: {x: 45.118004, y: 115.065, z: 146.117}
--- !u!1 &144550594 --- !u!1 &144550594
GameObject: GameObject:
...@@ -320,7 +320,7 @@ RectTransform: ...@@ -320,7 +320,7 @@ RectTransform:
m_Children: m_Children:
- {fileID: 1920747393} - {fileID: 1920747393}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 8 m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
...@@ -396,7 +396,7 @@ PrefabInstance: ...@@ -396,7 +396,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_LocalPosition.y propertyPath: m_LocalPosition.y
value: 0.08 value: -0.045
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_LocalPosition.z propertyPath: m_LocalPosition.z
...@@ -420,7 +420,7 @@ PrefabInstance: ...@@ -420,7 +420,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 0 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3} - target: {fileID: 400000, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_LocalEulerAnglesHint.x propertyPath: m_LocalEulerAnglesHint.x
...@@ -707,7 +707,7 @@ Transform: ...@@ -707,7 +707,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 6 m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &422404977 --- !u!1 &422404977
GameObject: GameObject:
...@@ -864,7 +864,7 @@ Transform: ...@@ -864,7 +864,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 7 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &535944724 --- !u!1 &535944724
GameObject: GameObject:
...@@ -1047,7 +1047,7 @@ Transform: ...@@ -1047,7 +1047,7 @@ Transform:
m_LocalScale: {x: 1, y: 4, z: 1} m_LocalScale: {x: 1, y: 4, z: 1}
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 5 m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &684756691 --- !u!1 &684756691
GameObject: GameObject:
...@@ -1079,7 +1079,7 @@ Transform: ...@@ -1079,7 +1079,7 @@ Transform:
- {fileID: 1675643438} - {fileID: 1675643438}
- {fileID: 1451305264} - {fileID: 1451305264}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 4 m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &866436393 --- !u!1 &866436393
GameObject: GameObject:
...@@ -1488,12 +1488,12 @@ Transform: ...@@ -1488,12 +1488,12 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1009368148} m_GameObject: {fileID: 1009368148}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0.48, z: 0} m_LocalPosition: {x: 2.6310663, y: 0, z: 2.165048}
m_LocalScale: {x: 3, y: 3, z: 3} m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
m_Children: [] m_Children: []
m_Father: {fileID: 1347135377} m_Father: {fileID: 0}
m_RootOrder: 17 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!135 &1009368150 --- !u!135 &1009368150
SphereCollider: SphereCollider:
...@@ -1841,7 +1841,7 @@ PrefabInstance: ...@@ -1841,7 +1841,7 @@ PrefabInstance:
- target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f, - target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f,
type: 3} type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 3 value: 5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f, - target: {fileID: 3052661700889384477, guid: 9cb473a50d07f1245b0f6a7ee2557d4f,
type: 3} type: 3}
...@@ -1955,12 +1955,6 @@ MonoBehaviour: ...@@ -1955,12 +1955,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 38927f5b66d24cc428e39ffa454b0bfb, type: 3} m_Script: {fileID: 11500000, guid: 38927f5b66d24cc428e39ffa454b0bfb, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: 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 --- !u!1 &1351049950
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
...@@ -2094,12 +2088,12 @@ Transform: ...@@ -2094,12 +2088,12 @@ Transform:
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1563243733} m_GameObject: {fileID: 1563243733}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 16.97, z: 0} m_LocalPosition: {x: 2.6310663, y: 8.44, z: 2.165048}
m_LocalScale: {x: 3, y: 3, z: 3} m_LocalScale: {x: 1.5, y: 1.5, z: 1.5}
m_Children: [] m_Children: []
m_Father: {fileID: 1347135377} m_Father: {fileID: 0}
m_RootOrder: 18 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1563243735 --- !u!23 &1563243735
MeshRenderer: MeshRenderer:
...@@ -2409,7 +2403,7 @@ Transform: ...@@ -2409,7 +2403,7 @@ Transform:
m_GameObject: {fileID: 1675643434} m_GameObject: {fileID: 1675643434}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} 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_Children: []
m_Father: {fileID: 684756692} m_Father: {fileID: 684756692}
m_RootOrder: 0 m_RootOrder: 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment