1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-22 00:14:18 +00:00

Add SlowlyDisappear component

This commit is contained in:
Steffo 2019-10-05 13:13:26 +02:00
parent bd75ae9524
commit 005229e2c3
3 changed files with 58 additions and 0 deletions

View file

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SlowlyDisappear : MonoBehaviour
{
public float disappearAfter;
protected float timeLeft;
protected SpriteRenderer sprite;
protected float FractionLeft {
get {
return timeLeft / disappearAfter;
}
}
private void Start() {
sprite = GetComponent<SpriteRenderer>();
timeLeft = disappearAfter;
}
private void Update() {
timeLeft -= Time.deltaTime;
if(sprite != null) {
sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, FractionLeft);
}
if(timeLeft < 0) {
Destroy(this.gameObject);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8cb7610d172100841907b194dece1565
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -13,6 +13,7 @@ GameObject:
- component: {fileID: 5473375028011702753}
- component: {fileID: 5473375028011702752}
- component: {fileID: 5473375028011702755}
- component: {fileID: 5319285082587561044}
m_Layer: 0
m_Name: Gravitation Object
m_TagString: Untagged
@ -135,6 +136,19 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
positionInList: 0
--- !u!114 &5319285082587561044
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5473375028011702754}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8cb7610d172100841907b194dece1565, type: 3}
m_Name:
m_EditorClassIdentifier:
disappearAfter: 5
--- !u!1 &8635663089806839545
GameObject:
m_ObjectHideFlags: 0