暂存一下
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!84 &8400000
|
||||
RenderTexture:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MemoryTexture
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_ForcedFallbackFormat: 4
|
||||
m_DownscaleFallback: 0
|
||||
m_IsAlphaChannelOptional: 0
|
||||
serializedVersion: 5
|
||||
m_Width: 2000
|
||||
m_Height: 1390
|
||||
m_AntiAliasing: 1
|
||||
m_MipCount: -1
|
||||
m_DepthStencilFormat: 94
|
||||
m_ColorFormat: 8
|
||||
m_MipMap: 0
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_BindMS: 0
|
||||
m_EnableCompatibleFormat: 1
|
||||
m_EnableRandomWrite: 0
|
||||
m_TextureSettings:
|
||||
serializedVersion: 2
|
||||
m_FilterMode: 1
|
||||
m_Aniso: 0
|
||||
m_MipBias: 0
|
||||
m_WrapU: 1
|
||||
m_WrapV: 1
|
||||
m_WrapW: 1
|
||||
m_Dimension: 2
|
||||
m_VolumeDepth: 1
|
||||
m_ShadowSamplingMode: 2
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f14927994098c5a4d8154aa4d0f8bb6c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 8400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -8,19 +8,20 @@ using AibisDream;
|
||||
using AibisDream.FixSystem;
|
||||
using AibisDream.Framework;
|
||||
using Cinemachine;
|
||||
using UnityEngine.Rendering;
|
||||
using System;
|
||||
|
||||
public class MemoryProcess : MonoBehaviour
|
||||
{
|
||||
public GameObject memoryView;
|
||||
public GameObject projector;
|
||||
|
||||
public Image memoryProcessImage; // 用于显示调取记忆的表现
|
||||
public Image memoryFinishedImage; // 用于显示记忆处理结束的表现
|
||||
|
||||
public Image memoryFinishedImageForFade; // 用于显示记忆处理结束的表现
|
||||
|
||||
public SpriteRenderer memoryFinishedspRender; // 用于显示记忆处理结束的表现
|
||||
public Image memoryFinishedImageNoColor; // 用于显示记忆处理结束的表现
|
||||
|
||||
[SerializeField] private Volume MainEffect;
|
||||
[SerializeField] private Volume MemoryClarityVloume;
|
||||
[SerializeField] private Volume Memoryfrequencyloume;
|
||||
[SerializeField] private Volume MemoryProcessVloume;
|
||||
public Slider frequencySlider; // 频率调节滑动条
|
||||
|
||||
public Slider claritySlider; // 频率调节滑动条
|
||||
@@ -37,7 +38,6 @@ public class MemoryProcess : MonoBehaviour
|
||||
private bool isFrequencyFound = false; // 追踪是否找到目标频率
|
||||
private bool isClarityFound = false; // 追踪是否找到目标清晰度
|
||||
|
||||
private Material processMaterial; // 目标材质
|
||||
private Material memoryMaterial; // 噪波材质
|
||||
|
||||
private PunchTape PunchTape;
|
||||
@@ -125,20 +125,20 @@ public class MemoryProcess : MonoBehaviour
|
||||
float GetRandomNumber()
|
||||
{
|
||||
// 随机决定选择哪个区间
|
||||
if (Random.value < 0.5f) // 50% 概率选择第一个区间
|
||||
if (UnityEngine.Random.value < 0.5f) // 50% 概率选择第一个区间
|
||||
{
|
||||
return Random.Range(0.5f, 2f);
|
||||
return UnityEngine.Random.Range(0.5f, 2f);
|
||||
}
|
||||
else // 50% 概率选择第二个区间
|
||||
{
|
||||
return Random.Range(4f, 5.5f);
|
||||
return UnityEngine.Random.Range(4f, 5.5f);
|
||||
}
|
||||
}
|
||||
|
||||
void OnFrequencyChanged(float value)
|
||||
{
|
||||
float distance = Mathf.Abs(value - targetFrequency);
|
||||
UpdateShaderParameters(distance);
|
||||
UpdateFrequencyShaderParameters(distance);
|
||||
CheckIfFound(distance, ref isFrequencyFound); // 这里更新 isFrequencyFound
|
||||
}
|
||||
|
||||
@@ -176,58 +176,52 @@ public class MemoryProcess : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateShaderParameters(float distance)
|
||||
void UpdateFrequencyShaderParameters(float distance)
|
||||
{
|
||||
if (processMaterial != null)
|
||||
{
|
||||
if (distance > 0.2f)
|
||||
{
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 1f);
|
||||
}
|
||||
else if (distance <= 0.2f && distance > 0f)
|
||||
{
|
||||
float alpha = Mathf.InverseLerp(0f, 0.2f, distance);
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", alpha);
|
||||
}
|
||||
}
|
||||
Memoryfrequencyloume.weight=Mathf.Lerp(0, 1, Mathf.InverseLerp(0f, 1f, distance));
|
||||
}
|
||||
|
||||
void UpdateClarityShaderParameters(float t)
|
||||
{
|
||||
if (memoryMaterial != null)
|
||||
{
|
||||
float smoothT = Mathf.SmoothStep(0, 1, t);
|
||||
float pixelateSize;
|
||||
// 根据 t 的值线性插值材质参数,实现平滑过渡
|
||||
//float pixelateSize = Mathf.Lerp(512, 20, smoothT);
|
||||
float offsetUvX = Mathf.Lerp(0, 0.12f, smoothT);
|
||||
float offsetUvY = Mathf.Lerp(0, 0.18f, smoothT);
|
||||
float distortAmount = Mathf.Lerp(0, 1.735f, smoothT);
|
||||
MemoryClarityVloume.weight=Mathf.Lerp(0, 1, Mathf.InverseLerp(0f, 1f, t));
|
||||
// if (memoryMaterial != null)
|
||||
// {
|
||||
// float smoothT = Mathf.SmoothStep(0, 1, t);
|
||||
// float pixelateSize;
|
||||
// // 根据 t 的值线性插值材质参数,实现平滑过渡
|
||||
// //float pixelateSize = Mathf.Lerp(512, 20, smoothT);
|
||||
// float offsetUvX = Mathf.Lerp(0, 0.12f, smoothT);
|
||||
// float offsetUvY = Mathf.Lerp(0, 0.18f, smoothT);
|
||||
// float distortAmount = Mathf.Lerp(0, 1.735f, smoothT);
|
||||
|
||||
if (t >= 0.7f && t <= 1)
|
||||
{
|
||||
// 在 t 值为 0.7 到 1 时,PixelateSize 在 15 到 30 之间变化
|
||||
pixelateSize = Mathf.Lerp(30, 15, Mathf.InverseLerp(0.7f, 1f, t));
|
||||
}
|
||||
else if (t > 0.35f && t < 0.7f)
|
||||
{
|
||||
// 在 t 值为 0.35 到 0.7 时,PixelateSize 在 30 到 50 之间变化
|
||||
pixelateSize = Mathf.Lerp(80, 30, Mathf.InverseLerp(0.35f, 0.7f, t));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 在 t 值小于 0.35 时,PixelateSize 在 50 到 512 之间变化
|
||||
pixelateSize = Mathf.Lerp(512, 80, Mathf.InverseLerp(0f, 0.35f, t));
|
||||
}
|
||||
// if (t >= 0.7f && t <= 1)
|
||||
// {
|
||||
// // 在 t 值为 0.7 到 1 时,PixelateSize 在 15 到 30 之间变化
|
||||
// pixelateSize = Mathf.Lerp(30, 15, Mathf.InverseLerp(0.7f, 1f, t));
|
||||
// }
|
||||
// else if (t > 0.35f && t < 0.7f)
|
||||
// {
|
||||
// // 在 t 值为 0.35 到 0.7 时,PixelateSize 在 30 到 50 之间变化
|
||||
// pixelateSize = Mathf.Lerp(80, 30, Mathf.InverseLerp(0.35f, 0.7f, t));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // 在 t 值小于 0.35 时,PixelateSize 在 50 到 512 之间变化
|
||||
// pixelateSize = Mathf.Lerp(512, 80, Mathf.InverseLerp(0f, 0.35f, t));
|
||||
// }
|
||||
|
||||
|
||||
memoryMaterial.SetFloat("_PixelateSize", pixelateSize);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", offsetUvX);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", offsetUvY);
|
||||
memoryMaterial.SetFloat("_DistortAmount", distortAmount);
|
||||
}
|
||||
// memoryMaterial.SetFloat("_PixelateSize", pixelateSize);
|
||||
// memoryMaterial.SetFloat("_OffsetUvX", offsetUvX);
|
||||
// memoryMaterial.SetFloat("_OffsetUvY", offsetUvY);
|
||||
// memoryMaterial.SetFloat("_DistortAmount", distortAmount);
|
||||
// }
|
||||
}
|
||||
public void TweenWeight(Volume postProcessingVolume, float targetWeight, float duration)
|
||||
{
|
||||
// 动态调整权重
|
||||
DOTween.To(() => postProcessingVolume.weight, x => postProcessingVolume.weight = x, targetWeight, duration);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
isFrequencyFound = false;
|
||||
@@ -249,24 +243,12 @@ public class MemoryProcess : MonoBehaviour
|
||||
claritySlider.interactable = true;
|
||||
}
|
||||
|
||||
memoryProcessImage.gameObject.SetActive(true);
|
||||
processMaterial = memoryProcessImage.material;
|
||||
memoryMaterial = memoryFinishedImage.material;
|
||||
//memoryFinishedImage.gameObject.SetActive(false);
|
||||
memoryFinishedImageNoColor.gameObject.SetActive(false);
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 1);
|
||||
processMaterial.SetFloat("_GlitchFade", 0);
|
||||
processMaterial.SetFloat("_StrongTintFade", 1);
|
||||
float distance = Mathf.Abs(3 - targetClarity);
|
||||
// 计算滑块值与目标清晰度之间的最大可能距离
|
||||
float maxDistance = Mathf.Max(
|
||||
Mathf.Abs(claritySlider.maxValue - targetClarity),
|
||||
Mathf.Abs(claritySlider.minValue - targetClarity)
|
||||
);
|
||||
// 归一化距离,确保 t 在 0 到 1 之间,且当滑块值等于目标清晰度时,t 等于 1
|
||||
float t = Mathf.Clamp01(distance / maxDistance);
|
||||
UpdateClarityShaderParameters(t);
|
||||
memoryFinishedspRender.color=Color.black;
|
||||
MemoryProcessVloume.weight=1;
|
||||
MemoryClarityVloume.weight=0;
|
||||
Memoryfrequencyloume.weight=0;
|
||||
PunchTape = null;
|
||||
|
||||
Color color = playBackground.color;
|
||||
color.a = 0f;
|
||||
playBackground.color = color;
|
||||
@@ -293,16 +275,10 @@ public class MemoryProcess : MonoBehaviour
|
||||
|
||||
[YarnCommand("ColorFadeOut")]
|
||||
public IEnumerator ColorFadeOut()
|
||||
{
|
||||
memoryFinishedImageForFade.sprite = memoryFinishedImage.sprite;
|
||||
memoryFinishedImageNoColor.sprite = memoryFinishedImage.sprite;
|
||||
memoryFinishedImageForFade.gameObject.SetActive(true);
|
||||
memoryFinishedImageNoColor.gameObject.SetActive(true);
|
||||
memoryFinishedImage.gameObject.SetActive(false);
|
||||
|
||||
{ fadeMaterial.SetFloat("_DirectionalDistortionFade",-15f);
|
||||
AudioManager.RandomPlayInteraction("colorerase");
|
||||
AudioManager.PauseMemoryAudio();
|
||||
Tween tween = fadeMaterial.DOFloat(-3, "_DirectionalDistortionFade", 3);
|
||||
Tween tween = fadeMaterial.DOFloat(0, "_DirectionalDistortionFade", 3);
|
||||
yield return tween.WaitForCompletion();
|
||||
}
|
||||
|
||||
@@ -312,10 +288,9 @@ public class MemoryProcess : MonoBehaviour
|
||||
if (useYarn)
|
||||
{
|
||||
fadeMaterial.SetFloat("_DirectionalDistortionFade", -15);
|
||||
memoryFinishedImage.gameObject.SetActive(true);
|
||||
FavoritesManager.Instance.CloseFavorites();
|
||||
Sprite memSprite = Resources.Load<Sprite>("Art/Memory/" + memName);
|
||||
memoryFinishedImage.sprite = memSprite;
|
||||
memoryFinishedspRender.sprite = memSprite;
|
||||
memoryFinishedImageNoColor.sprite = memSprite;
|
||||
if (memSprite == null)
|
||||
{
|
||||
@@ -328,13 +303,8 @@ public class MemoryProcess : MonoBehaviour
|
||||
playBackground.color = new Color(playBackground.color.r, playBackground.color.g, playBackground.color.b, 0);
|
||||
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
|
||||
// Set material properties
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 0);
|
||||
memoryMaterial.SetFloat("_PixelateSize", 512);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", 0);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", 0);
|
||||
memoryMaterial.SetFloat("_DistortAmount", 0);
|
||||
MemoryClarityVloume.weight=0;
|
||||
Memoryfrequencyloume.weight=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -346,13 +316,9 @@ public class MemoryProcess : MonoBehaviour
|
||||
playBackground.color = new Color(playBackground.color.r, playBackground.color.g, playBackground.color.b, 0);
|
||||
|
||||
yield return playBackground.DOFade(1f, 1f).WaitForCompletion(); // Fade to fully opaque over 1 second
|
||||
|
||||
// Set material properties
|
||||
processMaterial.SetFloat("_FullAlphaDissolveFade", 0);
|
||||
memoryMaterial.SetFloat("_PixelateSize", 512);
|
||||
memoryMaterial.SetFloat("_OffsetUvX", 0);
|
||||
memoryMaterial.SetFloat("_OffsetUvY", 0);
|
||||
memoryMaterial.SetFloat("_DistortAmount", 0);
|
||||
MemoryClarityVloume.weight=0;
|
||||
Memoryfrequencyloume.weight=0;
|
||||
DialogController.Instance.StartDialogNode(clueSlot.punchTape.ClueName);
|
||||
}
|
||||
}
|
||||
@@ -380,16 +346,16 @@ public class MemoryProcess : MonoBehaviour
|
||||
}
|
||||
|
||||
Sprite memorySprite = Resources.Load<Sprite>("Art/Memory/" + PunchTape.MemoryIndex);
|
||||
memoryFinishedImage.sprite = memorySprite;
|
||||
memoryFinishedspRender.sprite = memorySprite;
|
||||
memoryFinishedImageNoColor.sprite = memorySprite;
|
||||
if (memorySprite == null)
|
||||
{
|
||||
Debug.LogError("Memory not found: " + PunchTape.MemoryIndex);
|
||||
}
|
||||
|
||||
processMaterial.SetFloat("_StrongTintFade", 0);
|
||||
processMaterial.SetFloat("_GlitchFade", 1);
|
||||
|
||||
TweenWeight(MemoryProcessVloume,0,0.5f);
|
||||
TweenWeight(MemoryClarityVloume,0.5f,0.5f);
|
||||
TweenWeight(Memoryfrequencyloume,0.5f,0.5f);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
isProcessing = true; // 开始处理,设置为true
|
||||
frequencySlider.gameObject.SetActive(true);
|
||||
claritySlider.gameObject.SetActive(true);
|
||||
|
||||
Reference in New Issue
Block a user