Add the screenshot helper to the project, add assembly definitions and setup cross-references

This commit is contained in:
Michal Pikulski
2025-11-25 10:46:01 +01:00
parent 86c1df55f2
commit 83fcf24f52
89 changed files with 14031 additions and 0 deletions

8
Assets/External/SWAN Dev.meta vendored Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3ab815f1dbc7e044aef8cbeb26b3cab
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/External/SWAN Dev/Common.meta vendored Normal file
View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 1350c125f347c4d4db6de6f11d289676
folderAsset: yes
timeCreated: 1506317297
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[RequireComponent(typeof(CanvasScaler))]
public class DCanvasScalerHandler : MonoBehaviour
{
public Vector2 m_ReferenceResolution = new Vector2(1080, 1920);
void Start ()
{
CanvasScaler cs = GetComponent<CanvasScaler>();
if(cs)
{
if(Screen.width > Screen.height)
{
if(m_ReferenceResolution.x > m_ReferenceResolution.y) cs.referenceResolution = m_ReferenceResolution;
else cs.referenceResolution = new Vector2(m_ReferenceResolution.y, m_ReferenceResolution.x);
}
else
{
if (m_ReferenceResolution.x > m_ReferenceResolution.y) cs.referenceResolution = new Vector2(m_ReferenceResolution.y, m_ReferenceResolution.x);
else cs.referenceResolution = m_ReferenceResolution;
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4d97ce3077157c54db6c6ae23cd38048
timeCreated: 1548426802
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/DCanvasScalerHandler.cs
uploadId: 673764

View File

@@ -0,0 +1,276 @@
// Created by SwanDEV 2018
using UnityEngine;
/// <summary>
/// DynamicUI - Image Display Handler for UGUI Image & RawImage.
/// How to use: (1) add as a base class (Inherits), (2) Drop this script in a GameObject and reference it.
/// Call the SetImage/SetRawImage method.
/// </summary>
public class DImageDisplayHandler : MonoBehaviour
{
public enum BoundingTarget
{
/// <summary> Constraints the target image with the Vector2 size(m_Size). </summary>
Size,
/// <summary> Constraints the target image with the sizeDelta of the RectTranform(m_RectTransform). </summary>
RectTransform,
/// <summary> Constraints the target image with the device screen size. </summary>
Screen,
}
public enum BoundingType
{
SetNativeSize = 0,
/// <summary> Sets the entire image RectTransform to be constrained within a specified area size (width and height). </summary>
WidthAndHeight,
/// <summary> Sets the image RectTransform's width equal to the width of specified area size, the image height is not constrained. </summary>
Width,
/// <summary> Sets the image RectTransform's height equal to the height of specified area size, the image width is not constrained. </summary>
Height,
/// <summary> Sets the image RectTransform to cover the entire specified area size, either the image width or height will exceed that size if the aspect ratio is different. </summary>
FillAll,
}
[Header("[ Image Display Handler ]")]
public BoundingTarget m_BoundingTarget = BoundingTarget.Size;
public RectTransform m_RectTransform;
public Vector2 m_Size = new Vector2(512, 512);
[Space()]
public BoundingType m_BoundingType = BoundingType.SetNativeSize;
[Space()]
public float m_ScaleFactor = 1f;
/// <summary>Auto clear the texture of the last set Image/RawImage before setting a new one.</summary>
[Space()]
[Tooltip("Auto clear the texture of the last set Image/RawImage before setting a new one.")]
public bool m_AutoClearTexture = true;
/// <summary>
/// Is the target display(Image/RawImage) RectTranform (eulerAngles.z) rotated by 90/-90.
/// </summary>
[HideInInspector] public bool m_Rotated_90 = false;
public void SetImage(UnityEngine.UI.Image displayImage, Sprite sprite)
{
if (m_AutoClearTexture) Clear(displayImage);
displayImage.sprite = sprite;
_SetSize(displayImage);
}
public void SetImage(UnityEngine.UI.Image displayImage, Texture2D texture2D)
{
if (m_AutoClearTexture) Clear(displayImage);
displayImage.sprite = _TextureToSprite(texture2D);
_SetSize(displayImage);
}
public void SetRawImage(UnityEngine.UI.RawImage displayImage, Sprite sprite)
{
if (m_AutoClearTexture) Clear(displayImage);
displayImage.texture = (Texture)sprite.texture;
_SetSize(displayImage);
}
public void SetRawImage(UnityEngine.UI.RawImage displayImage, Texture2D texture2D)
{
if (m_AutoClearTexture) Clear(displayImage);
displayImage.texture = (Texture)texture2D;
_SetSize(displayImage);
}
public void SetRawImage(UnityEngine.UI.RawImage displayImage, Texture texture)
{
if (m_AutoClearTexture) Clear(displayImage);
displayImage.texture = texture;
_SetSize(displayImage);
}
public void SetImage(UnityEngine.UI.Image displayImage, float width, float height)
{
displayImage.rectTransform.sizeDelta = _CalculateSize(new Vector2(width, height));
_ApplyScaleFactor(displayImage.transform);
}
public void SetRawImage(UnityEngine.UI.RawImage displayImage, float width, float height)
{
displayImage.rectTransform.sizeDelta = _CalculateSize(new Vector2(width, height));
_ApplyScaleFactor(displayImage.transform);
}
private void _SetSize(UnityEngine.UI.Image displayImage)
{
if (m_BoundingType == BoundingType.SetNativeSize)
{
displayImage.SetNativeSize();
}
else
{
displayImage.rectTransform.sizeDelta = _CalculateSize(new Vector2(displayImage.sprite.texture.width, displayImage.sprite.texture.height));
}
_ApplyScaleFactor(displayImage.transform);
}
private void _SetSize(UnityEngine.UI.RawImage displayImage)
{
if (m_BoundingType == BoundingType.SetNativeSize)
{
displayImage.SetNativeSize();
}
else
{
displayImage.rectTransform.sizeDelta = _CalculateSize(new Vector2(displayImage.texture.width, displayImage.texture.height));
}
_ApplyScaleFactor(displayImage.transform);
}
private void _ApplyScaleFactor(Transform displayImageT)
{
displayImageT.localScale = new Vector3(m_ScaleFactor, m_ScaleFactor, 1f);
}
private Vector2 _CalculateSize(Vector2 textureSize)
{
Vector2 boundarySize = Vector2.zero;
switch (m_BoundingTarget)
{
case BoundingTarget.Size:
boundarySize = m_Size;
break;
case BoundingTarget.RectTransform:
boundarySize = m_RectTransform.GetComponent<RectTransform>().rect.size;
break;
case BoundingTarget.Screen:
boundarySize = new Vector2(Screen.width, Screen.height);
break;
}
float newWidth = textureSize.x;
float newHeight = textureSize.y;
float imageRatio = newWidth / newHeight;
switch (m_BoundingType)
{
case BoundingType.FillAll:
if (m_Rotated_90)
{
newHeight = boundarySize.x;
newWidth = newHeight * imageRatio;
if (newWidth < boundarySize.y)
{
newWidth = boundarySize.y;
newHeight = newWidth / imageRatio;
}
}
else
{
newWidth = boundarySize.x;
newHeight = newWidth / imageRatio;
if (newHeight < boundarySize.y)
{
newHeight = boundarySize.y;
newWidth = newHeight * imageRatio;
}
}
break;
case BoundingType.WidthAndHeight:
if (m_Rotated_90)
{
newHeight = boundarySize.x;
newWidth = newHeight * imageRatio;
if (newWidth > boundarySize.y)
{
newWidth = boundarySize.y;
newHeight = newWidth / imageRatio;
}
}
else
{
newWidth = boundarySize.x;
newHeight = newWidth / imageRatio;
if (newHeight > boundarySize.y)
{
newHeight = boundarySize.y;
newWidth = newHeight * imageRatio;
}
}
break;
case BoundingType.Width:
if (m_Rotated_90)
{
newHeight = boundarySize.x;
newWidth = newHeight * imageRatio;
}
else
{
newWidth = boundarySize.x;
newHeight = newWidth / imageRatio;
}
break;
case BoundingType.Height:
if (m_Rotated_90)
{
newWidth = boundarySize.y;
newHeight = newWidth / imageRatio;
}
else
{
newHeight = boundarySize.y;
newWidth = newHeight * imageRatio;
}
break;
default:
newWidth = textureSize.x;
newHeight = textureSize.y;
break;
}
return new Vector2(newWidth, newHeight);
}
private Sprite _TextureToSprite(Texture2D texture)
{
if (texture == null) return null;
Vector2 pivot = new Vector2(0.5f, 0.5f);
float pixelPerUnit = 100;
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), pivot, pixelPerUnit);
}
public void Clear(UnityEngine.UI.Image displayImage)
{
if (displayImage != null && displayImage.sprite != null && displayImage.sprite.texture != null)
{
Destroy(displayImage.sprite.texture);
displayImage.sprite = null;
}
}
public void Clear(UnityEngine.UI.RawImage displayImage)
{
if (displayImage != null && displayImage.texture != null)
{
Destroy(displayImage.texture);
displayImage.texture = null;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a44aec65d5a8844b1b91534d0499c7bb
timeCreated: 1523165703
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/DImageDisplayHandler.cs
uploadId: 673764

View File

@@ -0,0 +1,781 @@
// Created by SwanDEV 2017
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.IO;
using System.Text;
#if UNITY_2017_3_OR_NEWER
using UnityEngine.Networking;
#endif
/// <summary> Files, Paths, Names and IO common methods. (Last update: 2024-06-25) </summary>
public class FilePathName
{
private static string _lastGeneratedFileNameWithoutExt_fff = "";
private static int _lastSameFileNameCounter_fff = 1;
private static string _lastGeneratedFileNameWithoutExt = "";
private static int _lastSameFileNameCounter = 1;
public enum SaveFormat
{
NONE = -1,
GIF = 0,
JPG = 1,
PNG = 2,
}
#region ----- Instance -----
private static FilePathName fpn = null;
public static FilePathName Instance
{
get
{
if (fpn == null) fpn = new FilePathName();
return fpn;
}
}
#endregion
#region ----- Path & FileName -----
public enum AppPath
{
/// <summary> The directory path where you can store data that you want to be kept between runs. </summary>
PersistentDataPath = 0,
/// <summary> The directory path where temporary data can be stored. </summary>
TemporaryCachePath,
/// <summary> The folder located at /Assets/StreamingAssets in the project. Files in this directory will be included in the build. (Not work with System.IO methods when running on Android/WebGL, use Unity WWW or WebRequest instead) </summary>
StreamingAssetsPath,
/// <summary> The path at /Assets in the project. (Works in Unity editor only) </summary>
DataPath
}
public string GetAppPath(AppPath appPath)
{
string directory = "";
switch (appPath)
{
case AppPath.PersistentDataPath:
directory = Application.persistentDataPath;
break;
case AppPath.TemporaryCachePath:
directory = Application.temporaryCachePath;
break;
case AppPath.StreamingAssetsPath:
directory = Application.streamingAssetsPath;
break;
case AppPath.DataPath:
directory = Application.dataPath;
break;
}
return directory;
}
public string GetSaveDirectory(bool isTemporaryPath = false, string subFolder = "", bool createDirectoryIfNotExist = false)
{
string result = "";
if (isTemporaryPath)
{
result = Application.temporaryCachePath;
}
else
{
#if UNITY_EDITOR
result = Application.dataPath;
//result = Application.persistentDataPath;
#else
result = Application.persistentDataPath;
#endif
}
result = string.IsNullOrEmpty(subFolder) ? result : Path.Combine(result, subFolder);
if (createDirectoryIfNotExist && !Directory.Exists(result))
{
Directory.CreateDirectory(result);
}
return result;
}
public string GetFileNameWithoutExt(bool millisecond = false)
{
if (millisecond)
{
return _GetComparedFileName(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff"),
_lastGeneratedFileNameWithoutExt_fff, _lastSameFileNameCounter_fff,
out _lastGeneratedFileNameWithoutExt_fff, out _lastSameFileNameCounter_fff);
}
return _GetComparedFileName(DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"),
_lastGeneratedFileNameWithoutExt, _lastSameFileNameCounter,
out _lastGeneratedFileNameWithoutExt, out _lastSameFileNameCounter);
}
private string _GetComparedFileName(string newFileName, string lastGeneratedFileName, int sameFileNameCounter,
out string outLastGeneratedFileName, out int outSameFileNameCounter)
{
if (lastGeneratedFileName == newFileName)
{
sameFileNameCounter++;
}
else
{
sameFileNameCounter = 1;
}
outLastGeneratedFileName = newFileName;
outSameFileNameCounter = sameFileNameCounter;
if (sameFileNameCounter > 1)
{
newFileName += " " + sameFileNameCounter;
}
return newFileName;
}
public string GenerateFileNameWithDateTimeParameters(int YYYY, int MM, int DD, int hh = 0, int mm = 0, int ss = 0, int fff = -1)
{
DateTime dateTime = new DateTime(Mathf.Clamp(YYYY, 1, 9999), Mathf.Clamp(MM, 1, 12), Mathf.Clamp(DD, 1, 31), Mathf.Clamp(hh, 0, 23), Mathf.Clamp(mm, 0, 59), Mathf.Clamp(ss, 0, 59), Mathf.Clamp(fff, 0, 999));
return dateTime.ToString("yyyy-MM-dd-HH-mm-ss" + (fff < 0 ? "" : "-fff"));
}
/// <summary>
/// Parse the time string (generated by FilePathName class) to DateTime.
/// </summary>
/// <param name="timeString_FPN"> Time string generated by FilePathName class (e.g: 2019-08-31-00-00-00-000, or without millisecond: 2019-08-31-00-00-00) </param>
public DateTime TimeStringToTime(string timeString_FPN)
{
string[] texts = timeString_FPN.Split('-');
int.TryParse(texts[0], out int YYYY);
int.TryParse(texts[1], out int MM);
int.TryParse(texts[2], out int DD);
int.TryParse(texts[3], out int hh);
int.TryParse(texts[4], out int mm);
int.TryParse(texts[5], out int ss);
int fff = -1;
if (texts.Length > 6) int.TryParse(texts[6].Substring(0, 3), out fff);
DateTime dt = fff == -1 ? new DateTime(YYYY, MM, DD, hh, mm, ss) : new DateTime(YYYY, MM, DD, hh, mm, ss, fff);
return dt;
}
/// <summary>
/// Parse the filename (generated by FilePathName class) to DateTime.
/// </summary>
/// <param name="timeStringFileName_FPN"> FileName generated by FilePathName class (e.g: Photo_2019-08-31-00-00-00-000.jpg/.png, or without millisecond: Photo_2019-08-31-00-00-00.jpg/.png) </param>
public DateTime FileNameToTime(string timeStringFileName_FPN)
{
if (timeStringFileName_FPN.Contains(".")) timeStringFileName_FPN = timeStringFileName_FPN.Substring(0, timeStringFileName_FPN.IndexOf('.'));
string[] texts1 = timeStringFileName_FPN.Split('_');
return TimeStringToTime(texts1[0]);
}
/// <summary>
/// Compare the filename (generated by FilePathName class) with the provided DateTime. Return -1, 0, 1. (-1: fileName time is earlier; 0: equals; 1: fileName time is later)
/// </summary>
/// <param name="timeStringFileName_FPN"> FileName generated by FilePathName class (e.g: Photo_2019-08-31-00-00-00-000.jpg/.png, or without millisecond: Photo_2019-08-31-00-00-00.jpg/.png) </param>
/// <param name="dateTime"> The DateTime to be compared with the time formated file name string. </param>
public int CompareFileNameWithTime(string timeStringFileName_FPN, DateTime dateTime)
{
DateTime dt = FileNameToTime(timeStringFileName_FPN);
if (dt == dateTime) return 0;
else if (dt > dateTime) return 1;
else return -1;
}
/// <summary>
/// Check if the filename (generated by FilePathName class) within the Start and End DateTime interval.
/// </summary>
/// <param name="fileName_FPN"> FileName generated by FilePathName class (e.g: Photo_2019-08-31-00-00-00-000.jpg/.png) </param>
/// <param name="startDateTime">Start date time.</param>
/// <param name="endDateTime">End date time.</param>
public bool CheckFileNameWithinDateTimeInterval(string fileName_FPN, DateTime startDateTime, DateTime endDateTime)
{
return CompareFileNameWithTime(fileName_FPN, startDateTime) >= 0 && CompareFileNameWithTime(fileName_FPN, endDateTime) <= 0;
}
public string EnsureValidPath(string pathOrUrl)
{
string path = pathOrUrl;
if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
{
// WEB
}
else if (path.StartsWith("/idbfs/", StringComparison.OrdinalIgnoreCase))
{
// WebGL index DB
}
else
{
// Local path
path = EnsureLocalPath(path);
}
return path;
}
/// <summary>
/// Ensure the given path is a local path supported by the WWW/UWR class.
/// </summary>
public string EnsureLocalPath(string path)
{
if (path.StartsWith("jar:", StringComparison.OrdinalIgnoreCase)) // Android streamingAssetsPath
{ }
else if (!path.StartsWith("file:///", StringComparison.OrdinalIgnoreCase))
{
while (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
path = path.Remove(0, 1);
}
path = "file:///" + path;
}
return path;
}
public string EnsureValidFileName(string fileName)
{
string replaceChars = "[:\\\\/*\"?|<>']";
for (int i = 0; i < replaceChars.Length; i++)
{
if (fileName.Contains(replaceChars[i].ToString()))
{
fileName = fileName.Replace(replaceChars[i], '_');
}
}
return fileName;
}
public string GetGifFileName()
{
string timestamp = GetFileNameWithoutExt();
return "GIF_" + timestamp;
}
public string GetGifFullPath(string subFolder = "", bool createDirectoryIfNotExist = false)
{
return GetSaveDirectory(false, subFolder, createDirectoryIfNotExist) + "/" + GetGifFileName() + ".gif";
}
public string GetDownloadedGifSaveFullPath(string subFolder = "", bool createDirectoryIfNotExist = false)
{
return GetSaveDirectory(false, subFolder, createDirectoryIfNotExist) + "/" + GetGifFileName() + ".gif";
}
public string GetJpgFileName()
{
string timestamp = GetFileNameWithoutExt(true);
return "Photo_" + timestamp;
}
public string GetJpgFullPath(string subFolder = "", bool createDirectoryIfNotExist = false)
{
return GetSaveDirectory(false, subFolder, createDirectoryIfNotExist) + "/" + GetJpgFileName() + ".jpg";
}
public string GetPngFileName()
{
string timestamp = GetFileNameWithoutExt(true);
return "Photo_" + timestamp;
}
public string GetPngFullPath(string subFolder = "", bool createDirectoryIfNotExist = false)
{
return GetSaveDirectory(false, subFolder, createDirectoryIfNotExist) + "/" + GetPngFileName() + ".png";
}
#endregion
#region ----- IO -----
public byte[] ReadFileToBytes(string fromFullPath)
{
if (!File.Exists(fromFullPath))
{
#if UNITY_EDITOR
Debug.LogWarning("File Not Found: " + fromFullPath);
#endif
return null;
}
return File.ReadAllBytes(fromFullPath);
}
public void WriteBytesToFile(string toFullPath, byte[] byteArray)
{
CheckToCreateDirectory(Path.GetDirectoryName(toFullPath));
File.WriteAllBytes(toFullPath, byteArray);
}
public void CopyFile(string fromFullPath, string toFullPath, bool overwrite = false)
{
if (!File.Exists(fromFullPath))
{
#if UNITY_EDITOR
Debug.LogWarning("File Not Found: " + fromFullPath);
#endif
return;
}
CheckToCreateDirectory(Path.GetDirectoryName(toFullPath));
File.Copy(fromFullPath, toFullPath, overwrite);
}
public void MoveFile(string fromFullPath, string toFullPath, bool replaceIfExist = false)
{
if (!File.Exists(fromFullPath))
{
#if UNITY_EDITOR
Debug.LogWarning("File Not Found: " + fromFullPath);
#endif
return;
}
if (replaceIfExist && File.Exists(toFullPath)) File.Delete(toFullPath);
CheckToCreateDirectory(Path.GetDirectoryName(toFullPath));
File.Move(fromFullPath, toFullPath);
}
public void DeleteFile(string fileFullPath)
{
if (!File.Exists(fileFullPath))
{
#if UNITY_EDITOR
Debug.LogWarning("File Not Found: " + fileFullPath);
#endif
return;
}
File.Delete(fileFullPath);
}
public void CheckToCreateDirectory(string directory)
{
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
}
/// <summary> Determine whether a given path is a directory. </summary>
public bool PathIsDirectory(string path)
{
FileAttributes attr = File.GetAttributes(path);
if ((attr & FileAttributes.Directory) == FileAttributes.Directory) return true; else return false;
}
public void RenameFile(string originFilePath, string newFileName)
{
string directory = Path.GetDirectoryName(originFilePath);
string newFilePath = Path.Combine(directory, newFileName);
CopyFile(originFilePath, newFilePath, true);
}
public bool FileStreamTo(string fileFullpath, byte[] byteArray)
{
try
{
CheckToCreateDirectory(Path.GetDirectoryName(fileFullpath));
using (FileStream fs = new FileStream(fileFullpath, FileMode.Create, FileAccess.Write))
{
fs.Write(byteArray, 0, byteArray.Length);
return true; // success
}
}
catch (Exception e)
{
Console.WriteLine("Exception caught in process: {0}", e);
return false; // fail
}
}
public void WriteBytesToText(byte[] bytes, string toFileFullPath, string separator = "", bool toChar = true)
{
// int bkCount = 0;
StringBuilder sb = new StringBuilder();
if (string.IsNullOrEmpty(separator))
{
if (toChar)
{
for (int i = 0; i < bytes.Length; i++)
{
sb.Append((char)bytes[i]);
}
}
else
{
for (int i = 0; i < bytes.Length; i++)
{
sb.Append(bytes[i]);
//Test
// bkCount++;
// if(bkCount == 3)
// {
// bkCount = 0;
// sb.Append(" (" + (i+1)/3 + ")\n");
// }
}
}
}
else
{
if (toChar)
{
for (int i = 0; i < bytes.Length; i++)
{
sb.Append((char)bytes[i]);
sb.Append(separator);
}
}
else
{
for (int i = 0; i < bytes.Length; i++)
{
sb.Append(bytes[i]);
sb.Append(separator);
//Test
// bkCount++;
// if(bkCount == 3)
// {
// bkCount = 0;
// sb.Append(" (" + ((i+1)/3-1) + ")\n");
// }
}
}
}
CheckToCreateDirectory(Path.GetDirectoryName(toFileFullPath));
File.WriteAllText(toFileFullPath, sb.ToString());
}
/// <summary>
/// Saves texture as JPG/PNG on Windows/Mac.
/// </summary>
public string SaveImage(Texture2D texture, string subFolder, string fileName, SaveFormat imageFormat, Environment.SpecialFolder specialFolder = Environment.SpecialFolder.MyPictures, int jpgQuality = 90)
{
string extensionName = "." + imageFormat.ToString().ToLower();
byte[] bytes = null;
string gifPath = "";
switch (imageFormat)
{
case SaveFormat.JPG:
bytes = texture.EncodeToJPG(jpgQuality);
break;
case SaveFormat.PNG:
bytes = texture.EncodeToPNG();
break;
case SaveFormat.GIF:
#if PRO_GIF
gifPath = SaveBytes(new byte[] { 0 }, subFolder, fileName + extensionName, specialFolder);
ProGifTexturesToGIF tex2Gif = ProGifTexturesToGIF.Instance;
tex2Gif.Save(new List<Texture2D> { texture }, texture.width, texture.height, 1, -1, 10, (id, path) =>
{
Debug.Log("Save GIF.." + path + "\n" + gifPath);
CopyFile(path, gifPath, true);
DeleteFile(path);
}, null, ProGifTexturesToGIF.ResizeMode.ResizeKeepRatio, false);
#endif
break;
}
if (!string.IsNullOrEmpty(gifPath))
{
return gifPath;
}
return SaveBytes(bytes, subFolder, fileName + extensionName, specialFolder);
}
/// <summary>
/// Saves file byte array on Windows/Mac.
/// </summary>
public string SaveBytes(byte[] bytes, string subFolder, string fileNameWithExtension, Environment.SpecialFolder specialFolder = Environment.SpecialFolder.MyPictures)
{
string directory = Path.Combine(Environment.GetFolderPath(specialFolder), subFolder);
string savePath = Path.Combine(directory, fileNameWithExtension);
WriteBytesToFile(savePath, bytes);
return savePath;
}
public string SaveTextureAs(Texture2D texture2D, SaveFormat format = SaveFormat.JPG)
{
string savePath = string.Empty;
switch (format)
{
case SaveFormat.JPG:
savePath = GetJpgFullPath();
WriteBytesToFile(savePath, texture2D.EncodeToJPG(90));
break;
case SaveFormat.PNG:
savePath = GetPngFullPath();
WriteBytesToFile(savePath, texture2D.EncodeToPNG());
break;
case SaveFormat.GIF:
#if PRO_GIF
savePath = ProGifTexturesToGIF.Instance.Save(new List<Texture2D> { texture2D }, texture2D.width, texture2D.height, 1, -1, 10, null, null, ProGifTexturesToGIF.ResizeMode.ResizeKeepRatio, false);
#endif
break;
}
return savePath;
}
public string SaveTextureAs(Texture2D texture2D, AppPath appPath, string subFolder, bool isJPG, string optionalFileName_WithoutExtension = "")
{
string savePath = GetAppPath(appPath);
if (!string.IsNullOrEmpty(subFolder)) savePath = Path.Combine(savePath, subFolder);
if (!Directory.Exists(savePath)) Directory.CreateDirectory(savePath);
savePath = Path.Combine(savePath, (string.IsNullOrEmpty(optionalFileName_WithoutExtension) ? GetFileNameWithoutExt(true) : optionalFileName_WithoutExtension) + (isJPG ? ".jpg" : ".png"));
WriteBytesToFile(savePath, (isJPG ? texture2D.EncodeToJPG(90) : texture2D.EncodeToPNG()));
return savePath;
}
#if PRO_GIF
public string SaveTexturesAsGIF(List<Texture2D> textureList, int width, int height, int fps, int loop, int quality,
Action<int, string> onFileSaved = null, Action<int, float> onFileSaveProgress = null,
ProGifTexturesToGIF.ResizeMode resizeMode = ProGifTexturesToGIF.ResizeMode.ResizeKeepRatio)
{
return ProGifTexturesToGIF.Instance.Save(textureList, width, height, fps, loop, quality, onFileSaved, onFileSaveProgress, resizeMode, false);
}
#endif
public Texture2D LoadImage(string fullFilePath)
{
if (!File.Exists(fullFilePath))
{
#if UNITY_EDITOR
Debug.LogWarning("File not exist! " + fullFilePath);
#endif
return null;
}
else
{
Texture2D tex2D = new Texture2D(1, 1); //, TextureFormat.ARGB32, false);
tex2D.LoadImage(ReadFileToBytes(fullFilePath));
return tex2D;
}
}
/// <summary>
/// Load images in the target directory, to a texture2D list.
/// Warning! Loading a folder of images without setting a reasonable limit may crash your app due to running out of memory.
/// </summary>
/// <returns>A list of Texture2D.</returns>
/// <param name="directory">Directory.</param>
/// <param name="fileExtensions">A list of file extension names, indicating the type of files to be loaded. Load jpg, png if Null or Empty.</param>
/// <param name="startIndex">An offset index to load the image files from the target folder.</param>
/// <param name="maxImageToLoad">The maximum number of images to load.</param>
/// <param name="sortingMode">0: no sorting; 1: sort by filename ascending; 2: sort by filename descending</param>
/// <param name="onImageLoaded">A callback to be called on an image loaded, returns: fileIndex, filePath, and the Texture2D</param>
public List<Texture2D> LoadImages(string directory, List<string> fileExtensions = null, int startIndex = 0, int maxImageToLoad = 12, int sortingMode = 0, Action<int, string, Texture2D> onImageLoaded = null)
{
if (fileExtensions == null || fileExtensions.Count == 0)
{
fileExtensions = new List<string> { ".jpg", ".png" };
}
List<Texture2D> textureList = new List<Texture2D>();
List<string> filePaths = GetFilePathsRange(directory, fileExtensions, startIndex, maxImageToLoad, sortingMode);
for (int i = 0; i < filePaths.Count; i++)
{
Texture2D texture = LoadImage(filePaths[i]);
textureList.Add(texture);
onImageLoaded?.Invoke(startIndex + i, filePaths[i], texture);
}
return textureList;
}
/// <summary>
/// Load files in the target directory, to a byte[] list.
/// Warning! Loading a folder of files without setting a reasonable limit may crash your app due to running out of memory.
/// </summary>
/// <returns>A list of files' byte array data.</returns>
/// <param name="directory">Directory.</param>
/// <param name="fileExtensions">A list of file extension names, indicating the type of files to be loaded. Load all files if Null or Empty.</param>
/// <param name="startIndex">An offset index to load the image files from the target folder.</param>
/// <param name="maxImageToLoad">The maximum number of images to load.</param>
/// <param name="sortingMode">0: no sorting; 1: sort by filename ascending; 2: sort by filename descending</param>
/// <param name="onFileLoaded">A callback to be called on an file loaded, returns: fileIndex, filePath, and the file data</param>
public List<byte[]> LoadFiles(string directory, List<string> fileExtensions = null, int startIndex = 0, int maxFileToLoad = 12, int sortingMode = 0, Action<int, string, byte[]> onFileLoaded = null)
{
List<byte[]> fileByteList = new List<byte[]>();
List<string> filePaths = GetFilePathsRange(directory, fileExtensions, startIndex, maxFileToLoad, sortingMode);
for (int i = 0; i < filePaths.Count; i++)
{
byte[] data = ReadFileToBytes(filePaths[i]);
fileByteList.Add(data);
onFileLoaded?.Invoke(startIndex + i, filePaths[i], data);
}
return fileByteList;
}
public List<string> GetFilePathsRange(string directory, List<string> fileExtensions = null, int startIndex = 0, int maxFileToLoad = 12, int sortingMode = 0)
{
List<string> results = new List<string>();
List<string> filePaths = GetFilePaths(directory, fileExtensions, sortingMode);
int total = filePaths.Count;
if (startIndex < total)
{
int loadNum = Mathf.Min(total, startIndex + maxFileToLoad);
for (int i = startIndex; i < loadNum; i++)
{
results.Add(filePaths[i]);
}
}
return results;
}
/// <summary>
/// Get file paths in the target directory.
/// </summary>
/// <returns>File paths list.</returns>
/// <param name="directory">Directory.</param>
/// <param name="fileExtensions">A list of file extension names, indicating the type of file paths to get. Get all file paths if Null or Empty.</param>
/// <param name="sortingMode">0: no sorting; 1: sort by filename ascending; 2: sort by filename descending</param>
public List<string> GetFilePaths(string directory, List<string> fileExtensions = null, int sortingMode = 0)
{
if (!Directory.Exists(directory))
{
#if UNITY_EDITOR
Debug.Log("Directory Not Found: " + directory);
#endif
return new List<string>();
}
string[] allFiles_src = Directory.GetFiles(directory);
bool loadAllFile = (fileExtensions == null) ? true : (fileExtensions.Count == 0 ? true : false);
if (loadAllFile)
{
#if UNITY_EDITOR
Debug.Log("Load ALL");
#endif
List<string> fileList = new List<string>();
int len = allFiles_src.Length;
for (int i = 0; i < len; i++)
{
fileList.Add(allFiles_src[i]);
}
return fileList;
}
#if UNITY_EDITOR
Debug.Log("Load Filtered");
#endif
for (int i = 0; i < fileExtensions.Count; i++)
{
fileExtensions[i] = fileExtensions[i].ToLower();
}
List<string> filteredFilePathList = new List<string>();
foreach (string f in allFiles_src)
{
if (fileExtensions.Contains(Path.GetExtension(f).ToLower()))
{
filteredFilePathList.Add(f);
}
}
if (sortingMode == 1) filteredFilePathList.Sort();
if (sortingMode == 2) filteredFilePathList.Reverse();
return filteredFilePathList;
}
#if UNITY_2017_3_OR_NEWER
/// <summary>
/// Loads texture using UnityWebRequest. Return the texture in the onComplete callback.
/// ( IEnumerator: Remember to call this method in StartCoroutine )
/// </summary>
public IEnumerator LoadTextureUWR(string url, Action<Texture2D> onComplete)
{
using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(url))
{
yield return uwr.SendWebRequest();
#if UNITY_2020_1_OR_NEWER
if (uwr.result == UnityWebRequest.Result.ConnectionError || uwr.result == UnityWebRequest.Result.ProtocolError || uwr.result == UnityWebRequest.Result.DataProcessingError)
#else
if (uwr.isNetworkError || uwr.isHttpError)
#endif
{
#if UNITY_EDITOR
Debug.LogWarning("Failed to load texture: " + url);
#endif
}
else
{
if (onComplete != null) onComplete(DownloadHandlerTexture.GetContent(uwr));
}
}
}
#endif
#if UNITY_2017_3_OR_NEWER
/// <summary>
/// Loads file using UnityWebRequest. Return the byte array of the file in the onComplete callback.
/// ( IEnumerator: Remember to call this method in StartCoroutine )
/// </summary>
/// <returns>The file byte array.</returns>
/// <param name="url">Local file path or http/https link.</param>
/// <param name="onComplete">On load completed callback. Return the byte array of the downloaded file.</param>
/// <param name="onCompleteUWR">On load completed callback. Return the UnityWebRequest object.</param>
public IEnumerator LoadFileUWR(string url, Action<byte[]> onComplete = null, Action<UnityWebRequest> onCompleteUWR = null)
{
string path = EnsureValidPath(url);
using (UnityWebRequest uwr = UnityWebRequest.Get(path))
{
uwr.SendWebRequest();
while (!uwr.isDone)
{
yield return null;
}
#if UNITY_2020_1_OR_NEWER
if (uwr.result == UnityWebRequest.Result.ConnectionError || uwr.result == UnityWebRequest.Result.ProtocolError || uwr.result == UnityWebRequest.Result.DataProcessingError)
#else
if (uwr.isNetworkError || uwr.isHttpError)
#endif
{
if (onComplete != null) onComplete(null);
if (onCompleteUWR != null) onCompleteUWR(null);
Debug.LogError("File load error.\n" + uwr.error);
}
else
{
if (onComplete != null) onComplete(uwr.downloadHandler.data);
if (onCompleteUWR != null) onCompleteUWR(uwr);
}
}
}
#else
/// <summary>
/// Loads file using WWW. Return the byte array of the file in onLoadCompleted callback.
/// ( IEnumerator: Remember to call this method in StartCoroutine )
/// </summary>
/// <returns>The file byte array.</returns>
/// <param name="url">Local file path or http/https link.</param>
/// <param name="onLoadCompleted">On load completed callback. Return the byte array of the downloaded file.</param>
/// <param name="onLoadCompletedWWW">On load completed callback. Return the WWW object.</param>
public IEnumerator LoadFileWWW(string url, Action<byte[]> onLoadCompleted = null, Action<WWW> onLoadCompletedWWW = null)
{
string path = EnsureValidPath(url);
using (WWW www = new WWW(path))
{
yield return www;
if (string.IsNullOrEmpty(www.error) == false)
{
if (onLoadCompleted != null) onLoadCompleted(null);
if (onLoadCompletedWWW != null) onLoadCompletedWWW(null);
Debug.LogError("File load error.\n" + www.error);
yield break;
}
if (onLoadCompleted != null) onLoadCompleted(www.bytes);
if (onLoadCompletedWWW != null) onLoadCompletedWWW(www);
}
}
#endif
#endregion
public Sprite Texture2DToSprite(Texture2D texture2D)
{
if (texture2D == null) return null;
Vector2 pivot = new Vector2(0.5f, 0.5f);
float pixelPerUnit = 100;
return Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), pivot, pixelPerUnit);
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 4b06fb57cc187478aa017ccb83b15002
timeCreated: 1498492533
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/FilePathName.cs
uploadId: 673764

View File

@@ -0,0 +1,196 @@

using System;
using System.IO;
using UnityEngine;
namespace SDev
{
/// <summary>
/// Save byte array, Texture2D to file on current platform's Application data path or Windows/Mac special folder.
/// </summary>
public class FileSaveUtil
{
public enum AppPath
{
/// <summary> The directory path where you can store data that you want to be kept between runs. </summary>
PersistentDataPath = 0,
/// <summary> The directory path where temporary data can be stored. </summary>
TemporaryCachePath,
/// <summary> The folder located at /Assets/StreamingAssets in the project. (Not work with System.IO methods when running on Android/WebGL) </summary>
StreamingAssetsPath,
/// <summary> The folder located at /Assets in the project. (Work on the Unity editor only) </summary>
DataPath
}
public string GetAppPath(AppPath appPath)
{
string directory = "";
switch (appPath)
{
case AppPath.PersistentDataPath:
directory = Application.persistentDataPath;
break;
case AppPath.TemporaryCachePath:
directory = Application.temporaryCachePath;
break;
case AppPath.StreamingAssetsPath:
directory = Application.streamingAssetsPath;
break;
case AppPath.DataPath:
directory = Application.dataPath;
break;
}
return directory;
}
#region ----- Instance -----
private static FileSaveUtil _instance = null;
public static FileSaveUtil Instance
{
get
{
if (_instance == null) _instance = new FileSaveUtil();
return _instance;
}
}
#endregion
#region ----- Save Texture2D as EXR -----
/// <summary>
/// Saves Texture2D as EXR to accessible path (e.g. Application data path).
/// </summary>
public string SaveTextureAsEXR(Texture2D texture2D, string directory, string fileNameWithoutExtension, Texture2D.EXRFlags exrFlags = Texture2D.EXRFlags.None)
{
return SaveBytes(texture2D.EncodeToEXR(exrFlags), directory, fileNameWithoutExtension + ".exr");
}
/// <summary>
/// Saves Texture2D as JPG to Application data path.
/// </summary>
public string SaveTextureAsEXR(Texture2D texture2D, AppPath appPath, string subFolderName, string fileNameWithoutExtension, Texture2D.EXRFlags exrFlags = Texture2D.EXRFlags.None)
{
string directory = GetAppPath(appPath);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsEXR(texture2D, directory, fileNameWithoutExtension, exrFlags);
}
/// <summary>
/// Saves Texture2D as JPG to Windows/Mac special folder.
/// </summary>
public string SaveTextureAsEXR(Texture2D texture2D, Environment.SpecialFolder specialFolder, string subFolderName, string fileNameWithoutExtension, Texture2D.EXRFlags exrFlags = Texture2D.EXRFlags.None)
{
string directory = Environment.GetFolderPath(specialFolder);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsEXR(texture2D, directory, fileNameWithoutExtension, exrFlags);
}
#endregion
#region ----- Save Texture2D as JPG -----
/// <summary>
/// Saves Texture2D as JPG to accessible path (e.g. Application data path).
/// </summary>
public string SaveTextureAsJPG(Texture2D texture2D, string directory, string fileNameWithoutExtension, int quality = 90)
{
return SaveBytes(texture2D.EncodeToJPG(quality), directory, fileNameWithoutExtension + ".jpg");
}
/// <summary>
/// Saves Texture2D as JPG to Application data path.
/// </summary>
public string SaveTextureAsJPG(Texture2D texture2D, AppPath appPath, string subFolderName, string fileNameWithoutExtension, int quality = 90)
{
string directory = GetAppPath(appPath);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsJPG(texture2D, directory, fileNameWithoutExtension, quality);
}
/// <summary>
/// Saves Texture2D as JPG to Windows/Mac special folder.
/// </summary>
public string SaveTextureAsJPG(Texture2D texture2D, Environment.SpecialFolder specialFolder, string subFolderName, string fileNameWithoutExtension, int quality = 90)
{
string directory = Environment.GetFolderPath(specialFolder);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsJPG(texture2D, directory, fileNameWithoutExtension, quality);
}
#endregion
#region ----- Save Texture2D as PNG -----
/// <summary>
/// Saves Texture2D as PNG to accessible path (e.g. Application data path).
/// </summary>
public string SaveTextureAsPNG(Texture2D texture2D, string directory, string fileNameWithoutExtension)
{
return SaveBytes(texture2D.EncodeToPNG(), directory, fileNameWithoutExtension + ".png");
}
/// <summary>
/// Saves Texture2D as PNG to Application data path.
/// </summary>
public string SaveTextureAsPNG(Texture2D texture2D, AppPath appPath, string subFolderName, string fileNameWithoutExtension)
{
string directory = GetAppPath(appPath);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsPNG(texture2D, directory, fileNameWithoutExtension);
}
/// <summary>
/// Saves Texture2D as PNG to Windows/Mac special folder.
/// </summary>
public string SaveTextureAsPNG(Texture2D texture2D, Environment.SpecialFolder specialFolder, string subFolderName, string fileNameWithoutExtension)
{
string directory = Environment.GetFolderPath(specialFolder);
if (!string.IsNullOrEmpty(subFolderName)) directory = Path.Combine(directory, subFolderName);
return SaveTextureAsPNG(texture2D, directory, fileNameWithoutExtension);
}
#endregion
#region ----- Save byte array to File -----
/// <summary>
/// Saves file byte array to accessible path (e.g. Application data path).
/// </summary>
public string SaveBytes(byte[] bytes, string directory, string fileNameWithExtension)
{
if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
string savePath = Path.Combine(directory, fileNameWithExtension);
File.WriteAllBytes(savePath, bytes);
return savePath;
}
/// <summary>
/// Saves file byte array to Application data path.
/// </summary>
public string SaveBytes(byte[] bytes, AppPath appPath, string subFolderName, string fileNameWithExtension)
{
string directory = GetAppPath(appPath);
return SaveBytes(bytes, directory, fileNameWithExtension);
}
/// <summary>
/// Saves file byte array to Windows/Mac special folder.
/// </summary>
public string SaveBytes(byte[] bytes, Environment.SpecialFolder specialFolder, string subFolderName, string fileNameWithExtension)
{
string directory = Path.Combine(Environment.GetFolderPath(specialFolder), subFolderName);
return SaveBytes(bytes, directory, fileNameWithExtension);
}
/// <summary>
/// Saves file byte array to Windows/Mac special folder.
/// </summary>
public string SaveBytes(byte[] bytes, Environment.SpecialFolder specialFolder, string fileNameWithExtension)
{
string directory = Environment.GetFolderPath(specialFolder);
return SaveBytes(bytes, directory, fileNameWithExtension);
}
#endregion
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: f2594c43cd6ca45a79ae97dcb56e29c3
timeCreated: 1581483126
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/FileSaveUtil.cs
uploadId: 673764

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 93f9be3b4312e42d5b97f1d39c9de8df
folderAsset: yes
timeCreated: 1507540924
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: c6c5f3596ba1e425bbdaf3d737b6a2f1
timeCreated: 1509871138
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Fonts/Archived.zip
uploadId: 673764

Binary file not shown.

View File

@@ -0,0 +1,28 @@
fileFormatVersion: 2
guid: d8497cc02ae19440db5712114c197511
timeCreated: 1432116480
licenseType: Store
TrueTypeFontImporter:
serializedVersion: 4
fontSize: 16
forceTextureCase: -2
characterSpacing: 0
characterPadding: 1
includeFontData: 1
fontName: Bowlby One
fontNames:
- Bowlby One
fallbackFontReferences: []
customCharacters:
fontRenderingMode: 0
ascentCalculationMode: 1
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Fonts/BowlbyOne-Regular.ttf
uploadId: 673764

Binary file not shown.

View File

@@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 928f503de488e44408a8625d75d54c61
TrueTypeFontImporter:
serializedVersion: 2
fontSize: 16
forceTextureCase: -2
characterSpacing: 1
characterPadding: 0
includeFontData: 1
use2xBehaviour: 0
fontNames: []
customCharacters:
fontRenderingMode: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Fonts/DroidSansMono.ttf
uploadId: 673764

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fca35315925040ffa31514d1737fdb6
folderAsset: yes
timeCreated: 1509189743
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SpriteDefault
m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA _ALPHATEST_ON _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- PixelSnap: 0
- _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnableExternalAlpha: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Shininess: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Emission: {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

View File

@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 06815d34bb8fc42cc87fb36fd544e895
timeCreated: 1509189371
licenseType: Store
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Materials/SpriteDefault.mat
uploadId: 673764

View File

@@ -0,0 +1,98 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SpriteDiffuse
m_Shader: {fileID: 10800, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA _ALPHATEST_ON _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _AlphaTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- PixelSnap: 0
- _BumpScale: 1
- _ColorMask: 15
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _EnableExternalAlpha: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 1
- _OcclusionStrength: 1
- _Parallax: 0.02
- _Shininess: 1
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _UVSec: 0
- _UseUIAlphaClip: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Emission: {r: 0.49803922, g: 0.49803922, b: 0.49803922, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 2a24339e859244551bed51e4e9a5981d
timeCreated: 1509189371
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Materials/SpriteDiffuse.mat
uploadId: 673764

View File

@@ -0,0 +1,77 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: TransparentCutout
m_Shader: {fileID: 10751, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 4fef5a2006fff80409f004e4296bf8e5, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 8c3a517ff6bfbb34c8726553ee00b5d9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Materials/TransparentCutout.mat
uploadId: 673764

View File

@@ -0,0 +1,84 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: UnlitTexture
m_Shader: {fileID: 10752, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: ETC1_EXTERNAL_ALPHA _EMISSION
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- <noninit>:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: 720d0e265574a4eff864e3a06d08081e, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- <noninit>: 0
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.5
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- <noninit>: {r: 0, g: 9.289661e-35, b: 0, a: 9.289624e-35}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: b9168857582884d4291ec78efde6ecf6
timeCreated: 1509189371
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Materials/UnlitTexture.mat
uploadId: 673764

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,176 @@
fileFormatVersion: 2
guid: 4fef5a2006fff80409f004e4296bf8e5
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/Materials/sprite_demo.png
uploadId: 673764
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 0
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 512
resizeAlgorithm: 1
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 1
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: 4
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class OnEnableTrigger : MonoBehaviour
{
/// The condition/permission for triggering events in this script.
public EventTriggerPermission m_EventTriggerPermission = EventTriggerPermission.NotReady;
/// Do not trigger any event(in this script) earlier than this game time, game time is the time since the begin of the app started.
/// (Why? Sometimes you need to wait for other scripts to completely initiated before calling their methods.)
public float m_TiggerNotEarlyThanGameTime = 1f;
public enum EventTriggerPermission
{
/// Do not trigger any event(in this script)
NotReady = 0,
/// Wait after the provided game time(m_TiggerNotEarlyThanGameTime)
AfterGameTime,
/// Allow trigger events(in this script)
Ready,
}
public UnityEvent m_OnEnableEvent;
public UnityEvent m_OnDisableEvent;
void OnEnable()
{
if(m_EventTriggerPermission == EventTriggerPermission.Ready ||
(m_EventTriggerPermission == EventTriggerPermission.AfterGameTime && Time.time > m_TiggerNotEarlyThanGameTime))
{
m_OnEnableEvent.Invoke();
}
}
void OnDisable()
{
if(m_EventTriggerPermission == EventTriggerPermission.Ready ||
(m_EventTriggerPermission == EventTriggerPermission.AfterGameTime && Time.time > m_TiggerNotEarlyThanGameTime))
{
m_OnDisableEvent.Invoke();
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: c7864ff6ac004004d8315dd54408d46c
timeCreated: 1532858381
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/OnEnableTrigger.cs
uploadId: 673764

View File

@@ -0,0 +1,436 @@
// Created by SwanDEV 2017
using UnityEngine;
using System.Collections;
using System;
using SDev.Component;
/// <summary>
/// SDev simple Animation (Tweening).
/// </summary>
public class SDemoAnimation : MonoBehaviour
{
private static SDemoAnimation _instance = null;
public static SDemoAnimation Instance
{
get{
if(_instance == null)
{
_instance = FindObjectOfType<SDemoAnimation>();
if(_instance == null) _instance = new GameObject("[SDev Animation]").AddComponent<SDemoAnimation>();
}
return _instance;
}
}
public enum LoopType
{
None = 0,
Loop,
PingPong,
}
public SDemoControl Move(GameObject targetGO, Vector3 fromPosition, Vector3 toPosition, float time, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Move(targetGO, fromPosition, toPosition, time, 0f, loop, onComplete, control));
return control;
}
public SDemoControl Move(GameObject targetGO, Vector3 fromPosition, Vector3 toPosition, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Move(targetGO, fromPosition, toPosition, time, delay, loop, onComplete, control));
return control;
}
private IEnumerator _Move(GameObject targetGO, Vector3 fromPosition, Vector3 toPosition, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localPosition = fromPosition;
float elapsedTime = 0;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
targetGO.transform.localPosition = Vector3.Lerp(fromPosition, toPosition, (elapsedTime / time));
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localPosition = toPosition;
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Move(targetGO, fromPosition, toPosition, time, delay, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Move(targetGO, toPosition, fromPosition, time, delay, loop, onComplete, control));
}
public SDemoControl Scale(GameObject targetGO, Vector3 fromScale, Vector3 toScale, float time, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Scale(targetGO, fromScale, toScale, time, 0f, loop, onComplete, control));
return control;
}
public SDemoControl Scale(GameObject targetGO, Vector3 fromScale, Vector3 toScale, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Scale(targetGO, fromScale, toScale, time, delay, loop, onComplete, control));
return control;
}
private IEnumerator _Scale(GameObject targetGO, Vector3 fromScale, Vector3 toScale, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localScale = fromScale;
float elapsedTime = 0;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
targetGO.transform.localScale = Vector3.Lerp(fromScale, toScale, (elapsedTime / time));
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localScale = toScale;
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Scale(targetGO, fromScale, toScale, time, delay, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Scale(targetGO, toScale, fromScale, time, delay, loop, onComplete, control));
}
public SDemoControl Rotate(GameObject targetGO, Vector3 fromEulerAngle, Vector3 toEulerScale, float time, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Rotate(targetGO, fromEulerAngle, toEulerScale, time, 0f, loop, onComplete, control));
return control;
}
public SDemoControl Rotate(GameObject targetGO, Vector3 fromEulerAngle, Vector3 toEulerScale, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Rotate(targetGO, fromEulerAngle, toEulerScale, time, delay, loop, onComplete, control));
return control;
}
private IEnumerator _Rotate(GameObject targetGO, Vector3 fromEulerAngle, Vector3 toEulerAngle, float time, float delay, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localEulerAngles = fromEulerAngle;
float elapsedTime = 0;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
targetGO.transform.localEulerAngles = Vector3.Lerp(fromEulerAngle, toEulerAngle, (elapsedTime / time));
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
targetGO.transform.localEulerAngles = toEulerAngle;
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Rotate(targetGO, fromEulerAngle, toEulerAngle, time, delay, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Rotate(targetGO, toEulerAngle, fromEulerAngle, time, delay, loop, onComplete, control));
}
public SDemoControl FloatTo(float fromValue, float toValue, float time, Action<float> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_FloatTo(fromValue, toValue, time, 0f, onUpdate, loop, onComplete, control));
return control;
}
public SDemoControl FloatTo(float fromValue, float toValue, float time, float delay, Action<float> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_FloatTo(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
return control;
}
private IEnumerator _FloatTo(float fromValue, float toValue, float time, float delay, Action<float> onUpdate, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
float elapsedTime = 0;
float val = 0f;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
val = Mathf.Lerp(fromValue, toValue, (elapsedTime / time));
onUpdate(val);
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
onUpdate(toValue);
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_FloatTo(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_FloatTo(toValue, fromValue, time, delay, onUpdate, loop, onComplete, control));
}
public SDemoControl Vector2To(Vector2 fromValue, Vector2 toValue, float time, Action<Vector2> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector2To(fromValue, toValue, time, 0f, onUpdate, loop, onComplete, control));
return control;
}
public SDemoControl Vector2To(Vector2 fromValue, Vector2 toValue, float time, float delay, Action<Vector2> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector2To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
return control;
}
private IEnumerator _Vector2To(Vector2 fromValue, Vector2 toValue, float time, float delay, Action<Vector2> onUpdate, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
float elapsedTime = 0;
Vector2 val = Vector2.zero;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
val = Vector2.Lerp(fromValue, toValue, (elapsedTime / time));
onUpdate(val);
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
onUpdate(toValue);
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Vector2To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Vector2To(toValue, fromValue, time, delay, onUpdate, loop, onComplete, control));
}
public SDemoControl Vector3To(Vector3 fromValue, Vector3 toValue, float time, Action<Vector3> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector3To(fromValue, toValue, time, 0f, onUpdate, loop, onComplete, control));
return control;
}
public SDemoControl Vector3To(Vector3 fromValue, Vector3 toValue, float time, float delay, Action<Vector3> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector3To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
return control;
}
private IEnumerator _Vector3To(Vector3 fromValue, Vector3 toValue, float time, float delay, Action<Vector3> onUpdate, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
float elapsedTime = 0;
Vector3 val = Vector3.zero;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
val = Vector3.Lerp(fromValue, toValue, (elapsedTime / time));
onUpdate(val);
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
onUpdate(toValue);
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Vector3To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Vector3To(toValue, fromValue, time, delay, onUpdate, loop, onComplete, control));
}
public SDemoControl Vector4To(Vector4 fromValue, Vector4 toValue, float time, Action<Vector4> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector4To(fromValue, toValue, time, 0f, onUpdate, loop, onComplete, control));
return control;
}
public SDemoControl Vector4To(Vector4 fromValue, Vector4 toValue, float time, float delay, Action<Vector4> onUpdate, LoopType loop = LoopType.None, Action onComplete = null)
{
SDemoControl control = new SDemoControl();
StartCoroutine(_Vector4To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
return control;
}
private IEnumerator _Vector4To(Vector4 fromValue, Vector4 toValue, float time, float delay, Action<Vector4> onUpdate, LoopType loop = LoopType.None, Action onComplete = null, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
float elapsedTime = 0;
Vector4 val = Vector4.zero;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
val = Vector4.Lerp(fromValue, toValue, (elapsedTime / time));
onUpdate(val);
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
onUpdate(toValue);
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Vector4To(fromValue, toValue, time, delay, onUpdate, loop, onComplete, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Vector4To(toValue, fromValue, time, delay, onUpdate, loop, onComplete, control));
}
public SDemoControl Wait(float time, Action onComplete)
{
if(time < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_Wait(time, 0f, onComplete, LoopType.None, control));
return control;
}
public SDemoControl Wait(float time, Action onComplete, LoopType loop = LoopType.None)
{
if(time < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_Wait(time, 0f, onComplete, loop, control));
return control;
}
public SDemoControl Wait(float time, float delay, Action onComplete, LoopType loop = LoopType.None)
{
if(time < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_Wait(time, delay, onComplete, loop, control));
return control;
}
private IEnumerator _Wait(float time, float delay, Action onComplete, LoopType loop = LoopType.None, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
float elapsedTime = 0;
while (elapsedTime < time)
{
if(control.m_State == SDemoControl.State.Playing)
{
elapsedTime += Time.deltaTime;
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_Wait(time, delay, onComplete, loop, control));
else if(loop == LoopType.PingPong) StartCoroutine(_Wait(time, delay, onComplete, loop, control));
}
public SDemoControl WaitFrames(int frameNum, Action onComplete)
{
if(frameNum < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_WaitFrames(frameNum, 0f, onComplete, LoopType.None, control));
return control;
}
public SDemoControl WaitFrames(int frameNum, Action onComplete, LoopType loop = LoopType.None)
{
if(frameNum < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_WaitFrames(frameNum, 0f, onComplete, loop, control));
return control;
}
public SDemoControl WaitFrames(int frameNum, float delay, Action onComplete, LoopType loop = LoopType.None)
{
if(frameNum < 0) return null;
SDemoControl control = new SDemoControl();
StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
return control;
}
private IEnumerator _WaitFrames(int frameNum, float delay, Action onComplete, LoopType loop = LoopType.None, SDemoControl control = null)
{
if(delay > 0) yield return new WaitForSeconds(delay);
if(control.m_State == SDemoControl.State.Kill) yield break;
int currFrame = 0;
while (currFrame < frameNum)
{
if(control.m_State == SDemoControl.State.Playing)
{
currFrame++;
}
else if(control.m_State == SDemoControl.State.Kill)
{
loop = LoopType.None;
break;
}
yield return new WaitForEndOfFrame();
}
if(control.m_State == SDemoControl.State.Kill) yield break;
if(onComplete != null) onComplete();
if(loop == LoopType.Loop) StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
else if(loop == LoopType.PingPong) StartCoroutine(_WaitFrames(frameNum, delay, onComplete, loop, control));
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 34fdda83a19d24a06be41f2a39a61b42
timeCreated: 1506672609
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/SDemoAnimation.cs
uploadId: 673764

View File

@@ -0,0 +1,38 @@
// Created by SwanDEV 2017
using UnityEngine;
namespace SDev.Component
{
public class SDemoControl
{
public State m_State = State.Playing;
public enum State
{
/// <summary>
/// The tweening will be destroyed in the next update.
/// </summary>
Kill = 0,
Playing,
Paused,
}
public SelfAnimation.SelfAnimType m_SelfAnimType = SelfAnimation.SelfAnimType.None;
// public Vector3 initValue;
// public Vector3 fromValue;
// public Vector3 toValue;
// public float time = 0.5f;
// public float delay = 0f;
// public SDemoAnimation.LoopType loop = SDemoAnimation.LoopType.None;
// public bool destroyOnComplete = false;
// public bool executeAtStart = true;
// public bool enableInitValue = false;
//
// public UnityEvent onComplete;
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 07bb6d9dbb9c55c47b0dfac2078b58fc
timeCreated: 1532858381
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/SDemoControl.cs
uploadId: 673764

View File

@@ -0,0 +1,201 @@
//Created by SwanDEV 2017
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace SDev.Component
{
public class SelfAnimation : MonoBehaviour
{
public SDemoControl m_Control = null;
public enum SelfAnimType
{
None = 0,
Move,
Rotate,
Scale,
Move_RelativePosition,
}
public SelfAnimType m_SelfAnimType = SelfAnimType.None;
public SDemoAnimation.LoopType loop = SDemoAnimation.LoopType.None;
//public Vector3 initValue;
public Vector3 fromValue;
public Vector3 toValue;
public float time = 0.5f;
public float delay = 0f;
public float delay_Revert = 0f;
public bool executeAtStart = true;
public bool enableInitValue = false;
public bool destroyOnComplete = false;
public UnityEvent onComplete;
//private Vector3 _originRotation;
public Vector3 OriginPosition { get; private set; }
void Awake()
{
OriginPosition = transform.localPosition;
//_originRotation = transform.localEulerAngles;
if (executeAtStart) StartAnimation();
}
void OnEnable()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Playing;
}
void OnDisable()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Paused;
}
void OnComplete()
{
if (onComplete != null) onComplete.Invoke();
if (destroyOnComplete) Destroy(gameObject);
}
void OnDestroy()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Kill;
}
private bool _isOdd = false;
public void SwitchAnimation()
{
_isOdd = !_isOdd;
if (_isOdd)
{
StartAnimation(delay);
}
else
{
StartAnimationRevert(delay_Revert);
}
}
public void SwitchAnimationRevert()
{
_isOdd = !_isOdd;
if (!_isOdd)
{
StartAnimation(delay);
}
else
{
StartAnimationRevert(delay_Revert);
}
}
public void StartAnimation(float inDelay = 0f)
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Kill; // Kill the current tweening if existed
switch (m_SelfAnimType)
{
case SelfAnimType.Move:
if (enableInitValue) gameObject.transform.localPosition = fromValue;
m_Control = SDemoAnimation.Instance.Move(gameObject, fromValue, toValue, time, delay, loop, OnComplete);
break;
case SelfAnimType.Rotate:
if (enableInitValue) gameObject.transform.localEulerAngles = fromValue;
m_Control = SDemoAnimation.Instance.Rotate(gameObject, fromValue, toValue, time, delay, loop, OnComplete);
break;
case SelfAnimType.Scale:
if (enableInitValue) gameObject.transform.localScale = fromValue;
m_Control = SDemoAnimation.Instance.Scale(gameObject, fromValue, toValue, time, delay, loop, OnComplete);
break;
case SelfAnimType.Move_RelativePosition:
if (enableInitValue) gameObject.transform.localPosition = OriginPosition + fromValue;
m_Control = SDemoAnimation.Instance.Move(gameObject, OriginPosition + fromValue, OriginPosition + toValue, time, delay, loop, OnComplete);
break;
}
}
public void StartAnimationRevert(float inDelay = 0f)
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Kill; // Kill the current tweening if existed
switch (m_SelfAnimType)
{
case SelfAnimType.Move:
if (enableInitValue) gameObject.transform.localPosition = toValue;
m_Control = SDemoAnimation.Instance.Move(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
break;
case SelfAnimType.Rotate:
if (enableInitValue) gameObject.transform.localEulerAngles = toValue;
m_Control = SDemoAnimation.Instance.Rotate(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
break;
case SelfAnimType.Scale:
if (enableInitValue) gameObject.transform.localScale = toValue;
m_Control = SDemoAnimation.Instance.Scale(gameObject, toValue, fromValue, time, inDelay, loop, OnComplete);
break;
case SelfAnimType.Move_RelativePosition:
if (enableInitValue) gameObject.transform.localPosition = OriginPosition + toValue;
m_Control = SDemoAnimation.Instance.Move(gameObject, OriginPosition + toValue, OriginPosition + fromValue, time, inDelay, loop, OnComplete);
break;
}
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(SelfAnimation))]
public class SelfAnimationCustomEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
SelfAnimation anim = (SelfAnimation)target;
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Play"))
{
if (IsApplicationPlaying) anim.StartAnimation();
}
if (GUILayout.Button("Reverse"))
{
if (IsApplicationPlaying) anim.StartAnimationRevert();
}
if (GUILayout.Button("Pause"))
{
if (IsApplicationPlaying) anim.m_Control.m_State = SDemoControl.State.Paused;
}
EditorGUILayout.EndHorizontal();
}
private bool IsApplicationPlaying
{
get
{
bool isPlaying = Application.isPlaying;
if (!isPlaying)
{
Debug.Log("This function intended for use in the Editor play mode.");
}
return isPlaying;
}
}
}
#endif
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: dce419e36a78641928c771d2cd8b5b89
timeCreated: 1506672609
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/SelfAnimation.cs
uploadId: 673764

View File

@@ -0,0 +1,50 @@
// Created by SwanDEV 2017
using UnityEngine;
using UnityEngine.Events;
namespace SDev.Component
{
public class SelfCountdown : MonoBehaviour
{
public SDemoControl m_Control = null;
public float time = 0.5f;
public SDemoAnimation.LoopType loop = SDemoAnimation.LoopType.Loop;
public bool destroyOnComplete = false;
public bool executeAtStart = true;
public UnityEvent onComplete;
void Start()
{
if (!executeAtStart) return;
StartAnimation();
}
void OnComplete()
{
if (onComplete != null) onComplete.Invoke();
if (destroyOnComplete) GameObject.Destroy(gameObject);
}
void OnEnable()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Playing;
}
void OnDisable()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Paused;
}
void OnDestroy()
{
if (m_Control != null) m_Control.m_State = SDemoControl.State.Kill;
}
public void StartAnimation()
{
m_Control = SDemoAnimation.Instance.Wait(time, OnComplete, loop);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: bf6b408d30a1843cba586a34fd447012
timeCreated: 1511534849
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/Common/SelfCountdown.cs
uploadId: 673764

View File

@@ -0,0 +1,3 @@
{
"name": "SwanDevCommon"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6e5481446c8674f4ba82a809f7e78e9c
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 38fb88d137e1942928fa251ed41fd49f
folderAsset: yes
timeCreated: 1507827170
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: ef96326de2383584aaf09883f4a7d7c2
folderAsset: yes
timeCreated: 1548434007
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,339 @@
// Created By SwanDEV 2021
using System.Collections;
using UnityEngine;
using System.IO;
#if UNITY_EDITOR
using UnityEditor;
#endif
/// <summary>
/// Screenshot Helper codeless screenshot tool: capture images from the screen or using any specific camera in the scene.
/// [ HOW To USE ] Attach this script on a GameObject in the scene, or drag the CodelessScreenshotHelper prefab from the EditorExtensions folder to the scene.
/// </summary>
public class CodelessScreenshotHelper : MonoBehaviour
{
[Header("[ Save Settings ]")]
public FilePathName.AppPath m_SaveDirectory = FilePathName.AppPath.PersistentDataPath;
public SaveFormat m_SaveFormat = SaveFormat.PNG;
public enum SaveFormat
{
JPG = 0,
PNG,
}
public string m_FolderName;
[Tooltip("Optional filename without extension. (Will auto generate a filename base on date and time if this not provided)")]
public string m_OptionalFileName;
public string Save_FolderName { get { return m_FolderName; } set { m_FolderName = value; } }
public string Save_OptionalFileName { get { return m_OptionalFileName; } set { m_OptionalFileName = value; } }
//[Tooltip("Save image to External directory instead of in-app directory, the External directory can be accessed in Android Gallery or iOS Photos (Android & iOS only)")]
//public bool m_SaveExternal = false;
[Header("[ Burst Mode Capture Settings ]")]
[Tooltip("The number of images to capture")]
[Range(2, 999)] public int m_BurstCount = 10;
[Tooltip("The burst interval (in seconds)")]
[Range(0.05f, 10f)] public float m_BurstInterval = 0.1f;
public float BurstCapture_Count { get { return m_AntiAliasingLevel; } set { m_AntiAliasingLevel = (int)value; } }
public float BurstCapture_Interval { get { return m_ImageScale; } set { m_ImageScale = value; } }
[Header("[ Screen Capture Settings ]")]
[Tooltip("Capture fullscreen image. Ignore the screen position and size(width & height) values.")]
public bool m_IsFullscreen = true;
public Vector2 m_ScreenPosition = new Vector2(0, 0);
public int m_Width = 360;
public int m_Height = 360;
public bool CaptureScreen_Fullscreen { get { return m_IsFullscreen; } set { m_IsFullscreen = value; } }
public float CaptureScreen_PositionX { get { return m_ScreenPosition.x; } set { m_ScreenPosition.x = value; } }
public float CaptureScreen_PositionY { get { return m_ScreenPosition.y; } set { m_ScreenPosition.y = value; } }
public float CaptureScreen_Width { get { return m_Width; } set { m_Width = (int)value; } }
public float CaptureScreen_Height { get { return m_Height; } set { m_Height = (int)value; } }
[Header("[ Camera Capture Settings ]")]
[Tooltip("The camera for capturing screenshot. Drag camera on this variable or click the 'Find Camera' button to setup.")]
public Camera m_SelectedCamera;
public Camera[] m_AllCameras;
[Tooltip("The method for capturing image using camera. OnRenderImage: legacy mode for built-in render pipeline only; OnUpdateRender: universal mode suitable for all render pipelines.")]
public ScreenshotHelper.RenderMode m_RenderMode = ScreenshotHelper.RenderMode.OnUpdateRender;
[Tooltip("(For OnUpdateRender mode) The anti-aliasing level for the resulting texture, the greater value results in smoother object edges. Valid value: 1(OFF), 2, 4, 8")]
[Range(1, 8)] public int m_AntiAliasingLevel = 4;
[Range(0.1f, 4f)] public float m_ImageScale = 1.0f;
public float CaptureCamera_AALevel { get { return m_AntiAliasingLevel; } set { m_AntiAliasingLevel = (int)value; } }
public float CaptureCamera_Scale { get { return m_ImageScale; } set { m_ImageScale = value; } }
/// <summary> 0: capture image from screen, 1: capture image from selected camera </summary>
[HideInInspector] public int m_CaptureSourceIndex = 0;
[HideInInspector] public int m_CurrCameraIndex = 0;
[HideInInspector] public string m_BurstProgress = "0 / 0";
[HideInInspector] public string m_BurstState = "Stopped";
public string m_SavePath { get; private set; }
public string GetSaveDirectory()
{
string directory = FilePathName.Instance.GetAppPath(m_SaveDirectory);
return string.IsNullOrEmpty(m_FolderName) ? directory : Path.Combine(directory, m_FolderName);
}
public void FindCameras()
{
m_AllCameras = Camera.allCameras;
if (m_AllCameras != null && m_AllCameras.Length > 0 && m_SelectedCamera == null)
{
m_SelectedCamera = m_AllCameras[0];
}
}
public void SetCaptureSource(int index)
{
m_CaptureSourceIndex = index;
}
public void SetCamera(int index)
{
if (m_AllCameras == null || m_AllCameras.Length == 0) return;
m_CurrCameraIndex = Mathf.Clamp(index, 0, m_AllCameras.Length - 1);
if (m_CurrCameraIndex < m_AllCameras.Length) m_SelectedCamera = m_AllCameras[m_CurrCameraIndex];
}
public void Capture()
{
if (!Application.isPlaying) return;
m_BurstState = "Stopped";
if (m_CaptureSourceIndex == 0) // Capture from screen
{
if (!m_IsFullscreen && m_Width > 0 && m_Height > 0)
{
ScreenshotHelper.iCapture(m_ScreenPosition, new Vector2(m_Width, m_Height), (texture) =>
{
_SaveTexture(texture);
ScreenshotHelper.iClear(false);
});
}
else
{
ScreenshotHelper.iCaptureScreen((texture) =>
{
_SaveTexture(texture);
ScreenshotHelper.iClear(false);
});
}
}
else // Capture from selected camera
{
if (m_SelectedCamera == null) FindCameras();
ScreenshotHelper.AntiAliasingLevel = m_AntiAliasingLevel;
ScreenshotHelper.SetRenderMode(m_RenderMode);
ScreenshotHelper.iCaptureWithCamera(m_SelectedCamera, m_ImageScale, (texture) =>
{
_SaveTexture(texture);
ScreenshotHelper.iClear(false);
});
}
}
public void BurstCapture()
{
if (!Application.isPlaying) return;
_isBurstOnGoing = true;
StartCoroutine(_BurstCapture());
}
public void StopBurstCapture()
{
if (!Application.isPlaying) return;
_isBurstOnGoing = false;
}
private bool _isBurstOnGoing = false;
private IEnumerator _BurstCapture()
{
for (int i = 0; i < m_BurstCount; i++)
{
if (!_isBurstOnGoing)
{
m_BurstState = "Stopped";
m_BurstProgress = (i + 1) + " / " + m_BurstCount + " (Manually Stopped)";
yield break;
}
Capture();
m_BurstState = "On Going..";
m_BurstProgress = (i + 1) + " / " + m_BurstCount;
yield return new WaitForSeconds(m_BurstInterval);
}
m_BurstState = "Stopped";
}
private void _SaveTexture(Texture2D texture)
{
//if (m_SaveExternal)
//{
// string fileName = string.IsNullOrEmpty(m_OptionalFileName.Trim()) ? FilePathName.Instance.GetFileNameWithoutExt(true) : m_OptionalFileName;
// string folderName = string.IsNullOrEmpty(m_FolderName.Trim()) ? Application.productName : m_FolderName;
// m_SavePath = MobileMedia.SaveImage(texture, folderName, fileName, m_SaveFormat == SaveFormat.JPG ? MobileMedia.ImageFormat.JPG : MobileMedia.ImageFormat.PNG);
//}
//else
{
m_SavePath = FilePathName.Instance.SaveTextureAs(texture, m_SaveDirectory, m_FolderName, (m_SaveFormat == SaveFormat.JPG), m_OptionalFileName);
}
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(CodelessScreenshotHelper))]
public class CodelessScreenshotHelperCustomEditor : Editor
{
private static string[] cameraOptions = new string[] { };
private static string[] captureSources = new string[] { "From Screen", "From Camera" };
private static bool showHelpsMessage = false;
private string helpsMessage = "[ HOW ] Attach the CodelessScreenshotHelper script on a GameObject in the scene, or drag the CodelessScreenshotHelper prefab from the EditorExtensions folder to the scene."
+ "\n\n(1) Select a capture source: from Screen or Camera."
+ "\n(2) Start capture images by clicking the 'Capture', 'Start Captures' buttons."
+ "\n\n( What else? Modify other settings as appropriate. And, you can also reference the methods and dynamic parameters in the CodelessScreenshotHelper to your UI components like Button, Slider, InputField, and Toggle, etc. in the scene, this allows you to take screenshots at runtime in your app )"
+ "\n\n* If you are using the CodelessScreenshot prefab in your build, you may click the 'Apply All' button on the prefab inspector to save the prefab after changing the setting value(s), or just 'Unpack' the prefab. (This prevents the prefab from reverting to its last saved status)";
public override void OnInspectorGUI()
{
DrawDefaultInspector();
CodelessScreenshotHelper mono = (CodelessScreenshotHelper)target;
mono.m_CurrCameraIndex = GUILayout.SelectionGrid(mono.m_CurrCameraIndex, cameraOptions, 2);
mono.SetCamera(mono.m_CurrCameraIndex);
GUILayout.Label("Find all Cameras in the scene:");
if (GUILayout.Button("Find Cameras"))
{
_SetupCamera(mono);
}
GUILayout.Label("\n\nSelect Source: capture image(s) from " + (mono.m_CaptureSourceIndex == 0 ? "Screen" : "Camera"));
mono.m_CaptureSourceIndex = GUILayout.SelectionGrid(mono.m_CaptureSourceIndex, captureSources, 2);
mono.SetCaptureSource(mono.m_CaptureSourceIndex);
GUILayout.Label("[ Start Capture Image ]");
if (GUILayout.Button("Capture (Single)") && Application.isPlaying)
{
_SetupCamera(mono);
mono.Capture();
}
GUILayout.Label(" Burst Mode ( Count: " + mono.m_BurstCount + ", Interval: " + mono.m_BurstInterval + "s )");
GUILayout.BeginHorizontal();
if (GUILayout.Button("Start Captures (Burst)") && Application.isPlaying)
{
_SetupCamera(mono);
mono.BurstCapture();
}
if (GUILayout.Button("Stop Captures (Burst)"))
{
// Stop the burst mode capture.
mono.StopBurstCapture();
}
GUILayout.EndHorizontal();
GUILayout.Label("Burst Progress: " + mono.m_BurstProgress
+ "\nBurst State: " + mono.m_BurstState
+ "\n\nLast File Name: " + Path.GetFileName(mono.m_SavePath) + "\n");
if (GUILayout.Button("View Image"))
{
if (!Application.isPlaying || string.IsNullOrEmpty(mono.m_SavePath))
{
Debug.Log("Please play your scene and capture image in the Editor.");
return;
}
_OpenURL(mono.m_SavePath);
}
if (GUILayout.Button("Copy Image Path"))
{
if (!Application.isPlaying || string.IsNullOrEmpty(mono.m_SavePath))
{
Debug.Log("Please play your scene and capture image in the Editor.");
return;
}
TextEditor te = new TextEditor();
te.text = mono.m_SavePath;
te.SelectAll();
te.Copy();
Debug.Log("Copied: " + te.text);
}
GUILayout.Space(5);
if (GUILayout.Button("Show Save Directory"))
{
string directory = mono.GetSaveDirectory();
if (string.IsNullOrEmpty(directory)) return;
if (Directory.Exists(directory))
EditorUtility.RevealInFinder(directory);
else
Debug.LogWarning("Directory not exist: " + directory);
}
if (GUILayout.Button("Copy Save Directory"))
{
string directory = mono.GetSaveDirectory();
if (string.IsNullOrEmpty(directory)) return;
TextEditor te = new TextEditor();
te.text = directory;
te.SelectAll();
te.Copy();
Debug.Log("Copied: " + directory);
}
GUILayout.Space(10);
bool isLightSkin = !EditorGUIUtility.isProSkin;
Color tipTextColor = isLightSkin ? new Color(0.12f, 0.12f, 0.12f, 1f) : Color.cyan;
GUIStyle helpBoxStyle = new GUIStyle(EditorStyles.textArea);
helpBoxStyle.normal.textColor = tipTextColor;
GUIStyle tipsStyle = new GUIStyle(EditorStyles.boldLabel);
tipsStyle.normal.textColor = tipTextColor;
showHelpsMessage = GUILayout.Toggle(showHelpsMessage, " Help (How To Use? Click here...)", tipsStyle);
if (showHelpsMessage) GUILayout.Label(helpsMessage, helpBoxStyle);
GUILayout.Space(10);
if (GUILayout.Button("Write A Review (THANK YOU)"))
{
_OpenURL("https://www.swanob2.com/screenshot-helper");
}
}
private void _OpenURL(string url)
{
#if UNITY_EDITOR_OSX
System.Diagnostics.Process.Start(url);
#else
Application.OpenURL(url);
#endif
}
private void _SetupCamera(CodelessScreenshotHelper mono)
{
mono.FindCameras();
_SetCameraOptions(Camera.allCameras, mono);
}
private void _SetCameraOptions(Camera[] cameras, CodelessScreenshotHelper mono)
{
mono.m_CurrCameraIndex = 0;
cameraOptions = new string[cameras.Length];
for (int i = 0; i < cameras.Length; i++)
{
cameraOptions[i] = cameras[i].name;
if (mono.m_SelectedCamera && mono.m_SelectedCamera == cameras[i]) mono.m_CurrCameraIndex = i;
}
}
}
#endif

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 1a97182c5ebdc8841a797a0d04e5e030
timeCreated: 1548434015
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/EditorExtensions/CodelessScreenshotHelper.cs
uploadId: 673764

View File

@@ -0,0 +1,72 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1054522600342700}
m_IsPrefabParent: 1
--- !u!1 &1054522600342700
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4929284723867544}
- component: {fileID: 114421283962694778}
m_Layer: 0
m_Name: CodelessScreenshotHelper
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4929284723867544
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1054522600342700}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114421283962694778
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1054522600342700}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1a97182c5ebdc8841a797a0d04e5e030, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SaveDirectory: 0
m_SaveFormat: 1
m_OptionalSubFolder:
m_BurstCount: 10
m_BurstInterval: 0.5
m_IsFullscreen: 1
m_ScreenPosition: {x: 0, y: 0}
m_Width: 512
m_Height: 512
m_SelectedCamera: {fileID: 0}
m_AllCameras:
- {fileID: 0}
m_RenderMode: 1
m_AntiAliasingLevel: 4
m_ImageScale: 1
m_CaptureSourceIndex: 0
m_BurstProgress: 0 / 0
m_BurstState: Stopped
m_SavePath: C:/Users/Studio/AppData/LocalLow/SwanDev/ImageToolbox\2019-01-26-23-12-40-186.png

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: bd0609bd4db13dc4f92882b5d6efa1f1
timeCreated: 1548439383
licenseType: Store
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/EditorExtensions/CodelessScreenshotHelper.prefab
uploadId: 673764

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 42cc883878d924e77b442f902ed8d6b5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,62 @@
#if UNITY_EDITOR
using System.IO;
using UnityEngine;
using UnityEditor;
namespace SDev.EditorUtil
{
/// <summary>
/// Take screenshots of editor Windows.
/// Two ways to take screenshots with this script:
/// In the editor, select your scene view, game view, any editor window or inspector tab...
/// (Method 1) Tools > SWAN DEV > SSH Screenshot, or
/// (Method 2) Hotkeys: Shift + W
/// </summary>
public class EditorScreenshotHelper : MonoBehaviour
{
[MenuItem("Tools/SWAN DEV/SSH Screenshot (Shift+W) #w")] // %# : ctrl/cmd + shift
private static void Screenshot()
{
// Get actvive EditorWindow
EditorWindow activeWindow = EditorWindow.focusedWindow;
if (activeWindow == null) return;
// Get screen position and sizes
Vector2 vec2Position = activeWindow.position.position;
float sizeX = activeWindow.position.width;
float sizeY = activeWindow.position.height;
// Take Screenshot at given position and size
Color[] colors = UnityEditorInternal.InternalEditorUtility.ReadScreenPixel(vec2Position, (int)sizeX, (int)sizeY);
// Write result Color[] data into a Texture2D
Texture2D result = new Texture2D((int)sizeX, (int)sizeY);
result.SetPixels(colors);
// Encode the Texture2D to a PNG,
// you might want to change this to JPG for way less file size but slightly worse quality
// if you do don't forget to also change the file extension below
byte[] bytes = result.EncodeToPNG();
// In order to avoid bloading Texture2D into memory destroy it
Object.DestroyImmediate(result);
// Write the file to a folder in the project
System.DateTime DT = System.DateTime.Now;
string timeString = string.Format("_{0}-{1:00}-{2:00}_{3:00}-{4:00}-{5:00}-{6:000}", DT.Year, DT.Month, DT.Day, DT.Hour, DT.Minute, DT.Second, DT.Millisecond);
string directory = Path.Combine(Application.dataPath, "Screenshots");
if (!Directory.Exists(directory)) Directory.CreateDirectory(directory);
string savePath = Path.Combine(directory, "Screenshot" + timeString + ".png");
File.WriteAllBytes(savePath, bytes);
// Refresh the AssetsDatabase so the file actually appears in Unity
AssetDatabase.Refresh();
Debug.Log("Screenshot Hepler > New Screenshot saved (see 'Screenshots' folder in the project):\n" + savePath);
}
}
}
#endif

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: f547565e0a5144f45926e8be5cc18123
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/EditorExtensions/EditorViewCapture/EditorScreenshotHelper.cs
uploadId: 673764

View File

@@ -0,0 +1,19 @@
{
"name": "ScreenshotHelperEditor",
"rootNamespace": "",
"references": [
"GUID:3d84d9ab8c89619479722b2ddcd88a57",
"GUID:6e5481446c8674f4ba82a809f7e78e9c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bd13f89454a06024c91bc6852d5a87c3
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 6f21960995af24c91944c0c2299c914f
folderAsset: yes
timeCreated: 1507723565
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 40580b7281c0b418387e20a99f4be974
folderAsset: yes
timeCreated: 1507723760
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

View File

@@ -0,0 +1,192 @@
fileFormatVersion: 2
guid: 54858d04adfed4048b23fc1bf2db346e
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Images/Photo/001.jpg
uploadId: 673764
TextureImporter:
internalIDToNameTable:
- first:
89: 8900000
second: generatedCubemap
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

View File

@@ -0,0 +1,192 @@
fileFormatVersion: 2
guid: 9a5865a0aea534087b2690ec819f532d
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Images/Photo/002.jpg
uploadId: 673764
TextureImporter:
internalIDToNameTable:
- first:
89: 8900000
second: generatedCubemap
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

View File

@@ -0,0 +1,192 @@
fileFormatVersion: 2
guid: c0075ca9a781b468287c9c187348a44f
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Images/Photo/003.jpg
uploadId: 673764
TextureImporter:
internalIDToNameTable:
- first:
89: 8900000
second: generatedCubemap
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

View File

@@ -0,0 +1,192 @@
fileFormatVersion: 2
guid: 56e131277036d4c4a9ad2f3b4fdf6b85
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Images/Photo/004.jpg
uploadId: 673764
TextureImporter:
internalIDToNameTable:
- first:
89: 8900000
second: generatedCubemap
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 KiB

View File

@@ -0,0 +1,192 @@
fileFormatVersion: 2
guid: 4873e2e6165514c5992fc9d428607a4f
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Images/Photo/005.jpg
uploadId: 673764
TextureImporter:
internalIDToNameTable:
- first:
89: 8900000
second: generatedCubemap
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
flipGreenChannel: 0
isReadable: 1
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 1
swizzle: 50462976
cookieLightType: 1
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: iOS
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: Tizen
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 1
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
customData:
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable: {}
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: ced9e2018dad14caaa3257b4db4493aa
timeCreated: 1519915595
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Readme - Screenshot Helper Free.pdf
uploadId: 673764

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 3dbb8aa8d21be43dab54a5127963c2ae
folderAsset: yes
timeCreated: 1507827207
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,83 @@

using UnityEngine;
public class MinimumDemo : MonoBehaviour
{
public Camera m_Camera;
public MeshRenderer m_CubeMeshRenderer;
[Space]
public SDev.FileSaveUtil.AppPath ApplicationPath = SDev.FileSaveUtil.AppPath.PersistentDataPath;
public string SubFolderName;
public string FileName;
private Texture2D _texture2D;
public void TakeScreenshot()
{
//ScreenshotHelper.iClear(); // Clear the old texture (if any)
ScreenshotHelper.iCaptureScreen((texture2D) =>
{
if (_texture2D) Destroy(_texture2D); // Manually clear the old texture
_texture2D = texture2D;
// Set the new (captured) screenshot texture to the cube renderer.
m_CubeMeshRenderer.material.mainTexture = texture2D;
SaveTexture(texture2D);
});
}
public void CaptureWithCamera()
{
//ScreenshotHelper.iClear(); // Clear the old texture (if any)
ScreenshotHelper.iCaptureWithCamera(m_Camera, (texture2D) =>
{
if (_texture2D) Destroy(_texture2D); // Manually clear the old texture
_texture2D = texture2D;
// Set the new (captured) screenshot texture to the cube renderer.
m_CubeMeshRenderer.material.mainTexture = texture2D;
SaveTexture(texture2D);
});
}
private void SaveTexture(Texture2D texture2D)
{
// Example: Save to Application data path
string savePath = SDev.FileSaveUtil.Instance.SaveTextureAsJPG(texture2D, ApplicationPath, SubFolderName, FileName);
//string savePath = SDev.FileSaveUtil.Instance.SaveTextureAsJPG(texture2D, System.Environment.SpecialFolder.MyPictures, SubFolderName, FileName);
Debug.Log("Result - Texture resolution: " + texture2D.width + " x " + texture2D.height + "\nSaved at: " + savePath);
// ----- Below are other save methods for different Unity player platforms (ScreenshotHelper Plus or related plugin required) -----
// Example: Save to mobile device gallery(iOS/Android). <- Requires Mobile Media Plugin (Included in Screenshot Helper Plus, and SwanDev GIF Assets)
//MobileMedia.SaveImage(texture2D, SubFolderName, FileName, MobileMedia.ImageFormat.JPG);
// Example: Save to persistent data path on WebGL
//savePath = SDev.EasyIO.SaveImage(texture2D, SDev.EasyIO.ImageEncodeFormat.JPG, FileName + ".jpg", SubFolderName);
// Example: Open the 'Save As' dialog box on WebGL
//SDev.EasyIO.WebGL_SaveToLocal(texture2D.EncodeToJPG(), FileName + ".jpg");
}
public void Clear()
{
ScreenshotHelper.iClear();
}
public void OpenSaveFolder()
{
string dir = SDev.FileSaveUtil.Instance.GetAppPath(ApplicationPath);
string path = System.IO.Path.Combine(dir, SubFolderName);
if (!System.IO.Directory.Exists(path)) System.IO.Directory.CreateDirectory(path);
#if UNITY_EDITOR_OSX
System.Diagnostics.Process.Start(path);
#else
Application.OpenURL(path);
#endif
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 4d815b251b9ae2747be1c55d055b1586
timeCreated: 1532478200
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scenes/MinimumDemo.cs
uploadId: 673764

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: a490636f8f553fa4ca906067cf6c9fa7
timeCreated: 1532478803
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scenes/MinimumDemo.unity
uploadId: 673764

View File

@@ -0,0 +1,63 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!850595691 &4890085278179872738
LightingSettings:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: MinimumDemoSettings
serializedVersion: 3
m_GIWorkflowMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
m_RealtimeEnvironmentLighting: 1
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 0
m_BakeBackend: 0
m_LightmapMaxSize: 1024
m_BakeResolution: 40
m_Padding: 2
m_TextureCompression: 1
m_AO: 0
m_AOMaxDistance: 1
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
m_ExportTrainingData: 0
m_TrainingDataDestination: TrainingData
m_RealtimeResolution: 2
m_ForceWhiteAlbedo: 0
m_ForceUpdates: 0
m_FinalGather: 0
m_FinalGatherRayCount: 256
m_FinalGatherFiltering: 1
m_PVRCulling: 1
m_PVRSampling: 1
m_PVRDirectSampleCount: 32
m_PVRSampleCount: 500
m_PVREnvironmentSampleCount: 500
m_PVREnvironmentReferencePointCount: 2048
m_LightProbeSampleCountMultiplier: 4
m_PVRBounces: 2
m_PVRMinBounces: 2
m_PVREnvironmentMIS: 0
m_PVRFilteringMode: 0
m_PVRDenoiserTypeDirect: 0
m_PVRDenoiserTypeIndirect: 0
m_PVRDenoiserTypeAO: 0
m_PVRFilterTypeDirect: 0
m_PVRFilterTypeIndirect: 0
m_PVRFilterTypeAO: 0
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
m_PVRFilteringAtrousPositionSigmaIndirect: 2
m_PVRFilteringAtrousPositionSigmaAO: 1

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: d5563661363824e8397f0744c8c5b77d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 4890085278179872738
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scenes/MinimumDemoSettings.lighting
uploadId: 673764

View File

@@ -0,0 +1,223 @@
/// <summary>
/// By SwanDEV 2017
/// </summary>
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
/// <summary>
/// Screenshot Helper example.
/// </summary>
public class ScreenshotDemo : DImageDisplayHandler // Inherits the image handler script, we use this handler to set the captured texture/sprite for displaying on the UI Image in this demo.
{
[Header("[ Save Settings ]")]
public FilePathName.SaveFormat saveFormat = FilePathName.SaveFormat.JPG;
[Header("[ Camera Capture (Camera Capture method example) ]")]
[Tooltip("Request Texture2D or RenderTexture?")]
public bool m_RequestTexture2D_CameraCapture = true;
public float m_Scale = 1f;
public int m_TaregtWidth, m_TargetHeight;
[Header("[ Capture Cutout (Capture screen with cutout area Example) ]")]
public Vector2 iCaptureRegionSize = new Vector2(512, 512);
[Header("[ Object References ]")]
public CanvasScaler canvasScaler;
public UnityEngine.UI.Image displayImage;
public Text debugText;
public InputField widthInputField;
public InputField heightInputField;
public MeshRenderer cubeMesh;
public Camera camera1;
public Camera camera2;
public Camera camera3;
private void Start()
{
// Check the max. texture size support by the current device GPU
Debug.Log("Max. texture size support by the current device GPU: " + SystemInfo.maxTextureSize);
// Set the anti-aliasing level (1, 2, 4, 8), 1 = disable; 8 = best quality.
ScreenshotHelper.AntiAliasingLevel = 8;
ScreenshotHelper.iSetMainOnCapturedCallback((Sprite sprite) =>
{
// Your Code to use the captured sprite..
SetImage(sprite);
cubeMesh.material.mainTexture = sprite.texture;
switch (saveFormat)
{
case FilePathName.SaveFormat.JPG:
SaveAsJPG(sprite.texture);
break;
case FilePathName.SaveFormat.PNG:
SaveAsPNG(sprite.texture);
break;
case FilePathName.SaveFormat.GIF:
#if PRO_GIF
// Require Pro GIF to save image(s) as GIF.
SaveAsGIF(sprite.texture);
#endif
break;
}
});
// Show screenshot helper debug message
ScreenshotHelper.Instance.m_DebugText = debugText;
OnInputChanges();
// Check screen orientation for setting canvas resolution
if(Screen.width > Screen.height)
{
canvasScaler.referenceResolution = new Vector2(1920, 1080);
}
else
{
canvasScaler.referenceResolution = new Vector2(1080, 1920);
}
}
private PointerEventData uiPointerEventData = new PointerEventData(EventSystem.current);
private List<RaycastResult> uiRaycastResuls = new List<RaycastResult>();
private bool _isPointedOnUI = false;
private void Update()
{
/*if(Input.GetMouseButtonDown(0))
{
uiPointerEventData.position = Input.mousePosition;
EventSystem.current.RaycastAll(uiPointerEventData, uiRaycastResuls);
_isPointedOnUI = (uiRaycastResuls.Count > 0)? true:false;
}
if(Input.GetMouseButtonUp(0))
{
if(!_isPointedOnUI)
{
ScreenshotHelper.iCapture(Input.mousePosition, iCaptureRegionSize, (texture2D) => {
// Your Code to use the captured texture..
Debug.Log("Touch to capture screen, result image size: " + texture2D.width + " x " + texture2D.height);
});
}
}*/
}
public void OnInputChanges()
{
int captureWidth = 512;
int.TryParse(widthInputField.text, out captureWidth);
int captureHeight = 512;
int.TryParse(heightInputField.text, out captureHeight);
iCaptureRegionSize = new Vector2(captureWidth, captureHeight);
}
public void CaptureScreen()
{
ScreenshotHelper.iCaptureScreen((texture2D)=>{
// Your Code to use the captured texture..
Debug.Log("iCaptureScreen - result image size: " + texture2D.width + " x " + texture2D.height);
});
}
public void CaptureWithCamera(Camera camera)
{
if (m_RequestTexture2D_CameraCapture)
{
if (m_Scale > 0)
{
// Capture with camera, request Texture2D of the specific scale:
ScreenshotHelper.iCaptureWithCamera(camera, m_Scale, (texture2D) =>
{
// Your Code to use the captured texture..
Debug.Log("1. iCaptureWithCamera - result image size: " + texture2D.width + " x " + texture2D.height);
});
}
else
{
// Capture with camera, request Texture2D of the specific Width and Height:
ScreenshotHelper.iCaptureWithCamera(camera, (texture2D) =>
{
// Your Code to use the captured texture..
Debug.Log("2. iCaptureWithCamera - result image size: " + texture2D.width + " x " + texture2D.height);
}, m_TaregtWidth, m_TargetHeight);
}
}
else
{
if (m_Scale > 0)
{
// Capture with camera, request RenderTexture of the specific scale:
ScreenshotHelper.iCaptureWithCamera_RenderTexture(camera, m_Scale, (renderTexture) =>
{
// Your Code to use the captured texture..
Debug.Log("3. iCaptureWithCamera - result image size: " + renderTexture.width + " x " + renderTexture.height);
});
}
else
{
// Capture with camera, request RenderTexture of the specific Width and Height:
ScreenshotHelper.iCaptureWithCamera_RenderTexture(camera, (renderTexture) =>
{
// Your Code to use the captured texture..
Debug.Log("4. iCaptureWithCamera - result image size: " + renderTexture.width + " x " + renderTexture.height);
}, m_TaregtWidth, m_TargetHeight);
}
}
}
private void SetImage(Sprite sprite)
{
base.Clear(displayImage); // Clear the previous texture (if any)
base.SetImage(displayImage, sprite); // Set the sprite to the UI Image, using the DImageDisplayHandler that inherited by this demo script.
}
public void Clear()
{
base.Clear(displayImage);
displayImage.rectTransform.sizeDelta = Vector2.zero;
ClearScreenshotHelper();
}
public void ClearScreenshotHelper()
{
ScreenshotHelper.iClear(clearCallback: false, clearTextures: true);
}
private void SaveAsJPG(Texture2D tex2D)
{
string debugMessage = "Saved_as_JPG_to:_" + new FilePathName().SaveTextureAs(tex2D, FilePathName.SaveFormat.JPG);
ScreenshotHelper.Instance.UpdateDebugText(debugMessage);
}
private void SaveAsPNG(Texture2D tex2D)
{
string debugMessage = "Saved_as_PNG_to:_" + new FilePathName().SaveTextureAs(tex2D, FilePathName.SaveFormat.PNG);
ScreenshotHelper.Instance.UpdateDebugText(debugMessage);
}
#if PRO_GIF
private void SaveAsGIF(Texture2D tex2D)
{
string debugMessage = "Saved as GIF to: " + new FilePathName().SaveTextureAs(tex2D, FilePathName.SaveFormat.GIF);
ScreenshotHelper.Instance.UpdateDebugText(debugMessage);
}
#endif
public void UnRegRenderCameras()
{
ScreenshotHelper.iUnRegisterAllRenderCameras();
}
public void MoreAssets()
{
Application.OpenURL("https://www.swanob2.com/assets");
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 614475b0fd1d54ad088aeff598138f0d
timeCreated: 1507705456
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scenes/ScreenshotDemo.cs
uploadId: 673764

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,15 @@
fileFormatVersion: 2
guid: 33689c9ca9ef3489da2cace4a1b94d00
timeCreated: 1507723470
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scenes/ScreenshotDemo.unity
uploadId: 673764

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,115 @@
fileFormatVersion: 2
guid: 720d0e265574a4eff864e3a06d08081e
timeCreated: 1507868063
licenseType: Store
TextureImporter:
fileIDToRecycleName: {}
serializedVersion: 4
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 1
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
filterMode: -1
aniso: -1
mipBias: -1
wrapMode: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spritePixelsToUnits: 100
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: Standalone
maxTextureSize: 2048
textureFormat: 3
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
- buildTarget: iPhone
maxTextureSize: 2048
textureFormat: 3
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
- buildTarget: Android
maxTextureSize: 2048
textureFormat: 3
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 1
- buildTarget: Tizen
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
- buildTarget: WebGL
maxTextureSize: 2048
textureFormat: -1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
spritePackingTag:
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/ScreenshotHelper_128.png
uploadId: 673764

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: e09426ae3c68348fd8ed86469f338c2d
folderAsset: yes
timeCreated: 1507827224
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
// Created by SwanDEV 2017
using UnityEngine;
public class CameraOnRender : CameraRenderBase
{
private void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination);
if (_toDestroyScript) Destroy(this); // remove this script from the camera
if (!_toCapture) return;
_toCapture = false;
RenderTexture renderTexture = null;
Vector2 targetSize;
bool customSize = _targetWidth > 0 && _targetHeight > 0;
if (customSize)
{
_SystemTextureLimit(ref _targetWidth, ref _targetHeight);
float W = Mathf.Max(_targetWidth, _targetHeight);
float H = W;
_CalSizeWithAspectRatio(ref W, ref H, new Vector2(source.width, source.height));
float scale = Mathf.Max(_targetWidth / W, _targetHeight / H);
W = Mathf.Round(W * scale);
H = Mathf.Round(H * scale);
renderTexture = new RenderTexture((int)W, (int)H, 24);
targetSize = new Vector2(_targetWidth, _targetHeight);
}
else
{
int W = (int)(source.width * _scale);
int H = (int)(source.height * _scale);
_SystemTextureLimit(ref W, ref H);
renderTexture = new RenderTexture(W, H, 24);
targetSize = new Vector2(W, H);
}
if (_onCaptureCallback != null)
{
if (source.width != renderTexture.width || source.height != renderTexture.height)
{
Graphics.Blit(source, renderTexture);
_onCaptureCallback(_CutOutAndCropTexture(renderTexture, new Rect(0, 0, renderTexture.width, renderTexture.height), targetSize, isFullScreen: true));
}
else
{
_onCaptureCallback(_CutOutAndCropTexture(source, new Rect(0, 0, renderTexture.width, renderTexture.height), targetSize, isFullScreen: true));
}
_onCaptureCallback = null;
if (renderTexture) Destroy(renderTexture);
#if UNITY_EDITOR
Debug.Log("OnRenderImage - Texture2D * " + _scale);
#endif
}
else if (_onCaptureCallbackRTex != null)
{
Graphics.Blit(source, renderTexture);
_onCaptureCallbackRTex(_CutOutAndCropRenderTexture(renderTexture, new Rect(0, 0, renderTexture.width, renderTexture.height), targetSize, isFullScreen: true));
_onCaptureCallbackRTex = null;
#if UNITY_EDITOR
Debug.Log("OnRenderImage - RenderTexture * " + _scale);
#endif
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a935fd643bb624c6fb5d0d19e47679ad
timeCreated: 1507808962
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scripts/CameraOnRender.cs
uploadId: 673764

View File

@@ -0,0 +1,79 @@
// Created by SwanDEV 2019
using UnityEngine;
public class CameraOnUpdateRender : CameraRenderBase
{
/// <summary>
/// [Camera capture methods Only] The anti-aliasing level for the resulting texture,
/// the greater value results in the edges of the image look smoother. Available value: 1(OFF), 2, 4, 8.
/// The greater value will increase the memory consumption for the result texture, please adjust the values as need.
/// (This value will not be applied if your project AntiAliasing level is enabled and greater)
/// </summary>
public int m_AntiAliasingLevel = 4;
private void Update()
{
OnUpdateRender();
}
private void OnUpdateRender()
{
if (_toDestroyScript) Destroy(this); // remove this script from the camera
if (!_toCapture) return;
_toCapture = false;
if (rCamera == null) rCamera = GetComponent<Camera>();
//Display display = Display.displays != null ? Display.displays[rCamera.targetDisplay] : null;
//int W = display != null ? display.renderingWidth : Screen.width;
//int H = display != null ? display.renderingHeight : Screen.height;
int W, H;
if (Display.displays != null && rCamera.targetDisplay < Display.displays.Length)
{
Display display = Display.displays[rCamera.targetDisplay];
W = display.renderingWidth;
H = display.renderingHeight;
}
else
{
W = rCamera.pixelWidth;
H = rCamera.pixelHeight;
}
RenderTexture renderTexture = new RenderTexture(W, H, 24);
m_AntiAliasingLevel = Mathf.Clamp(m_AntiAliasingLevel, 1, 8);
if (m_AntiAliasingLevel == 3 || m_AntiAliasingLevel == 5) m_AntiAliasingLevel = 4; else if (m_AntiAliasingLevel == 6 || m_AntiAliasingLevel == 7) m_AntiAliasingLevel = 8;
if (QualitySettings.antiAliasing < m_AntiAliasingLevel) renderTexture.antiAliasing = m_AntiAliasingLevel;
rCamera.targetTexture = renderTexture;
rCamera.Render();
rCamera.targetTexture = null;
bool customSize = _targetWidth > 0 && _targetHeight > 0;
bool subScreenCam = rCamera.rect.width < 1f || rCamera.rect.height < 1f || rCamera.rect.x > 0f || rCamera.rect.y > 0f;
if (subScreenCam || customSize || _scale != 1f)
{
int width = customSize ? _targetWidth : (int)(rCamera.pixelWidth * _scale);
int height = customSize ? _targetHeight : (int)(rCamera.pixelHeight * _scale);
_SystemTextureLimit(ref width, ref height);
Vector2 targetSize = new Vector2(width, height);
renderTexture = _CutOutAndCropRenderTexture(renderTexture, new Rect(Mathf.CeilToInt(rCamera.pixelRect.x), rCamera.pixelRect.y, rCamera.pixelRect.width, rCamera.pixelRect.height), targetSize, isFullScreen: false);
}
if (_onCaptureCallback != null)
{
_onCaptureCallback(_RenderTextureToTexture2D(renderTexture));
_onCaptureCallback = null;
#if UNITY_EDITOR
Debug.Log("OnUpdateRender - Texture2D * " + _scale);
#endif
}
else if (_onCaptureCallbackRTex != null)
{
_onCaptureCallbackRTex(renderTexture);
_onCaptureCallbackRTex = null;
#if UNITY_EDITOR
Debug.Log("OnUpdateRender - RenderTexture * " + _scale);
#endif
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 5c47c8fd6d1584f7cb6af66c9228c177
timeCreated: 1564498839
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scripts/CameraOnUpdateRender.cs
uploadId: 673764

View File

@@ -0,0 +1,182 @@
// Created by SwanDEV 2019
using UnityEngine;
using System;
public class CameraRenderBase : MonoBehaviour
{
protected Action<Texture2D> _onCaptureCallback = null;
protected Action<RenderTexture> _onCaptureCallbackRTex = null;
protected bool _toCapture = true;
protected int _targetWidth = 0;
protected int _targetHeight = 0;
/// <summary> A value for scaling the texture. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU) </summary>
protected float _scale = 1f;
protected Camera rCamera;
public bool _toDestroyScript;
private bool _destroySourceOnConverted = true;
private void _Init()
{
_toCapture = true;
_toDestroyScript = false;
}
public void SetOnCaptureCallback(Action<Texture2D> onCaptured, float scale)
{
_onCaptureCallback = onCaptured;
_onCaptureCallbackRTex = null;
_scale = Mathf.Clamp(scale, 0.1f, 4f);
_targetWidth = 0;
_targetHeight = 0;
_Init();
}
public void SetOnCaptureCallback(Action<Texture2D> onCaptured, int width = 0, int height = 0)
{
_onCaptureCallback = onCaptured;
_onCaptureCallbackRTex = null;
_scale = 1f;
_targetWidth = width;
_targetHeight = height;
_Init();
}
public void SetOnCaptureCallback(Action<RenderTexture> onCaptured, float scale)
{
_onCaptureCallback = null;
_onCaptureCallbackRTex = onCaptured;
_scale = Mathf.Clamp(scale, 0.1f, 4f);
_targetWidth = 0;
_targetHeight = 0;
_Init();
}
public void SetOnCaptureCallback(Action<RenderTexture> onCaptured, int width = 0, int height = 0)
{
_onCaptureCallback = null;
_onCaptureCallbackRTex = onCaptured;
_scale = 1f;
_targetWidth = width;
_targetHeight = height;
_Init();
}
protected Texture2D _RenderTextureToTexture2D(RenderTexture source)
{
RenderTexture.active = source;
Texture2D tex = new Texture2D(source.width, source.height, TextureFormat.RGBA32, false); // 24
tex.ReadPixels(new Rect(0, 0, source.width, source.height), 0, 0);
tex.Apply();
RenderTexture.active = null;
if (_destroySourceOnConverted) Destroy(source);
return tex;
}
protected Texture2D _CutOutAndCropTexture(RenderTexture source, Rect cutoutRect, Vector2 cropAspectRatio, bool isFullScreen)
{
float W = cutoutRect.width, H = cutoutRect.height;
_CalSizeWithAspectRatio(ref W, ref H, cropAspectRatio);
W = (int)W;
H = (int)H;
RenderTexture.active = source;
Texture2D texture2D = new Texture2D((int)W, (int)H, TextureFormat.RGBA32, false); // 24
if (isFullScreen)
{
texture2D.ReadPixels(new Rect((source.width - texture2D.width) / 2, (source.height - texture2D.height) / 2, texture2D.width, texture2D.height), 0, 0);
}
else
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2
|| SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3
|| SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLCore
|| SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Metal)
{ // Origin(0, 0) is at the bottom left corner
texture2D.ReadPixels(new Rect(cutoutRect.x, cutoutRect.y, W, H), 0, 0);
}
else // DX, Vulkan
{ // Origin(0, 0) is at the top left corner
texture2D.ReadPixels(new Rect((cutoutRect.x + (cutoutRect.width - W) / 2f), (source.height - cutoutRect.y - cutoutRect.height + (cutoutRect.height - H) / 2f), W, H), 0, 0);
}
}
texture2D.Apply();
RenderTexture.active = null;
if (_destroySourceOnConverted) Destroy(source);
return texture2D;
}
protected RenderTexture _CutOutAndCropRenderTexture(RenderTexture source, Rect rect, Vector2 targetSize, bool isFullScreen)
{
RenderTexture rt = new RenderTexture((int)targetSize.x, (int)targetSize.y, 24);
Texture2D temp = _CutOutAndCropTexture(source, rect, targetSize, isFullScreen);
Graphics.Blit(temp, rt);
Destroy(temp);
return rt;
}
public void Clear()
{
_onCaptureCallback = null;
_onCaptureCallbackRTex = null;
_toCapture = false;
_toDestroyScript = true;
}
protected static void _CalSizeWithAspectRatio(ref float originWidth, ref float originHeight, Vector2 targetAspectRatio)
{
float W = originWidth;
float H = originHeight;
float originRatio = W / H;
float targetRatio = targetAspectRatio.x / targetAspectRatio.y;
if (originRatio > targetRatio)
{
if (targetRatio == 1)
{ // 1:1 image
if (W > H) W = H; else if (H > W) H = W;
}
else W = H * targetRatio;
}
else if (originRatio < targetRatio)
{
if (targetRatio == 1)
{ // 1:1 image
if (W > H) W = H; else if (H > W) H = W;
}
else H = W / targetRatio;
}
originWidth = W;
originHeight = H;
}
protected void _SystemTextureLimit(ref int width, ref int height)
{
float maxSize = SystemInfo.maxTextureSize;
if (width > maxSize || height > maxSize)
{
if (width > height)
{
height = (int)(height * (maxSize / width));
width = (int)maxSize;
}
else if (width < height)
{
width = (int)(width * (maxSize / height));
height = (int)maxSize;
}
else width = height = (int)maxSize;
#if UNITY_EDITOR
Debug.Log("The target texture size is larger than the max that supports by the current device. Limited to the max size : " + maxSize);
#endif
}
}
}

View File

@@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 5b6d4c5bc936c4a4387851830c91eaf5
timeCreated: 1564498643
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scripts/CameraRenderBase.cs
uploadId: 673764

View File

@@ -0,0 +1,16 @@
{
"name": "ScreenshotHelper",
"rootNamespace": "",
"references": [
"GUID:6e5481446c8674f4ba82a809f7e78e9c"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3d84d9ab8c89619479722b2ddcd88a57
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,928 @@
/// <summary>
/// By SwanDEV 2017
/// </summary>
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System;
public class ScreenshotHelper : MonoBehaviour
{
public UnityEvent m_MainOnCaptured;
/// <summary> The method for capturing image using camera. OnRenderImage: legacy mode for built-in render pipeline only; OnUpdateRender: universal mode suitable for all render pipelines. </summary>
[Tooltip("The method for capturing image using camera. OnRenderImage: legacy mode for built-in render pipeline only; OnUpdateRender: universal mode suitable for all render pipelines.")]
public RenderMode m_RenderMode = RenderMode.OnUpdateRender; // Default: OnUpdateRender
public enum RenderMode
{
/// <summary> Support Unity built-in render pipeline only. Suggested if you didn't configure your project for using Scriptable Render Pipeline (URP/LWRP/HDRP). </summary>
OnRenderImage = 0,
/// <summary>
/// Support both Unity built-in render pipeline and Scriptable Render Pipeline (URP/LWRP/HDRP).
/// Support Anti-Aliasing for camera capture methods, even the Anti-Aliasing option is disabled in the Unity QualitySettings.
/// </summary>
OnUpdateRender,
}
/// <summary> [OnUpdateRender mode camera capture methods Only] The anti-aliasing level for the resulting texture, the greater value results in smoother object edges. Valid value: 1(OFF), 2, 4, 8 </summary>
[Tooltip("[OnUpdateRender mode camera capture methods Only] The anti-aliasing level for the resulting texture, the greater value results in smoother object edges. Valid value: 1(OFF), 2, 4, 8")]
[Range(1, 8)] public int m_AntiAliasingLevel = 4;
private bool _isBeingCaptureScreen = false;
private Texture2D _texture2D = null;
private RenderTexture _renderTexture = null;
[Tooltip("Optional debug text.")]
public Text m_DebugText;
private static ScreenshotHelper _instance = null;
public static ScreenshotHelper Instance
{
get {
if (_instance == null)
{
_instance = new GameObject("[ScreenshotHelper]").AddComponent<ScreenshotHelper>();
}
return _instance;
}
}
/// <summary> Clear the instance of ScreenshotHelper: Destroy the stored textures, remove callbacks, remove script from camera. </summary>
public void Clear(bool clearCallback = true, bool clearTextures = true)
{
if (clearCallback && m_MainOnCaptured != null)
{
m_MainOnCaptured.RemoveAllListeners();
m_MainOnCaptured = null;
}
if (clearTextures)
{
if (_texture2D) ClearTexture2D(ref _texture2D);
if (_renderTexture) ClearRenderTexture(ref _renderTexture);
if (_cachedSprite) Destroy(_cachedSprite);
}
// Remove camera render script from cameras
UnRegisterAllRenderCameras();
}
private void Awake()
{
if (_instance == null) _instance = this;
}
private void _InitMainOnCaptured(bool clearExistingCallbacks)
{
if (m_MainOnCaptured == null) m_MainOnCaptured = new UnityEvent();
if (clearExistingCallbacks) m_MainOnCaptured.RemoveAllListeners();
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public void SetMainOnCapturedCallback(Action mainOnCaptured, bool clearExistingCallbacks = true)
{
_InitMainOnCaptured(clearExistingCallbacks);
m_MainOnCaptured.AddListener(delegate {
mainOnCaptured();
});
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return the captured images as Texture2D.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture, return a Texture2D.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public void SetMainOnCapturedCallback(Action<Texture2D> mainOnCaptured, bool clearExistingCallbacks = true)
{
_InitMainOnCaptured(clearExistingCallbacks);
m_MainOnCaptured.AddListener(delegate {
mainOnCaptured(_texture2D);
});
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return the captured images as Sprite.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture, return a Sprite.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public void SetMainOnCapturedCallback(Action<Sprite> mainOnCaptured, bool clearExistingCallbacks = true)
{
_InitMainOnCaptured(clearExistingCallbacks);
m_MainOnCaptured.AddListener(delegate {
mainOnCaptured(GetCurrentSprite());
});
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return the captured images as RenderTexture.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture, return a RenderTexture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public void SetMainOnCapturedCallback(Action<RenderTexture> mainOnCaptured, bool clearExistingCallbacks = true)
{
_InitMainOnCaptured(clearExistingCallbacks);
m_MainOnCaptured.AddListener(delegate {
mainOnCaptured(GetCurrentRenderTexture());
});
}
/// <summary>
/// Capture the full screen, return a Texture2D in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureScreen(Action<Texture2D> onCapturedCallback = null)
{
StartCoroutine(_TakeFullscreen(onCapturedCallback, null, null));
}
/// <summary>
/// Capture the full screen, return a Sprite in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureScreen_Sprite(Action<Sprite> onCapturedCallback = null)
{
StartCoroutine(_TakeFullscreen(null, onCapturedCallback, null));
}
/// <summary>
/// Capture the full screen, return a RenderTexture in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureScreen_RenderTexture(Action<RenderTexture> onCapturedCallback = null)
{
StartCoroutine(_TakeFullscreen(null, null, onCapturedCallback));
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a Texture2D in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void Capture(Vector2 screenPosition, Vector2 imageSize, Action<Texture2D> onCapturedCallback = null)
{
if (_isBeingCaptureScreen)
{
Debug.LogWarning("Screenshot being captured, please wait for at least 1 frame for starting another capture!");
return;
}
_isBeingCaptureScreen = true;
Rect rect = new Rect(screenPosition, imageSize);
StartCoroutine(_ReadPixelWithRect(rect, onCapturedCallback, null, null, true));
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a Sprite in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void Capture_Sprite(Vector2 screenPosition, Vector2 imageSize, Action<Sprite> onCapturedCallback = null)
{
if (_isBeingCaptureScreen)
{
Debug.LogWarning("Screenshot being captured, please wait for at least 1 frame for starting another capture!");
return;
}
_isBeingCaptureScreen = true;
Rect rect = new Rect(screenPosition, imageSize);
StartCoroutine(_ReadPixelWithRect(rect, null, onCapturedCallback, null, true));
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a RenderTexture in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void Capture_RenderTexture(Vector2 screenPosition, Vector2 imageSize, Action<RenderTexture> onCapturedCallback = null)
{
if (_isBeingCaptureScreen)
{
Debug.LogWarning("Screenshot being captured, please wait for at least 1 frame for starting another capture!");
return;
}
_isBeingCaptureScreen = true;
Rect rect = new Rect(screenPosition, imageSize);
StartCoroutine(_ReadPixelWithRect(rect, null, null, onCapturedCallback, true));
}
private Rect _ConstraintRectWithScreen(Rect rect)
{
int ScreenWidth = Screen.width;
int ScreenHeight = Screen.height;
// Size correction
if (rect.width > ScreenWidth) rect.size = new Vector2(ScreenWidth, rect.height);
if (rect.height > ScreenHeight) rect.size = new Vector2(rect.width, ScreenHeight);
// Position correction
if (rect.x + rect.width / 2 > ScreenWidth)
rect.position = new Vector2(rect.x - (rect.x + rect.width / 2 - ScreenWidth), rect.y);
if (rect.x - rect.width / 2 < 0)
rect.position = new Vector2(rect.x + (rect.width / 2 - rect.x), rect.y);
if (rect.y + rect.height / 2 > ScreenHeight)
rect.position = new Vector2(rect.x, rect.y - (rect.y + rect.height / 2 - ScreenHeight));
if (rect.y - rect.height / 2 < 0)
rect.position = new Vector2(rect.x, rect.y + (rect.height / 2 - rect.y));
UpdateDebugText("Capture position: " + rect.position + " | imageSize: " + rect.size);
return rect;
}
/// <summary>
/// Capture image with the view of the target camera. Return a Texture2D in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public void CaptureWithCamera(Camera camera, Action<Texture2D> onCapturedCallback = null, int width = 0, int height = 0)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, onCapturedCallback, null, null);
}, width, height);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a Sprite in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public void CaptureWithCamera_Sprite(Camera camera, Action<Sprite> onCapturedCallback = null, int width = 0, int height = 0)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, null, onCapturedCallback, null);
}, width, height);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public void CaptureWithCamera_RenderTexture(Camera camera, Action<RenderTexture> onCapturedCallback = null, int width = 0, int height = 0)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, null, null, onCapturedCallback);
}, width, height);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a Texture2D in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">Apply this scale to capture image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureWithCamera(Camera camera, float scale, Action<Texture2D> onCapturedCallback = null)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, onCapturedCallback, null, null);
}, scale);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a Sprite in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">Apply this scale to capture image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureWithCamera_Sprite(Camera camera, float scale, Action<Sprite> onCapturedCallback = null)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, null, onCapturedCallback, null);
}, scale);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">Apply this scale to capture image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureWithCamera_RenderTexture(Camera camera, float scale, Action<RenderTexture> onCapturedCallback = null)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((Texture2D tex) =>
{
_OnCallbacks(tex, null, null, onCapturedCallback);
}, scale);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback. This is a faster method if you want RenderTexture only.
/// (*** This method will Not create Texture2D or Sprite, even when you access the GetCurrentTexture or GetCurrentSprite methods, or in the MainOnCaptured callback)
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On captured callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public void CaptureRenderTextureWithCamera(Camera camera, Action<RenderTexture> onCapturedCallback = null, int width = 0, int height = 0)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((RenderTexture rTex) =>
{
_renderTexture = rTex;
if (onCapturedCallback != null) onCapturedCallback(_renderTexture);
if (m_MainOnCaptured != null) m_MainOnCaptured.Invoke();
}, width, height);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback. This is a faster method if you want RenderTexture only.
/// (*** This method will Not create Texture2D or Sprite, even when you access the GetCurrentTexture or GetCurrentSprite methods, or in the MainOnCaptured callback)
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">Apply this scale to capture image. (Scale the image size down to the minimum of 0.1X and up to 4X)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public void CaptureRenderTextureWithCamera(Camera camera, float scale, Action<RenderTexture> onCapturedCallback = null)
{
UpdateDebugText(camera.name + " rect: " + camera.pixelWidth + " x " + camera.pixelHeight);
CameraRenderBase cameraBase = RegisterRenderCamera(camera);
if (cameraBase != null)
{
cameraBase.SetOnCaptureCallback((RenderTexture rTex) =>
{
_renderTexture = rTex;
if (onCapturedCallback != null) onCapturedCallback(_renderTexture);
if (m_MainOnCaptured != null) m_MainOnCaptured.Invoke();
}, scale);
}
else
{
Debug.LogWarning("Require this camera to be registered with method RegisterRenderCamera!");
}
}
/// <summary>
/// Get the currently stored Texture2D.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public Texture2D GetCurrentTexture()
{
return _texture2D;
}
/// <summary>
/// Return the sprite that converts from the current stored texture2D.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public Sprite GetCurrentSprite()
{
if (_cachedSprite && _cachedSprite.texture == _texture2D) return _cachedSprite;
if (_cachedSprite) Destroy(_cachedSprite);
_cachedSprite = ToSprite(GetCurrentTexture());
return _cachedSprite;
}
private Sprite _cachedSprite = null;
/// <summary>
/// Get the currently stored RenderTexture.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public RenderTexture GetCurrentRenderTexture()
{
if (_renderTexture && _cachedTexture2D == _texture2D) return _renderTexture;
_cachedTexture2D = _texture2D;
_renderTexture = new RenderTexture(_texture2D.width, _texture2D.height, 24);
Graphics.Blit(_texture2D, _renderTexture);
return _renderTexture;
}
private Texture2D _cachedTexture2D = null;
private void _OnCallbacks(Texture2D texture2D, Action<Texture2D> onCapturedTexture2D, Action<Sprite> onCapturedSprite, Action<RenderTexture> onCapturedRenderTexture)
{
_texture2D = texture2D;
if (onCapturedTexture2D != null) onCapturedTexture2D(GetCurrentTexture());
if (onCapturedSprite != null) onCapturedSprite(GetCurrentSprite());
if (onCapturedRenderTexture != null) onCapturedRenderTexture(GetCurrentRenderTexture());
if (m_MainOnCaptured != null) m_MainOnCaptured.Invoke();
}
private void _ProceedReadPixels(Rect targetRect, Action<Texture2D> onCapturedTexture2D, Action<Sprite> onCapturedSprite, Action<RenderTexture> onCapturedRenderTexture)
{
// Size correction for target rect
if (targetRect.width > Screen.width) targetRect.width = Screen.width;
if (targetRect.height > Screen.height) targetRect.height = Screen.height;
_texture2D = new Texture2D((int)targetRect.width, (int)targetRect.height, TextureFormat.RGB24, false);
Rect rect = new Rect(targetRect.position.x - targetRect.width / 2, targetRect.position.y - targetRect.height / 2, targetRect.width, targetRect.height);
_texture2D.ReadPixels(rect, 0, 0);
_texture2D.Apply();
_isBeingCaptureScreen = false;
_OnCallbacks(_texture2D, onCapturedTexture2D, onCapturedSprite, onCapturedRenderTexture);
UpdateDebugText("Capture screenPosition: (" + targetRect.position.x + ", " + targetRect.position.y + ") | imageSize: (" + targetRect.width + ", " + targetRect.height + ")");
}
private IEnumerator _TakeFullscreen(Action<Texture2D> onCapturedTexture2D, Action<Sprite> onCapturedSprite, Action<RenderTexture> onCapturedRenderTexture)
{
// Ensure to Read Pixels inside drawing frame
yield return new WaitForEndOfFrame();
Rect targetRect = new Rect(Screen.width / 2, Screen.height / 2, Screen.width, Screen.height);
_ProceedReadPixels(targetRect, onCapturedTexture2D, onCapturedSprite, onCapturedRenderTexture);
}
private IEnumerator _ReadPixelWithRect(Rect targetRect, Action<Texture2D> onCapturedTexture2D, Action<Sprite> onCapturedSprite, Action<RenderTexture> onCapturedRenderTexture, bool constraintTargetRectWithScreen = false)
{
// Ensure to Read Pixels inside drawing frame
yield return new WaitForEndOfFrame();
if (constraintTargetRectWithScreen) targetRect = _ConstraintRectWithScreen(targetRect);
_ProceedReadPixels(targetRect, onCapturedTexture2D, onCapturedSprite, onCapturedRenderTexture);
}
/// <summary>
/// Attach a camera render script on the camera to capture image from camera.
/// </summary>
/// <param name="camera">Target Camera.</param>
public CameraRenderBase RegisterRenderCamera(Camera camera)
{
switch (m_RenderMode)
{
case RenderMode.OnRenderImage:
if (camera.gameObject.GetComponent<CameraOnUpdateRender>() != null)
{
camera.gameObject.GetComponent<CameraOnUpdateRender>().Clear();
}
if (camera.gameObject.GetComponent<CameraOnRender>() == null)
{
camera.gameObject.AddComponent<CameraOnRender>();
}
break;
case RenderMode.OnUpdateRender:
if (camera.gameObject.GetComponent<CameraOnRender>() != null)
{
camera.gameObject.GetComponent<CameraOnRender>().Clear();
}
if (camera.gameObject.GetComponent<CameraOnUpdateRender>() == null)
{
camera.gameObject.AddComponent<CameraOnUpdateRender>().m_AntiAliasingLevel = m_AntiAliasingLevel;
}
else
{
camera.gameObject.GetComponent<CameraOnUpdateRender>().m_AntiAliasingLevel = m_AntiAliasingLevel;
}
break;
}
return camera.GetComponent<CameraRenderBase>();
}
/// <summary>
/// Clear the instance of camera render and remove the script.
/// </summary>
/// <param name="camera">Target Camera.</param>
public void UnRegisterRenderCamera(Camera camera)
{
if (camera != null && camera.gameObject.GetComponent<CameraOnRender>() != null)
{
camera.gameObject.GetComponent<CameraOnRender>().Clear();
}
if (camera != null && camera.gameObject.GetComponent<CameraOnUpdateRender>() != null)
{
camera.gameObject.GetComponent<CameraOnUpdateRender>().Clear();
}
}
/// <summary> Clear the instance of camera render on all cameras, and remove the script. </summary>
public void UnRegisterAllRenderCameras()
{
Camera[] cameras = Camera.allCameras;
if (cameras != null)
{
foreach (Camera cam in cameras)
{
UnRegisterRenderCamera(cam);
}
}
}
#region ----- Static Methods -----
/// <summary> Set the RenderMode for capturing image using camera. (For camera capture methods Only) </summary>
public static void SetRenderMode(RenderMode renderMode)
{
Instance.m_RenderMode = renderMode;
}
/// <summary>
/// [Camera capture methods Only] The anti-aliasing level for the resulting texture,
/// the greater value results in the edges of the image look smoother. Available value: 1(OFF), 2, 4, 8.
/// The greater value will increase the memory consumption for the result texture, please adjust the values as need.
/// (This value will not be applied if your project AntiAliasing level is enabled and greater)
/// </summary>
public static int AntiAliasingLevel
{
get
{
return Instance.m_AntiAliasingLevel;
}
set
{
Instance.m_AntiAliasingLevel = value;
}
}
/// <summary>
/// Get the currently stored Texture2D.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public static Texture2D CurrentTexture
{
get
{
return Instance.GetCurrentTexture();
}
}
/// <summary>
/// Return the sprite that converts from the current texture2D.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public static Sprite CurrentSprite
{
get
{
return Instance.GetCurrentSprite();
}
}
/// <summary>
/// Get the currently stored RenderTexture.
/// (If you did not take any screenshot before, this will return a null)
/// </summary>
public static RenderTexture CurrentRenderTexture
{
get
{
return Instance.GetCurrentRenderTexture();
}
}
/// <summary>
/// Set the main onCaptured callback to be invoked by all capture methods.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public static void iSetMainOnCapturedCallback(Action mainOnCaptured, bool clearExistingCallbacks = true)
{
Instance.SetMainOnCapturedCallback(mainOnCaptured, clearExistingCallbacks);
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return a Texture2D in the callback, at each capture.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public static void iSetMainOnCapturedCallback(Action<Texture2D> mainOnCaptured, bool clearExistingCallbacks = true)
{
Instance.SetMainOnCapturedCallback(mainOnCaptured, clearExistingCallbacks);
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return a Sprite in the callback, at each capture.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public static void iSetMainOnCapturedCallback(Action<Sprite> mainOnCaptured, bool clearExistingCallbacks = true)
{
Instance.SetMainOnCapturedCallback(mainOnCaptured, clearExistingCallbacks);
}
/// <summary>
/// Set the main onCaptured callback for receiving all images from all capture methods. Return a RenderTexture in the callback, at each capture.
/// </summary>
/// <param name="mainOnCaptured">The callback to be fired at each capture.</param>
/// <param name="clearExistingCallbacks">If 'true', remove all the callbacks that added before, i.e. replace them with the new callback. Else add the new callback at the end of the existing callbacks.</param>
public static void iSetMainOnCapturedCallback(Action<RenderTexture> mainOnCaptured, bool clearExistingCallbacks = true)
{
Instance.SetMainOnCapturedCallback(mainOnCaptured, clearExistingCallbacks);
}
/// <summary>
/// Capture the full screen, return a Texture2D in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureScreen(Action<Texture2D> onCapturedCallback = null)
{
Instance.CaptureScreen(onCapturedCallback);
}
/// <summary>
/// Capture the full screen, return a Sprite in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureScreen_Sprite(Action<Sprite> onCapturedCallback = null)
{
Instance.CaptureScreen_Sprite(onCapturedCallback);
}
/// <summary>
/// Capture the full screen, return a RenderTexture in the callback.
/// </summary>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureScreen_RenderTexture(Action<RenderTexture> onCapturedCallback = null)
{
Instance.CaptureScreen_RenderTexture(onCapturedCallback);
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a Texture2D in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCapture(Vector2 screenPosition, Vector2 imageSize, Action<Texture2D> onCapturedCallback = null)
{
Instance.Capture(screenPosition, imageSize, onCapturedCallback);
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a Sprite in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCapture_Sprite(Vector2 screenPosition, Vector2 imageSize, Action<Sprite> onCapturedCallback = null)
{
Instance.Capture_Sprite(screenPosition, imageSize, onCapturedCallback);
}
/// <summary>
/// Capture a portion of the screen at specific screen position, return a RenderTexture in the callback.
/// </summary>
/// <param name="screenPosition">Screen position.</param>
/// <param name="imageSize">The target image size.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCapture_RenderTexture(Vector2 screenPosition, Vector2 imageSize, Action<RenderTexture> onCapturedCallback = null)
{
Instance.Capture_RenderTexture(screenPosition, imageSize, onCapturedCallback);
}
/// <summary>
/// Capture image with the view of the target camera. Return a Texture2D in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public static void iCaptureWithCamera(Camera camera, Action<Texture2D> onCapturedCallback = null, int width = 0, int height = 0)
{
Instance.CaptureWithCamera(camera, onCapturedCallback, width, height);
}
/// <summary>
/// Capture image with the view of the target camera. Return a Sprite in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public static void iCaptureWithCamera_Sprite(Camera camera, Action<Sprite> onCapturedCallback = null, int width = 0, int height = 0)
{
Instance.CaptureWithCamera_Sprite(camera, onCapturedCallback, width, height);
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public static void iCaptureWithCamera_RenderTexture(Camera camera, Action<RenderTexture> onCapturedCallback = null, int width = 0, int height = 0)
{
Instance.CaptureWithCamera_RenderTexture(camera, onCapturedCallback, width, height);
}
/// <summary>
/// Capture image with the view of the target camera. Return a Texture2D in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">The value uses to scale the image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureWithCamera(Camera camera, float scale, Action<Texture2D> onCapturedCallback = null)
{
Instance.CaptureWithCamera(camera, scale, onCapturedCallback);
}
/// <summary>
/// Capture image with the view of the target camera. Return a Sprite in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">The value uses to scale the image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureWithCamera_Sprite(Camera camera, float scale, Action<Sprite> onCapturedCallback = null)
{
Instance.CaptureWithCamera_Sprite(camera, scale, onCapturedCallback);
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">The value uses to scale the image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
public static void iCaptureWithCamera_RenderTexture(Camera camera, float scale, Action<RenderTexture> onCapturedCallback = null)
{
Instance.CaptureWithCamera_RenderTexture(camera, scale, onCapturedCallback);
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="onCapturedCallback">On Captured Callback.</param>
/// <param name="width">Texture target width.</param>
/// <param name="height">Texture target height.</param>
public static void iCaptureRenderTextureWithCamera(Camera camera, Action<RenderTexture> onCapturedCallback = null, int width = 0, int height = 0)
{
Instance.CaptureRenderTextureWithCamera(camera, onCapturedCallback, width, height);
}
/// <summary>
/// Capture image with the view of the target camera. Return a RenderTexture in the callback.
/// </summary>
/// <param name="camera">Target Camera.</param>
/// <param name="scale">The value uses to scale the image. (Scale the image size down to the minimum of 0.1X and up to 4X, the maximum texture size depends on device GPU)</param>
/// <param name="onCapturedCallback">On captured callback, return the captured RenderTexture.</param>
public static void iCaptureRenderTextureWithCamera(Camera camera, float scale, Action<RenderTexture> onCapturedCallback = null)
{
Instance.CaptureRenderTextureWithCamera(camera, scale, onCapturedCallback);
}
/// <summary>
/// Attach a camera render script on the camera to capture image from camera.
/// </summary>
/// <param name="camera">Target Camera.</param>
public static void iRegisterRenderCamera(Camera camera)
{
Instance.RegisterRenderCamera(camera);
}
/// <summary>
/// Clear the instance of camera render and remove the script.
/// </summary>
/// <param name="camera">Target Camera.</param>
public static void iUnRegisterRenderCamera(Camera camera)
{
Instance.UnRegisterRenderCamera(camera);
}
/// <summary>
/// Clear the instance of camera render on all cameras, and remove the script.
/// </summary>
public static void iUnRegisterAllRenderCameras()
{
Instance.UnRegisterAllRenderCameras();
}
/// <summary>
/// Clear the instance of ScreenshotHelper:
/// Destroy the stored textures, remove callbacks, remove script from camera.
/// </summary>
public static void iClear(bool clearCallback = true, bool clearTextures = true)
{
Instance.Clear(clearCallback, clearTextures);
}
#endregion
#region ----- Others -----
public void UpdateDebugText(string text)
{
if(m_DebugText != null)
{
Debug.Log(text);
m_DebugText.text = text;
}
}
/// <summary> Create a Sprite with the provided Texture2D. </summary>
public static Sprite ToSprite(Texture2D texture)
{
if(texture == null) return null;
Vector2 pivot = new Vector2(0.5f, 0.5f);
float pixelPerUnit = 100;
return Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), pivot, pixelPerUnit);
}
/// <summary>
/// Destroy the target Texture2D.
/// Optional to create a 1x1 pixel texture to replace it (for preventing the warnings in some cases, Metal: Fragment shader missing texture...).
/// </summary>
public static void ClearTexture2D(ref Texture2D texture, bool replaceWithMinimumTexture = false)
{
Destroy(texture);
if (replaceWithMinimumTexture) texture = new Texture2D(1, 1);
}
/// <summary>
/// Destroy the target RenderTexture.
/// Optional to create a 1x1 pixel texture to replace it (for preventing the warnings in some cases, Metal: Fragment shader missing texture...).
/// </summary>
public static void ClearRenderTexture(ref RenderTexture texture, bool replaceWithMinimumTexture = false)
{
Destroy(texture);
if (replaceWithMinimumTexture) texture = new RenderTexture(1, 1, 24);
}
#endregion
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d32b80267226945ab8d1a32f285b2397
timeCreated: 1507614495
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 130885
packageName: Screenshot Helper Free
packageVersion: 1.3.8
assetPath: Assets/SWAN Dev/ScreenshotHelper/Scripts/ScreenshotHelper.cs
uploadId: 673764