-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRingEffect.cs
More file actions
37 lines (32 loc) · 953 Bytes
/
Copy pathRingEffect.cs
File metadata and controls
37 lines (32 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RingEffect : MonoBehaviour
{
[SerializeField] private float MAX_RADIUS;
[SerializeField] private float TIME;
private float bornTime;
// Start is called before the first frame update
void Start()
{
Game game = Game.Get();
bornTime = game.time;
}
// Update is called once per frame
void Update()
{
Game game = Game.Get();
// TIME•bŒo‚Á‚½‚çÁ‚¦‚é
if (game.time - bornTime > TIME)
{
Destroy(gameObject);
}
float timeRate = (game.time - bornTime) / TIME;
float scale = (1 - timeRate) * 1 + timeRate * MAX_RADIUS;
transform.localScale = new Vector3(scale, scale, 1);
var renderer = GetComponent<SpriteRenderer>();
var color = renderer.color;
color.a = 1 - timeRate;
renderer.color = color;
}
}