private void Update() { // ditch out if we already have our first stamp if ((stampCount > 0 && singleStampOnly)) { return; } // check the cache to see if our current orientation would benefit from a new stamp if (captureCamera.IsReady && !captureCamera.IsRequestingImage) { if (!map.IsCached(cameraOrientation.position, cameraOrientation.rotation)) { captureCamera.RequestImage(OnReceivedImage); } } // If we have a target light rotation to get to, start lerping! if (lightStartTime > 0) { float t = Mathf.Clamp01((Time.time - lightStartTime) / lightTargetDuration); if (t >= 1) { lightStartTime = 0; } // This is a cheap cubic in/out easing function, so we aren't doing this linear (ew) t = t < .5f ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1; directionalLight.transform.localRotation = Quaternion.Lerp(lightStartDir, lightTargetDir, t); } }
/// <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); }); }