public IEnumerator TakeScreenshot()
    {
        int i = 0;

        while (File.Exists("Assets/Screenshot" + i + ".png"))
        {
            i++;
            yield return(0);
        }
        string path = "Assets/Screenshot" + i + ".png";

        Heatmap.Screenshot(path, camera);
    }
Exemplo n.º 2
0
    public void OnGUI()
    {
        if (GUI.Button(screenshotRect, "Screenshot"))
        {
            camera1.enabled = false;
            camera2.enabled = true;

            Debug.Log(camera2.isActiveAndEnabled);

            // Positions / Camera / How large to draw heat points
            Texture2D heatmapImage = Heatmap.CreateHeatmap(points.ToArray(),
                                                           camera2, 40);

            // Draw the Heatmap in front of the camera
            Heatmap.CreateRenderPlane(heatmapImage);

            // And take the screenshot!
            Heatmap.Screenshot("Assets/MyScreenshot.png");
        }
        StringUtility.Vector3ArrayToTextAsset(points.ToArray(), HeatmapTextAssetPath);
    }
Exemplo n.º 3
0
    public void CheckQuit()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            rift1.enabled   = false;
            rift2.enabled   = false;
            camera2.enabled = true;

            Debug.Log(camera2.isActiveAndEnabled);

            // Positions / Camera / How large to draw heat points
            Texture2D heatmapImage = Heatmap.CreateHeatmap(points.ToArray(),
                                                           camera2, 20);
            // Draw the Heatmap in front of the camera
            Heatmap.CreateRenderPlane(heatmapImage);

            // And take the screenshot!
            Heatmap.Screenshot("Assets/MyScreenshot.png");
        }
        StringUtility.Vector3ArrayToTextAsset(points.ToArray(), HeatmapTextAssetPath);
        Application.Quit();
    }
Exemplo n.º 4
0
 /*!	<summary>
  *	Creates and saves a screenshot.
  *	</summary>
  *	<remarks>
  *	Call this to take a screenshot with the current camera.  Will not overwrite images if path already exists.
  *	</remarks>
  *	<param name="map">The path to save screenshot image to.  Path is relative to Unity project. Ex: "Assets/MyScreenshot.png"</param>
  *	<returns>
  *	Returns a string containing the actual path image was saved to.  This may be different than passed string if the path previously existed.
  *	</returns>
  */
 public static string Screenshot(string path)
 {
     return(Heatmap.Screenshot(path, (Camera)null));
 }
Exemplo n.º 5
0
    public void OnGUI()
    {
        if (cam == null)
        {
            CreateCamera();
        }

        GUILayout.Label("Heatmap Text Asset", EditorStyles.boldLabel);
        heatmapTextAsset = (TextAsset)EditorGUILayout.ObjectField(heatmapTextAsset, typeof(TextAsset), true);

        GUILayout.Space(2);

        GUILayout.Label("Camera Orientation", EditorStyles.boldLabel);

        cameraOrientation = (CameraOrientation)EditorGUILayout.EnumPopup(cameraOrientation);

        if (previousOrientation != cameraOrientation)
        {
            AutosizeCamera(cam, cameraOrientation);
            previousOrientation = cameraOrientation;
        }

        // Camera Utility
        if (cameraOrientation == CameraOrientation.MANUAL)
        {
            cam = (Camera)EditorGUILayout.ObjectField(cam, typeof(Camera), true);
        }
        else
        {
            if (cameraOrientation == CameraOrientation.FORWARD)
            {
                cam.transform.rotation = Quaternion.Euler(Vector3.zero);
            }

            if (cameraOrientation == CameraOrientation.DOWN)
            {
                cam.transform.rotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
            }

            if (GUI.Button(new Rect(0, Screen.height - 22, Screen.width, 20), "Force Update World Bounds"))
            {
                worldBounds = GetWorldBounds();
            }
        }

        pointRadius = EditorGUILayout.IntField("Point Radius", pointRadius);

        GUILayout.Label("cam - " + cam.name + ": " + cam.pixelWidth + ", " + cam.pixelHeight + "\nscreen: " + Screen.width + ", " + Screen.height);

        // Heatmap tools!
        if (GUILayout.Button("Refresh Heatmap"))
        {
            if (heatmapTextAsset == null)
            {
                Debug.LogWarning("No Heatmap log selected!");
                return;
            }
            EditorApplication.ExecuteMenuItem("Window/Game");
            heatmapOverlay = Heatmap.CreateHeatmap(StringUtility.Vector3ArrayWithFile(heatmapTextAsset), cam, pointRadius);
        }

        if (GUILayout.Button("Screenshot"))
        {
            Heatmap.Screenshot("Assets/ImAHeatmap.png", cam);
        }

        if (heatmapOverlay)
        {
            GUILayout.Label(heatmapOverlay);
        }
    }