初始化
This commit is contained in:
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09d6ef90e4e945d19add5fc6e861e2ff
|
||||
timeCreated: 1679041703
|
||||
28
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/ColorModeEnum.cs
vendored
Normal file
28
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/ColorModeEnum.cs
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
using Sirenix.OdinInspector;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色叠加模式
|
||||
/// </summary>
|
||||
public enum ColorModeEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 混合源和覆盖。
|
||||
/// </summary>
|
||||
[LabelText("混合源和覆盖")]
|
||||
Blend = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 添加源颜色和叠加。
|
||||
/// </summary>
|
||||
[LabelText("添加源颜色和叠加")]
|
||||
Additive = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 在叠加之间筛选源颜色。
|
||||
/// </summary>
|
||||
[LabelText("在叠加之间筛选源颜色")]
|
||||
Screen = 2,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ca73f53dcfd4fc88ace0eaf0b2d924f
|
||||
timeCreated: 1681377423
|
||||
759
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/EffectControl.cs
vendored
Normal file
759
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/EffectControl.cs
vendored
Normal file
@@ -0,0 +1,759 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 效果控制
|
||||
/// </summary>
|
||||
[AddComponentMenu("YIUIBind/Effect/Effect Control 特效控制器")]
|
||||
public sealed class EffectControl : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[LabelText("循环中")]
|
||||
private bool looping = false;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("延迟时间")]
|
||||
private float delay = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("效果持续时间")]
|
||||
private float duration = 5.0f;
|
||||
|
||||
[SerializeField]
|
||||
[LabelText("随着时间的推移而逐渐消失")]
|
||||
private float fadeout = 1.0f;
|
||||
|
||||
private PlayState state = PlayState.Stopping;
|
||||
private float timer;
|
||||
private List<ParticleSystem> particleSystems;
|
||||
private List<Animator> animators;
|
||||
private List<Animation> animations;
|
||||
private float playbackSpeed = 1.0f;
|
||||
|
||||
private bool releaseAfterFinish = false;
|
||||
|
||||
public bool ReleaseAfterFinish
|
||||
{
|
||||
get { return releaseAfterFinish; }
|
||||
set { releaseAfterFinish = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 淡出事件
|
||||
/// </summary>
|
||||
public event Action FadeoutEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 完成事件
|
||||
/// </summary>
|
||||
public event Action FinishEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 效果的播放状态
|
||||
/// </summary>
|
||||
private enum PlayState
|
||||
{
|
||||
Stopping,
|
||||
Pending,
|
||||
Playing,
|
||||
Pausing,
|
||||
Fadeouting,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个值,该值指示此效果是否正在循环
|
||||
/// </summary>
|
||||
public bool IsLooping
|
||||
{
|
||||
get { return this.looping; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个值,该值指示是否暂停此效果。
|
||||
/// </summary>
|
||||
public bool IsPaused
|
||||
{
|
||||
get { return PlayState.Pausing == this.state; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个值,该值指示是否停止此效果。
|
||||
/// </summary>
|
||||
public bool IsStopped
|
||||
{
|
||||
get { return PlayState.Stopping == this.state; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取效果持续时间。
|
||||
/// </summary>
|
||||
public float Duration
|
||||
{
|
||||
get { return this.duration; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取效果淡出时间。
|
||||
/// </summary>
|
||||
public float Fadeout
|
||||
{
|
||||
get { return this.fadeout; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置此效果的播放速度。
|
||||
/// </summary>
|
||||
public float PlaybackSpeed
|
||||
{
|
||||
get { return this.playbackSpeed; }
|
||||
|
||||
set
|
||||
{
|
||||
this.playbackSpeed = value;
|
||||
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
var main = particleSystem.main;
|
||||
main.simulationSpeed = this.playbackSpeed;
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
animator.speed = this.playbackSpeed;
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
var clip = animation.clip;
|
||||
if (clip != null)
|
||||
{
|
||||
animation[clip.name].speed = this.playbackSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 得到粒子系统。
|
||||
/// </summary>
|
||||
private List<ParticleSystem> ParticleSystems
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.particleSystems == null)
|
||||
{
|
||||
this.particleSystems = ListPool<ParticleSystem>.Get();
|
||||
this.GetComponentsInChildren(true, particleSystems);
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
var main = particleSystem.main;
|
||||
main.simulationSpeed = this.playbackSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
return this.particleSystems;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取动画器
|
||||
/// </summary>
|
||||
private List<Animator> Animators
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.animators == null)
|
||||
{
|
||||
this.animators = ListPool<Animator>.Get();
|
||||
this.GetComponentsInChildren(true, this.animators);
|
||||
foreach (var animator in this.animators)
|
||||
{
|
||||
animator.speed = this.playbackSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
return this.animators;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取动画
|
||||
/// </summary>
|
||||
private List<Animation> Animations
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.animations == null)
|
||||
{
|
||||
this.animations = ListPool<Animation>.Get();
|
||||
this.GetComponentsInChildren(true, this.animations);
|
||||
foreach (var animation in this.animations)
|
||||
{
|
||||
var clip = animation.clip;
|
||||
if (clip != null)
|
||||
{
|
||||
animation[clip.name].speed = this.playbackSpeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.animations;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 估计持续时间。
|
||||
/// </summary>
|
||||
public void EstimateDuration()
|
||||
{
|
||||
this.looping = false;
|
||||
this.duration = 0.0f;
|
||||
this.fadeout = 0.0f;
|
||||
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
if (particleSystem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (particleSystem.main.loop)
|
||||
{
|
||||
this.looping = true;
|
||||
}
|
||||
|
||||
if (this.duration < particleSystem.main.duration)
|
||||
{
|
||||
this.duration = particleSystem.main.duration;
|
||||
}
|
||||
|
||||
if (this.fadeout < particleSystem.main.startLifetimeMultiplier)
|
||||
{
|
||||
this.fadeout = particleSystem.main.startLifetimeMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
if (animation == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clip = animation.clip;
|
||||
if (clip == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (clip.isLooping)
|
||||
{
|
||||
this.looping = true;
|
||||
}
|
||||
|
||||
if (this.duration < clip.length)
|
||||
{
|
||||
this.duration = clip.length;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
||||
if (stateInfo.loop)
|
||||
{
|
||||
this.looping = true;
|
||||
}
|
||||
|
||||
if (this.duration < stateInfo.length)
|
||||
{
|
||||
this.duration = stateInfo.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 刷新此效果。
|
||||
/// </summary>
|
||||
public void Refresh()
|
||||
{
|
||||
if (this.particleSystems != null)
|
||||
{
|
||||
ListPool<ParticleSystem>.Put(this.particleSystems);
|
||||
this.particleSystems = null;
|
||||
}
|
||||
|
||||
if (this.animations != null)
|
||||
{
|
||||
ListPool<Animation>.Put(this.animations);
|
||||
this.animations = null;
|
||||
}
|
||||
|
||||
if (this.animators != null)
|
||||
{
|
||||
ListPool<Animator>.Put(this.animators);
|
||||
this.animators = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始模拟。
|
||||
/// </summary>
|
||||
public void SimulateInit()
|
||||
{
|
||||
// 烘焙所有动画师。
|
||||
var animators = this.Animators;
|
||||
foreach (var animator in animators)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (animator.runtimeAnimatorController == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const float FrameRate = 30f;
|
||||
var stateInfo = animator.GetCurrentAnimatorStateInfo(0);
|
||||
int frameCount = (int)((stateInfo.length * FrameRate) + 2);
|
||||
|
||||
animator.Rebind();
|
||||
animator.StopPlayback();
|
||||
animator.recorderStartTime = 0;
|
||||
animator.StartRecording(frameCount);
|
||||
|
||||
for (var i = 0; i < frameCount - 1; ++i)
|
||||
{
|
||||
animator.Update(i / FrameRate);
|
||||
}
|
||||
|
||||
animator.StopRecording();
|
||||
animator.StartPlayback();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始模拟效果。
|
||||
/// </summary>
|
||||
public void SimulateStart()
|
||||
{
|
||||
var particleSystems = this.ParticleSystems;
|
||||
foreach (var ps in particleSystems)
|
||||
{
|
||||
if (ps == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ps.Simulate(0, false, true);
|
||||
ps.time = 0;
|
||||
ps.Play();
|
||||
}
|
||||
|
||||
var animators = this.Animators;
|
||||
foreach (var animator in animators)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (animator.runtimeAnimatorController == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
animator.playbackTime = 0.0f;
|
||||
animator.Update(0.0f);
|
||||
}
|
||||
|
||||
var animations = this.Animations;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clip = animation.clip;
|
||||
if (clip == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
clip.SampleAnimation(animation.gameObject, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过增量时间更新模拟的效果。
|
||||
/// </summary>
|
||||
public void SimulateDelta(float time, float deltaTime)
|
||||
{
|
||||
var particleSystems = this.ParticleSystems;
|
||||
foreach (var ps in particleSystems)
|
||||
{
|
||||
if (ps == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ps.Simulate(deltaTime, false, false);
|
||||
}
|
||||
|
||||
var animators = this.Animators;
|
||||
foreach (var animator in animators)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (animator.runtimeAnimatorController == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
animator.playbackTime = time;
|
||||
animator.Update(0.0f);
|
||||
}
|
||||
|
||||
var animations = this.Animations;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clip = animation.clip;
|
||||
if (clip == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
clip.SampleAnimation(animation.gameObject, time);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 模拟在编辑器模式下。
|
||||
/// </summary>
|
||||
public void Simulate(float time)
|
||||
{
|
||||
var randomKeeper = new Dictionary<ParticleSystem, KeyValuePair<bool, uint>>();
|
||||
var particleSystems = this.ParticleSystems;
|
||||
foreach (var ps in particleSystems)
|
||||
{
|
||||
if (ps == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ps.Stop(false);
|
||||
var pair = new KeyValuePair<bool, uint>(
|
||||
ps.useAutoRandomSeed, ps.randomSeed);
|
||||
randomKeeper.Add(ps, pair);
|
||||
if (!ps.isPlaying)
|
||||
{
|
||||
ps.useAutoRandomSeed = false;
|
||||
ps.randomSeed = 0;
|
||||
}
|
||||
|
||||
ps.Simulate(0, false, true);
|
||||
ps.time = 0;
|
||||
ps.Play();
|
||||
}
|
||||
|
||||
for (float i = 0.0f; i < time; i += 0.02f)
|
||||
{
|
||||
foreach (var ps in particleSystems)
|
||||
{
|
||||
if (ps == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ps.Simulate(0.02f, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ps in particleSystems)
|
||||
{
|
||||
if (ps == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ps.Stop(false);
|
||||
var pair = randomKeeper[ps];
|
||||
ps.randomSeed = pair.Value;
|
||||
ps.useAutoRandomSeed = pair.Key;
|
||||
}
|
||||
|
||||
var animators = this.Animators;
|
||||
foreach (var animator in animators)
|
||||
{
|
||||
if (animator == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (animator.runtimeAnimatorController == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
animator.playbackTime = time;
|
||||
animator.Update(0.0f);
|
||||
}
|
||||
|
||||
var animations = this.Animations;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var clip = animation.clip;
|
||||
if (clip == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
clip.SampleAnimation(animation.gameObject, time);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 开始
|
||||
/// </summary>
|
||||
public void Play()
|
||||
{
|
||||
if (PlayState.Playing == this.state)
|
||||
{
|
||||
this.Stop();
|
||||
}
|
||||
|
||||
this.state = PlayState.Pending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停
|
||||
/// </summary>
|
||||
public void Pause()
|
||||
{
|
||||
if (PlayState.Playing == this.state)
|
||||
{
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
particleSystem.Pause(false);
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
animator.speed = 0.0f;
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
var clip = animation.clip;
|
||||
if (clip != null)
|
||||
{
|
||||
animation[clip.name].speed = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
this.state = PlayState.Pausing;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新开始
|
||||
/// </summary>
|
||||
public void Resume()
|
||||
{
|
||||
if (PlayState.Pausing == this.state)
|
||||
{
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
particleSystem.Play(false);
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
animator.speed = this.playbackSpeed;
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
var clip = animation.clip;
|
||||
if (clip != null)
|
||||
{
|
||||
animation[clip.name].speed = this.playbackSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
this.state = PlayState.Playing;
|
||||
}
|
||||
}
|
||||
|
||||
public void ForceCallFinishEvent()
|
||||
{
|
||||
if (this.FinishEvent != null)
|
||||
{
|
||||
this.FinishEvent();
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearFinishEvent()
|
||||
{
|
||||
this.FinishEvent = null;
|
||||
this.ReleaseAfterFinish = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (this.state != PlayState.Stopping)
|
||||
{
|
||||
this.state = PlayState.Fadeouting;
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
particleSystem.Stop(false);
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
animator.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
if (animation.playAutomatically)
|
||||
{
|
||||
animation.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
animation.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.FadeoutEvent != null)
|
||||
{
|
||||
this.FadeoutEvent();
|
||||
this.FadeoutEvent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
this.timer = 0.0f;
|
||||
this.state = PlayState.Stopping;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (this.particleSystems == null)
|
||||
{
|
||||
this.particleSystems = ListPool<ParticleSystem>.Get();
|
||||
this.GetComponentsInChildren(true, this.particleSystems);
|
||||
}
|
||||
|
||||
this.Reset();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (PlayState.Stopping == this.state ||
|
||||
PlayState.Pausing == this.state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.timer += Time.deltaTime * this.playbackSpeed;
|
||||
if (PlayState.Pending == this.state && this.timer >= this.delay)
|
||||
{
|
||||
foreach (var particleSystem in this.ParticleSystems)
|
||||
{
|
||||
particleSystem.Play(false);
|
||||
}
|
||||
|
||||
foreach (var animator in this.Animators)
|
||||
{
|
||||
animator.gameObject.SetActive(false);
|
||||
animator.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
foreach (var animation in this.Animations)
|
||||
{
|
||||
if (animation.playAutomatically)
|
||||
{
|
||||
animation.gameObject.SetActive(false);
|
||||
animation.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
animation.Stop();
|
||||
animation.Play();
|
||||
}
|
||||
}
|
||||
|
||||
this.state = PlayState.Playing;
|
||||
}
|
||||
|
||||
if (!this.looping)
|
||||
{
|
||||
if (PlayState.Playing == this.state &&
|
||||
this.timer >= this.duration)
|
||||
{
|
||||
this.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayState.Fadeouting == this.state &&
|
||||
this.timer >= this.duration + this.fadeout)
|
||||
{
|
||||
this.state = PlayState.Stopping;
|
||||
if (this.FinishEvent != null)
|
||||
{
|
||||
this.FinishEvent();
|
||||
this.FinishEvent = null;
|
||||
if (ReleaseAfterFinish)
|
||||
{
|
||||
ReleaseAfterFinish = false;
|
||||
|
||||
//Debug.LogError("TODO GameObjectPool");
|
||||
//GameObjectPool.Instance.Free(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baa80460a939459984ae4185c1d08399
|
||||
timeCreated: 1679041703
|
||||
191
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/PreviewObject.cs
vendored
Normal file
191
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/PreviewObject.cs
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 这是一个仅用于编辑器的脚本,用于在编辑模式下显示预览对象
|
||||
/// </summary>
|
||||
[ExecuteInEditMode]
|
||||
public sealed class PreviewObject : MonoBehaviour
|
||||
{
|
||||
private GameObject preview;
|
||||
private bool simulateInEditMode = true; //记录播放时间
|
||||
private float playingTime = 0.0f;
|
||||
private double lastTime = -1.0;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示是否在编辑模式下模拟。
|
||||
/// </summary>
|
||||
public bool SimulateInEditMode
|
||||
{
|
||||
get { return this.simulateInEditMode; }
|
||||
set { this.simulateInEditMode = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除预览对象。
|
||||
/// </summary>
|
||||
public void ClearPreview()
|
||||
{
|
||||
if (this.preview != null)
|
||||
{
|
||||
var deletePreview = this.preview;
|
||||
this.preview = null;
|
||||
EditorApplication.delayCall += () => { GameObject.DestroyImmediate(deletePreview); };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置预览对象
|
||||
/// </summary>
|
||||
public void SetPreview(GameObject previewObj)
|
||||
{
|
||||
// Destroy the pre-preview.
|
||||
if (this.preview != null)
|
||||
{
|
||||
var deletePreview = this.preview;
|
||||
this.preview = null;
|
||||
EditorApplication.delayCall += () => { GameObject.DestroyImmediate(deletePreview); };
|
||||
}
|
||||
|
||||
// Attach the preview object.
|
||||
this.preview = previewObj;
|
||||
this.preview.tag = "EditorOnly";
|
||||
this.preview.transform.SetParent(this.transform, false);
|
||||
|
||||
// Start the animation.
|
||||
if (this.simulateInEditMode)
|
||||
{
|
||||
var effectControl = this.preview.GetComponent<EffectControl>();
|
||||
if (effectControl != null)
|
||||
{
|
||||
effectControl.SimulateInit();
|
||||
effectControl.SimulateStart();
|
||||
}
|
||||
else
|
||||
{
|
||||
var particelSystems = this.preview.GetComponentsInChildren<ParticleSystem>();
|
||||
foreach (var ps in particelSystems)
|
||||
{
|
||||
ps.Simulate(0.0f, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Hide this preview.
|
||||
this.SetHideFlags(this.preview, HideFlags.DontSave);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.hideFlags = HideFlags.DontSave;
|
||||
EditorApplication.playModeStateChanged += (PlayModeStateChange state) =>
|
||||
{
|
||||
if (EditorApplication.isPlaying ||
|
||||
EditorApplication.isPlayingOrWillChangePlaymode ||
|
||||
EditorApplication.isCompiling)
|
||||
{
|
||||
if (this.preview != null)
|
||||
{
|
||||
GameObject.DestroyImmediate(this.preview);
|
||||
this.preview = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (this.preview != null)
|
||||
{
|
||||
GameObject.DestroyImmediate(this.preview);
|
||||
this.preview = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EditorApplication.update += this.UpdatePreview;
|
||||
this.lastTime = EditorApplication.timeSinceStartup;
|
||||
if (this.preview != null)
|
||||
{
|
||||
this.preview.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EditorApplication.update -= this.UpdatePreview;
|
||||
if (this.preview != null)
|
||||
{
|
||||
this.preview.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePreview()
|
||||
{
|
||||
if (!this.simulateInEditMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var timeSinceStartup = EditorApplication.timeSinceStartup;
|
||||
var deltaTime = (float)(timeSinceStartup - this.lastTime);
|
||||
this.lastTime = timeSinceStartup;
|
||||
this.playingTime += deltaTime;
|
||||
|
||||
if (this.preview == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Start the animation.
|
||||
var effectControl = this.preview.GetComponent<EffectControl>();
|
||||
if (effectControl != null)
|
||||
{
|
||||
effectControl.SimulateDelta(this.playingTime, deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
float playTime = 0.0f;
|
||||
var particelSystems =
|
||||
this.preview.GetComponentsInChildren<ParticleSystem>();
|
||||
foreach (var ps in particelSystems)
|
||||
{
|
||||
if (playTime < ps.main.duration)
|
||||
{
|
||||
playTime = ps.main.duration;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var ps in particelSystems)
|
||||
{
|
||||
ps.Simulate(deltaTime, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetHideFlags(GameObject obj, HideFlags flags)
|
||||
{
|
||||
obj.hideFlags = flags;
|
||||
for (int i = 0; i < obj.transform.childCount; ++i)
|
||||
{
|
||||
var child = obj.transform.GetChild(i);
|
||||
this.SetHideFlags(child.gameObject, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c63b46be60d4b3f990e04cccd7196b1
|
||||
timeCreated: 1679041382
|
||||
240
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UI-Effect.shader
vendored
Normal file
240
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UI-Effect.shader
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
Shader "YIUI/UIEffect"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
|
||||
_Color("Tint", Color) = (1,1,1,1)
|
||||
|
||||
_StencilComp("Stencil Comparison", Float) = 8
|
||||
_Stencil("Stencil ID", Float) = 0
|
||||
_StencilOp("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
|
||||
|
||||
_OverlayTex("Overlay Texture", 2D) = "white" {}
|
||||
_OverlaySpeed("Overlay Texture Speed", Float) = 1
|
||||
_BlurDistance("Blur Distance", Float) = 0.015
|
||||
_GrayLerp("Grayscale Lerp", Float) = 1
|
||||
_LightOffset("Light Offset", Float) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue" = "Transparent"
|
||||
"IgnoreProjector" = "True"
|
||||
"RenderType" = "Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref[_Stencil]
|
||||
Comp[_StencilComp]
|
||||
Pass[_StencilOp]
|
||||
ReadMask[_StencilReadMask]
|
||||
WriteMask[_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Default"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
//#pragma multi_compile __ UIEFFECT_OVERLAY UIEFFECT_OVERLAY_ANIMATION
|
||||
#pragma multi_compile __ UIEFFECT_GRAYSCALE UIEFFECT_GRAYSCALE_LERP
|
||||
#pragma multi_compile __ UIEFFECT_WHITEALL
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
#if defined(UIEFFECT_OVERLAY) || defined(UIEFFECT_OVERLAY_ANIMATION) || defined(UIEFFECT_INNER_BEVEL)
|
||||
float2 texcoord1 : TEXCOORD1;
|
||||
#endif
|
||||
#if defined(UIEFFECT_INNER_BEVEL)
|
||||
float4 tangent : TANGENT;
|
||||
#endif
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
#if defined(UIEFFECT_OVERLAY) || defined(UIEFFECT_OVERLAY_ANIMATION) || defined(UIEFFECT_INNER_BEVEL)
|
||||
half4 texcoord : TEXCOORD0;
|
||||
#else
|
||||
half2 texcoord : TEXCOORD0;
|
||||
#endif
|
||||
#if defined(UIEFFECT_INNER_BEVEL)
|
||||
float4 tangent : TEXCOORD1;
|
||||
#endif
|
||||
float4 worldPosition : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
half _IsInUICamera;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
#if defined(UIEFFECT_OVERLAY) || defined(UIEFFECT_OVERLAY_ANIMATION) || defined(UIEFFECT_INNER_BEVEL)
|
||||
OUT.texcoord.xy = IN.texcoord;
|
||||
OUT.texcoord.zw = IN.texcoord1;
|
||||
#else
|
||||
OUT.texcoord = IN.texcoord;
|
||||
#endif
|
||||
|
||||
#if defined(UIEFFECT_INNER_BEVEL)
|
||||
OUT.tangent = IN.tangent;
|
||||
#endif
|
||||
//IN.color.rgb *=
|
||||
OUT.color = IN.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
// Overlay
|
||||
sampler2D _OverlayTex;
|
||||
int _OverlayColorMode;
|
||||
float _OverlaySpeed;
|
||||
|
||||
// Inner Bevel
|
||||
fixed4 _HighlightColor;
|
||||
int _HighlightColorMode;
|
||||
fixed4 _ShadowColor;
|
||||
int _ShadowColorMode;
|
||||
half2 _HighlightOffset;
|
||||
|
||||
// Blur.
|
||||
float _BlurDistance;
|
||||
|
||||
// Grayscale.
|
||||
float _GrayLerp;
|
||||
|
||||
// LightOffset.
|
||||
float _LightOffset;
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord.xy) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
#ifdef UIEFFECT_BLUR
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x + _BlurDistance, IN.texcoord.y + _BlurDistance)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x + _BlurDistance, IN.texcoord.y)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + _BlurDistance)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x - _BlurDistance, IN.texcoord.y - _BlurDistance)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x + _BlurDistance, IN.texcoord.y - _BlurDistance)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x - _BlurDistance, IN.texcoord.y + _BlurDistance)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x - _BlurDistance, IN.texcoord.y)) * IN.color;
|
||||
color += tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y - _BlurDistance)) * IN.color;
|
||||
color = color / 9;
|
||||
#endif
|
||||
|
||||
#if defined(UIEFFECT_OVERLAY) || defined(UIEFFECT_OVERLAY_ANIMATION)
|
||||
half2 uv = IN.texcoord.zw;
|
||||
# ifdef UIEFFECT_OVERLAY_ANIMATION
|
||||
uv.x += _Time.y * _OverlaySpeed;
|
||||
# endif
|
||||
half4 overlay = tex2D(_OverlayTex, uv);
|
||||
if (_OverlayColorMode == 0)
|
||||
{
|
||||
color.rgb = color.rgb * (1 - overlay.a) + overlay.rgb * overlay.a;
|
||||
}
|
||||
else if (_OverlayColorMode == 1)
|
||||
{
|
||||
color.rgb += overlay.rgb;
|
||||
}
|
||||
else if (_OverlayColorMode == 2)
|
||||
{
|
||||
color.rgb = half3(1, 1, 1) - (half3(1, 1, 1) - color.rgb) * (half3(1, 1, 1) - overlay.rgb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(UIEFFECT_INNER_BEVEL)
|
||||
float factor = min(IN.texcoord.z, 1);
|
||||
half2 highlightOffset = _HighlightOffset.x * half2(IN.tangent.xy) - _HighlightOffset.y * half2(IN.tangent.zw);
|
||||
fixed shadowColAlpha = (1 - tex2D(_MainTex, IN.texcoord + highlightOffset).a) * _ShadowColor.a * factor;
|
||||
|
||||
if (_ShadowColorMode == 0)
|
||||
{
|
||||
color.rgb = color.rgb * (1 - shadowColAlpha) + _ShadowColor.rgb * shadowColAlpha;
|
||||
}
|
||||
else if (_ShadowColorMode == 1)
|
||||
{
|
||||
color.rgb = color.rgb + _ShadowColor.rgb * shadowColAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.rgb = color.rgb * (1 - shadowColAlpha) + color.rgb * _ShadowColor.rgb * shadowColAlpha;
|
||||
}
|
||||
|
||||
fixed highlightColAlpha = (1 - tex2D(_MainTex, IN.texcoord - highlightOffset).a) * _HighlightColor.a * factor;
|
||||
if (_HighlightColorMode == 0)
|
||||
{
|
||||
color.rgb = color.rgb * (1 - highlightColAlpha) + _HighlightColor.rgb * highlightColAlpha;
|
||||
}
|
||||
else if (_HighlightColorMode == 1)
|
||||
{
|
||||
color.rgb = color.rgb + _HighlightColor.rgb * highlightColAlpha;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.rgb = color.rgb * (1 - highlightColAlpha) + color.rgb * _HighlightColor.rgb * highlightColAlpha;
|
||||
}
|
||||
#endif
|
||||
|
||||
color.rgb = LinearToGammaSpace(color.rgb) * _LightOffset;
|
||||
|
||||
#ifdef UIEFFECT_GRAYSCALE
|
||||
color.rgb = Luminance(color.rgb) * 1; //全灰状态下,设置X倍亮度
|
||||
#elif UIEFFECT_GRAYSCALE_LERP
|
||||
color.rgb = lerp(Luminance(color.rgb), color.rgb, _GrayLerp);
|
||||
#endif
|
||||
|
||||
color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(color.a - 0.001);
|
||||
#endif
|
||||
|
||||
#ifdef UIEFFECT_WHITEALL
|
||||
color = (1, 1, 1, color.a);
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
10
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UI-Effect.shader.meta
vendored
Normal file
10
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UI-Effect.shader.meta
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ede8a18f8efc110419beef4572e9109b
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
181
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIEffectMaterialKey.cs
vendored
Normal file
181
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIEffectMaterialKey.cs
vendored
Normal file
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
internal struct UIEffectMaterialKey : IEquatable<UIEffectMaterialKey>
|
||||
{
|
||||
internal float BlurDistance;
|
||||
|
||||
internal Texture2D OverlayTexture;
|
||||
internal ColorModeEnum OverlayColorMode;
|
||||
internal float OverlaySpeed;
|
||||
|
||||
internal bool EnableInnerBevel;
|
||||
internal Color HighlightColor;
|
||||
internal ColorModeEnum HighlightColorMode;
|
||||
internal Color ShadowColor;
|
||||
internal ColorModeEnum ShadowColorMode;
|
||||
internal Vector2 HighlightOffset;
|
||||
|
||||
internal byte GrayScale;
|
||||
|
||||
public bool Equals(UIEffectMaterialKey o)
|
||||
{
|
||||
if (this.BlurDistance != o.BlurDistance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.OverlayTexture != o.OverlayTexture)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.OverlayColorMode != o.OverlayColorMode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.OverlaySpeed != o.OverlaySpeed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.EnableInnerBevel != o.EnableInnerBevel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.HighlightColor != o.HighlightColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.HighlightColorMode != o.HighlightColorMode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.ShadowColor != o.ShadowColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.ShadowColorMode != o.ShadowColorMode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.HighlightOffset != o.HighlightOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.GrayScale != o.GrayScale)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hash = this.BlurDistance.GetHashCode();
|
||||
if (this.OverlayTexture != null)
|
||||
{
|
||||
hash = (397 * hash) ^ this.OverlayTexture.GetHashCode();
|
||||
}
|
||||
|
||||
hash = (397 * hash) ^ this.OverlayColorMode.GetHashCode();
|
||||
hash = (397 * hash) ^ this.OverlaySpeed.GetHashCode();
|
||||
hash = (397 * hash) ^ this.EnableInnerBevel.GetHashCode();
|
||||
hash = (397 * hash) ^ this.HighlightColor.GetHashCode();
|
||||
hash = (397 * hash) ^ this.HighlightColorMode.GetHashCode();
|
||||
hash = (397 * hash) ^ this.ShadowColor.GetHashCode();
|
||||
hash = (397 * hash) ^ this.ShadowColorMode.GetHashCode();
|
||||
hash = (397 * hash) ^ this.HighlightOffset.GetHashCode();
|
||||
hash = (397 * hash) ^ this.GrayScale.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
internal Material CreateMaterial()
|
||||
{
|
||||
if (this.BlurDistance == 0 &&
|
||||
this.OverlayTexture == null &&
|
||||
!this.EnableInnerBevel &&
|
||||
this.GrayScale == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var shader = Shader.Find("YIUI/UIEffect");
|
||||
if (shader == null)
|
||||
{
|
||||
Debug.LogError("Can not found shader: 'YIUI/UIEffect'");
|
||||
return null;
|
||||
}
|
||||
|
||||
var material = new Material(shader);
|
||||
if (this.BlurDistance > 0)
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_BLUR");
|
||||
material.SetFloat(
|
||||
"_BlurDistance", this.BlurDistance);
|
||||
}
|
||||
|
||||
if (this.OverlayTexture != null)
|
||||
{
|
||||
if (this.OverlaySpeed > 0)
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_OVERLAY_ANIMATION");
|
||||
material.SetFloat(
|
||||
"_OverlaySpeed", this.OverlaySpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_OVERLAY");
|
||||
}
|
||||
|
||||
material.SetTexture(
|
||||
"_OverlayTex", this.OverlayTexture);
|
||||
material.SetInt(
|
||||
"_OverlayColorMode", (int)this.OverlayColorMode);
|
||||
}
|
||||
|
||||
if (this.EnableInnerBevel)
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_INNER_BEVEL");
|
||||
material.SetColor(
|
||||
"_HighlightColor", this.HighlightColor);
|
||||
material.SetInt(
|
||||
"_HighlightColorMode", (int)this.HighlightColorMode);
|
||||
material.SetColor(
|
||||
"_ShadowColor", this.ShadowColor);
|
||||
material.SetInt(
|
||||
"_ShadowColorMode", (int)this.ShadowColorMode);
|
||||
material.SetVector(
|
||||
"_HighlightOffset", this.HighlightOffset);
|
||||
}
|
||||
|
||||
if (this.GrayScale > 0)
|
||||
{
|
||||
if (this.GrayScale == 255)
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_GRAYSCALE");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("UIEFFECT_GRAYSCALE_LERP");
|
||||
material.SetFloat(
|
||||
"_GrayLerp",
|
||||
1.0f - (this.GrayScale / 255.0f));
|
||||
}
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fed5620bfa944b1fad6e01825dc407f3
|
||||
timeCreated: 1681377403
|
||||
107
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIEffectMaterials.cs
vendored
Normal file
107
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIEffectMaterials.cs
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
internal static class UIEffectMaterials
|
||||
{
|
||||
private static Dictionary<UIEffectMaterialKey, MaterialRef> materials =
|
||||
new Dictionary<UIEffectMaterialKey, MaterialRef>();
|
||||
|
||||
private static Dictionary<Material, UIEffectMaterialKey> lookup =
|
||||
new Dictionary<Material, UIEffectMaterialKey>();
|
||||
|
||||
internal static Material Get(UIEffectMaterialKey key)
|
||||
{
|
||||
MaterialRef matref;
|
||||
if (materials.TryGetValue(key, out matref))
|
||||
{
|
||||
++matref.RefCount;
|
||||
return matref.Material;
|
||||
}
|
||||
|
||||
var material = key.CreateMaterial();
|
||||
if (material == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
materials.Add(key, new MaterialRef(material));
|
||||
lookup.Add(material, key);
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
internal static void Free(Material material)
|
||||
{
|
||||
UIEffectMaterialKey key;
|
||||
if (!lookup.TryGetValue(material, out key))
|
||||
{
|
||||
Debug.LogError("Can not find the material key.");
|
||||
return;
|
||||
}
|
||||
|
||||
MaterialRef matref;
|
||||
if (!materials.TryGetValue(key, out matref))
|
||||
{
|
||||
Debug.LogError("Can not find the material reference.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (--matref.RefCount <= 0)
|
||||
{
|
||||
matref.Material.SafeDestroySelf();
|
||||
materials.Remove(key);
|
||||
lookup.Remove(material);
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private static void ClearCache()
|
||||
{
|
||||
materials.Clear();
|
||||
lookup.Clear();
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
#endif
|
||||
|
||||
private class MaterialKeyComparer : IEqualityComparer<UIEffectMaterialKey>
|
||||
{
|
||||
public bool Equals(UIEffectMaterialKey x, UIEffectMaterialKey y)
|
||||
{
|
||||
return x.Equals(y);
|
||||
}
|
||||
|
||||
public int GetHashCode(UIEffectMaterialKey obj)
|
||||
{
|
||||
return obj.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private class MaterialRef
|
||||
{
|
||||
private Material material;
|
||||
private int refcount;
|
||||
|
||||
public MaterialRef(Material material)
|
||||
{
|
||||
this.material = material;
|
||||
this.refcount = 1;
|
||||
}
|
||||
|
||||
public Material Material
|
||||
{
|
||||
get { return this.material; }
|
||||
}
|
||||
|
||||
public int RefCount
|
||||
{
|
||||
get { return this.refcount; }
|
||||
set { this.refcount = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c308540ddff41bc953ee01138bba22e
|
||||
timeCreated: 1681377592
|
||||
78
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIGrayscale.cs
vendored
Normal file
78
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIGrayscale.cs
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(UIMaterialEffect))]
|
||||
public sealed class UIGrayscale : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
[Range(0, 255)]
|
||||
private int grayscale = 0;
|
||||
|
||||
private UIMaterialEffect materialEffect;
|
||||
|
||||
public int GrayScale
|
||||
{
|
||||
get { return this.grayscale; }
|
||||
|
||||
set
|
||||
{
|
||||
if (this.grayscale != value)
|
||||
{
|
||||
this.grayscale = value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.Refresh();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (this.materialEffect != null)
|
||||
{
|
||||
var key = this.materialEffect.MaterialKey;
|
||||
key.GrayScale = 0;
|
||||
this.materialEffect.MaterialKey = key;
|
||||
this.materialEffect.MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
this.Refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var prefabType = PrefabUtility.GetPrefabType(this.gameObject);
|
||||
if (prefabType == PrefabType.Prefab)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (this.materialEffect == null)
|
||||
{
|
||||
this.materialEffect =
|
||||
this.GetOrAddComponent<UIMaterialEffect>();
|
||||
}
|
||||
|
||||
var key = this.materialEffect.MaterialKey;
|
||||
key.GrayScale = (byte)this.grayscale;
|
||||
this.materialEffect.MaterialKey = key;
|
||||
this.materialEffect.MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3499dbcc4b3d4088a5a6557cc38479d9
|
||||
timeCreated: 1681377624
|
||||
87
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIMaterialEffect.cs
vendored
Normal file
87
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Effect/UIMaterialEffect.cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
public sealed class UIMaterialEffect : MonoBehaviour, IMaterialModifier
|
||||
{
|
||||
private Graphic graphic;
|
||||
private UIEffectMaterialKey materialKey;
|
||||
private Material material;
|
||||
|
||||
internal UIEffectMaterialKey MaterialKey
|
||||
{
|
||||
get { return this.materialKey; }
|
||||
|
||||
set
|
||||
{
|
||||
if (!this.materialKey.Equals(value))
|
||||
{
|
||||
this.materialKey = value;
|
||||
if (this.material != null)
|
||||
{
|
||||
UIEffectMaterials.Free(this.material);
|
||||
this.material = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Material GetModifiedMaterial(Material baseMaterial)
|
||||
{
|
||||
Material usedMaterial = baseMaterial;
|
||||
if (this.enabled)
|
||||
{
|
||||
if (this.material == null)
|
||||
{
|
||||
this.material = UIEffectMaterials.Get(this.materialKey);
|
||||
}
|
||||
|
||||
if (this.material)
|
||||
{
|
||||
usedMaterial = this.material;
|
||||
}
|
||||
}
|
||||
|
||||
var maskable = this.graphic as MaskableGraphic;
|
||||
if (maskable != null)
|
||||
{
|
||||
return maskable.GetModifiedMaterial(usedMaterial);
|
||||
}
|
||||
|
||||
return usedMaterial;
|
||||
}
|
||||
|
||||
internal void MarkDirty()
|
||||
{
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.graphic = this.GetComponent<Graphic>();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (this.graphic != null)
|
||||
{
|
||||
this.graphic.SetMaterialDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09fb950d90f2446d896c58e2ae60c109
|
||||
timeCreated: 1681377379
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dab7d1e90fe449988fd5b162c80df4e0
|
||||
timeCreated: 1683685546
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public class DontDestroyOnLoadSelf : MonoBehaviour
|
||||
{
|
||||
private void Awake()
|
||||
{
|
||||
DontDestroyOnLoad(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cab7ade402b47a59bac4364f126f5e2
|
||||
timeCreated: 1686305565
|
||||
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Material.meta
vendored
Normal file
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Material.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68e0b5cacd4464943b44fd79240b87bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5179c1895e56a09479b597dab49cee80
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: YIUIImageBackGaussianBlur
|
||||
m_Shader: {fileID: 4800000, guid: b87c7e95a7d24459a865da64d4f3dc0f, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineZOffsetMaskTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AdditionalLightIgnoreCelShade: 0.9
|
||||
- _BlurAmount: 1
|
||||
- _BlurSize: 1
|
||||
- _BumpScale: 1
|
||||
- _CelShadeMidPoint: -0.5
|
||||
- _CelShadeSoftness: 0.05
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DirectLightMultiplier: 1
|
||||
- _DstBlend: 0
|
||||
- _EmissionMulByBaseColor: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _IndirectLightMultiplier: 1
|
||||
- _IsFace: 0
|
||||
- _MainLightIgnoreCelShade: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionRemapEnd: 1
|
||||
- _OcclusionRemapStart: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineWidth: 1
|
||||
- _OutlineZOffset: 0.0001
|
||||
- _OutlineZOffsetMaskRemapEnd: 1
|
||||
- _OutlineZOffsetMaskRemapStart: 0
|
||||
- _Parallax: 0.02
|
||||
- _ReceiveShadowMappingAmount: 0.65
|
||||
- _ReceiveShadowMappingPosOffset: 0
|
||||
- _Size: 2.69
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseAlphaClipping: 0
|
||||
- _UseEmission: 0
|
||||
- _UseOcclusion: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
- _blurSizeXY: 2
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionMapChannelMask: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _IndirectLightMinColor: {r: 0.1, g: 0.1, b: 0.1, a: 1}
|
||||
- _OcclusionMapChannelMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _OutlineColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _ShadowMapColor: {r: 1, g: 0.825, b: 0.78, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b243a8b8a144cb5488839c274b4072cc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,122 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: YIUIImageSelfGaussianBlur
|
||||
m_Shader: {fileID: 4800000, guid: eb17f9241e3a4581bb550a6de10f9a08, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OutlineZOffsetMaskTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AdditionalLightIgnoreCelShade: 0.9
|
||||
- _BlurAmount: 1
|
||||
- _BlurSize: 1
|
||||
- _BumpScale: 1
|
||||
- _CelShadeMidPoint: -0.5
|
||||
- _CelShadeSoftness: 0.05
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DirectLightMultiplier: 1
|
||||
- _DstBlend: 0
|
||||
- _EmissionMulByBaseColor: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _IndirectLightMultiplier: 1
|
||||
- _IsFace: 0
|
||||
- _MainLightIgnoreCelShade: 0
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionRemapEnd: 1
|
||||
- _OcclusionRemapStart: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _OutlineWidth: 1
|
||||
- _OutlineZOffset: 0.0001
|
||||
- _OutlineZOffsetMaskRemapEnd: 1
|
||||
- _OutlineZOffsetMaskRemapStart: 0
|
||||
- _Parallax: 0.02
|
||||
- _ReceiveShadowMappingAmount: 0.65
|
||||
- _ReceiveShadowMappingPosOffset: 0
|
||||
- _Size: 5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseAlphaClipping: 0
|
||||
- _UseEmission: 0
|
||||
- _UseOcclusion: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
- _blurSizeXY: 2
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _EmissionMapChannelMask: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _IndirectLightMinColor: {r: 0.1, g: 0.1, b: 0.1, a: 1}
|
||||
- _OcclusionMapChannelMask: {r: 1, g: 0, b: 0, a: 0}
|
||||
- _OutlineColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
- _ShadowMapColor: {r: 1, g: 0.825, b: 0.78, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca3c9f0dd5f094b4ba6f37b2706a4e58
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Shader.meta
vendored
Normal file
8
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Shader.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1a0effc252dac64aa48cee03bf2b6d6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7d20bdc19810bb46ae73540310e0036
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,90 @@
|
||||
Shader "YIUIShader/YIUICameraGaussianBlur"
|
||||
{
|
||||
// 高斯模糊
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {} // 主纹理
|
||||
_BlurSize ("Blur Size", Float) = 1.0 // 模糊尺寸(纹理坐标的偏移量)
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
CGINCLUDE
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex; // 主纹理
|
||||
half4 _MainTex_TexelSize; // _MainTex的像素尺寸大小, float4(1/width, 1/height, width, height)
|
||||
float _BlurSize; // 模糊尺寸(纹理坐标的偏移量)
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 pos : SV_POSITION; // 模型空间顶点坐标
|
||||
half2 uv[5]: TEXCOORD0; // 5个邻域的纹理坐标
|
||||
};
|
||||
|
||||
v2f vertBlurVertical(appdata_img v)
|
||||
{
|
||||
// 垂直模糊顶点着色器
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // 模型空间顶点坐标变换到裁剪空间, 等价于: mul(UNITY_MATRIX_MVP, v.vertex)
|
||||
half2 uv = v.texcoord;
|
||||
o.uv[0] = uv;
|
||||
o.uv[1] = uv + float2(0.0, _MainTex_TexelSize.y * 1.0) * _BlurSize;
|
||||
o.uv[2] = uv - float2(0.0, _MainTex_TexelSize.y * 1.0) * _BlurSize;
|
||||
o.uv[3] = uv + float2(0.0, _MainTex_TexelSize.y * 2.0) * _BlurSize;
|
||||
o.uv[4] = uv - float2(0.0, _MainTex_TexelSize.y * 2.0) * _BlurSize;
|
||||
return o;
|
||||
}
|
||||
|
||||
v2f vertBlurHorizontal(appdata_img v)
|
||||
{
|
||||
// 水平模糊顶点着色器
|
||||
v2f o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // 模型空间顶点坐标变换到裁剪空间, 等价于: mul(UNITY_MATRIX_MVP, v.vertex)
|
||||
half2 uv = v.texcoord;
|
||||
o.uv[0] = uv;
|
||||
o.uv[1] = uv + float2(_MainTex_TexelSize.x * 1.0, 0.0) * _BlurSize;
|
||||
o.uv[2] = uv - float2(_MainTex_TexelSize.x * 1.0, 0.0) * _BlurSize;
|
||||
o.uv[3] = uv + float2(_MainTex_TexelSize.x * 2.0, 0.0) * _BlurSize;
|
||||
o.uv[4] = uv - float2(_MainTex_TexelSize.x * 2.0, 0.0) * _BlurSize;
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 fragBlur(v2f i) : SV_Target
|
||||
{
|
||||
float weight[3] = {0.4026, 0.2442, 0.0545}; // 大小为5的一维高斯核,实际只需记录3个权值
|
||||
fixed3 sum = tex2D(_MainTex, i.uv[0]).rgb * weight[0];
|
||||
for (int j = 1; j < 3; j++)
|
||||
{
|
||||
sum += tex2D(_MainTex, i.uv[j * 2 - 1]).rgb * weight[j]; // 中心右侧或下侧的纹理*权值
|
||||
sum += tex2D(_MainTex, i.uv[j * 2]).rgb * weight[j]; // 中心左侧或上侧的纹理*权值
|
||||
}
|
||||
return fixed4(sum, 1.0);
|
||||
}
|
||||
ENDCG
|
||||
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
NAME "GAUSSIAN_BLUR_VERTICAL"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertBlurVertical
|
||||
#pragma fragment fragBlur
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
NAME "GAUSSIAN_BLUR_HORIZONTAL"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vertBlurHorizontal
|
||||
#pragma fragment fragBlur
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Diffuse"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f7e2d96029d0f040a214d05230aec54
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
preprocessorOverride: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
Shader "YIUIShader/YIUICameraMotionBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {} // 主纹理
|
||||
_BlurAmount ("Blur Amount", Float) = 1.0 // 模糊值, 通过alpha通道控制当前屏幕纹理与历史屏幕纹理进行混合
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
CGINCLUDE
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
sampler2D _MainTex; // 主纹理
|
||||
fixed _BlurAmount; // 模糊值, 通过alpha通道控制当前屏幕纹理与历史屏幕纹理进行混合
|
||||
|
||||
fixed4 fragRGB(v2f_img i) : SV_Target
|
||||
{
|
||||
// v2f_img为内置结构体, 里面只包含pos和uv
|
||||
return fixed4(tex2D(_MainTex, i.uv).rgb, _BlurAmount);
|
||||
}
|
||||
|
||||
half4 fragA(v2f_img i) : SV_Target
|
||||
{
|
||||
// v2f_img为内置结构体, 里面只包含pos和uv
|
||||
return tex2D(_MainTex, i.uv);
|
||||
}
|
||||
ENDCG
|
||||
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask RGB // 允许通过的颜色通道, 取值有: 0、R、G、B、A、RGBA的组合(RG、RGB等)
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_img // 使用内置的vert_img顶点着色器
|
||||
#pragma fragment fragRGB // _BlurAmount只参与混合, 不影响alpha值
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Blend One Zero
|
||||
ColorMask A // 允许通过的颜色通道, 取值有: 0、R、G、B、A、RGBA的组合(RG、RGB等)
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_img // 使用内置的vert_img顶点着色器
|
||||
#pragma fragment fragA // 使用纹理原本的alpha值
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
FallBack Off
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7198712ca3044b794c0b7fb9b85d81a
|
||||
timeCreated: 1687675483
|
||||
@@ -0,0 +1,267 @@
|
||||
Shader "YIUIShader/YIUIImageBackGaussianBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Main Color", Color) = (1,1,1,1)
|
||||
_Size ("Size", Range(0, 20)) = 1
|
||||
}
|
||||
Category
|
||||
{
|
||||
|
||||
// We must be transparent, so other objects are drawn before this one.
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType" = "Plane"
|
||||
"CanUseSpriteAtlas" = "True"
|
||||
}
|
||||
|
||||
|
||||
SubShader
|
||||
{
|
||||
|
||||
// Horizontal blur
|
||||
GrabPass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Always"
|
||||
}
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Always"
|
||||
}
|
||||
Name "BackBlurHor"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 uvgrab : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
||||
o.uvgrab.zw = o.vertex.zw;
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
float4 _GrabTexture_TexelSize;
|
||||
float4 _MainTex_TexelSize;
|
||||
float _Size;
|
||||
uniform float4 _Color;
|
||||
// static float GaussianKernel[9] = {
|
||||
// 0.05, 0.09, 0.12,
|
||||
// 0.15, 0.18, 0.15,
|
||||
// 0.12, 0.09, 0.05
|
||||
// };
|
||||
// static float GaussianKernel[19] = {
|
||||
// 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09,
|
||||
// 0.1,
|
||||
// 0.09, 0.08, 0.07, 0.06, 0.05, 0.04, 0.03, 0.02, 0.01,
|
||||
// };
|
||||
// static float GaussianKernelD[19] = {
|
||||
// -9.0, -8.0, -7.0, -6.0, -5.0, -4.0, -3.0, -2.0, -1.0,
|
||||
// 0.0,
|
||||
// +1.0, +2.0, +3.0, +4.0, +5.0, +6.0, +7.0, +8.0, +9.0,
|
||||
// };
|
||||
half4 GrabPixel(v2f i, float weight, float kernelx)
|
||||
{
|
||||
if (i.uvgrab.x == 0 && i.uvgrab.y == 0)
|
||||
{
|
||||
kernelx = 0;
|
||||
}
|
||||
return tex2Dproj(_GrabTexture,
|
||||
UNITY_PROJ_COORD(
|
||||
float4(i.uvgrab.x + _GrabTexture_TexelSize.x*kernelx*_Size, i.uvgrab.y, i.
|
||||
uvgrab.z, i.uvgrab.w))) * weight;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
// #define GRABPIXEL(weight, kernelx) tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x + _GrabTexture_TexelSize.x * kernelx*_Size, i.uvgrab.y, i.uvgrab.z, i.uvgrab.w))) * weight
|
||||
|
||||
sum += GrabPixel(i, 0.05, -4.0);
|
||||
sum += GrabPixel(i, 0.09, -3.0);
|
||||
sum += GrabPixel(i, 0.12, -2.0);
|
||||
sum += GrabPixel(i, 0.15, -1.0);
|
||||
sum += GrabPixel(i, 0.18, 0.0);
|
||||
sum += GrabPixel(i, 0.15, +1.0);
|
||||
sum += GrabPixel(i, 0.12, +2.0);
|
||||
sum += GrabPixel(i, 0.09, +3.0);
|
||||
sum += GrabPixel(i, 0.05, +4.0);
|
||||
// sum += GrabPixel(i, 0.01, -9.0);
|
||||
// sum += GrabPixel(i, 0.02, -8.0);
|
||||
// sum += GrabPixel(i, 0.03, -7.0);
|
||||
// sum += GrabPixel(i, 0.04, -6.0);
|
||||
// sum += GrabPixel(i, 0.05, -5.0);
|
||||
// sum += GrabPixel(i, 0.06, -4.0);
|
||||
// sum += GrabPixel(i, 0.07, -3.0);
|
||||
// sum += GrabPixel(i, 0.08, -2.0);
|
||||
// sum += GrabPixel(i, 0.09, -1.0);
|
||||
// sum += GrabPixel(i, 0.10, 0.0);
|
||||
// sum += GrabPixel(i, 0.09, +1.0);
|
||||
// sum += GrabPixel(i, 0.08, +2.0);
|
||||
// sum += GrabPixel(i, 0.07, +3.0);
|
||||
// sum += GrabPixel(i, 0.06, +4.0);
|
||||
// sum += GrabPixel(i, 0.05, +5.0);
|
||||
// sum += GrabPixel(i, 0.04, +6.0);
|
||||
// sum += GrabPixel(i, 0.03, +7.0);
|
||||
// sum += GrabPixel(i, 0.02, +8.0);
|
||||
// sum += GrabPixel(i, 0.01, +9.0);
|
||||
float4 col5 = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
|
||||
float decayFactor = 1.0f;
|
||||
if (i.uvgrab.x == 0 && i.uvgrab.y == 0)
|
||||
{
|
||||
decayFactor = 0;
|
||||
}
|
||||
sum = lerp(col5, sum, decayFactor) * i.color * _Color;
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
// Vertical blur
|
||||
GrabPass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Always"
|
||||
}
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"LightMode" = "Always"
|
||||
}
|
||||
Name "BackBlurVer"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 texcoord: TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 uvgrab : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
};
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
float scale = -1.0;
|
||||
#else
|
||||
float scale = 1.0;
|
||||
#endif
|
||||
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y * scale) + o.vertex.w) * 0.5;
|
||||
o.uvgrab.zw = o.vertex.zw;
|
||||
o.color = v.color;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _GrabTexture;
|
||||
float4 _GrabTexture_TexelSize;
|
||||
float _Size;
|
||||
uniform float4 _Color;
|
||||
|
||||
half4 GrabPixel(v2f i, float weight, float kernely)
|
||||
{
|
||||
if (i.uvgrab.x == 0 && i.uvgrab.y == 0)
|
||||
{
|
||||
kernely = 0;
|
||||
}
|
||||
return tex2Dproj(_GrabTexture,
|
||||
UNITY_PROJ_COORD(
|
||||
float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y*kernely*_Size, i.
|
||||
uvgrab.z, i.uvgrab.w))) * weight;
|
||||
}
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
// #define GRABPIXEL(weight,kernely) tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(float4(i.uvgrab.x, i.uvgrab.y + _GrabTexture_TexelSize.y * kernely*_Size, i.uvgrab.z, i.uvgrab.w))) * weight
|
||||
|
||||
sum += GrabPixel(i, 0.05, -4.0);
|
||||
sum += GrabPixel(i, 0.09, -3.0);
|
||||
sum += GrabPixel(i, 0.12, -2.0);
|
||||
sum += GrabPixel(i, 0.15, -1.0);
|
||||
sum += GrabPixel(i, 0.18, 0.0);
|
||||
sum += GrabPixel(i, 0.15, +1.0);
|
||||
sum += GrabPixel(i, 0.12, +2.0);
|
||||
sum += GrabPixel(i, 0.09, +3.0);
|
||||
sum += GrabPixel(i, 0.05, +4.0);
|
||||
// sum += GrabPixel(i, 0.01, -9.0);
|
||||
// sum += GrabPixel(i, 0.02, -8.0);
|
||||
// sum += GrabPixel(i, 0.03, -7.0);
|
||||
// sum += GrabPixel(i, 0.04, -6.0);
|
||||
// sum += GrabPixel(i, 0.05, -5.0);
|
||||
// sum += GrabPixel(i, 0.06, -4.0);
|
||||
// sum += GrabPixel(i, 0.07, -3.0);
|
||||
// sum += GrabPixel(i, 0.08, -2.0);
|
||||
// sum += GrabPixel(i, 0.09, -1.0);
|
||||
// sum += GrabPixel(i, 0.10, 0.0);
|
||||
// sum += GrabPixel(i, 0.09, +1.0);
|
||||
// sum += GrabPixel(i, 0.08, +2.0);
|
||||
// sum += GrabPixel(i, 0.07, +3.0);
|
||||
// sum += GrabPixel(i, 0.06, +4.0);
|
||||
// sum += GrabPixel(i, 0.05, +5.0);
|
||||
// sum += GrabPixel(i, 0.04, +6.0);
|
||||
// sum += GrabPixel(i, 0.03, +7.0);
|
||||
// sum += GrabPixel(i, 0.02, +8.0);
|
||||
// sum += GrabPixel(i, 0.01, +9.0);
|
||||
float4 col5 = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
|
||||
float decayFactor = 1.0f;
|
||||
if (i.uvgrab.x == 0 && i.uvgrab.y == 0)
|
||||
{
|
||||
decayFactor = 0;
|
||||
}
|
||||
sum = lerp(col5, sum, decayFactor) * i.color * _Color;
|
||||
|
||||
return sum;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b87c7e95a7d24459a865da64d4f3dc0f
|
||||
timeCreated: 1687676969
|
||||
@@ -0,0 +1,373 @@
|
||||
Shader "YIUIShader/YIUIImageSelfGaussianBlur"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector]_StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector]_Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector]_StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector]_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector]_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector]_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
_Size ("Size", Range(0, 50)) = 5
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FrontBlurHor"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
float _Size;
|
||||
|
||||
half4 GrabPixel(v2f i, float weight, float kernelx)
|
||||
{
|
||||
if (_Size <= 1 || weight == 0)
|
||||
{
|
||||
return tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size, i.texcoord.y)) *
|
||||
weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size * 0.2,
|
||||
i.texcoord.y)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size * 0.4,
|
||||
i.texcoord.y)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size * 0.6,
|
||||
i.texcoord.y)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size * 0.8,
|
||||
i.texcoord.y)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x + _MainTex_TexelSize.x * kernelx * _Size * 1.0,
|
||||
i.texcoord.y)) * 0.2;
|
||||
return (sum + _TextureSampleAdd) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
half4 GrabPixely(v2f i, float weight, float kernely)
|
||||
{
|
||||
if (_Size <= 1 || weight == 0)
|
||||
{
|
||||
return tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size)) *
|
||||
weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.2)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.4)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.6)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.8)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 1.0)) * 0.2;
|
||||
return (sum + _TextureSampleAdd) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
// #define GRABPIXEL(weight, kernelx) (tex2D(_MainTex, half2(IN.texcoord.x + _MainTex_TexelSize.x * kernelx*_Size, IN.texcoord.y)) + _TextureSampleAdd) * weight
|
||||
|
||||
// sum += GrabPixel(IN, 0.05, -4.0);
|
||||
// sum += GrabPixel(IN, 0.09, -3.0);
|
||||
// sum += GrabPixel(IN, 0.12, -2.0);
|
||||
// sum += GrabPixel(IN, 0.15, -1.0);
|
||||
// sum += GrabPixel(IN, 0.18, 0.0);
|
||||
// sum += GrabPixel(IN, 0.15, +1.0);
|
||||
// sum += GrabPixel(IN, 0.12, +2.0);
|
||||
// sum += GrabPixel(IN, 0.09, +3.0);
|
||||
// sum += GrabPixel(IN, 0.05, +4.0);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
sum += GrabPixel(IN, 1.0 / 9, i - 4.0);
|
||||
}
|
||||
|
||||
// half4 sumy = half4(0,0,0,0);
|
||||
// for(int i=0;i<15;i++){
|
||||
// sumy += GrabPixely(IN, 1.0/15, i-7.0);
|
||||
// }
|
||||
// half4 sum = (sumx + sumy) * 0.5;
|
||||
|
||||
// sum += GrabPixel(IN, 0.01, -9.0);
|
||||
// sum += GrabPixel(IN, 0.02, -8.0);
|
||||
// sum += GrabPixel(IN, 0.03, -7.0);
|
||||
// sum += GrabPixel(IN, 0.04, -6.0);
|
||||
// sum += GrabPixel(IN, 0.05, -5.0);
|
||||
// sum += GrabPixel(IN, 0.06, -4.0);
|
||||
// sum += GrabPixel(IN, 0.07, -3.0);
|
||||
// sum += GrabPixel(IN, 0.08, -2.0);
|
||||
// sum += GrabPixel(IN, 0.09, -1.0);
|
||||
// sum += GrabPixel(IN, 0.10, 0.0);
|
||||
// sum += GrabPixel(IN, 0.09, +1.0);
|
||||
// sum += GrabPixel(IN, 0.08, +2.0);
|
||||
// sum += GrabPixel(IN, 0.07, +3.0);
|
||||
// sum += GrabPixel(IN, 0.06, +4.0);
|
||||
// sum += GrabPixel(IN, 0.05, +5.0);
|
||||
// sum += GrabPixel(IN, 0.04, +6.0);
|
||||
// sum += GrabPixel(IN, 0.03, +7.0);
|
||||
// sum += GrabPixel(IN, 0.02, +8.0);
|
||||
// sum += GrabPixel(IN, 0.01, +9.0);
|
||||
|
||||
sum = sum * IN.color;
|
||||
sum.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (sum.a - 0.001);
|
||||
#endif
|
||||
return sum;
|
||||
|
||||
// float distance = _Distance;
|
||||
|
||||
// fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color /= 9;
|
||||
|
||||
// color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
// #ifdef UNITY_UI_ALPHACLIP
|
||||
// clip (color.a - 0.001);
|
||||
// #endif
|
||||
|
||||
// return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "FrontBlurVer"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
v2f vert(appdata_t IN)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
OUT.color = IN.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
float _Size;
|
||||
|
||||
half4 GrabPixel(v2f i, float weight, float kernely)
|
||||
{
|
||||
if (_Size <= 1 || weight == 0)
|
||||
{
|
||||
return tex2D(_MainTex, half2(i.texcoord.x, i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size)) *
|
||||
weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.2)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.4)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.6)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 0.8)) * 0.2;
|
||||
sum += tex2D(_MainTex, half2(i.texcoord.x,
|
||||
i.texcoord.y + _MainTex_TexelSize.y * kernely * _Size * 1.0)) * 0.2;
|
||||
return (sum + _TextureSampleAdd) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 sum = half4(0, 0, 0, 0);
|
||||
// #define GRABPIXEL(weight, kernely) (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + _MainTex_TexelSize.y * kernely*_Size)) + _TextureSampleAdd) * weight
|
||||
|
||||
// sum += GrabPixel(IN, 0.05, -4.0);
|
||||
// sum += GrabPixel(IN, 0.09, -3.0);
|
||||
// sum += GrabPixel(IN, 0.12, -2.0);
|
||||
// sum += GrabPixel(IN, 0.15, -1.0);
|
||||
// sum += GrabPixel(IN, 0.18, 0.0);
|
||||
// sum += GrabPixel(IN, 0.15, +1.0);
|
||||
// sum += GrabPixel(IN, 0.12, +2.0);
|
||||
// sum += GrabPixel(IN, 0.09, +3.0);
|
||||
// sum += GrabPixel(IN, 0.05, +4.0);
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
sum += GrabPixel(IN, 1.0 / 9, i - 4.0);
|
||||
}
|
||||
|
||||
// sum += GrabPixel(IN, 0.01, -9.0);
|
||||
// sum += GrabPixel(IN, 0.02, -8.0);
|
||||
// sum += GrabPixel(IN, 0.03, -7.0);
|
||||
// sum += GrabPixel(IN, 0.04, -6.0);
|
||||
// sum += GrabPixel(IN, 0.05, -5.0);
|
||||
// sum += GrabPixel(IN, 0.06, -4.0);
|
||||
// sum += GrabPixel(IN, 0.07, -3.0);
|
||||
// sum += GrabPixel(IN, 0.08, -2.0);
|
||||
// sum += GrabPixel(IN, 0.09, -1.0);
|
||||
// sum += GrabPixel(IN, 0.10, 0.0);
|
||||
// sum += GrabPixel(IN, 0.09, +1.0);
|
||||
// sum += GrabPixel(IN, 0.08, +2.0);
|
||||
// sum += GrabPixel(IN, 0.07, +3.0);
|
||||
// sum += GrabPixel(IN, 0.06, +4.0);
|
||||
// sum += GrabPixel(IN, 0.05, +5.0);
|
||||
// sum += GrabPixel(IN, 0.04, +6.0);
|
||||
// sum += GrabPixel(IN, 0.03, +7.0);
|
||||
// sum += GrabPixel(IN, 0.02, +8.0);
|
||||
// sum += GrabPixel(IN, 0.01, +9.0);
|
||||
|
||||
sum = sum * IN.color;
|
||||
sum.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (sum.a - 0.001);
|
||||
#endif
|
||||
return sum;
|
||||
|
||||
// float distance = _Distance;
|
||||
|
||||
// fixed4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd) * IN.color;
|
||||
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x + distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y - distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x - distance, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color += (tex2D(_MainTex, half2(IN.texcoord.x, IN.texcoord.y + distance)) + _TextureSampleAdd) * IN.color;
|
||||
// color /= 9;
|
||||
|
||||
// color.a *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
// #ifdef UNITY_UI_ALPHACLIP
|
||||
// clip (color.a - 0.001);
|
||||
// #endif
|
||||
|
||||
// return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb17f9241e3a4581bb550a6de10f9a08
|
||||
timeCreated: 1687676099
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Tool.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/Tool.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50be4e96eeea40549787af25e84adb8d
|
||||
timeCreated: 1685603306
|
||||
@@ -0,0 +1,334 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public class ContentSizeFilterByChildren: UIBehaviour, ILayoutElement, ILayoutSelfController, ILayoutGroup
|
||||
{
|
||||
public enum FitMode
|
||||
{
|
||||
Width,
|
||||
Height,
|
||||
Both
|
||||
}
|
||||
|
||||
public enum SizeMode
|
||||
{
|
||||
Add,
|
||||
Max
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected SizeMode m_Size = SizeMode.Add;
|
||||
|
||||
[SerializeField]
|
||||
protected FitMode m_Fit = FitMode.Height;
|
||||
|
||||
public FitMode fit
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_Fit;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_Fit = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float m_MaxSize = int.MaxValue;
|
||||
|
||||
public float maxSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_MaxSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_MaxSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected int m_layoutPriority = 1;
|
||||
|
||||
public int layoutPriority
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_layoutPriority;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_layoutPriority = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float m_minWidth = -1;
|
||||
|
||||
public float minWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_minWidth;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_minWidth = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float m_minHeight = -1;
|
||||
|
||||
public float minHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_minHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_minHeight = value;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float m_Space = 0;
|
||||
|
||||
[System.NonSerialized]
|
||||
private RectTransform m_Rect;
|
||||
|
||||
private RectTransform rectTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Rect == null)
|
||||
m_Rect = GetComponent<RectTransform>();
|
||||
return m_Rect;
|
||||
}
|
||||
}
|
||||
|
||||
private HorizontalOrVerticalLayoutGroup m_LayoutGroup = null;
|
||||
|
||||
public void AutoSize()
|
||||
{
|
||||
if (m_Fit == FitMode.Width || m_Fit == FitMode.Both)
|
||||
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal,
|
||||
((ILayoutElement)this).preferredWidth);
|
||||
if (m_Fit == FitMode.Height || m_Fit == FitMode.Both)
|
||||
rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical,
|
||||
((ILayoutElement)this).preferredHeight);
|
||||
}
|
||||
|
||||
void ILayoutController.SetLayoutHorizontal()
|
||||
{
|
||||
AutoSize();
|
||||
}
|
||||
|
||||
void ILayoutController.SetLayoutVertical()
|
||||
{
|
||||
AutoSize();
|
||||
}
|
||||
|
||||
float ILayoutElement.minWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_minWidth;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.preferredWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
float size = -1;
|
||||
float max = -2;
|
||||
if (m_Fit == FitMode.Width || m_Fit == FitMode.Both)
|
||||
{
|
||||
max = 0;
|
||||
size = 0;
|
||||
float spacing = m_Space;
|
||||
if (m_LayoutGroup != null)
|
||||
{
|
||||
size = size + m_LayoutGroup.padding.left + m_LayoutGroup.padding.right;
|
||||
if (m_LayoutGroup is HorizontalLayoutGroup)
|
||||
spacing = m_LayoutGroup.spacing;
|
||||
}
|
||||
|
||||
int One = 1;
|
||||
for (int i = 0; i < rectTransform.childCount; ++i)
|
||||
{
|
||||
var child = rectTransform.GetChild(i) as RectTransform;
|
||||
if (child.gameObject.activeSelf)
|
||||
{
|
||||
var ignore = child.GetComponent<ILayoutIgnorer>();
|
||||
if (ignore != null && ignore.ignoreLayout)
|
||||
continue;
|
||||
|
||||
if (m_Size == SizeMode.Add)
|
||||
{
|
||||
size += Mathf.Max(0, LayoutUtility.GetPreferredWidth(child));
|
||||
|
||||
if (One == 0)
|
||||
size += spacing;
|
||||
if (One == 1)
|
||||
One = 0;
|
||||
}
|
||||
|
||||
//else if (m_Size == SizeMode.Max)
|
||||
//{
|
||||
// size = size + Mathf.Max(size, LayoutUtility.GetPreferredWidth(child));
|
||||
// break;
|
||||
//}
|
||||
else if (m_Size == SizeMode.Max)
|
||||
{
|
||||
max = Mathf.Max(max, LayoutUtility.GetPreferredWidth(child) + size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Size == SizeMode.Max)
|
||||
size = max;
|
||||
|
||||
size = Mathf.Min(maxSize, size);
|
||||
if (minWidth > 0)
|
||||
{
|
||||
size = Mathf.Max(minWidth, size);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.flexibleWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.minHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_minHeight;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.preferredHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
float size = -1;
|
||||
float max = 0;
|
||||
if (m_Fit == FitMode.Height || m_Fit == FitMode.Both)
|
||||
{
|
||||
size = 0;
|
||||
float spacing = m_Space;
|
||||
if (m_LayoutGroup != null)
|
||||
{
|
||||
size = size + m_LayoutGroup.padding.top + m_LayoutGroup.padding.bottom;
|
||||
if (m_LayoutGroup is VerticalLayoutGroup)
|
||||
spacing = m_LayoutGroup.spacing;
|
||||
}
|
||||
|
||||
int One = 1;
|
||||
|
||||
for (int i = 0; i < rectTransform.childCount; ++i)
|
||||
{
|
||||
var child = rectTransform.GetChild(i) as RectTransform;
|
||||
if (child.gameObject.activeSelf)
|
||||
{
|
||||
var ignore = child.GetComponent<ILayoutIgnorer>();
|
||||
if (ignore != null && ignore.ignoreLayout)
|
||||
continue;
|
||||
|
||||
if (m_Size == SizeMode.Add)
|
||||
{
|
||||
size += Mathf.Max(0, LayoutUtility.GetPreferredHeight(child));
|
||||
|
||||
if (One == 0)
|
||||
size += spacing;
|
||||
if (One == 1)
|
||||
One = 0;
|
||||
}
|
||||
else if (m_Size == SizeMode.Max)
|
||||
{
|
||||
max = Mathf.Max(max, LayoutUtility.GetPreferredHeight(child) + size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Size == SizeMode.Max)
|
||||
size = max;
|
||||
size = Mathf.Min(maxSize, size);
|
||||
if (minHeight > 0)
|
||||
{
|
||||
size = Mathf.Max(minHeight, size);
|
||||
}
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.flexibleHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int ILayoutElement.layoutPriority
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_layoutPriority;
|
||||
}
|
||||
}
|
||||
|
||||
void ILayoutElement.CalculateLayoutInputHorizontal()
|
||||
{
|
||||
AutoSize();
|
||||
}
|
||||
|
||||
void ILayoutElement.CalculateLayoutInputVertical()
|
||||
{
|
||||
AutoSize();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
}
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
m_LayoutGroup = GetComponent<HorizontalOrVerticalLayoutGroup>();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
protected override void OnValidate()
|
||||
{
|
||||
OnEnable();
|
||||
m_LayoutGroup = GetComponent<HorizontalOrVerticalLayoutGroup>();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d75fd91549d34a5f9f811c6159dd09f5
|
||||
timeCreated: 1685603306
|
||||
@@ -0,0 +1,105 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
public class ContentSizeFilterByRect : UIBehaviour, ILayoutElement
|
||||
{
|
||||
public enum FitMode
|
||||
{
|
||||
Width,
|
||||
Height,
|
||||
Both,
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected FitMode m_Fit = FitMode.Both;
|
||||
|
||||
public FitMode fit
|
||||
{
|
||||
get { return m_Fit; }
|
||||
set { m_Fit = value; }
|
||||
}
|
||||
|
||||
[System.NonSerialized]
|
||||
private RectTransform m_Rect;
|
||||
|
||||
private RectTransform rectTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Rect == null)
|
||||
m_Rect = GetComponent<RectTransform>();
|
||||
return m_Rect;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.minWidth
|
||||
{
|
||||
get { return ((ILayoutElement)this).preferredWidth; }
|
||||
}
|
||||
|
||||
float ILayoutElement.preferredWidth
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Fit == FitMode.Both || m_Fit == FitMode.Width)
|
||||
return rectTransform.rect.width;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.flexibleWidth
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
|
||||
float ILayoutElement.minHeight
|
||||
{
|
||||
get { return ((ILayoutElement)this).preferredHeight; }
|
||||
}
|
||||
|
||||
float ILayoutElement.preferredHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Fit == FitMode.Both || m_Fit == FitMode.Height)
|
||||
return rectTransform.rect.height;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
float ILayoutElement.flexibleHeight
|
||||
{
|
||||
get { return -1; }
|
||||
}
|
||||
|
||||
int ILayoutElement.layoutPriority
|
||||
{
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
void ILayoutElement.CalculateLayoutInputHorizontal()
|
||||
{
|
||||
}
|
||||
|
||||
void ILayoutElement.CalculateLayoutInputVertical()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
LayoutRebuilder.MarkLayoutForRebuild(rectTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dd126203a544f88b9f34f27f68cc9c9
|
||||
timeCreated: 1685603306
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6186b8e335f184c478290e546e273795
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,60 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 高斯模糊特效
|
||||
/// </summary>
|
||||
[ExecuteInEditMode] // 编辑态可以查看脚本运行效果
|
||||
[RequireComponent(typeof(Camera))] // 需要相机组件
|
||||
public class YIUICameraGaussianBlur : MonoBehaviour
|
||||
{
|
||||
[Range(0, 4)]
|
||||
public int iterations = 3; // 高斯模糊迭代次数
|
||||
|
||||
[Range(0.2f, 3.0f)]
|
||||
public float blurSpread = 0.6f; // 每次迭代纹理坐标偏移的速度
|
||||
|
||||
[Range(1, 8)]
|
||||
public int downSample = 2; // 降采样比率
|
||||
|
||||
private Material material = null; // 材质
|
||||
|
||||
private void Start()
|
||||
{
|
||||
material = new Material(Shader.Find("YIUIShader/YIUICameraGaussianBlur"));
|
||||
material.hideFlags = HideFlags.DontSave;
|
||||
}
|
||||
|
||||
void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
if (material != null)
|
||||
{
|
||||
int rtW = src.width / downSample; // 降采样的纹理宽度
|
||||
int rtH = src.height / downSample; // 降采样的纹理高度
|
||||
RenderTexture buffer0 = RenderTexture.GetTemporary(rtW, rtH, 0);
|
||||
buffer0.filterMode = FilterMode.Bilinear; // 滤波模式设置为双线性
|
||||
Graphics.Blit(src, buffer0);
|
||||
for (int i = 0; i < iterations; i++)
|
||||
{
|
||||
material.SetFloat("_BlurSize", 1.0f + i * blurSpread); // 设置模糊尺寸(纹理坐标的偏移量)
|
||||
RenderTexture buffer1 = RenderTexture.GetTemporary(rtW, rtH, 0);
|
||||
Graphics.Blit(buffer0, buffer1, material, 0); // 渲染垂直的Pass
|
||||
RenderTexture.ReleaseTemporary(buffer0);
|
||||
buffer0 = buffer1;
|
||||
buffer1 = RenderTexture.GetTemporary(rtW, rtH, 0);
|
||||
Graphics.Blit(buffer0, buffer1, material, 1); // 渲染水平的Pass
|
||||
RenderTexture.ReleaseTemporary(buffer0);
|
||||
buffer0 = buffer1;
|
||||
}
|
||||
|
||||
Graphics.Blit(buffer0, dest);
|
||||
RenderTexture.ReleaseTemporary(buffer0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics.Blit(src, dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05dc8c238e41430f83e9e0d0278b96e2
|
||||
timeCreated: 1687674753
|
||||
@@ -0,0 +1,52 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 运动模糊特效
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(Camera))] // 需要相机组件
|
||||
public class YIUICameraMotionBlur : MonoBehaviour
|
||||
{
|
||||
[Range(0.0f, 0.9f)]
|
||||
public float blurAmount = 0.5f; // 模糊值, 值越大拖尾效果越明显
|
||||
|
||||
private RenderTexture historyTexture; // 历史屏幕纹理
|
||||
private Material material = null; // 材质
|
||||
|
||||
private void Start()
|
||||
{
|
||||
material = new Material(Shader.Find("YIUIShader/YIUICameraMotionBlur"));
|
||||
material.hideFlags = HideFlags.DontSave;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
// 脚本不运行时立即销毁, 下次开始应用运动模糊时, 重新混合图像
|
||||
DestroyImmediate(historyTexture);
|
||||
}
|
||||
|
||||
void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
if (material != null)
|
||||
{
|
||||
// 初始化时或窗口尺寸变化时, 创建叠加纹理
|
||||
if (historyTexture == null || historyTexture.width != src.width || historyTexture.height != src.height)
|
||||
{
|
||||
DestroyImmediate(historyTexture);
|
||||
historyTexture = new RenderTexture(src.width, src.height, 0);
|
||||
historyTexture.hideFlags = HideFlags.HideAndDontSave;
|
||||
Graphics.Blit(src, historyTexture);
|
||||
}
|
||||
|
||||
material.SetFloat("_BlurAmount", 1.0f - blurAmount); // 设置模糊值, 通过alpha通道控制当前屏幕纹理与历史屏幕纹理进行混合
|
||||
Graphics.Blit(src, historyTexture, material);
|
||||
Graphics.Blit(historyTexture, dest);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics.Blit(src, dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1166d12e60c4b7bb71939e1d5c3762f
|
||||
timeCreated: 1687675445
|
||||
@@ -0,0 +1,77 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8203712829968715909
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 6187606721477242293}
|
||||
- component: {fileID: 1806377903031401790}
|
||||
- component: {fileID: 8893579309878970462}
|
||||
m_Layer: 5
|
||||
m_Name: YIUIImageBackGaussianBlur
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &6187606721477242293
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8203712829968715909}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &1806377903031401790
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8203712829968715909}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &8893579309878970462
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8203712829968715909}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: b243a8b8a144cb5488839c274b4072cc, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0840c9a860a39f4da384be99598b879
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,77 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &3554010424902499222
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3433778286568191839}
|
||||
- component: {fileID: 154720680013837306}
|
||||
- component: {fileID: 1533940618106898788}
|
||||
m_Layer: 5
|
||||
m_Name: YIUIImageSelfGaussianBlur
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &3433778286568191839
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3554010424902499222}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &154720680013837306
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3554010424902499222}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &1533940618106898788
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3554010424902499222}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: ca3c9f0dd5f094b4ba6f37b2706a4e58, type: 2}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8555a9e30644f748bccd04169b1734b
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,69 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
///自适应不同分辨率。
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(CanvasScaler))]
|
||||
[ExecuteInEditMode]
|
||||
public class ResolutionAdapter : MonoBehaviour
|
||||
{
|
||||
private Canvas canvas;
|
||||
private CanvasScaler scaler;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
this.canvas = this.GetComponent<Canvas>();
|
||||
if (null == this.canvas || !this.canvas.isRootCanvas)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.AdaptResolution();
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
this.AdaptResolution();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
this.AdaptResolution();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void AdaptResolution()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
var prefabType = PrefabUtility.GetPrefabAssetType(this.gameObject);
|
||||
if (prefabType == PrefabAssetType.Regular)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (null == this.scaler)
|
||||
{
|
||||
this.scaler = this.GetComponent<CanvasScaler>();
|
||||
}
|
||||
|
||||
var radio = (float)Screen.width / Screen.height;
|
||||
var refRadio = this.scaler.referenceResolution.x / this.scaler.referenceResolution.y;
|
||||
if (radio >= refRadio)
|
||||
{
|
||||
this.scaler.matchWidthOrHeight = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.scaler.matchWidthOrHeight = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bfab45850b3741c2b940fc389674b52e
|
||||
timeCreated: 1685603306
|
||||
@@ -0,0 +1,85 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击按钮影响组件大小
|
||||
/// </summary>
|
||||
public class YIUIClickEffect : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
[Tooltip("被影响的目标")]
|
||||
public RectTransform targetTsf;
|
||||
|
||||
[Tooltip("变化大小 (倍数)")]
|
||||
public float scaleValue = 0.9f;
|
||||
|
||||
[Tooltip("变小时间")]
|
||||
public float scaleTime = 0;
|
||||
|
||||
[Tooltip("变大时间")]
|
||||
public float popTime = 0;
|
||||
|
||||
private Button m_button;
|
||||
|
||||
private Vector3 targetScale; //目标大小
|
||||
private Vector3 atScale; //当前大小
|
||||
|
||||
/// <summary>
|
||||
/// 可调整动画状态
|
||||
/// </summary>
|
||||
public Ease ease = Ease.OutElastic;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
m_button = GetComponent<Button>(); //需要先挂button 否则无效
|
||||
if (targetTsf == null) //如果没有目标则默认自己为目标
|
||||
{
|
||||
targetTsf = transform.gameObject.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
atScale = targetTsf.localScale;
|
||||
targetScale = atScale * scaleValue;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
targetTsf.DOKill();
|
||||
}
|
||||
|
||||
//按下
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (m_button)
|
||||
{
|
||||
if (m_button.enabled && m_button.interactable)
|
||||
{
|
||||
targetTsf.DOScale(targetScale, scaleTime).SetEase(ease);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetTsf.DOScale(targetScale, scaleTime).SetEase(ease);
|
||||
}
|
||||
}
|
||||
|
||||
//抬起
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
targetTsf.DOKill();
|
||||
targetTsf.DOScale(atScale, popTime).SetEase(ease); //回到本来大小
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
private void OnValidate()
|
||||
{
|
||||
if (targetTsf == null) //如果没有目标则默认自己为目标
|
||||
{
|
||||
targetTsf = transform.gameObject.GetComponent<RectTransform>();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39a07d1afeeb4dcc812559d0b9fea3b9
|
||||
timeCreated: 1685603306
|
||||
@@ -0,0 +1,88 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine.EventSystems;
|
||||
using EventSystem = UnityEngine.EventSystems.EventSystem;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 点击穿透
|
||||
/// 只支持穿透一层
|
||||
/// 可嵌套使用 达到无限穿透效果
|
||||
/// </summary>
|
||||
[AddComponentMenu("YIUIFramework/Widget/点击穿透 【YIUIClickEventPenetration】")]
|
||||
public class YIUIClickEventPenetration: MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
|
||||
{
|
||||
[LabelText("穿透 按下")]
|
||||
public bool Down = true;
|
||||
|
||||
[LabelText("穿透 抬起")]
|
||||
public bool Up = true;
|
||||
|
||||
[LabelText("穿透 点击")]
|
||||
public bool Click = true;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (!Down) return;
|
||||
PassEvent(eventData, ExecuteEvents.pointerDownHandler);
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
if (!Up) return;
|
||||
PassEvent(eventData, ExecuteEvents.pointerUpHandler);
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
if (!Click) return;
|
||||
PassEvent(eventData, ExecuteEvents.pointerClickHandler);
|
||||
}
|
||||
|
||||
private void PassEvent<T>(PointerEventData pointerEventData, ExecuteEvents.EventFunction<T> eventFunction) where T : IEventSystemHandler
|
||||
{
|
||||
var raycastResults = new List<RaycastResult>();
|
||||
|
||||
EventSystem.current.RaycastAll(pointerEventData, raycastResults);
|
||||
GameObject nextGameObject = null;
|
||||
|
||||
for (int i = 0; i < raycastResults.Count; i++)
|
||||
{
|
||||
if (raycastResults[i].gameObject == gameObject)
|
||||
{
|
||||
if (i + 1 < raycastResults.Count)
|
||||
{
|
||||
nextGameObject = raycastResults[i + 1].gameObject;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nextGameObject != null && nextGameObject != gameObject)
|
||||
{
|
||||
ExecuteEvents.ExecuteHierarchy(nextGameObject, pointerEventData, eventFunction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
1.下层Button没响应问题
|
||||
|
||||
如果只传递一层的情况 Button的Text文本 或者Button下面有遮挡物 并且Raycast Target是true的情况
|
||||
它会传递给Text或者 其他遮挡物 而Button 不会收到点击消息 所以如果想要下层百分百生效 最好的情况是
|
||||
把Button 下面的遮挡物 Raycast Target设置为false 因为如果一直往下传递的话
|
||||
当前点击的位置无论叠加多少层Button 他都会响应 所以一直往下传递是不可控的情况
|
||||
|
||||
2.下层Toggle没响应问题
|
||||
|
||||
再有一种情况是Toggle 我在UI上的Toggle 自身没有Image 组件 Toggle的Target Graphic
|
||||
设置的是Background 然后事件传递到Backgeround 之后 Toggle并没有响应 所以如果想让Toggle也响应该事件
|
||||
需要将Toggle的Target Graphic设置为自身 给Toggle添加一个Image 并且Raycast Target 设置为true 并且没有遮挡物即可
|
||||
|
||||
总结注意下一层是什么 有可能是你不知道的东西阻挡了 所以没有达到你的效果
|
||||
*/
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3984fa60b73484ea0cb07d95f4e0c5f
|
||||
timeCreated: 1727426512
|
||||
62
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlock.cs
vendored
Normal file
62
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlock.cs
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 不可见的一个图,用来阻挡UI的投射。
|
||||
/// </summary>
|
||||
public class UIBlock : Graphic, ICanvasRaycastFilter
|
||||
{
|
||||
public override bool raycastTarget
|
||||
{
|
||||
get => true;
|
||||
set { }
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||
"StyleCop.CSharp.NamingRules",
|
||||
"SA1300:ElementMustBeginWithUpperCaseLetter",
|
||||
Justification = "Reviewed. Suppression is OK here.")]
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||
"StyleCop.CSharp.NamingRules",
|
||||
"SA1300:ElementMustBeginWithUpperCaseLetter",
|
||||
Justification = "Reviewed. Suppression is OK here.")]
|
||||
public override Material materialForRendering
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
public bool IsRaycastLocationValid(
|
||||
Vector2 screenPoint, Camera eventCamera)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
}
|
||||
|
||||
public override void SetAllDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetLayoutDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetMaterialDirty()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlock.cs.meta
vendored
Normal file
3
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlock.cs.meta
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 189105a42ee74f83ba5487327c2d3580
|
||||
timeCreated: 1683685551
|
||||
113
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlockPolygon.cs
vendored
Normal file
113
UnityGame/Assets/Scripts/ThirdParty/YIUIFramework/Plugins/YIUIMono/Widget/UIBlockPolygon.cs
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace YIUIFramework
|
||||
{
|
||||
/// <summary>
|
||||
/// 图像与多边形块
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(PolygonCollider2D))]
|
||||
public sealed class UIBlockPolygon : Graphic, ICanvasRaycastFilter
|
||||
{
|
||||
public override bool raycastTarget
|
||||
{
|
||||
get { return true; }
|
||||
set { }
|
||||
}
|
||||
|
||||
private PolygonCollider2D polygon = null;
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||
"StyleCop.CSharp.NamingRules",
|
||||
"SA1300:ElementMustBeginWithUpperCaseLetter",
|
||||
Justification = "Reviewed. Suppression is OK here.")]
|
||||
public override Texture mainTexture
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
||||
"StyleCop.CSharp.NamingRules",
|
||||
"SA1300:ElementMustBeginWithUpperCaseLetter",
|
||||
Justification = "Reviewed. Suppression is OK here.")]
|
||||
public override Material materialForRendering
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
private PolygonCollider2D Polygon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.polygon == null)
|
||||
{
|
||||
this.polygon = this.GetComponent<PolygonCollider2D>();
|
||||
Physics2D.Simulate(0);
|
||||
}
|
||||
|
||||
return this.polygon;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsRaycastLocationValid(
|
||||
Vector2 screenPoint, Camera eventCamera)
|
||||
{
|
||||
if (eventCamera != null)
|
||||
{
|
||||
Vector3 worldPoint;
|
||||
if (RectTransformUtility.ScreenPointToWorldPointInRectangle(
|
||||
this.rectTransform,
|
||||
screenPoint,
|
||||
eventCamera,
|
||||
out worldPoint))
|
||||
{
|
||||
return this.Polygon.OverlapPoint(worldPoint);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Polygon.OverlapPoint(screenPoint);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPopulateMesh(VertexHelper vh)
|
||||
{
|
||||
vh.Clear();
|
||||
}
|
||||
|
||||
public override void SetAllDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetLayoutDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetVerticesDirty()
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetMaterialDirty()
|
||||
{
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
protected override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
this.transform.localPosition = Vector3.zero;
|
||||
float w = (this.rectTransform.sizeDelta.x * 0.5f) + 0.1f;
|
||||
float h = (this.rectTransform.sizeDelta.y * 0.5f) + 0.1f;
|
||||
this.Polygon.points = new Vector2[]
|
||||
{
|
||||
new Vector2(-w, -h),
|
||||
new Vector2(w, -h),
|
||||
new Vector2(w, h),
|
||||
new Vector2(-w, h)
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f08f0e78a63f4f3fa2552a445caabfc8
|
||||
timeCreated: 1683685651
|
||||
Reference in New Issue
Block a user