add some extra assets FX and SFX
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
[RequireComponent(typeof(ParticleSystem))]
|
||||
public class ParticleSystemScaleLifetime : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _LifetimeFactor;
|
||||
[SerializeField] Transform _ScaleObject;
|
||||
private ParticleSystem _particleSystem;
|
||||
private bool _playedFlag;
|
||||
private void Awake()
|
||||
{
|
||||
_particleSystem = GetComponent<ParticleSystem>();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (_particleSystem.isPlaying)
|
||||
{
|
||||
ParticleSystem.MainModule main = _particleSystem.main;
|
||||
main.startLifetime = _LifetimeFactor * _ScaleObject.localScale.z;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9acc547824e458345b4524902b21069d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxAddons/ParticleSystemScaleLifetime.cs
|
||||
uploadId: 840846
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
[RequireComponent(typeof(ParticleSystem))]
|
||||
public class ParticleSystemStartStopLifetime : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _StartLifetime;
|
||||
[SerializeField] private float _StopLifetime;
|
||||
private ParticleSystem _particleSystem;
|
||||
private bool _playedFlag;
|
||||
private void Awake()
|
||||
{
|
||||
_particleSystem = GetComponent<ParticleSystem>();
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (_particleSystem.isEmitting && !_playedFlag)
|
||||
{
|
||||
_playedFlag = true;
|
||||
}
|
||||
if (!_particleSystem.isEmitting && _playedFlag)
|
||||
{
|
||||
ParticleSystem.Particle[] particles = new ParticleSystem.Particle[_particleSystem.particleCount];
|
||||
_particleSystem.GetParticles(particles);
|
||||
for (int i = 0; i < particles.Length; i++)
|
||||
{
|
||||
float percentage = particles[i].remainingLifetime / particles[i].startLifetime;
|
||||
particles[i].startLifetime = _StopLifetime;
|
||||
particles[i].remainingLifetime = _StopLifetime * percentage;
|
||||
}
|
||||
_particleSystem.SetParticles(particles);
|
||||
_playedFlag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 255c58e12f3e05245afde891bf9647ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxAddons/ParticleSystemStartStopLifetime.cs
|
||||
uploadId: 840846
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace PixPlays.ElementalVFX
|
||||
{
|
||||
[RequireComponent(typeof(TrailRenderer))]
|
||||
public class TrailScaleWithHierarchy : MonoBehaviour
|
||||
{
|
||||
private TrailRenderer _trailRenderer;
|
||||
private float _initialWidth;
|
||||
private float _initialTrailTime;
|
||||
private void Start()
|
||||
{
|
||||
_trailRenderer = GetComponent<TrailRenderer>();
|
||||
_initialWidth = _trailRenderer.widthMultiplier;
|
||||
_initialTrailTime = _trailRenderer.time;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
_trailRenderer.widthMultiplier = GetWorldScale(transform, _initialWidth);
|
||||
_trailRenderer.time = _initialTrailTime * _trailRenderer.widthMultiplier;
|
||||
}
|
||||
|
||||
private float GetWorldScale(Transform obj,float scale=1)
|
||||
{
|
||||
float newScale = obj.localScale.x * scale;
|
||||
if (obj.parent != null)
|
||||
{
|
||||
return GetWorldScale(obj.parent, newScale);
|
||||
}
|
||||
return newScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da1b031a13b76d34892fdc5af6a0d348
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 297318
|
||||
packageName: Elemental Spells Full Pack VFX
|
||||
packageVersion: 1.0.1
|
||||
assetPath: Assets/PixPlays/Components/Scripts/VfxAddons/TrailScaleWithHierarchy.cs
|
||||
uploadId: 840846
|
||||
Reference in New Issue
Block a user