Passion & UI

This commit is contained in:
SoulliesOfficial
2026-06-12 17:11:39 -04:00
parent 7bc1e1722c
commit 6d7ebc5825
3444 changed files with 865284 additions and 463132 deletions

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Michsky.UI.Shift
{
public class BlurManager : MonoBehaviour
{
[Header("Resources")]
public Material blurMaterial;
[Header("Settings")]
[Range(0.0f, 10)] public float blurValue = 5.0f;
[Range(0.1f, 50)] public float animationSpeed = 25;
public string customProperty = "_Size";
float currentBlurValue;
void Start()
{
if (customProperty == null)
customProperty = "_Size";
blurMaterial.SetFloat(customProperty, 0);
}
IEnumerator BlurIn()
{
currentBlurValue = blurMaterial.GetFloat(customProperty);
while (currentBlurValue <= blurValue)
{
currentBlurValue += Time.deltaTime * animationSpeed;
if (currentBlurValue >= blurValue)
currentBlurValue = blurValue;
blurMaterial.SetFloat(customProperty, currentBlurValue);
yield return null;
}
StopCoroutine("BlurIn");
}
IEnumerator BlurOut()
{
currentBlurValue = blurMaterial.GetFloat(customProperty);
while (currentBlurValue >= 0)
{
currentBlurValue -= Time.deltaTime * animationSpeed;
if (currentBlurValue <= 0)
currentBlurValue = 0;
blurMaterial.SetFloat(customProperty, currentBlurValue);
yield return null;
}
StopCoroutine("BlurOut");
}
public void BlurInAnim()
{
if (gameObject.activeInHierarchy == false)
return;
StopCoroutine("BlurOut");
StartCoroutine("BlurIn");
}
public void BlurOutAnim()
{
if (gameObject.activeInHierarchy == false)
return;
StopCoroutine("BlurIn");
StartCoroutine("BlurOut");
}
public void SetBlurValue(float cbv)
{
blurValue = cbv;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6622d2cb114c7794789ae9db3cd3924c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 157943
packageName: Shift - Complete Sci-Fi UI
packageVersion: 2.0.12
assetPath: Assets/Shift - Complete Sci-Fi UI/Scripts/Rendering/BlurManager.cs
uploadId: 915518

View File

@@ -0,0 +1,277 @@
using UnityEngine;
using UnityEngine.UI;
namespace Michsky.UI.Shift
{
public class GradientEffect : BaseMeshEffect
{
[Header("Gradient Style")]
[Tooltip("Gradient Direction")]
[SerializeField] Direction m_Direction;
[Tooltip("Color1: Top or Left")]
[SerializeField] Color m_Color1 = Color.white;
[Tooltip("Color2: Bottom or Right")]
[SerializeField] Color m_Color2 = Color.white;
[Tooltip("Color3: For diagonal")]
[SerializeField] Color m_Color3 = Color.white;
[Tooltip("Color4: For diagonal")]
[SerializeField] Color m_Color4 = Color.white;
[Tooltip("Gradient rotation")]
[SerializeField] [Range(-180, 180)] float m_Rotation;
[Tooltip("Gradient offset for Horizontal, Vertical or Angle")]
[SerializeField] [Range(-1, 1)] float m_Offset1;
[Tooltip("Gradient offset for Diagonal")]
[SerializeField] [Range(-1, 1)] float m_Offset2;
[Header("Settings")]
[Tooltip("Gradient style for Text.")]
[SerializeField] GradientStyle m_GradientStyle;
[Tooltip("Color space to correct color")]
[SerializeField] ColorSpace m_ColorSpace = ColorSpace.Uninitialized;
[Tooltip("Ignore aspect ratio")]
[SerializeField] bool m_IgnoreAspectRatio = true;
public Graphic TargetGraphic { get { return base.graphic; } }
public enum Direction
{
Horizontal,
Vertical,
Angle,
Diagonal,
}
public enum GradientStyle
{
Rect,
Fit,
Split,
}
public Direction DirectionMain
{
get { return m_Direction; }
set
{
if (m_Direction != value)
m_Direction = value;
}
}
public Color Color1
{
get { return m_Color1; }
set
{
if (m_Color1 != value)
m_Color1 = value;
}
}
public Color Color2
{
get { return m_Color2; }
set
{
if (m_Color2 != value)
m_Color2 = value;
}
}
public Color Color3
{
get { return m_Color3; }
set
{
if (m_Color3 != value)
m_Color3 = value;
}
}
public Color Color4
{
get { return m_Color4; }
set
{
if (m_Color4 != value)
m_Color4 = value;
}
}
public float Rotation
{
get
{
return m_Direction == Direction.Horizontal ? -90
: m_Direction == Direction.Vertical ? 0
: m_Rotation;
}
set
{
if (!Mathf.Approximately(m_Rotation, value))
m_Rotation = value;
}
}
public float Offset
{
get { return m_Offset1; }
set
{
if (m_Offset1 != value)
m_Offset1 = value;
}
}
public Vector2 Offset2
{
get { return new Vector2(m_Offset2, m_Offset1); }
set
{
if (m_Offset1 != value.y || m_Offset2 != value.x)
{
m_Offset1 = value.y;
m_Offset2 = value.x;
}
}
}
public GradientStyle GradientStyleMain
{
get { return m_GradientStyle; }
set
{
if (m_GradientStyle != value)
m_GradientStyle = value;
}
}
public ColorSpace ColorSpace
{
get { return m_ColorSpace; }
set
{
if (m_ColorSpace != value)
m_ColorSpace = value;
}
}
public bool IgnoreAspectRatio
{
get { return m_IgnoreAspectRatio; }
set
{
if (m_IgnoreAspectRatio != value)
m_IgnoreAspectRatio = value;
}
}
public override void ModifyMesh(VertexHelper vh)
{
if (!IsActive())
return;
Rect rect = default(Rect);
UIVertex vertex = default(UIVertex);
if (m_GradientStyle == GradientStyle.Rect)
rect = graphic.rectTransform.rect;
else if (m_GradientStyle == GradientStyle.Split)
rect.Set(0, 0, 1, 1);
else if (m_GradientStyle == GradientStyle.Fit)
{
rect.xMin = rect.yMin = float.MaxValue;
rect.xMax = rect.yMax = float.MinValue;
for (int i = 0; i < vh.currentVertCount; i++)
{
vh.PopulateUIVertex(ref vertex, i);
rect.xMin = Mathf.Min(rect.xMin, vertex.position.x);
rect.yMin = Mathf.Min(rect.yMin, vertex.position.y);
rect.xMax = Mathf.Max(rect.xMax, vertex.position.x);
rect.yMax = Mathf.Max(rect.yMax, vertex.position.y);
}
}
float rad = Rotation * Mathf.Deg2Rad;
Vector2 dir = new Vector2(Mathf.Cos(rad), Mathf.Sin(rad));
if (!m_IgnoreAspectRatio && Direction.Angle <= m_Direction)
{
dir.x *= rect.height / rect.width;
dir = dir.normalized;
}
Color color;
Vector2 nomalizedPos;
Matrix2x3 localMatrix = new Matrix2x3(rect, dir.x, dir.y);
for (int i = 0; i < vh.currentVertCount; i++)
{
vh.PopulateUIVertex(ref vertex, i);
if (m_GradientStyle == GradientStyle.Split)
nomalizedPos = localMatrix * s_SplitedCharacterPosition[i % 4] + Offset2;
else
nomalizedPos = localMatrix * vertex.position + Offset2;
if (DirectionMain == Direction.Diagonal)
{
color = Color.LerpUnclamped(
Color.LerpUnclamped(m_Color1, m_Color2, nomalizedPos.x),
Color.LerpUnclamped(m_Color3, m_Color4, nomalizedPos.x),
nomalizedPos.y);
}
else
color = Color.LerpUnclamped(m_Color2, m_Color1, nomalizedPos.y);
vertex.color *= (m_ColorSpace == ColorSpace.Gamma) ? color.gamma
: (m_ColorSpace == ColorSpace.Linear) ? color.linear
: color;
vh.SetUIVertex(vertex, i);
}
}
static readonly Vector2[] s_SplitedCharacterPosition = { Vector2.up, Vector2.one, Vector2.right, Vector2.zero };
struct Matrix2x3
{
public float m00, m01, m02, m10, m11, m12;
public Matrix2x3(Rect rect, float cos, float sin)
{
const float center = 0.5f;
float dx = -rect.xMin / rect.width - center;
float dy = -rect.yMin / rect.height - center;
m00 = cos / rect.width;
m01 = -sin / rect.height;
m02 = dx * cos - dy * sin + center;
m10 = sin / rect.width;
m11 = cos / rect.height;
m12 = dx * sin + dy * cos + center;
}
public static Vector2 operator *(Matrix2x3 m, Vector2 v)
{
return new Vector2(
(m.m00 * v.x) + (m.m01 * v.y) + m.m02,
(m.m10 * v.x) + (m.m11 * v.y) + m.m12
);
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9244185ea7b8c40459faea55ff92b26f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 157943
packageName: Shift - Complete Sci-Fi UI
packageVersion: 2.0.12
assetPath: Assets/Shift - Complete Sci-Fi UI/Scripts/Rendering/GradientEffect.cs
uploadId: 915518

View File

@@ -0,0 +1,293 @@
// This class is a modification on the class shared publicly by Glenn Powell (glennpow) that can be found here
// http://forum.unity3d.com/threads/free-script-particle-systems-in-ui-screen-space-overlay.406862/
using UnityEngine;
using UnityEngine.UI;
namespace Michsky.UI.Shift
{
[ExecuteInEditMode]
[RequireComponent(typeof(CanvasRenderer))]
[RequireComponent(typeof(ParticleSystem))]
public class UIParticleRenderer : MaskableGraphic
{
[Tooltip("Having this enabled run the system in LateUpdate rather than in Update making it faster but less precise (more clunky)")]
public bool fixedTime = true;
private Transform _transform;
private ParticleSystem pSystem;
private ParticleSystem.Particle[] particles;
private UIVertex[] _quad = new UIVertex[4];
private Vector4 imageUV = Vector4.zero;
private ParticleSystem.TextureSheetAnimationModule textureSheetAnimation;
private int textureSheetAnimationFrames;
private Vector2 textureSheetAnimationFrameSize;
private ParticleSystemRenderer pRenderer;
private Material currentMaterial;
private Texture currentTexture;
private ParticleSystem.MainModule mainModule;
public override Texture mainTexture
{
get
{
return currentTexture;
}
}
protected bool Initialize()
{
// initialize members
if (_transform == null)
{
_transform = transform;
}
if (pSystem == null)
{
pSystem = GetComponent<ParticleSystem>();
if (pSystem == null)
return false;
mainModule = pSystem.main;
if (pSystem.main.maxParticles > 14000)
{
mainModule.maxParticles = 14000;
}
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
if (pRenderer != null)
pRenderer.enabled = false;
Shader foundShader = Shader.Find("UI/Particles/Additive");
Material pMaterial = new Material(foundShader);
if (material == null)
material = pMaterial;
currentMaterial = material;
if (currentMaterial && currentMaterial.HasProperty("_MainTex"))
{
currentTexture = currentMaterial.mainTexture;
if (currentTexture == null)
currentTexture = Texture2D.whiteTexture;
}
material = currentMaterial;
// automatically set scaling
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
particles = null;
}
if (particles == null)
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
imageUV = new Vector4(0, 0, 1, 1);
// prepare texture sheet animation
textureSheetAnimation = pSystem.textureSheetAnimation;
textureSheetAnimationFrames = 0;
textureSheetAnimationFrameSize = Vector2.zero;
if (textureSheetAnimation.enabled)
{
textureSheetAnimationFrames = textureSheetAnimation.numTilesX * textureSheetAnimation.numTilesY;
textureSheetAnimationFrameSize = new Vector2(1f / textureSheetAnimation.numTilesX, 1f / textureSheetAnimation.numTilesY);
}
return true;
}
protected override void Awake()
{
base.Awake();
if (!Initialize())
enabled = false;
}
protected override void OnPopulateMesh(VertexHelper vh)
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
if (!Initialize())
return;
}
#endif
// prepare vertices
vh.Clear();
if (!gameObject.activeInHierarchy)
return;
Vector2 temp = Vector2.zero;
Vector2 corner1 = Vector2.zero;
Vector2 corner2 = Vector2.zero;
// iterate through current particles
int count = pSystem.GetParticles(particles);
for (int i = 0; i < count; ++i)
{
ParticleSystem.Particle particle = particles[i];
// get particle properties
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
float rotation = -particle.rotation * Mathf.Deg2Rad;
float rotation90 = rotation + Mathf.PI / 2;
Color32 color = particle.GetCurrentColor(pSystem);
float size = particle.GetCurrentSize(pSystem) * 0.5f;
// apply scale
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
position /= canvas.scaleFactor;
// apply texture sheet animation
Vector4 particleUV = imageUV;
if (textureSheetAnimation.enabled)
{
float frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime));
frameProgress = Mathf.Repeat(frameProgress * textureSheetAnimation.cycleCount, 1);
int frame = 0;
switch (textureSheetAnimation.animation)
{
case ParticleSystemAnimationType.WholeSheet:
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
break;
case ParticleSystemAnimationType.SingleRow:
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
int row = textureSheetAnimation.rowIndex;
// if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
// row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
// }
frame += row * textureSheetAnimation.numTilesX;
break;
}
frame %= textureSheetAnimationFrames;
particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
particleUV.y = Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y;
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
}
temp.x = particleUV.x;
temp.y = particleUV.y;
_quad[0] = UIVertex.simpleVert;
_quad[0].color = color;
_quad[0].uv0 = temp;
temp.x = particleUV.x;
temp.y = particleUV.w;
_quad[1] = UIVertex.simpleVert;
_quad[1].color = color;
_quad[1].uv0 = temp;
temp.x = particleUV.z;
temp.y = particleUV.w;
_quad[2] = UIVertex.simpleVert;
_quad[2].color = color;
_quad[2].uv0 = temp;
temp.x = particleUV.z;
temp.y = particleUV.y;
_quad[3] = UIVertex.simpleVert;
_quad[3].color = color;
_quad[3].uv0 = temp;
if (rotation == 0)
{
// no rotation
corner1.x = position.x - size;
corner1.y = position.y - size;
corner2.x = position.x + size;
corner2.y = position.y + size;
temp.x = corner1.x;
temp.y = corner1.y;
_quad[0].position = temp;
temp.x = corner1.x;
temp.y = corner2.y;
_quad[1].position = temp;
temp.x = corner2.x;
temp.y = corner2.y;
_quad[2].position = temp;
temp.x = corner2.x;
temp.y = corner1.y;
_quad[3].position = temp;
}
else
{
// apply rotation
Vector2 right = new Vector2(Mathf.Cos(rotation), Mathf.Sin(rotation)) * size;
Vector2 up = new Vector2(Mathf.Cos(rotation90), Mathf.Sin(rotation90)) * size;
_quad[0].position = position - right - up;
_quad[1].position = position - right + up;
_quad[2].position = position + right + up;
_quad[3].position = position + right - up;
}
vh.AddUIVertexQuad(_quad);
}
}
void Update()
{
if (!fixedTime && Application.isPlaying)
{
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
SetAllDirty();
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
{
pSystem = null;
Initialize();
}
}
}
void LateUpdate()
{
if (!Application.isPlaying)
SetAllDirty();
else
{
if (fixedTime)
{
pSystem.Simulate(Time.unscaledDeltaTime, false, false, true);
SetAllDirty();
if ((currentMaterial != null && currentTexture != currentMaterial.mainTexture) ||
(material != null && currentMaterial != null && material.shader != currentMaterial.shader))
{
pSystem = null;
Initialize();
}
}
}
if (material == currentMaterial)
return;
pSystem = null;
Initialize();
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 50bd9175b683c0d44a7f2e04e4be3c5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 157943
packageName: Shift - Complete Sci-Fi UI
packageVersion: 2.0.12
assetPath: Assets/Shift - Complete Sci-Fi UI/Scripts/Rendering/UIParticleRenderer.cs
uploadId: 915518