public void OnMarkerHoverEnd(MarkerTip marker) { lineActive = false; currentLine.numCornerVertices = 0; Vector3 oldPos = currentLine.GetPosition(0); for (int i = 1; i < currentLine.positionCount; i++) { Vector3 newPos = currentLine.GetPosition(i); BoxCollider bc = currentLine.gameObject.AddComponent <BoxCollider>(); bc.isTrigger = true; Vector3 size = newPos - oldPos; size.x = Mathf.Abs(size.x); size.y = Mathf.Abs(size.y); size.z = 0.00759f; bc.size = size; Vector3 c = oldPos + new Vector3(0, 0, -0.02f); bc.center = c; oldPos = newPos; } }
public void StopDraw(MarkerTip tip) { if (tip) { Marker marker = tip.GetComponentInParent <Marker>(); marker.SetMarkerUp(); } }
public void OnTriggerExit(Collider other) { MarkerTip tip = other.GetComponent <MarkerTip>(); if (tip && !tip.drawing) { StopDraw(tip); Debug.Log("Stopping draw!"); } }
public void OnTriggerStay(Collider other) { MarkerTip tip = other.GetComponent <MarkerTip>(); if (tip && tip.drawing) { Vector3 pos = GetComponent <Collider>().ClosestPointOnBounds(other.transform.position); Draw(tip, pos); } }
public void Draw(MarkerTip tip, Vector3 point) { if (tip) { Marker marker = tip.GetComponentInParent <Marker>(); point.z = lineZ; marker.DrawPoint(point, gameObject); marker.transform.position = new Vector3(marker.transform.position.x, marker.transform.position.y, z); } }
public void StartDraw(MarkerTip tip, Vector3 point) { if (tip) { Marker marker = tip.GetComponentInParent <Marker>(); if (marker) { z = marker.transform.position.z; marker.SetMarkerDown(point, gameObject); tip.drawing = true; } } }
/* * public void OnCollisionEnter(Collision other) * { * * MarkerTip tip = other.collider.GetComponent<MarkerTip>(); * StartDraw(tip, other.contacts[0].point); * * foreach (Rigidbody body in other.collider.GetComponentsInParent<Rigidbody>()) * { * * body.freezeRotation = true; * * } * } * * public void OnCollisionStay(Collision other) * { * * MarkerTip tip = other.collider.GetComponent<MarkerTip>(); * Draw(tip, other.contacts[0].point); * * } * * public void OnCollisionExit(Collision other) * { * * MarkerTip tip = other.collider.GetComponent<MarkerTip>(); * StopDraw(tip); * * foreach (Rigidbody body in other.collider.GetComponentsInParent<Rigidbody>()) * { * * body.freezeRotation = false; * * * } * } */ public void OnTriggerEnter(Collider other) { MarkerTip tip = other.GetComponent <MarkerTip>(); if (tip && tip.drawPrepped && !tip.drawing) { Vector3 pos = GetComponent <Collider>().ClosestPointOnBounds(other.transform.position); lineZ = pos.z; StartDraw(tip, pos); Debug.Log("SETTING LINE Z"); } }
public void OnMarkerHoverUpdate(MarkerTip marker) { if (lineActive) { currentLine.positionCount = index + 1; Vector3 worldMarkerPos = marker.transform.position; Vector3 localMarkerPos = currentLine.transform.InverseTransformPoint(worldMarkerPos); Vector3 clippedZPos = new Vector3(localMarkerPos.x, localMarkerPos.y, -0.00759f); currentLine.SetPosition(index, clippedZPos); index++; } }
//Marker Stuff public void OnMarkerHoverBegin(MarkerTip markerTip) { lineNum++; line = new GameObject(lineName + lineNum.ToString());//Increments the lineNum value and then creates a new line object with the lineName and lineNum to gen name. line.transform.SetParent(gameObject.transform.Find("LineDump").transform); currentLine = line.gameObject.AddComponent <LineRenderer>(); currentLine.startWidth = marker.GetComponent <MarkerInteraction>().width; currentLine.endWidth = marker.GetComponent <MarkerInteraction>().width; currentLine.alignment = LineAlignment.Local; currentLine.colorGradient.mode = GradientMode.Fixed; currentLine.textureMode = LineTextureMode.Stretch; currentLine.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion; currentLine.useWorldSpace = false; currentLine.material.shader = Shader.Find("Sprites/Default"); currentLine.startColor = marker.GetComponent <MarkerInteraction>().color; currentLine.endColor = marker.GetComponent <MarkerInteraction>().color; currentLine.transform.localScale = new Vector3(0.125f, 0.5f, 99.95f); currentLine.transform.localRotation = Quaternion.Euler(0, 0, 0); currentLine.transform.localPosition = Vector3.zero; currentLine.gameObject.AddComponent <LineInteraction>(); index = 0; lineActive = true; this.markerTip = markerTip; }
private void OnMarkerHoverBegin(MarkerTip marker) { onMarkerHoverBegin.Invoke(); }
private void OnMarkerHoverEnd(MarkerTip marker) { onMarkerHoverEnd.Invoke(); }
private void OnMarkerHoverUpdate(MarkerTip marker) { onMarkerHoverUpdate.Invoke(); }