Insanely huge initial commit

This commit is contained in:
2026-02-21 16:40:15 -08:00
parent 2ba1c94b88
commit ee9aee0a1b
33825 changed files with 5213498 additions and 0 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,12 @@
fileFormatVersion: 2
guid: a1347817507220a4384f3ff6f7c24546
timeCreated: 1539852386
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
[RequireComponent(typeof(TranslucentImageSource))]
public class ChangeBlurConfig : MonoBehaviour
{
TranslucentImageSource source;
public TranslucentImage[] translucentImages;
// Use this for initialization
void Awake()
{
source = GetComponent<TranslucentImageSource>();
}
public void ChangeBlurStrength(float value)
{
//source.BlurRadius = value;
((ScalableBlurConfig) source.BlurConfig).Strength = value;
}
public void SetUpdateRate(float value)
{
source.MaxUpdateRate = value;
}
public float GetUpdateRate()
{
return source.MaxUpdateRate;
}
public void ChangeBlurSize(float value)
{
//source.BlurRadius = value;
((ScalableBlurConfig) source.BlurConfig).Radius = value;
}
public void ChangeIteration(float value)
{
// source.Iteration = Mathf.RoundToInt(value);
((ScalableBlurConfig) source.BlurConfig).Iteration = Mathf.RoundToInt(value);
}
public void ChangeDownsample(float value)
{
source.Downsample = Mathf.RoundToInt(value);
}
public void ChangeVibrancy(float value)
{
for (int i = 0; i < translucentImages.Length; i++)
{
translucentImages[i].vibrancy = value;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 06d55b4a5e282964cbd7ea4acfceffb7
timeCreated: 1539852386
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections;
using System.Collections.Generic;
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;
public Graphic[] foregroudGraphic;
public Text[] texts;
Camera cam;
void Start()
{
cam = Camera.main;
}
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;
switch (scheme)
{
case DemoColorScheme.Light:
bg = lightBackgroudColor;
fg = lightForegroudColor;
txt = lightTextColor;
break;
case DemoColorScheme.Dark:
bg = darkBackgroudColor;
fg = darkForegroudColor;
txt = darkTextColor;
break;
default:
throw new ArgumentOutOfRangeException("scheme", scheme, null);
}
cam.backgroundColor = bg;
foreach (var graphic in foregroudGraphic)
{
graphic.color = fg;
}
foreach (var text in texts)
{
text.color = txt;
}
}
}
}

View File

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

View File

@@ -0,0 +1,32 @@
using UnityEngine;
using UnityEngine.EventSystems;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class ControlCenter : MonoBehaviour
{
public RectTransform handle;
RectTransform rt;
void Start()
{
rt = GetComponent<RectTransform>();
}
void Update()
{
if (Mathf.Approximately(handle.rect.height, 0))
return;
rt.anchoredPosition = new Vector2(
rt.anchoredPosition.x,
Mathf.Clamp(rt.anchoredPosition.y, -rt.rect.height / 2 + handle.rect.height, rt.rect.height / 2 - 1)
);
}
public void Drag(BaseEventData baseEventData)
{
PointerEventData data = (PointerEventData) baseEventData;
rt.position = new Vector2(rt.position.x, rt.position.y + data.delta.y);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4dd4a18235f55924cbd544608c9cc4a8
timeCreated: 1539852386
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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,12 @@
fileFormatVersion: 2
guid: 22bbf57ec543cee42a5aa0ec2dd9e457
timeCreated: 1539852386
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
{
"name": "LeTai.TranslucentImage.Demo",
"references": [
"LeTai.TranslucentImage"
],
"includePlatforms": [],
"excludePlatforms": []
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3f4122c32873e8c43b4fee7cb4e3ccff
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class PlatformPreset : MonoBehaviour
{
public Preset[] presets;
// Use this for initialization
void Start()
{
Slider sizeSlider = GameObject.Find("Size Slider").GetComponent<Slider>();
Slider iterationSlider = GameObject.Find("Iteration Slider").GetComponent<Slider>();
Slider downsampleSlider = GameObject.Find("Downsample Slider").GetComponent<Slider>();
Slider maxUpdateRateField = GameObject.Find("Max update rate Slider").GetComponent<Slider>();
foreach (Preset preset in presets)
{
if (preset.platform == Application.platform)
{
sizeSlider.value = preset.size;
iterationSlider.value = preset.iteration;
downsampleSlider.value = preset.downsample;
maxUpdateRateField.value = preset.maxUpdateRate;
}
}
}
}
[Serializable]
public struct Preset
{
public RuntimePlatform platform;
public float size;
public int iteration;
public int downsample;
public float maxUpdateRate;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e3fa58b3b16576b46b8b4f7985c67d6c
timeCreated: 1539852387
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class SetText : MonoBehaviour
{
public string format = "0.0";
Text text;
// Use this for initialization
void Awake()
{
text = GetComponent<Text>();
}
public void Set(float value)
{
text.text = value.ToString(format);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d2b0369b1e90a8c41a1dbf3a4f3be2d1
timeCreated: 1477628633
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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,11 @@
fileFormatVersion: 2
guid: 7f46f825babce194292e0c4ca0ba5bd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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,11 @@
fileFormatVersion: 2
guid: 9357d99646ca651449e2ee107b027115
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class ToggleSecondBlurLayer : MonoBehaviour
{
public ChangeBlurConfig changer;
public Slider updateRateInput;
void Start()
{
StartCoroutine(DisableSource());
}
IEnumerator DisableSource()
{
yield return null;
changer.SetUpdateRate(0);
}
public void Toggle()
{
if (Mathf.Approximately(changer.GetUpdateRate(), 0))
changer.SetUpdateRate(updateRateInput.value);
else
changer.SetUpdateRate(0);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5e947ce450237b149bc88d672de1dcde
timeCreated: 1489637496
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using UnityEngine;
namespace LeTai.Asset.TranslucentImage.Demo
{
public class UnrestrictFramerate : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
// Debug.Log(Application.targetFrameRate.ToString());
Application.targetFrameRate = 120;
}
}
}

View File

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

View File

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

View File

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