/// <summary> /// Returns whether the POI is currently registered. /// </summary> public bool POIisRegistered(CompassProPOI poi) { if (icons == null) { return(false); } int iconsCount = icons.Count; for (int k = 0; k < iconsCount; k++) { if (icons[k].poi.id == poi.id) { return(true); } } return(false); }
/// <summary> /// Used to add a POI to the compass. Returns false if POI is already registered. /// </summary> public bool POIRegister(CompassProPOI newPOI) { if (icons == null) { return(false); } int iconsCount = icons.Count; for (int k = 0; k < iconsCount; k++) { if (icons[k].poi == newPOI) { return(false); } } CompassActiveIcon newIcon = new CompassActiveIcon(newPOI); icons.Add(newIcon); return(true); }
/// <summary> /// Call this method to remove a POI from the compass. /// </summary> public void POIUnregister(CompassProPOI newPOI) { if (icons == null) { return; } int iconsCount = icons.Count; for (int k = 0; k < iconsCount; k++) { if (icons[k].poi == newPOI) { if (icons[k].rectTransform != null && icons[k].rectTransform.gameObject != null) { DestroyImmediate(icons[k].rectTransform.gameObject); } icons.RemoveAt(k); break; } } }
/// <summary> /// Shows given POI as gizmo in the scene and makes its icon always visible in the compass bar /// </summary> public void POIFocus(CompassProPOI existingPOI) { if (icons == null) { return; } int iconsCount = icons.Count; for (int k = 0; k < iconsCount; k++) { if (icons[k].poi == existingPOI) { icons[k].poi.showPlayModeGizmo = true; icons[k].poi.clampPosition = true; } else if (icons[k].poi != null) { icons[k].poi.showPlayModeGizmo = false; icons[k].poi.clampPosition = false; } } }
/// <summary> /// Show a light beacon over the specified POI. /// </summary> public GameObject POIShowBeacon(CompassProPOI existingPOI, float duration, float horizontalScale, float intensity, Color tintColor) { Transform beacon = existingPOI.transform.Find("POIBeacon"); if (beacon != null) { return(beacon.gameObject); } GameObject beaconObj = Instantiate(Resources.Load <GameObject>("CNPro/Prefabs/POIBeacon")); beaconObj.name = "POIBeacon"; beacon = beaconObj.transform; beacon.localScale = new Vector3(beacon.localScale.x * horizontalScale, beacon.localScale.y, beacon.localScale.z); beacon.position = existingPOI.transform.position + Misc.Vector3up * beacon.transform.localScale.y * 0.5f; beacon.SetParent(existingPOI.transform, true); BeaconAnimator anim = beacon.gameObject.GetComponent <BeaconAnimator>(); anim.duration = duration; anim.tintColor = tintColor; anim.intensity = intensity; if (audioSource != null) { if (existingPOI.beaconAudioClip != null) { audioSource.PlayOneShot(existingPOI.beaconAudioClip); } else if (_beaconDefaultAudioClip != null) { audioSource.PlayOneShot(_beaconDefaultAudioClip); } } return(beaconObj); }
/// <summary> /// Show a light beacon over the specified POI. /// </summary> public GameObject POIShowBeacon(CompassProPOI existingPOI, float duration, float horizontalScale = 1f) { return(POIShowBeacon(existingPOI, duration, horizontalScale, 1f, Color.white)); }