Ejemplo n.º 1
0
        /// <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);
        }
        /// <summary> Stamps the current camera to the cubemap. </summary>
        private void Stamp()
        {
            if (map == null)
            {
                return;
            }

            cam.RequestImage((tex, mat) =>
            {
                Quaternion rot;
                if (overrideGyro)
                {
                    rot = Quaternion.LookRotation(overrideDir, Vector3.up);
                }
                else
                {
                    rot = EditorGyro.GetRotation();
                }
                map.Stamp(tex, 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);
            });
        }
 private void Update()
 {
     transform.localRotation = EditorGyro.GetRotation();
 }