阶段性完成
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class Blitter
|
||||
{
|
||||
static Mesh fullscreenTriangle;
|
||||
|
||||
/// <summary>
|
||||
/// A fullscreen triangle mesh.
|
||||
/// </summary>
|
||||
static Mesh FullscreenTriangle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (fullscreenTriangle != null)
|
||||
return fullscreenTriangle;
|
||||
|
||||
fullscreenTriangle = new Mesh { name = "Fullscreen Triangle" };
|
||||
fullscreenTriangle.SetVertices(
|
||||
new List<Vector3> {
|
||||
new Vector3(-1f, -1f, 0f),
|
||||
new Vector3(-1f, 3f, 0f),
|
||||
new Vector3(3f, -1f, 0f)
|
||||
}
|
||||
);
|
||||
fullscreenTriangle.SetIndices(new[] { 0, 1, 2 }, MeshTopology.Triangles, 0, false);
|
||||
fullscreenTriangle.UploadMeshData(false);
|
||||
|
||||
return fullscreenTriangle;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Blit(
|
||||
CommandBuffer cmd,
|
||||
RenderTargetIdentifier source,
|
||||
RenderTargetIdentifier destination,
|
||||
Material material,
|
||||
int passIndex,
|
||||
MaterialPropertyBlock propertyBlock = null,
|
||||
Rect viewport = default
|
||||
)
|
||||
{
|
||||
cmd.SetGlobalTexture(ShaderID.MAIN_TEX, source);
|
||||
cmd.SetRenderTarget(new RenderTargetIdentifier(destination, 0, CubemapFace.Unknown, -1),
|
||||
RenderBufferLoadAction.DontCare,
|
||||
RenderBufferStoreAction.Store,
|
||||
RenderBufferLoadAction.DontCare,
|
||||
RenderBufferStoreAction.DontCare);
|
||||
if (viewport.width != 0)
|
||||
cmd.SetViewport(viewport);
|
||||
|
||||
if (SystemInfo.graphicsShaderLevel >= 30
|
||||
#if !UNITY_2023_1_OR_NEWER
|
||||
&& SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2
|
||||
#endif
|
||||
)
|
||||
cmd.DrawProcedural(Matrix4x4.identity, material, passIndex, MeshTopology.Triangles, 3, 1, propertyBlock);
|
||||
else
|
||||
cmd.DrawMesh(FullscreenTriangle, Matrix4x4.identity, material, 0, passIndex, propertyBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 263b05d298234228b5e7ccfae5ac0b69
|
||||
timeCreated: 1730191817
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/Blitter.cs
|
||||
uploadId: 824068
|
||||
@@ -0,0 +1,73 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class BlurExecutor
|
||||
{
|
||||
static readonly int[] TEMP_RT = new int[14];
|
||||
|
||||
static BlurExecutor()
|
||||
{
|
||||
for (var i = 0; i < TEMP_RT.Length; i++)
|
||||
{
|
||||
TEMP_RT[i] = Shader.PropertyToID($"TI_intermediate_rt_{i}");
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct BlurExecutionData
|
||||
{
|
||||
public readonly RenderTargetIdentifier sourceTex;
|
||||
public readonly TranslucentImageSource blurSource;
|
||||
public readonly IBlurAlgorithm blurAlgorithm;
|
||||
|
||||
public BlurExecutionData(
|
||||
RenderTargetIdentifier sourceTex,
|
||||
TranslucentImageSource blurSource,
|
||||
IBlurAlgorithm blurAlgorithm
|
||||
)
|
||||
{
|
||||
this.sourceTex = sourceTex;
|
||||
this.blurSource = blurSource;
|
||||
this.blurAlgorithm = blurAlgorithm;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ExecuteBlurWithTempTextures(CommandBuffer cmd, ref BlurExecutionData data)
|
||||
{
|
||||
var desc = data.blurSource.BlurredScreen.descriptor;
|
||||
desc.msaaSamples = 1;
|
||||
desc.useMipMap = false;
|
||||
desc.depthBufferBits = 0;
|
||||
|
||||
var cropRegionSize = data.blurSource.BlurRegion.size;
|
||||
var scratchesCount = data.blurAlgorithm.GetScratchesCount(desc.width / cropRegionSize.x,
|
||||
desc.height / cropRegionSize.y);
|
||||
for (int i = 0; i < scratchesCount; i++)
|
||||
{
|
||||
data.blurAlgorithm.GetNextScratchDescriptor(ref desc);
|
||||
cmd.GetTemporaryRT(TEMP_RT[i], desc, FilterMode.Bilinear);
|
||||
data.blurAlgorithm.SetScratch(i, TEMP_RT[i]);
|
||||
}
|
||||
|
||||
{
|
||||
ExecuteBlur(cmd, ref data);
|
||||
}
|
||||
|
||||
for (int i = 0; i < scratchesCount; i++)
|
||||
cmd.ReleaseTemporaryRT(TEMP_RT[i]);
|
||||
}
|
||||
|
||||
public static void ExecuteBlur(CommandBuffer cmd, ref BlurExecutionData data)
|
||||
{
|
||||
var blurSource = data.blurSource;
|
||||
|
||||
data.blurAlgorithm.Blur(cmd,
|
||||
data.sourceTex,
|
||||
blurSource.BlurRegion,
|
||||
blurSource.ActiveRegion,
|
||||
blurSource.BackgroundFill,
|
||||
blurSource.BlurredScreen);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fff8a033240e1c4491e2587b6d285e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/BlurExecutor.cs
|
||||
uploadId: 824068
|
||||
@@ -0,0 +1,75 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class RectUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Fast approximate equal for rect position and size in range [0,1]
|
||||
/// </summary>
|
||||
internal static bool ApproximateEqual01(Rect a, Rect b)
|
||||
{
|
||||
return QuickApproximate01(a.x, b.x)
|
||||
&& QuickApproximate01(a.y, b.y)
|
||||
&& QuickApproximate01(a.width, b.width)
|
||||
&& QuickApproximate01(a.height, b.height);
|
||||
}
|
||||
|
||||
|
||||
private static bool QuickApproximate01(float a, float b)
|
||||
{
|
||||
const float epsilon01 = 5.9604644e-8f; // different between 1 and largest float < 1
|
||||
return Mathf.Abs(b - a) < epsilon01;
|
||||
}
|
||||
|
||||
public static Rect Intersect(Rect a, Rect b)
|
||||
{
|
||||
float xMin = Mathf.Max(a.xMin, b.xMin);
|
||||
float xMax = Mathf.Min(a.xMax, b.xMax);
|
||||
float yMin = Mathf.Max(a.yMin, b.yMin);
|
||||
float yMax = Mathf.Min(a.yMax, b.yMax);
|
||||
|
||||
if (xMin < xMax && yMin < yMax)
|
||||
{
|
||||
return new Rect(xMin, yMin, xMax - xMin, yMax - yMin);
|
||||
}
|
||||
|
||||
return Rect.zero;
|
||||
}
|
||||
|
||||
public static Rect Crop(Rect src, Rect cropRegion)
|
||||
{
|
||||
var rect = src;
|
||||
rect.x += cropRegion.x * rect.width;
|
||||
rect.y += cropRegion.y * rect.height;
|
||||
rect.width *= cropRegion.width;
|
||||
rect.height *= cropRegion.height;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
public static Vector4 ToMinMaxVector(Rect rect)
|
||||
{
|
||||
return new Vector4(rect.xMin,
|
||||
rect.yMin,
|
||||
rect.xMax,
|
||||
rect.yMax);
|
||||
}
|
||||
|
||||
public static Vector4 ToVector4(Rect rect)
|
||||
{
|
||||
return new Vector4(rect.xMin,
|
||||
rect.yMin,
|
||||
rect.width,
|
||||
rect.height);
|
||||
}
|
||||
|
||||
public static Rect Expand(Rect rect, Vector2 padding)
|
||||
{
|
||||
return new Rect(rect.x - padding.x,
|
||||
rect.y - padding.y,
|
||||
rect.width + 2 * padding.x,
|
||||
rect.height + 2 * padding.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29b4a2967894477c93934b7e21ce2d5b
|
||||
timeCreated: 1558521365
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/RectUtils.cs
|
||||
uploadId: 824068
|
||||
@@ -0,0 +1,179 @@
|
||||
// Due to the use of asmdef in the ../Editor folder, this class cannot be put there,
|
||||
// as then it cannot be referenced outside of the assembly
|
||||
// The Blur region GUI requires the use of OnGUI for interactivity,
|
||||
// so it cannot be completely done within the custom Editor either
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class ResizableScreenRect
|
||||
{
|
||||
const float BORDER_THICKNESS = 2;
|
||||
const float DRAG_EXTEND = 16;
|
||||
|
||||
delegate void DragHandlerDelegate(Vector2 delta, ref Rect rect);
|
||||
|
||||
static DragHandlerDelegate currentDragHandler;
|
||||
|
||||
static void DrawSquareFromCenter(Vector2 postion, float extent)
|
||||
{
|
||||
var v = Vector2.one * extent;
|
||||
GUI.DrawTexture(new Rect(postion - v, v * 2), Texture2D.whiteTexture);
|
||||
}
|
||||
|
||||
public static Rect Draw(Rect normalizedScreenRect, bool interactable = false)
|
||||
{
|
||||
var guiRect = normalizedScreenRect;
|
||||
guiRect.y = 1 - guiRect.y - guiRect.height;
|
||||
guiRect.x *= Screen.width;
|
||||
guiRect.width *= Screen.width;
|
||||
guiRect.y *= Screen.height;
|
||||
guiRect.height *= Screen.height;
|
||||
|
||||
var borderThickness = BORDER_THICKNESS * EditorGUIUtility.pixelsPerPoint;
|
||||
GUI.DrawTexture(new Rect(guiRect.x - borderThickness,
|
||||
guiRect.y - borderThickness,
|
||||
borderThickness,
|
||||
guiRect.height + borderThickness * 2),
|
||||
Texture2D.whiteTexture);
|
||||
GUI.DrawTexture(new Rect(guiRect.x,
|
||||
guiRect.y - borderThickness,
|
||||
guiRect.width + 1,
|
||||
borderThickness),
|
||||
Texture2D.whiteTexture);
|
||||
GUI.DrawTexture(new Rect(guiRect.xMax,
|
||||
guiRect.y - borderThickness,
|
||||
borderThickness,
|
||||
guiRect.height + borderThickness * 2),
|
||||
Texture2D.whiteTexture);
|
||||
GUI.DrawTexture(new Rect(guiRect.x,
|
||||
guiRect.yMax,
|
||||
guiRect.width + 1,
|
||||
borderThickness),
|
||||
Texture2D.whiteTexture);
|
||||
if (interactable)
|
||||
{
|
||||
var boxExtend = borderThickness * 2;
|
||||
DrawSquareFromCenter(guiRect.min, boxExtend);
|
||||
DrawSquareFromCenter(guiRect.max, boxExtend);
|
||||
DrawSquareFromCenter(new Vector2(guiRect.xMax, guiRect.yMin), boxExtend);
|
||||
DrawSquareFromCenter(new Vector2(guiRect.xMin, guiRect.yMax), boxExtend);
|
||||
}
|
||||
|
||||
if (interactable)
|
||||
guiRect = HandleEvent(guiRect);
|
||||
|
||||
|
||||
var result = guiRect;
|
||||
|
||||
result.x /= Screen.width;
|
||||
result.y /= Screen.height;
|
||||
result.width /= Screen.width;
|
||||
result.height /= Screen.height;
|
||||
result.y = 1 - result.y - result.height;
|
||||
|
||||
result.xMin = Mathf.Max(0, result.xMin);
|
||||
result.yMin = Mathf.Max(0, result.yMin);
|
||||
result.width = Mathf.Min(1, result.width);
|
||||
result.height = Mathf.Min(1, result.height);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static Rect HandleEvent(Rect guiRect)
|
||||
{
|
||||
var ev = Event.current;
|
||||
if (ev.type == EventType.MouseDown && ev.button == 0)
|
||||
{
|
||||
currentDragHandler = ChooseDragHandler(guiRect, ev.mousePosition);
|
||||
}
|
||||
else if (ev.type == EventType.MouseUp)
|
||||
{
|
||||
currentDragHandler = null;
|
||||
}
|
||||
else if (ev.type == EventType.MouseDrag)
|
||||
{
|
||||
currentDragHandler?.Invoke(ev.delta, ref guiRect);
|
||||
}
|
||||
|
||||
return guiRect;
|
||||
}
|
||||
|
||||
static DragHandlerDelegate ChooseDragHandler(Rect rect, Vector2 pointer)
|
||||
{
|
||||
float extend = DRAG_EXTEND * EditorGUIUtility.pixelsPerPoint;
|
||||
|
||||
bool PointerXNear(float point) => Mathf.Abs(point - pointer.x) <= extend;
|
||||
bool PointerYNear(float point) => Mathf.Abs(point - pointer.y) <= extend;
|
||||
|
||||
if (PointerXNear(rect.xMin))
|
||||
{
|
||||
if (PointerYNear(rect.yMin)) return DRAG_HANDLER_TOP_LEFT;
|
||||
if (PointerYNear(rect.yMax)) return DRAG_HANDLER_BOTTOM_LEFT;
|
||||
return DRAG_HANDLER_LEFT;
|
||||
}
|
||||
|
||||
if (PointerXNear(rect.xMax))
|
||||
{
|
||||
if (PointerYNear(rect.yMin)) return DRAG_HANDLER_TOP_RIGHT;
|
||||
if (PointerYNear(rect.yMax)) return DRAG_HANDLER_BOTTOM_RIGHT;
|
||||
return DRAG_HANDLER_RIGHT;
|
||||
}
|
||||
|
||||
if (PointerYNear(rect.yMin)) return DRAG_HANDLER_TOP;
|
||||
if (PointerYNear(rect.yMax)) return DRAG_HANDLER_BOTTOM;
|
||||
|
||||
if (!rect.Contains(pointer))
|
||||
return null;
|
||||
|
||||
return DRAG_HANDLER_CENTER;
|
||||
}
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_CENTER =
|
||||
(Vector2 delta, ref Rect rect) => { rect.position += delta; };
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_LEFT =
|
||||
(Vector2 delta, ref Rect rect) => { rect.xMin += delta.x; };
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_TOP =
|
||||
(Vector2 delta, ref Rect rect) => { rect.yMin += delta.y; };
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_BOTTOM =
|
||||
(Vector2 delta, ref Rect rect) => { rect.yMax += delta.y; };
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_RIGHT =
|
||||
(Vector2 delta, ref Rect rect) => { rect.xMax += delta.x; };
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_TOP_LEFT =
|
||||
(Vector2 delta, ref Rect rect) =>
|
||||
{
|
||||
rect.xMin += delta.x;
|
||||
rect.yMin += delta.y;
|
||||
};
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_TOP_RIGHT =
|
||||
(Vector2 delta, ref Rect rect) =>
|
||||
{
|
||||
rect.xMax += delta.x;
|
||||
rect.yMin += delta.y;
|
||||
};
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_BOTTOM_RIGHT =
|
||||
(Vector2 delta, ref Rect rect) =>
|
||||
{
|
||||
rect.xMax += delta.x;
|
||||
rect.yMax += delta.y;
|
||||
};
|
||||
|
||||
static readonly DragHandlerDelegate DRAG_HANDLER_BOTTOM_LEFT =
|
||||
(Vector2 delta, ref Rect rect) =>
|
||||
{
|
||||
rect.xMin += delta.x;
|
||||
rect.yMax += delta.y;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b71ecc50ad61ec745a62fe5d0c7f8810
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/ResizableScreenRect.cs
|
||||
uploadId: 824068
|
||||
@@ -0,0 +1,37 @@
|
||||
using LeTai.Paraform.Scaffold;
|
||||
using UnityEngine;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class ShaderID
|
||||
{
|
||||
public static readonly int BLUR_TEX = Shader.PropertyToID("_BlurTex");
|
||||
public static readonly int MAIN_TEX = Shader.PropertyToID("_MainTex");
|
||||
public static readonly int OFFSET = Shader.PropertyToID("_Offset");
|
||||
public static readonly int TARGET_SIZE = Shader.PropertyToID("_TargetSize");
|
||||
public static readonly int BACKGROUND_COLOR = Shader.PropertyToID("_BackgroundColor");
|
||||
public static readonly int CROP_REGION = Shader.PropertyToID("_CropRegion");
|
||||
public static readonly int IS_LAST = Shader.PropertyToID("_IsLast");
|
||||
// public static readonly int ENV_TEX = Shader.PropertyToID("_EnvTex");
|
||||
|
||||
public const string KW_BACKGROUND_MODE_COLORFUL = "_BACKGROUND_MODE_COLORFUL";
|
||||
public const string KW_BACKGROUND_MODE_NORMAL = "_BACKGROUND_MODE_NORMAL";
|
||||
public const string KW_BACKGROUND_MODE_OPAQUE = "_BACKGROUND_MODE_OPAQUE";
|
||||
|
||||
public static readonly int G_CANVAS_SCALE_FACTOR = ParaformMaterial.ShaderID.G_CANVAS_SCALE_FACTOR;
|
||||
|
||||
public const string REFRACTION_MODE_OFF = ParaformMaterial.ShaderID.REFRACTION_MODE_OFF;
|
||||
public const string REFRACTION_MODE_ON = ParaformMaterial.ShaderID.REFRACTION_MODE_ON;
|
||||
public const string REFRACTION_MODE_CHROMATIC = ParaformMaterial.ShaderID.REFRACTION_MODE_CHROMATIC;
|
||||
public static readonly int REFRACTIVE_INDEX_DUMMY = ParaformMaterial.ShaderID.REFRACTIVE_INDEX_DUMMY;
|
||||
public static readonly int CHROMATIC_DISPERSION_DUMMY = ParaformMaterial.ShaderID.CHROMATIC_DISPERSION_DUMMY;
|
||||
public static readonly int REFRACTIVE_INDEX_RATIOS = ParaformMaterial.ShaderID.REFRACTIVE_INDEX_RATIOS;
|
||||
|
||||
public const string USE_EDGE_GLINT = ParaformMaterial.ShaderID.USE_EDGE_GLINT;
|
||||
public static readonly int EDGE_GLINT_DIRECTIONS = ParaformMaterial.ShaderID.EDGE_GLINT_DIRECTIONS;
|
||||
public static readonly int EDGE_GLINT1_STRENGTH = ParaformMaterial.ShaderID.EDGE_GLINT1_STRENGTH;
|
||||
public static readonly int EDGE_GLINT2_STRENGTH = ParaformMaterial.ShaderID.EDGE_GLINT2_STRENGTH;
|
||||
public static readonly int EDGE_GLINT_WRAP_RAW = ParaformMaterial.ShaderID.EDGE_GLINT_WRAP_RAW;
|
||||
public static readonly int EDGE_GLINT_SHARPNESS_RAW = ParaformMaterial.ShaderID.EDGE_GLINT_SHARPNESS_RAW;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e531f31ceeeb4a2d99d46564b2754c17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/ShaderID.cs
|
||||
uploadId: 824068
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace LeTai.Asset.TranslucentImage
|
||||
{
|
||||
public static class Shims
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T FindObjectOfType<T>(bool includeInactive = false, bool sorted = true) where T : Object
|
||||
{
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
if (sorted)
|
||||
return Object.FindFirstObjectByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude);
|
||||
else
|
||||
return Object.FindAnyObjectByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude);
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
return Object.FindObjectOfType<T>(includeInactive);
|
||||
#else
|
||||
return Object.FindObjectOfType<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T[] FindObjectsOfType<T>(bool includeInactive = false) where T : Object
|
||||
{
|
||||
#if UNITY_2023_1_OR_NEWER
|
||||
return Object.FindObjectsByType<T>(includeInactive ? FindObjectsInactive.Include : FindObjectsInactive.Exclude,
|
||||
FindObjectsSortMode.None);
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
return Object.FindObjectsOfType<T>(includeInactive);
|
||||
#else
|
||||
return Object.FindObjectsOfType<T>();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa7ab5ec42143544499feb36b80d3720
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 78464
|
||||
packageName: Translucent Image - Fast UI Background Blur
|
||||
packageVersion: 6.5.0
|
||||
assetPath: Assets/Le Tai's Asset/TranslucentImage/Script/Utilities/Shims.cs
|
||||
uploadId: 824068
|
||||
Reference in New Issue
Block a user