Ejemplo n.º 1
0
        /// <summary>
        /// Removes ShadowsCameraEvents from the camera.
        /// </summary>
        /// <param name="cameras">
        /// Cameras to remove the ShadowsCameraEvents component from.
        /// </param>
        public void RemoveCameraEvents(Camera[] cameras)
        {
            for (int i = 0; i < cameras.Length; i++)
            {
                ShadowsCameraEvents cameraEvents = cameras[i].GetComponent <ShadowsCameraEvents>();
                if (cameraEvents != null)
                {
#if UNITY_EDITOR
                    DestroyImmediate(cameraEvents);
#else
                    Destroy(cameraEvents);
#endif
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attaches ShadowsCameraEvents to <paramref name="camera"/>.
        /// </summary>
        /// <param name="camera">
        /// The camera to attach the ShadowsCameraEvents component.
        /// </param>
        /// <param name="hideFlags">
        /// <see cref="HideFlags"/> to apply to <paramref name="camera"/>.
        /// </param>
        public void UpdateCameraEvents(Camera camera, HideFlags hideFlags)
        {
            NoShadowsCamera noShadowsCamera = camera.GetComponent <NoShadowsCamera>();

            if (noShadowsCamera != null)
            {
                return;
            }

            ShadowsCameraEvents cameraEvents = camera.GetComponent <ShadowsCameraEvents>();

            if (cameraEvents == null)
            {
                cameraEvents = camera.gameObject.AddComponent <ShadowsCameraEvents>();
            }

            cameraEvents.hideFlags = hideFlags;
        }
        private void OnEnable()
        {
            ShadowsCameraEvents cameraEvents = GetComponent <ShadowsCameraEvents>();

            if (cameraEvents == null)
            {
                return;
            }

#if UNITY_EDITOR
            if (Application.isPlaying)
            {
                Destroy(cameraEvents);
            }
            else
            {
                DestroyImmediate(cameraEvents);
            }
#else
            Destroy(cameraEvents);
#endif
        }