阶段性完成

This commit is contained in:
SoulliesOfficial
2025-12-08 05:27:53 -05:00
parent ef7b479712
commit f7af60351b
8770 changed files with 15637030 additions and 208354 deletions

View File

@@ -0,0 +1,52 @@
using System;
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class AutoMoveAndRotate : MonoBehaviour
{
public Vector3andSpace moveUnitsPerSecond;
public Vector3andSpace rotateDegreesPerSecond;
public bool ignoreTimescale, lateUpdate;
float m_LastRealTime;
void Start()
{
m_LastRealTime = Time.realtimeSinceStartup;
}
void Update()
{
if (!lateUpdate)
DoWork();
}
void LateUpdate()
{
if (lateUpdate)
DoWork();
}
void DoWork()
{
float deltaTime = Time.deltaTime;
if (ignoreTimescale)
{
deltaTime = (Time.realtimeSinceStartup - m_LastRealTime);
m_LastRealTime = Time.realtimeSinceStartup;
}
transform.Translate(moveUnitsPerSecond.value * deltaTime, moveUnitsPerSecond.space);
transform.Rotate(rotateDegreesPerSecond.value * deltaTime, moveUnitsPerSecond.space);
}
[Serializable]
public class Vector3andSpace
{
public Vector3 value;
public Space space = Space.Self;
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a1347817507220a4384f3ff6f7c24546
timeCreated: 1539852386
licenseType: Store
MonoImporter:
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/Demo/zz_Common/Scripts/AutoMoveAndRotate.cs
uploadId: 824068

View File

@@ -0,0 +1,85 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class ColorSchemeManager : MonoBehaviour
{
public Color lightBackgroudColor = Color.white;
public Color lightForegroudColor = Color.white;
public Color lightTextColor = Color.white;
public Color darkBackgroudColor = Color.black;
public Color darkForegroudColor = Color.black;
public Color darkTextColor = Color.black;
float lightSpriteBlending;
public float darkSpriteBlending = .6f;
public TranslucentImage[] foregroundGraphic;
public Text[] texts;
Camera cam;
void Start()
{
cam = Camera.main;
lightSpriteBlending = foregroundGraphic[0].foregroundOpacity;
}
void OnDestroy()
{
foreach (var graphic in foregroundGraphic)
{
graphic.foregroundOpacity = lightSpriteBlending;
}
}
public enum DemoColorScheme
{
Light,
Dark
}
public void SetLightScheme(bool on)
{
SetColorScheme(on ? DemoColorScheme.Light : DemoColorScheme.Dark);
}
public void SetColorScheme(DemoColorScheme scheme)
{
Color bg, fg, txt;
float sb;
switch (scheme)
{
case DemoColorScheme.Light:
bg = lightBackgroudColor;
fg = lightForegroudColor;
txt = lightTextColor;
sb = lightSpriteBlending;
break;
case DemoColorScheme.Dark:
bg = darkBackgroudColor;
fg = darkForegroudColor;
txt = darkTextColor;
sb = darkSpriteBlending;
break;
default:
throw new ArgumentOutOfRangeException(nameof(scheme), scheme, null);
}
cam.backgroundColor = bg;
foreach (var graphic in foregroundGraphic)
{
graphic.color = fg;
graphic.foregroundOpacity = sb;
}
foreach (var text in texts)
{
text.color = txt;
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 599504881c0a2e640bec3d873e2d2deb
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/Demo/zz_Common/Scripts/ColorSchemeManager.cs
uploadId: 824068

View File

@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
[RequireComponent(typeof(Text))]
public class FPSCounter : MonoBehaviour
{
const float fpsMeasurePeriod = 0.5f;
int m_FpsAccumulator;
float m_FpsNextPeriod;
int m_CurrentFps;
string display = "{0} FPS";
Text m_Text;
void Start()
{
m_FpsNextPeriod = Time.realtimeSinceStartup + fpsMeasurePeriod;
m_Text = GetComponent<Text>();
display = m_Text.text;
}
void Update()
{
// measure average frames per second
m_FpsAccumulator++;
if (Time.realtimeSinceStartup > m_FpsNextPeriod)
{
m_CurrentFps = (int) (m_FpsAccumulator / fpsMeasurePeriod);
m_FpsAccumulator = 0;
m_FpsNextPeriod += fpsMeasurePeriod;
m_Text.text = string.Format(display, m_CurrentFps);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 22bbf57ec543cee42a5aa0ec2dd9e457
timeCreated: 1539852386
licenseType: Store
MonoImporter:
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/Demo/zz_Common/Scripts/FPSCounter.cs
uploadId: 824068

View File

@@ -0,0 +1,16 @@
{
"name": "LeTai.Asset.TranslucentImage.Demo",
"rootNamespace": "",
"references": [
"GUID:ff218ee40fe2b8648ab3234d56415557"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 3f4122c32873e8c43b4fee7cb4e3ccff
AssemblyDefinitionImporter:
externalObjects: {}
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/Demo/zz_Common/Scripts/LeTai.TranslucentImage.Demo.asmdef
uploadId: 824068

View File

@@ -0,0 +1,74 @@
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class MainDemoViewController : MonoBehaviour
{
public Toggle toggleLightMode;
public Toggle toggleDarkMode;
public Slider sliderBlurStrength;
public Slider sliderVibrancy;
public Slider sliderUpdateRate;
public TranslucentImage[] translucentImages;
TranslucentImageSource source;
float backupBlurStrength;
float[] backupVibrancy;
void Start()
{
source = Shims.FindObjectOfType<TranslucentImageSource>();
var colorSchemeManager = GetComponent<ColorSchemeManager>();
BackupValues();
toggleLightMode.onValueChanged.AddListener(isOn =>
{
if (isOn) colorSchemeManager.SetColorScheme(ColorSchemeManager.DemoColorScheme.Light);
});
toggleDarkMode.onValueChanged.AddListener(isOn =>
{
if (isOn) colorSchemeManager.SetColorScheme(ColorSchemeManager.DemoColorScheme.Dark);
});
sliderBlurStrength.onValueChanged.AddListener(value =>
{
source.BlurConfig.Strength = value;
});
sliderVibrancy.onValueChanged.AddListener(value =>
{
for (int i = 0; i < translucentImages.Length; i++)
{
translucentImages[i].vibrancy = value;
}
});
sliderUpdateRate.onValueChanged.AddListener(value =>
{
source.MaxUpdateRate = Mathf.Approximately(value, sliderUpdateRate.maxValue) ? float.PositiveInfinity : value;
});
}
void BackupValues()
{
backupBlurStrength = source.BlurConfig.Strength;
backupVibrancy = new float[translucentImages.Length];
for (int i = 0; i < translucentImages.Length; i++)
{
backupVibrancy[i] = translucentImages[i].vibrancy;
}
}
void OnDestroy()
{
source.BlurConfig.Strength = backupBlurStrength;
for (int i = 0; i < translucentImages.Length; i++)
{
translucentImages[i].vibrancy = backupVibrancy[i];
}
}
}
};

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: dd99521253ec99041bc605263259bd45
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/Demo/zz_Common/Scripts/MainDemoViewController.cs
uploadId: 824068

View File

@@ -0,0 +1,169 @@
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class SimpleCameraController : MonoBehaviour
{
class CameraState
{
public float yaw;
public float pitch;
public float roll;
public float x;
public float y;
public float z;
public void SetFromTransform(Transform t)
{
pitch = t.eulerAngles.x;
yaw = t.eulerAngles.y;
roll = t.eulerAngles.z;
x = t.position.x;
y = t.position.y;
z = t.position.z;
}
public void Translate(Vector3 translation)
{
Vector3 rotatedTranslation = Quaternion.Euler(pitch, yaw, roll) * translation;
x += rotatedTranslation.x;
y += rotatedTranslation.y;
z += rotatedTranslation.z;
}
public void LerpTowards(CameraState target, float positionLerpPct, float rotationLerpPct)
{
yaw = Mathf.Lerp(yaw, target.yaw, rotationLerpPct);
pitch = Mathf.Lerp(pitch, target.pitch, rotationLerpPct);
roll = Mathf.Lerp(roll, target.roll, rotationLerpPct);
x = Mathf.Lerp(x, target.x, positionLerpPct);
y = Mathf.Lerp(y, target.y, positionLerpPct);
z = Mathf.Lerp(z, target.z, positionLerpPct);
}
public void UpdateTransform(Transform t)
{
t.eulerAngles = new Vector3(pitch, yaw, roll);
t.position = new Vector3(x, y, z);
}
}
CameraState m_TargetCameraState = new CameraState();
CameraState m_InterpolatingCameraState = new CameraState();
[Header("Movement Settings")]
[Tooltip("Exponential boost factor on translation, controllable by mouse wheel.")]
public float boost = 3.5f;
[Tooltip("Time it takes to interpolate camera position 99% of the way to the target."), Range(0.001f, 1f)]
public float positionLerpTime = 0.2f;
[Header("Rotation Settings")]
[Tooltip("X = Change in mouse position.\nY = Multiplicative factor for camera rotation.")]
public AnimationCurve mouseSensitivityCurve = new AnimationCurve(new Keyframe(0f, 0.5f, 0f, 5f), new Keyframe(1f, 2.5f, 0f, 0f));
[Tooltip("Time it takes to interpolate camera rotation 99% of the way to the target."), Range(0.001f, 1f)]
public float rotationLerpTime = 0.01f;
[Tooltip("Whether or not to invert our Y axis for mouse input to rotation.")]
public bool invertY = false;
void OnEnable()
{
m_TargetCameraState.SetFromTransform(transform);
m_InterpolatingCameraState.SetFromTransform(transform);
}
Vector3 GetInputTranslationDirection()
{
Vector3 direction = new Vector3();
if (Input.GetKey(KeyCode.W))
{
direction += Vector3.forward;
}
if (Input.GetKey(KeyCode.S))
{
direction += Vector3.back;
}
if (Input.GetKey(KeyCode.A))
{
direction += Vector3.left;
}
if (Input.GetKey(KeyCode.D))
{
direction += Vector3.right;
}
if (Input.GetKey(KeyCode.Q))
{
direction += Vector3.down;
}
if (Input.GetKey(KeyCode.E))
{
direction += Vector3.up;
}
return direction;
}
void Update()
{
// Exit Sample
if (Input.GetKey(KeyCode.Escape))
{
Application.Quit();
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#endif
}
// Hide and lock cursor when right mouse button pressed
if (Input.GetMouseButtonDown(1))
{
Cursor.lockState = CursorLockMode.Locked;
}
// Unlock and show cursor when right mouse button released
if (Input.GetMouseButtonUp(1))
{
Cursor.visible = true;
Cursor.lockState = CursorLockMode.None;
}
// Rotation
if (Input.GetMouseButton(1))
{
var mouseMovement = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y") * (invertY ? 1 : -1));
var mouseSensitivityFactor = mouseSensitivityCurve.Evaluate(mouseMovement.magnitude);
m_TargetCameraState.yaw += mouseMovement.x * mouseSensitivityFactor;
m_TargetCameraState.pitch += mouseMovement.y * mouseSensitivityFactor;
}
// Translation
var translation = GetInputTranslationDirection() * Time.deltaTime;
// Speed up movement when shift key held
if (Input.GetKey(KeyCode.LeftShift))
{
translation *= 10.0f;
}
// Modify movement by a boost factor (defined in Inspector and modified in play mode through the mouse scroll wheel)
boost += Input.mouseScrollDelta.y * 0.2f;
translation *= Mathf.Pow(2.0f, boost);
m_TargetCameraState.Translate(translation);
// Framerate-independent interpolation
// Calculate the lerp amount, such that we get 99% of the way to our target in the specified time
var positionLerpPct = 1f - Mathf.Exp((Mathf.Log(1f - 0.99f) / positionLerpTime) * Time.deltaTime);
var rotationLerpPct = 1f - Mathf.Exp((Mathf.Log(1f - 0.99f) / rotationLerpTime) * Time.deltaTime);
m_InterpolatingCameraState.LerpTowards(m_TargetCameraState, positionLerpPct, rotationLerpPct);
m_InterpolatingCameraState.UpdateTransform(transform);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7f46f825babce194292e0c4ca0ba5bd3
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/Demo/zz_Common/Scripts/SimpleCameraController.cs
uploadId: 824068

View File

@@ -0,0 +1,19 @@
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
[RequireComponent(typeof(Slider))]
public class SliderChangeOnStart : MonoBehaviour
{
Slider slider;
void Start()
{
slider = GetComponent<Slider>();
slider.value -= 1;
slider.value += 1;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9357d99646ca651449e2ee107b027115
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/Demo/zz_Common/Scripts/SliderChangeOnStart.cs
uploadId: 824068

View File

@@ -0,0 +1,13 @@
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class UnrestrictFramerate : MonoBehaviour
{
void Start()
{
if (Application.isMobilePlatform)
Application.targetFrameRate = 120;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c62dd66bd61e2454d9c669a5b3bf4f05
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/Demo/zz_Common/Scripts/UnrestrictFramerate.cs
uploadId: 824068

View File

@@ -0,0 +1,23 @@
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class WorldSpaceSetup : MonoBehaviour
{
public Camera sceneCamera;
public Camera uiCamera;
public void SetUIAlwaysOnTop(bool isAlwaysOnTop)
{
//In always on top mode, main camera shouldn't render the UI
//Equivalent to toggling the layer "UI" in the inspector
if (isAlwaysOnTop)
sceneCamera.cullingMask &= ~(1 << LayerMask.NameToLayer("UI"));
else
sceneCamera.cullingMask |= 1 << LayerMask.NameToLayer("UI");
//Instead, another camera that have higher depth should do that.
uiCamera.gameObject.SetActive(isAlwaysOnTop);
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: e2181769f309a2648928badd595855cf
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/Demo/zz_Common/Scripts/WorldSpaceSetup.cs
uploadId: 824068