You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CrowdControl/Assets/AlmostEngine/UltimateScreenshotCreator/Example/Scripts/TakeScreenshotButton.cs

34 lines
768 B
C#

3 months ago
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using AlmostEngine.Screenshot;
namespace AlmostEngine.Examples
{
/// <summary>
/// Add this component to a button to take a screenshot when pressed.
/// </summary>
[RequireComponent (typeof(Button))]
public class TakeScreenshotButton : MonoBehaviour
{
Button m_Button;
ScreenshotManager m_ScreenshotManager;
void Start ()
{
m_ScreenshotManager = GameObject.FindObjectOfType<ScreenshotManager> ();
m_Button = GetComponent<Button> ();
m_Button.onClick.AddListener (OnClickCallback);
}
void OnClickCallback ()
{
if (m_ScreenshotManager) {
m_ScreenshotManager.Capture ();
}
}
}
}