void startTrace(RaycastHit h, Touch t, bool hasHit) { Vector3? start = hasHit ? (Vector3?)h.point : null; TouchTrace tr = new TouchTrace(Time.time, start); liveTraces.Add(t.fingerId, tr); }
void drawTrace(TouchTrace tr, TraceConfig config) { if (tr.startPos != null) { Gizmos.color = config.StartColor; Gizmos.DrawSphere(tr.startPos.Value, config.SphereSize); } if (tr.endPos != null) { Gizmos.color = config.EndColor; Gizmos.DrawSphere(tr.endPos.Value, config.SphereSize); } Gizmos.color = config.PathColor; Vector3?fromPos = null; foreach (Vector3 pos in tr.positions) { if (fromPos == null) { fromPos = (Vector3?)tr.startPos; } if (fromPos != null) { Gizmos.DrawLine(fromPos.Value, pos); } fromPos = (Vector3?)pos; } }
void updateTrace(RaycastHit h, Touch t) { if (!liveTraces.ContainsKey(t.fingerId)) { return; } TouchTrace tr = liveTraces[t.fingerId]; tr.positions.Add(h.point); }
void endTrace(RaycastHit h, Touch t, bool hasHit) { if (!liveTraces.ContainsKey(t.fingerId)) { return; } TouchTrace tr = liveTraces[t.fingerId]; tr.endTime = Time.time; if (hasHit) { tr.endPos = (Vector3?)h.point; } oldTraces.Add(tr); liveTraces.Remove(t.fingerId); }
void drawTrace(TouchTrace tr, TraceConfig config) { if (tr.startPos != null) { Gizmos.color = config.StartColor; Gizmos.DrawSphere(tr.startPos.Value, config.SphereSize); } if (tr.endPos != null) { Gizmos.color = config.EndColor; Gizmos.DrawSphere(tr.endPos.Value, config.SphereSize); } Gizmos.color = config.PathColor; Vector3? fromPos = null; foreach (Vector3 pos in tr.positions) { if (fromPos == null) fromPos = (Vector3?)tr.startPos; if (fromPos != null) Gizmos.DrawLine(fromPos.Value, pos); fromPos = (Vector3?)pos; } }