void Start() { screenCap = new Texture2D(300, 200, TextureFormat.RGB24, false); // 1 border = new Texture2D(2, 2, TextureFormat.ARGB32, false); // 2 border.Apply(); ssButton.SetActive(true); SizeSlider.SetActive(true); AddButton.SetActive(true); }
public void ScreenShot() { if (Input.GetKeyUp(KeyCode.Mouse0)) { captureScreenshot("true"); ssButton.SetActive(false); SizeSlider.SetActive(false); AddButton.SetActive(false); } }
void ReleaseDesignerOutlets() { if (BlackButton != null) { BlackButton.Dispose(); BlackButton = null; } if (LastActionTimeLabel != null) { LastActionTimeLabel.Dispose(); LastActionTimeLabel = null; } if (RedButton != null) { RedButton.Dispose(); RedButton = null; } if (RedrawSwitch != null) { RedrawSwitch.Dispose(); RedrawSwitch = null; } if (SizeSlider != null) { SizeSlider.Dispose(); SizeSlider = null; } if (YellowButton != null) { YellowButton.Dispose(); YellowButton = null; } }
public IEnumerator Capture() { yield return(new WaitForEndOfFrame()); screenCap.ReadPixels(new Rect(198, 98, 298, 198), 0, 0); screenCap.Apply(); // Encode texture into PNG byte[] bytes = screenCap.EncodeToPNG(); //Object.Destroy(screenCap); // For testing purposes, also write to a file in the project folder string screenshotFilename = "Green_" + System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".JPG"; ScreenCapture.CaptureScreenshot(screenshotFilename); if (Application.platform == RuntimePlatform.Android) { string myFolderLocation = "/sdcard/DCIM/ARDinasours/"; if (!System.IO.Directory.Exists(myFolderLocation)) { System.IO.Directory.CreateDirectory(myFolderLocation); } movePath = myFolderLocation + screenshotFilename; } filePath = screenshotFilename; shot = true; ssButton.SetActive(true); SizeSlider.SetActive(true); AddButton.SetActive(true); ActiveUrl = movePath; // string action = Intent.ACTION_MEDIA_SCANNER_SCAN_FILE AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); string action = intentClass.GetStatic <string>("ACTION_MEDIA_SCANNER_SCAN_FILE"); // Intent intentObject = new Intent(action); AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent", action); // Uri uriObject = Uri.parse("file:" + filePath); AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); AndroidJavaObject uriObject = uriClass.CallStatic <AndroidJavaObject>("parse", "file://" + movePath); // intentObject.setData(uriObject); intentObject.Call <AndroidJavaObject>("setData", uriObject); // this.sendBroadcast(intentObject); AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unity.GetStatic <AndroidJavaObject>("currentActivity"); currentActivity.Call("sendBroadcast", intentObject); }