protected virtual async void OnEnable() { // Save initial settings in case we wish to restore them startSky = RenderSettings.skybox; // Save initial light settings if (directionalLight != null) { startLightColor = directionalLight.color; startLightRot = directionalLight.transform.rotation; startLightBrightness = directionalLight.intensity; UpdateDirectionalLight(); } probe.mode = UnityEngine.Rendering.ReflectionProbeMode.Custom; CameraResolution resolution = new CameraResolution(); resolution.nativeResolution = NativeResolutionMode.Smallest; resolution.resize = ResizeWhen.Never; await cameraCapture.InitializeAsync(true, resolution); if (map == null) { map = new CubeMapper(); map.Create(cameraCapture.FieldOfView * stampFovMultiplier, mapResolution); map.StampExpireDistance = stampExpireDistance; } probe.customBakedTexture = map.Map; RenderSettings.skybox = map.SkyMaterial; RenderSettings.ambientMode = AmbientMode.Skybox; DynamicGI.UpdateEnvironment(); }
private async void OnEnable() { Texture2D tex = new Texture2D(1, 1); tex.hideFlags = HideFlags.HideAndDontSave; tex.SetPixels(new Color[] { new Color(1, 1, 1, 0) }); tex.Apply(); previewStyle = new GUIStyle(); previewStyle.normal.background = tex; cam = new CameraCaptureWebcam(null, Camera.main.fieldOfView); CameraResolution resolution = new CameraResolution(); resolution.nativeResolution = NativeResolutionMode.Largest; resolution.resize = ResizeWhen.Never; await cam.InitializeAsync(true, resolution); }