Create isolated scriptable object for dealing with istantiating Vfx
This commit is contained in:
Nico 2025-06-27 15:19:41 -07:00
parent 6919efe549
commit f3a6315a65
11 changed files with 10071 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4d965c8262ff5834a878255a7345baac
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: daf6ae43ee06c424ba624a471e90b72c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View 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());
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2b91e52b0bfa8904ca14f8379059ff5c

View 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}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 835827cc500c145458403d8ca0ebdd36
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View 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}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2b4a9d2bdf4f1e34287cf15a4825a45d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant: