DDDD
This commit is contained in:
@@ -7490,7 +7490,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -60.000122}
|
||||
m_AnchoredPosition: {x: 0, y: -60}
|
||||
m_SizeDelta: {x: 70, y: -120}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &56942380
|
||||
@@ -84095,7 +84095,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -60}
|
||||
m_AnchoredPosition: {x: 0, y: -60.000244}
|
||||
m_SizeDelta: {x: 20, y: -120}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &744733221
|
||||
@@ -134448,7 +134448,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -60}
|
||||
m_AnchoredPosition: {x: 0, y: -60.000244}
|
||||
m_SizeDelta: {x: 20, y: -120}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!114 &1162464619
|
||||
@@ -227071,6 +227071,50 @@ MonoBehaviour:
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!1 &1950491582
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1950491584}
|
||||
- component: {fileID: 1950491583}
|
||||
m_Layer: 0
|
||||
m_Name: ScreenshotCapturer
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &1950491583
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1950491582}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0c9b2dc114877d3479675dbe81e42739, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!4 &1950491584
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1950491582}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 555.19385, y: 829.94635, z: -225.59857}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1951076298
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -257611,3 +257655,4 @@ SceneRoots:
|
||||
- {fileID: 519420032}
|
||||
- {fileID: 2059699478}
|
||||
- {fileID: 1278188414}
|
||||
- {fileID: 1950491584}
|
||||
|
||||
53
Assets/Scripts/Utils/ScreenshotCapturer.cs
Normal file
53
Assets/Scripts/Utils/ScreenshotCapturer.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
public class ScreenshotCapturer : MonoBehaviour
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.F12))
|
||||
{
|
||||
CaptureScreenshot();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void CaptureScreenshot()
|
||||
{
|
||||
// 获取Assets上一级目录路径
|
||||
string projectPath = Directory.GetParent(Application.dataPath).FullName;
|
||||
string screenshotDir = Path.Combine(projectPath, "Screenshots");
|
||||
|
||||
// 如果目录不存在则创建
|
||||
if (!Directory.Exists(screenshotDir))
|
||||
{
|
||||
Directory.CreateDirectory(screenshotDir);
|
||||
}
|
||||
|
||||
// 生成基于时间的文件名
|
||||
string timestamp = System.DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
|
||||
string filename = $"Screenshot_{timestamp}.png";
|
||||
string fullPath = Path.Combine(screenshotDir, filename);
|
||||
|
||||
// 确保文件名唯一
|
||||
int counter = 1;
|
||||
while (File.Exists(fullPath))
|
||||
{
|
||||
filename = $"Screenshot_{timestamp}_{counter}.png";
|
||||
fullPath = Path.Combine(screenshotDir, filename);
|
||||
counter++;
|
||||
}
|
||||
|
||||
// 截取屏幕
|
||||
ScreenCapture.CaptureScreenshot(fullPath);
|
||||
Debug.Log($"Screenshot saved to: {fullPath}");
|
||||
|
||||
// 刷新资源数据库(如果需要)
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
2
Assets/Scripts/Utils/ScreenshotCapturer.cs.meta
Normal file
2
Assets/Scripts/Utils/ScreenshotCapturer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c9b2dc114877d3479675dbe81e42739
|
||||
Reference in New Issue
Block a user