public void RemoveMarker( dfRadarMarker item ) { if( markers.Remove( item ) ) { ensureControlReference(); if( item.marker != null ) Destroy( item.marker ); if( item.outOfRangeMarker != null ) Destroy( item.outOfRangeMarker ); control.RemoveControl( item.marker ); } }
private void updateMarker(dfRadarMarker item) { Vector3 centerPos = target.transform.position; Vector3 extPos = item.transform.position; float dx = centerPos.x - extPos.x; float dz = centerPos.z - extPos.z; float deltay = Mathf.Atan2(dx, -dz) * Mathf.Rad2Deg + 90 + target.transform.eulerAngles.y; float dist = Vector3.Distance(centerPos, extPos); if (dist > maxDetectDistance) { item.marker.IsVisible = false; if (item.outOfRangeMarker != null) { var marker = item.outOfRangeMarker; marker.IsVisible = true; marker.transform.position = control.transform.position; marker.transform.eulerAngles = new Vector3(0, 0, deltay - 90); } return; } else if (item.outOfRangeMarker != null) { item.outOfRangeMarker.IsVisible = false; } float bX = dist * Mathf.Cos(deltay * Mathf.Deg2Rad); float bY = dist * Mathf.Sin(deltay * Mathf.Deg2Rad); var mapScale = radarRadius / maxDetectDistance * control.PixelsToUnits(); bX = bX * mapScale; bY = bY * mapScale; item.marker.transform.localPosition = new Vector3(bX, bY, 0); item.marker.IsVisible = true; item.marker.Pivot = dfPivotPoint.MiddleCenter; }
public void AddMarker( dfRadarMarker item ) { if( string.IsNullOrEmpty( item.markerType ) ) return; ensureControlReference(); item.marker = instantiateMarker( item.markerType ); if( item.marker == null ) return; if( !string.IsNullOrEmpty( item.outOfRangeType ) ) item.outOfRangeMarker = instantiateMarker( item.outOfRangeType ); markers.Add( item ); }
public void RemoveMarker(dfRadarMarker item) { if (markers.Remove(item)) { ensureControlReference(); if (item.marker != null) { Destroy(item.marker); } if (item.outOfRangeMarker != null) { Destroy(item.outOfRangeMarker); } control.RemoveControl(item.marker); } }
public void AddMarker(dfRadarMarker item) { if (string.IsNullOrEmpty(item.markerType)) { return; } ensureControlReference(); item.marker = instantiateMarker(item.markerType); if (item.marker == null) { return; } if (!string.IsNullOrEmpty(item.outOfRangeType)) { item.outOfRangeMarker = instantiateMarker(item.outOfRangeType); } markers.Add(item); }
private void updateMarker( dfRadarMarker item ) { Vector3 centerPos = target.transform.position; Vector3 extPos = item.transform.position; float dx = centerPos.x - extPos.x; float dz = centerPos.z - extPos.z; float deltay = Mathf.Atan2( dx, -dz ) * Mathf.Rad2Deg + 90 + target.transform.eulerAngles.y; float dist = Vector3.Distance( centerPos, extPos ); if( dist > maxDetectDistance ) { item.marker.IsVisible = false; if( item.outOfRangeMarker != null ) { var marker = item.outOfRangeMarker; marker.IsVisible = true; marker.transform.position = control.transform.position; marker.transform.eulerAngles = new Vector3( 0, 0, deltay - 90 ); } return; } else if( item.outOfRangeMarker != null ) { item.outOfRangeMarker.IsVisible = false; } float bX = dist * Mathf.Cos( deltay * Mathf.Deg2Rad ); float bY = dist * Mathf.Sin( deltay * Mathf.Deg2Rad ); var mapScale = radarRadius / maxDetectDistance * control.PixelsToUnits(); bX = bX * mapScale; bY = bY * mapScale; item.marker.transform.localPosition = new Vector3( bX, bY, 0 ); item.marker.IsVisible = true; item.marker.Pivot = dfPivotPoint.MiddleCenter; }
private void Awake() { rm = GetComponent<dfRadarMarker>(); }