From 4e9500b48f000bb90a3d54f44bb9d42c21f3ebd4 Mon Sep 17 00:00:00 2001 From: unknown <john.schihada@hotmail.com> Date: Thu, 6 Feb 2020 22:07:32 +0100 Subject: [PATCH] Added Basic Pushout-Highlighting --- .../InteractionEngine/CommunicationEvents.cs | 1 + Assets/InteractionEngine/ShinyThings.cs | 70 ++++++++++++++++++- Assets/InventoryStuff/ScrollDetails.cs | 3 + Assets/TreeWorld.unity | 25 +++---- 4 files changed, 85 insertions(+), 14 deletions(-) diff --git a/Assets/InteractionEngine/CommunicationEvents.cs b/Assets/InteractionEngine/CommunicationEvents.cs index cfb988a0..3da1224d 100644 --- a/Assets/InteractionEngine/CommunicationEvents.cs +++ b/Assets/InteractionEngine/CommunicationEvents.cs @@ -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(); diff --git a/Assets/InteractionEngine/ShinyThings.cs b/Assets/InteractionEngine/ShinyThings.cs index 146d347a..f887af97 100644 --- a/Assets/InteractionEngine/ShinyThings.cs +++ b/Assets/InteractionEngine/ShinyThings.cs @@ -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; diff --git a/Assets/InventoryStuff/ScrollDetails.cs b/Assets/InventoryStuff/ScrollDetails.cs index 12dca2d2..57c6db1d 100644 --- a/Assets/InventoryStuff/ScrollDetails.cs +++ b/Assets/InventoryStuff/ScrollDetails.cs @@ -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); } } } diff --git a/Assets/TreeWorld.unity b/Assets/TreeWorld.unity index 7f519974..e520258e 100644 --- a/Assets/TreeWorld.unity +++ b/Assets/TreeWorld.unity @@ -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 -- GitLab