-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using UnityEngine; | ||
using static BreathingVFX; | ||
using Random = UnityEngine.Random; | ||
|
||
public class BreathingVFX : MonoBehaviour | ||
{ | ||
public enum Asix | ||
{ | ||
X, Y, Z | ||
} | ||
|
||
public Asix asix; | ||
public float time = 5f; | ||
public float mul = 0.1f; | ||
|
||
float clock; | ||
|
||
protected void Start() | ||
{ | ||
clock = Random.Range(-5f, 5f); | ||
} | ||
|
||
protected void Update() | ||
{ | ||
clock += Time.deltaTime * time; | ||
|
||
switch (asix) | ||
{ | ||
case Asix.X: | ||
transform.localScale = new Vector3(1f + Mathf.Sin(clock) * mul, 1f, 1f); | ||
break; | ||
case Asix.Y: | ||
transform.localScale = new Vector3(1, 1f + Mathf.Sin(clock) * mul, 1f); | ||
break; | ||
case Asix.Z: | ||
transform.localScale = new Vector3(1, 1f, 1f + Mathf.Sin(clock) * mul); | ||
break; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
[ExecuteInEditMode] | ||
public class DissolveControlVFX : MonoBehaviour | ||
{ | ||
private Material dissolveMaterialInstance; | ||
|
||
[Range(0f, 1f)] | ||
public float dissolveValue = 0.0f; | ||
public Texture texture; // Public texture to be set via Editor or scripts | ||
|
||
void Start() | ||
{ | ||
Renderer renderer = GetComponent<Renderer>(); | ||
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>(); | ||
Image image = GetComponent<Image>(); | ||
RawImage rawImage = GetComponent<RawImage>(); | ||
|
||
if (renderer != null) | ||
{ | ||
dissolveMaterialInstance = new Material(renderer.sharedMaterial); | ||
renderer.material = dissolveMaterialInstance; | ||
} | ||
else if (spriteRenderer != null) | ||
{ | ||
dissolveMaterialInstance = new Material(spriteRenderer.sharedMaterial); | ||
spriteRenderer.material = dissolveMaterialInstance; | ||
} | ||
else if (image != null) | ||
{ | ||
dissolveMaterialInstance = new Material(image.material); | ||
image.material = dissolveMaterialInstance; | ||
} | ||
else if (rawImage != null) | ||
{ | ||
dissolveMaterialInstance = new Material(rawImage.material); | ||
rawImage.material = dissolveMaterialInstance; | ||
} | ||
else | ||
{ | ||
Debug.LogWarning("DissolveControl: No compatible renderer found on the GameObject.", this); | ||
} | ||
} | ||
|
||
void Update() | ||
{ | ||
if (dissolveMaterialInstance != null) | ||
{ | ||
dissolveMaterialInstance.SetFloat("_DissolveThreshold", dissolveValue); | ||
|
||
// Check if the texture is not null and set it | ||
if (texture != null) | ||
{ | ||
dissolveMaterialInstance.SetTexture("_NoiseTex", texture); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using UnityEngine; | ||
|
||
public class FadeGlowVFX : MonoBehaviour | ||
{ | ||
public float speed = 0.2f; | ||
public float from = 0f; | ||
public float to = 1f; | ||
|
||
public SpriteRenderer sr; | ||
|
||
void Update() | ||
{ | ||
var srColor = sr.color; | ||
srColor.a = Remap(Mathf.Abs(Mathf.Sin(Time.time * speed)), -1f, 1f, from, to); | ||
sr.color = srColor; | ||
} | ||
|
||
public static float Remap(float value, float from1, float to1, float from2, float to2) | ||
{ | ||
return (value - from1) / (to1 - from1) * (to2 - from2) + from2; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
namespace Animations | ||
{ | ||
public class FlashVFX : MonoBehaviour | ||
{ | ||
[SerializeField] private SpriteRenderer spriteRenderer; | ||
[SerializeField] private Material flashMaterial; | ||
[SerializeField] private float duration; | ||
|
||
public float Duration => duration; | ||
|
||
private Material originalMaterial; | ||
private Coroutine flashRoutine; | ||
|
||
[ContextMenu("Flash")] | ||
public void Flash() | ||
{ | ||
if (flashRoutine != null) | ||
{ | ||
StopCoroutine(flashRoutine); | ||
} | ||
flashRoutine = StartCoroutine(FlashRoutine()); | ||
} | ||
|
||
private void Start() | ||
{ | ||
originalMaterial = spriteRenderer.material; | ||
} | ||
|
||
private IEnumerator FlashRoutine() | ||
{ | ||
spriteRenderer.material = flashMaterial; | ||
yield return new WaitForSeconds(duration); | ||
spriteRenderer.material = originalMaterial; | ||
flashRoutine = null; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using UnityEngine; | ||
|
||
public class MeanderVFX : MonoBehaviour | ||
{ | ||
public float pos = 0f; | ||
public float angle = 5f; | ||
public float speed = 2f; | ||
|
||
private Quaternion startRotation; | ||
private Vector3 startPosition; | ||
|
||
float time; | ||
|
||
void Start() | ||
{ | ||
time = Random.Range(0f, 10f); | ||
startRotation = transform.rotation; | ||
startPosition = transform.localPosition; | ||
} | ||
|
||
void Update() | ||
{ | ||
time += Time.deltaTime; | ||
|
||
float angleChange = Mathf.Sin(time * speed) * angle; | ||
Quaternion currentRotation = Quaternion.Euler(0f, 0f, angleChange); | ||
transform.rotation = startRotation * currentRotation; | ||
|
||
Vector3 newpos = new Vector3(Mathf.Sin(time * speed) * pos, 0, 0); | ||
transform.localPosition = startPosition + newpos; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using UnityEngine; | ||
|
||
public class NoiseVFX : MonoBehaviour | ||
{ | ||
public float strength = 0.1f; | ||
public float duration; | ||
private float currentDuration; | ||
|
||
|
||
private void Start() | ||
{ | ||
currentDuration = duration; | ||
} | ||
|
||
void Update() | ||
{ | ||
if (currentDuration <= 0) | ||
{ | ||
currentDuration = duration; | ||
transform.localPosition = Random.insideUnitCircle * strength; | ||
} | ||
currentDuration -= Time.deltaTime; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using UnityEngine; | ||
|
||
public class RestartIntervalVFX : MonoBehaviour | ||
{ | ||
public float interval = 1f; | ||
public bool isActivated = false; | ||
public GameObject target; | ||
private float clock = 0f; | ||
|
||
private void Update() | ||
{ | ||
clock += Time.deltaTime; | ||
|
||
if (clock > interval) | ||
{ | ||
clock = 0; | ||
isActivated = !isActivated; | ||
target.SetActive(isActivated); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.