Skip to content

Commit

Permalink
#modify 修改Shader
Browse files Browse the repository at this point in the history
  • Loading branch information
falseeeeeeeeee committed Mar 13, 2024
1 parent b6ff600 commit d15aba7
Show file tree
Hide file tree
Showing 95 changed files with 3,886 additions and 4,866 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions ShaderLib_2022/Assets/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

90 changes: 90 additions & 0 deletions ShaderLib_2022/Assets/Editor/ScreenShotWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System.IO;
using UnityEditor;
using UnityEngine;

public class ScreenShotWindow : EditorWindow
{
private Camera m_Camera;
private string filePath;
private bool m_IsEnableAlpha = false;
private CameraClearFlags m_CameraClearFlags;

[MenuItem("Tools/屏幕截图")]
private static void Init()
{
ScreenShotWindow window = GetWindowWithRect<ScreenShotWindow>(new Rect(0, 0, 300, 150));
window.titleContent = new GUIContent("屏幕截图");
window.Show();
}

private void OnGUI()
{
EditorGUILayout.Space();
m_Camera = EditorGUILayout.ObjectField("选择摄像机", m_Camera, typeof(Camera), true) as Camera;

if (GUILayout.Button("选择保存位置"))
{
filePath = EditorUtility.OpenFolderPanel("", "", "");
}

m_IsEnableAlpha = EditorGUILayout.Toggle("是否使用纯色背景", m_IsEnableAlpha); //是否开启透明通道
EditorGUILayout.Space();
if (GUILayout.Button("单摄像机截图"))
{
TakeShot();
}
if (GUILayout.Button("窗口截图(含UI)"))
{
string fileName = filePath + "/" + $"{System.DateTime.Now:yyyy-MM-dd_HH-mm-ss}" + ".png";
ScreenCapture.CaptureScreenshot(fileName);
}
EditorGUILayout.Space();
if (GUILayout.Button("打开导出文件夹"))
{
if (string.IsNullOrEmpty(filePath))
{
Debug.LogError("<color=red>" + "没有选择截图保存位置" + "</color>");
return;
}
Application.OpenURL("file://" + filePath);
}
}

private void TakeShot()
{
if (m_Camera == null)
{
Debug.LogError("<color=red>" + "没有选择摄像机" + "</color>");
return;
}

if (string.IsNullOrEmpty(filePath))
{
Debug.LogError("<color=red>" + "没有选择截图保存位置" + "</color>");
return;
}

m_CameraClearFlags = m_Camera.clearFlags;
if (m_IsEnableAlpha)
{
m_Camera.clearFlags = CameraClearFlags.Depth;
}

int resolutionX = (int)Handles.GetMainGameViewSize().x;
int resolutionY = (int)Handles.GetMainGameViewSize().y;
RenderTexture rt = new RenderTexture(resolutionX, resolutionY, 24);
m_Camera.targetTexture = rt;
Texture2D screenShot = new Texture2D(resolutionX, resolutionY, TextureFormat.ARGB32, false);
m_Camera.Render();
RenderTexture.active = rt;
screenShot.ReadPixels(new Rect(0, 0, resolutionX, resolutionY), 0, 0);
m_Camera.targetTexture = null;
RenderTexture.active = null;
m_Camera.clearFlags = m_CameraClearFlags;
//Destroy(rt);
byte[] bytes = screenShot.EncodeToPNG();
string fileName = filePath + "/" + $"{System.DateTime.Now:yyyy-MM-dd_HH-mm-ss}" + ".png";
File.WriteAllBytes(fileName, bytes);
Debug.Log("截图成功");
}
}
11 changes: 11 additions & 0 deletions ShaderLib_2022/Assets/Editor/ScreenShotWindow.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ShaderLib_2022/Assets/Settings/URP/URP-HighFidelity.asset
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ MonoBehaviour:
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_SoftShadowQuality: 3
m_AdditionalLightsCookieResolution: 4096
m_AdditionalLightsCookieFormat: 4
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_SupportsDynamicBatching: 1
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_SupportsLightLayers: 1
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
Expand Down
Loading

0 comments on commit d15aba7

Please sign in to comment.