增加A2WToolBox工具集,增加Launch场景核LaunchPanel

This commit is contained in:
Wurui
2025-11-08 11:06:48 +08:00
parent 3e92e5684a
commit 3b43829e85
726 changed files with 87807 additions and 215 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace A2W
{
public static class Utils
{
public static T GetRandomEnumValue<T>() where T : System.Enum
{
T[] values = (T[])System.Enum.GetValues(typeof(T));
return values[UnityEngine.Random.Range(0, values.Length)];
}
// 调用示例MyEnum randomValue = GetRandomEnumValue<MyEnum>();
public static Texture2D CaptureScreenshot(Rect rect)
{
Texture2D screenshot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false);
screenshot.ReadPixels(rect, 0, 0);
screenshot.Apply();
return screenshot;
}
public static Texture2D CaptureCamera(Camera camera, Rect rect)
{
RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);
camera.targetTexture = rt;
camera.Render();
// 可以做多个相机
RenderTexture.active = rt;
Texture2D screenshot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false);
screenshot.ReadPixels(rect, 0, 0);
screenshot.Apply();
camera.targetTexture = null;
RenderTexture.active = null;
GameObject.Destroy(rt);
return screenshot;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3faa0dd1cfec1ea41aefeb649ef4fb30
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: