[Fix] All in one + add dice

This commit is contained in:
2026-02-23 22:24:46 +07:00
parent 4f942cd7c0
commit 2f9e082d75
1593 changed files with 474068 additions and 31 deletions
@@ -0,0 +1,93 @@
using UnityEngine;
namespace AllIn13DShader
{
public class AlphaTween : MonoBehaviour
{
private static int MATPROP_ID_GENERAL_ALPHA = Shader.PropertyToID("_GeneralAlpha");
public enum State
{
NONE = 0,
FADE_IN = 1,
FADE_OUT = 2,
}
private MeshRenderer[] meshRenderers;
private bool IsTweening
{
get
{
bool res = state != State.NONE;
return res;
}
}
private AnimationCurve alphaCurve;
private float duration;
private float timer;
private State state;
private float alphaSrc;
private float alphaDst;
public void Init(DemoSceneConfiguration demoSceneConfig, MeshRenderer[] meshRenderers)
{
alphaCurve = demoSceneConfig.alphaCurve;
duration = demoSceneConfig.alphaDuration;
timer = 0f;
this.meshRenderers = meshRenderers;
state = State.NONE;
}
public void FadeIn()
{
timer = 0f;
state = State.FADE_IN;
alphaSrc = 0f;
alphaDst = 1f;
}
public void FadeOut()
{
timer = 0f;
state = State.FADE_OUT;
alphaSrc = 1f;
alphaDst = 0f;
}
public void Update()
{
if (IsTweening)
{
UpdateTweening();
}
}
private void UpdateTweening()
{
timer += Time.deltaTime;
float t = timer / duration;
float curveT = alphaCurve.Evaluate(t);
float alpha = Mathf.Lerp(alphaSrc, alphaDst, curveT);
for(int i = 0; i < meshRenderers.Length; i++)
{
meshRenderers[i].sharedMaterial.SetFloat(MATPROP_ID_GENERAL_ALPHA, alpha);
}
if(t >= 1f)
{
state = State.NONE;
timer = 0f;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 9808fa4c0fb72f24992e04c8617c3cf6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/AlphaTween.cs
uploadId: 865720
@@ -0,0 +1,21 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AllIn13DShader
{
public class PositionTween : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 55365ba5f8752694da63758c0d7d993f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PositionTween.cs
uploadId: 865720
@@ -0,0 +1,35 @@
using UnityEngine;
namespace AllIn13DShader
{
public class PropertyTween
{
protected int propID;
protected Material mat;
protected float currentValue;
[SerializeField] protected string propertyName;
public virtual void Init(Material mat)
{
this.mat = mat;
propID = Shader.PropertyToID(propertyName);
}
public virtual void Update(float deltaTime)
{
Tween(deltaTime);
UpdateMaterial();
}
protected virtual void Tween(float deltaTime)
{
}
private void UpdateMaterial()
{
mat.SetFloat(propID, currentValue);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: c901b6122eaa4db44878b49f5d994634
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTween.cs
uploadId: 865720
@@ -0,0 +1,41 @@
using UnityEngine;
namespace AllIn13DShader
{
[System.Serializable]
public class PropertyTweenCollection
{
public Material mat;
public PropertyTweenFader[] faderTweens;
public PropertyTweenSinWave[] sinWaveTweens;
public void Init()
{
if(mat == null) return;
for (int i = 0; i < faderTweens.Length; i++)
{
faderTweens[i].Init(mat);
}
for (int i = 0; i < sinWaveTweens.Length; i++)
{
sinWaveTweens[i].Init(mat);
}
}
public void Update(float deltaTime)
{
for(int i = 0; i < faderTweens.Length; i++)
{
faderTweens[i].Update(deltaTime);
}
for (int i = 0; i < sinWaveTweens.Length; i++)
{
sinWaveTweens[i].Update(deltaTime);
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: eab8b01b4c9522440b3c4c308e49ae16
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenCollection.cs
uploadId: 865720
@@ -0,0 +1,102 @@
using UnityEngine;
namespace AllIn13DShader
{
[System.Serializable]
public class PropertyTweenFader : PropertyTween
{
public enum State
{
WAITING_FOR_FADE_IN = 0,
FADING_IN = 1,
WAITING_FOR_FADE_OUT = 2,
FADING_OUT = 3,
}
private float timer;
private State state;
[Header("Config")]
public float waitingForFadeInTime;
public float fadeInDuration;
public float waitingForFadeOutTime;
public float fadeOutDuration;
public override void Init(Material mat)
{
base.Init(mat);
state = State.WAITING_FOR_FADE_IN;
timer = 0f;
}
protected override void Tween(float deltaTime)
{
switch (state)
{
case State.WAITING_FOR_FADE_IN:
UpdateWaitingForFadeIn();
break;
case State.FADING_IN:
UpdateFadingIn();
break;
case State.WAITING_FOR_FADE_OUT:
UpdateWaitingForFadeOut();
break;
case State.FADING_OUT:
UpdateFadingOut();
break;
}
}
private void UpdateWaitingForFadeIn()
{
timer += Time.deltaTime;
if (timer >= waitingForFadeInTime)
{
state = State.FADING_IN;
timer = 0f;
}
}
private void UpdateFadingIn()
{
timer += Time.deltaTime;
float t = timer / fadeInDuration;
currentValue = t;
if (timer >= fadeInDuration)
{
state = State.WAITING_FOR_FADE_OUT;
timer = 0f;
}
}
private void UpdateWaitingForFadeOut()
{
timer += Time.deltaTime;
if (timer >= waitingForFadeOutTime)
{
state = State.FADING_OUT;
timer = 0f;
}
}
private void UpdateFadingOut()
{
timer += Time.deltaTime;
float t = timer / fadeOutDuration;
currentValue = 1 - t;
if (timer >= fadeOutDuration)
{
state = State.WAITING_FOR_FADE_IN;
timer = 0f;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 977c8373a22e2be4b8f17402a41cf8e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenFader.cs
uploadId: 865720
@@ -0,0 +1,19 @@
using UnityEngine;
namespace AllIn13DShader
{
[System.Serializable]
public class PropertyTweenSinWave : PropertyTween
{
[Header("Configuration")]
public float minValue;
public float maxValue;
public float speed;
protected override void Tween(float deltaTime)
{
float sin01 = (Mathf.Sin(Time.time * speed) + 1f) * 0.5f;
currentValue = Mathf.Lerp(minValue, maxValue, sin01);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 109d7bd9dbc4170448a098f3590a932c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/PropertyTweenSinWave.cs
uploadId: 865720
@@ -0,0 +1,42 @@
using System;
using UnityEngine;
namespace AllIn13DShader
{
public class SinVerticalPositionTween : MonoBehaviour
{
private float timer;
public float speed = 5;
public float minY = -1;
public float maxY = 1;
public Transform target;
private void OnEnable()
{
timer = 0f;
}
private void OnDisable()
{
timer = 0f;
}
public void Update()
{
timer += Time.deltaTime;
float sin01 = (Mathf.Sin(timer * speed) + 1f) * 0.5f;
Vector3 localPos = target.localPosition;
localPos.y = Mathf.Lerp(minY, maxY, sin01);
target.localPosition = localPos;
}
private void Reset()
{
if(target == null) target = transform;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: bfd62d9a148e2cf47ad5cddb1f76c278
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/SinVerticalPositionTween.cs
uploadId: 865720
@@ -0,0 +1,110 @@
using System;
using UnityEngine;
namespace AllIn13DShader
{
public class TransformScaler : MonoBehaviour
{
public enum ScalingType
{
NONE,
SCALING_UP,
SCALING_DOWN,
}
private float scaleDuration;
private AnimationCurve scaleCurve;
private Vector3 localScaleSrc;
private Vector3 localScaleDst;
private float timer;
private ScalingType scalingType;
private Action<ScalingType> scaleFinishedCallback;
public void Init(DemoSceneConfiguration demoSceneConfig)
{
Init(demoSceneConfig, null);
}
public void Init(DemoSceneConfiguration demoSceneConfig, Action<ScalingType> scaleFinishedCallback)
{
scaleDuration = demoSceneConfig.scaleDuration;
scaleCurve = demoSceneConfig.scalingCurve;
this.scaleFinishedCallback = scaleFinishedCallback;
}
public void ScaleUp()
{
transform.localScale = Vector3.zero;
timer = 0f;
scalingType = ScalingType.SCALING_UP;
localScaleSrc = Vector3.zero;
localScaleDst = Vector3.one;
}
public void ScaleDown()
{
transform.localScale = Vector3.one;
timer = 0f;
scalingType = ScalingType.SCALING_DOWN;
localScaleSrc = Vector3.one;
localScaleDst = Vector3.zero;
}
private void Update()
{
if (IsScaling())
{
UpdateScaling();
}
}
private void UpdateScaling()
{
timer += Time.deltaTime;
float t = timer / scaleDuration;
float curveT = t;
if (scalingType == ScalingType.SCALING_UP)
{
curveT = scaleCurve.Evaluate(t);
}
else if (scalingType == ScalingType.SCALING_DOWN)
{
curveT = 1 - scaleCurve.Evaluate(1 - t);
}
float scale = Mathf.LerpUnclamped(localScaleSrc.x, localScaleDst.x, curveT);
scale = Mathf.Max(0f, scale);
transform.localScale = Vector3.one * scale;
if (t >= 1f)
{
timer = 0f;
if (scalingType == ScalingType.SCALING_DOWN)
{
gameObject.SetActive(false);
}
if(scaleFinishedCallback != null)
{
scaleFinishedCallback(scalingType);
}
scalingType = ScalingType.NONE;
}
}
public bool IsScaling()
{
return scalingType != ScalingType.NONE;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 71c6c2d242f3c2243bf1fcaa88c90071
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 316173
packageName: All In 1 3D-Shader
packageVersion: 2.72
assetPath: Assets/Plugins/AllIn13DShader/Demo/Scripts/Tweens/TransformScaler.cs
uploadId: 865720