浏览代码

Added Screenshot Manager

/main
Thomas ICHÉ 5 年前
当前提交
cb40941b
共有 4 个文件被更改,包括 107 次插入0 次删除
  1. 50
      Resources/Default_ScreenshotManager.prefab
  2. 7
      Resources/Default_ScreenshotManager.prefab.meta
  3. 39
      Runtime/Managers/Implementations/ScreenshotManager.cs
  4. 11
      Runtime/Managers/Implementations/ScreenshotManager.cs.meta

50
Resources/Default_ScreenshotManager.prefab


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3458548586705312115
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4274681909587443583}
- component: {fileID: 4200313255308878045}
m_Layer: 0
m_Name: Default_ScreenshotManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4274681909587443583
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3458548586705312115}
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 &4200313255308878045
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3458548586705312115}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 82e5ad90f67f2ab4f8c09dedbb3beda3, type: 3}
m_Name:
m_EditorClassIdentifier:
ScreenshotKeyCode: 292
SuperSize: 1
Prefix: Screenshot
OnBeforeScreenshot: []
OnAfterScreenshot: []

7
Resources/Default_ScreenshotManager.prefab.meta


fileFormatVersion: 2
guid: d5d0f799eba3c5247b17338b1be98808
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

39
Runtime/Managers/Implementations/ScreenshotManager.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients
{
[ManagerDefaultPrefab("ScreenshotManager")]
public class ScreenshotManager : Manager
{
[Header("Capture")]
public KeyCode ScreenshotKeyCode = KeyCode.F11;
[Range(1, 5)]
public int SuperSize = 1;
[Header("File name")]
public string Prefix = "Screenshot";
[Header("Actions")]
[ReorderableList]
public Callable[] OnBeforeScreenshot;
[ReorderableList]
public Callable[] OnAfterScreenshot;
public void Update()
{
if (Input.GetKeyDown(ScreenshotKeyCode))
{
var now = System.DateTime.Now;
Callable.Call(OnBeforeScreenshot);
string path = $"{Application.dataPath}/../{Prefix}-{now.Year}{now.Month}{now.Day}-{now.Hour}{now.Minute}{now.Second}{now.Millisecond}.png";
Debug.Log($"Capturing Screenshot (Supersampled to {SuperSize}x) to the file : {path}");
ScreenCapture.CaptureScreenshot(path, SuperSize);
Callable.Call(OnAfterScreenshot);
}
}
}
}

11
Runtime/Managers/Implementations/ScreenshotManager.cs.meta


fileFormatVersion: 2
guid: 82e5ad90f67f2ab4f8c09dedbb3beda3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存