Example #1
0
        private async Task TakeStampAsync()
        {
            var result = await cameraCapture.RequestTextureAsync();

            var texture = result.Texture;
            var matrix  = result.Matrix;

            map.Stamp(texture, matrix.GetColumn(3), matrix.rotation, matrix.MultiplyVector(Vector3.forward));
            stampCount += 1;

            DynamicGI.UpdateEnvironment();

            if (useDirectionalLight)
            {
                UpdateDirectionalLight();
            }
        }
        /// <summary>
        /// Stamps the current camera to the cubemap.
        /// </summary>
        /// <returns>
        /// A <see cref="Task"/> that represents the operation.
        /// </returns>
        private async Task StampAsync()
        {
            // If we have no map, nothing to do.
            if (map == null)
            {
                return;
            }

            // If the camera isn't ready, also nothing to do.
            if (!cam.IsReady)
            {
                return;
            }

            // Request a texture from the camera
            var result = await cam.RequestTextureAsync();

            Quaternion rot;

            if (overrideGyro)
            {
                rot = Quaternion.LookRotation(overrideDir, Vector3.up);
            }
            else
            {
                rot = EditorGyro.GetRotation();
            }
            map.Stamp(result.Texture, Vector3.zero, rot, overrideDir.normalized);

            // Generate a unique filename
            string path = "Assets/CamCubemap.png";
            int    curr = 1;

            while (File.Exists(path))
            {
                curr += 1;
                path  = string.Format("Assets/CamCubemap{0}.png", curr);
            }

            SaveCubemap(map.Map, path);
            previewAsset = AssetDatabase.LoadAssetAtPath <Object>(path);

            // Ping it, so the user knows we made it
            Selection.activeObject = previewAsset;
            EditorGUIUtility.PingObject(previewAsset);
        }