Skip to content
Snippets Groups Projects
Commit 4e9500b4 authored by John Schihada's avatar John Schihada
Browse files

Added Basic Pushout-Highlighting

parent 19951035
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,7 @@ public class ShinyEvent : UnityEvent<Fact> {
public static ShinyEvent StopCurveDrawingEvent = new ShinyEvent();
//Event for stopping all previews -> Made When ToolMode is changed
public static ShinyEvent StopPreviewsEvent = new ShinyEvent();
public static ShinyEvent PushoutFactEvent = new ShinyEvent();
......
......@@ -28,6 +28,14 @@ public class ShinyThings : MonoBehaviour
private Vector3 angleMiddlePoint;
private float curveRadius;
//Variables for Pushout-Highlighting
private Fact highlightedPushoutFact;
private bool timerActive { get; set; }
private float timer { get; set; }
private float timerDuration = 3.0f;
public Material pushoutMaterial;
private Material tempMaterial;
// Start is called before the first frame update
public void Start()
{
......@@ -37,6 +45,10 @@ public void Start()
CommunicationEvents.StartCurveDrawingEvent.AddListener(ActivateCurveDrawing);
CommunicationEvents.StopCurveDrawingEvent.AddListener(DeactivateCurveDrawing);
CommunicationEvents.StopPreviewsEvent.AddListener(StopPreviews);
CommunicationEvents.PushoutFactEvent.AddListener(StartPushoutFactHighlighting);
this.timerActive = false;
this.timer = 0;
}
// Update is called once per frame
......@@ -60,9 +72,18 @@ public void Update()
UpdateLineDrawing(this.transform.position);
else if (this.curveDrawingActivated)
UpdateCurveDrawing(this.transform.position);
//If the Timer is Active, check if timerDuration is reached and stop Pushout-Highlighting
if (this.timerActive)
{
this.timer += Time.deltaTime;
if (this.timer >= this.timerDuration)
{
this.timerActive = false;
this.timer = 0;
StopPushoutFactHighlighting();
}
}
}
private void Highlighting(RaycastHit hit)
......@@ -169,6 +190,51 @@ public void OnMouseOverFactEnd(Transform selection)
}
}
public void StartPushoutFactHighlighting(Fact startFact) {
highlightedPushoutFact = startFact;
if (typeof(PointFact).IsInstanceOfType(highlightedPushoutFact))
{
PointFact fact = (PointFact)highlightedPushoutFact;
tempMaterial = fact.Representation.transform.GetChild(0).GetComponent<MeshRenderer>().material;
fact.Representation.transform.GetChild(0).GetComponent<MeshRenderer>().material = pushoutMaterial;
}
else if (typeof(LineFact).IsInstanceOfType(highlightedPushoutFact))
{
LineFact fact = (LineFact)highlightedPushoutFact;
tempMaterial = fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material;
fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material = pushoutMaterial;
}
else if (typeof(AngleFact).IsInstanceOfType(highlightedPushoutFact)) {
AngleFact fact = (AngleFact)highlightedPushoutFact;
tempMaterial = fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material;
fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material = pushoutMaterial;
}
//Activate Timer
this.timerActive = true;
}
public void StopPushoutFactHighlighting() {
if (typeof(PointFact).IsInstanceOfType(highlightedPushoutFact))
{
PointFact fact = (PointFact)highlightedPushoutFact;
fact.Representation.transform.GetChild(0).GetComponent<MeshRenderer>().material = tempMaterial;
}
else if (typeof(LineFact).IsInstanceOfType(highlightedPushoutFact))
{
LineFact fact = (LineFact)highlightedPushoutFact;
fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material = tempMaterial;
}
else if (typeof(AngleFact).IsInstanceOfType(highlightedPushoutFact))
{
AngleFact fact = (AngleFact)highlightedPushoutFact;
fact.Representation.transform.GetChild(0).GetChild(0).GetComponent<MeshRenderer>().material = tempMaterial;
}
}
public void ActivateLineDrawing(Fact startFact)
{
this.lineRenderer.positionCount = 2;
......
......@@ -211,6 +211,7 @@ private void readPushout(string txt) {
PointFact pf = new PointFact(id, a, b, c, f.uri);
CommunicationEvents.Facts.Insert(id, pf);
CommunicationEvents.AddFactEvent.Invoke(pf);
CommunicationEvents.PushoutFactEvent.Invoke(pf);
}
if (f.isDistance()) {
int id = factManager.GetFirstEmptyID();
......@@ -219,6 +220,7 @@ private void readPushout(string txt) {
LineFact lf = new LineFact(id, pid1, pid2, f.uri, f.value);
CommunicationEvents.Facts.Insert(id, lf);
CommunicationEvents.AddFactEvent.Invoke(lf);
CommunicationEvents.PushoutFactEvent.Invoke(lf);
}
if (f.isAngle()){
int id = factManager.GetFirstEmptyID();
......@@ -228,6 +230,7 @@ private void readPushout(string txt) {
AngleFact af = new AngleFact(id, pid1, pid2, pid3, f.uri, f.value);
CommunicationEvents.Facts.Insert(id, af);
CommunicationEvents.AddFactEvent.Invoke(af);
CommunicationEvents.PushoutFactEvent.Invoke(af);
}
}
}
......
......@@ -346,47 +346,47 @@ PrefabInstance:
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100020, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100014, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100022, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100016, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100024, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100018, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100026, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100020, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100028, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100022, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100030, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100024, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100032, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100026, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100034, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100028, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100014, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100030, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100016, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100032, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 100018, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
- target: {fileID: 100034, guid: c91c1eb85782d5748ace27eb4d7415bb, type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
......@@ -2559,6 +2559,7 @@ MonoBehaviour:
defaultMaterial: {fileID: 2100000, guid: 8ae9adf4dc782964387385c1e8c0eb72, type: 2}
highlightMaterial: {fileID: 2100000, guid: c7daa82e15f0cf04d92d0f41ce84f9df, type: 2}
lineRenderer: {fileID: 1661088668}
pushoutMaterial: {fileID: 2100000, guid: d9c43ce51f1a01d41a18fae03c0d406c, type: 2}
--- !u!114 &1661088670
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -3099,7 +3100,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0.0001373291}
m_AnchoredPosition: {x: 0, y: 0.000076293945}
m_SizeDelta: {x: -17, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &2421006697587610782
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment