Refactor
Create isolated scriptable object for dealing with istantiating Vfx
This commit is contained in:
parent
6919efe549
commit
f3a6315a65
4988
Assets/_GAME_/Vfx/VfxExplosion01.prefab
Normal file
4988
Assets/_GAME_/Vfx/VfxExplosion01.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/_GAME_/Vfx/VfxExplosion01.prefab.meta
Normal file
7
Assets/_GAME_/Vfx/VfxExplosion01.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4d965c8262ff5834a878255a7345baac
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
4988
Assets/_GAME_/Vfx/VfxExplosion02.prefab
Normal file
4988
Assets/_GAME_/Vfx/VfxExplosion02.prefab
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/_GAME_/Vfx/VfxExplosion02.prefab.meta
Normal file
7
Assets/_GAME_/Vfx/VfxExplosion02.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: daf6ae43ee06c424ba624a471e90b72c
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
33
Assets/_GAME_/Vfx/VfxHandlerBase.cs
Normal file
33
Assets/_GAME_/Vfx/VfxHandlerBase.cs
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[CreateAssetMenu(menuName = "Custom/VfxHandler", fileName = "NewVfxHandler")]
|
||||||
|
public class VfxHandlerBase : ScriptableObject {
|
||||||
|
[Header("VFX Dependencies")]
|
||||||
|
public GameObject VfxExplosion;
|
||||||
|
private GameObject VfxExplosionParentInstance;
|
||||||
|
private List<ParticleSystem> VfxExplosionParticles = new List<ParticleSystem>();
|
||||||
|
|
||||||
|
public bool Initialized { get; private set; }
|
||||||
|
|
||||||
|
private void Awake() {
|
||||||
|
VfxExplosionParticles.Clear();
|
||||||
|
if (VfxExplosion) {
|
||||||
|
VfxExplosionParentInstance = Instantiate(VfxExplosion, Vector3.one, Quaternion.identity);
|
||||||
|
var foundParticleSystems = VfxExplosionParentInstance.GetComponentsInChildren<ParticleSystem>();
|
||||||
|
VfxExplosionParticles.AddRange(foundParticleSystems);
|
||||||
|
VfxExplosionParticles.ForEach((x) => x.transform.localScale = Vector3.one);
|
||||||
|
}
|
||||||
|
|
||||||
|
Initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PlayAll(Vector3? location = null, Quaternion? rotation = null) {
|
||||||
|
if (!Initialized) return;
|
||||||
|
if (VfxExplosionParentInstance) {
|
||||||
|
if (location != null) VfxExplosionParentInstance.transform.position = (Vector3)location;
|
||||||
|
if (rotation != null) VfxExplosionParentInstance.transform.rotation = (Quaternion)rotation;
|
||||||
|
VfxExplosionParticles.ForEach((x) => x.Play());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/_GAME_/Vfx/VfxHandlerBase.cs.meta
Normal file
2
Assets/_GAME_/Vfx/VfxHandlerBase.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b91e52b0bfa8904ca14f8379059ff5c
|
||||||
15
Assets/_GAME_/Vfx/VfxHandlerExplosion01.asset
Normal file
15
Assets/_GAME_/Vfx/VfxHandlerExplosion01.asset
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2b91e52b0bfa8904ca14f8379059ff5c, type: 3}
|
||||||
|
m_Name: VfxHandlerExplosion01
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
VfxExplosion: {fileID: 0}
|
||||||
8
Assets/_GAME_/Vfx/VfxHandlerExplosion01.asset.meta
Normal file
8
Assets/_GAME_/Vfx/VfxHandlerExplosion01.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 835827cc500c145458403d8ca0ebdd36
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
15
Assets/_GAME_/Vfx/VfxHandlerExplosion02.asset
Normal file
15
Assets/_GAME_/Vfx/VfxHandlerExplosion02.asset
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2b91e52b0bfa8904ca14f8379059ff5c, type: 3}
|
||||||
|
m_Name: VfxHandlerExplosion02
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
VfxExplosion: {fileID: 0}
|
||||||
8
Assets/_GAME_/Vfx/VfxHandlerExplosion02.asset.meta
Normal file
8
Assets/_GAME_/Vfx/VfxHandlerExplosion02.asset.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2b4a9d2bdf4f1e34287cf15a4825a45d
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Reference in New Issue
Block a user