Beispiel #1
0
        /// <summary>
        /// Show a light beacon over the specified POI.
        /// </summary>
        public void POIShowBeacon(Vector3 position, float duration, float horizontalScale, float intensity, Color tintColor)
        {
            string     beaconName = "POIBeacon " + position;
            GameObject beaconObj  = GameObject.Find(beaconName);

            if (beaconObj != null)
            {
                return;
            }

            beaconObj      = Instantiate(Resources.Load <GameObject>("CNPro/Prefabs/POIBeacon"));
            beaconObj.name = beaconName;
            Transform beacon = beaconObj.transform;

            beacon.localScale = new Vector3(beacon.localScale.x * horizontalScale, beacon.localScale.y, beacon.localScale.z);
            beacon.position   = position + Misc.Vector3up * beacon.transform.localScale.y * 0.5f;
            BeaconAnimator anim = beacon.gameObject.GetComponent <BeaconAnimator>();

            anim.duration  = duration;
            anim.tintColor = tintColor;
            anim.intensity = intensity;

            if (audioSource != null)
            {
                if (_beaconDefaultAudioClip != null)
                {
                    audioSource.PlayOneShot(_beaconDefaultAudioClip);
                }
            }
        }
Beispiel #2
0
        /// <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);
        }