private static bool AddVFXToTurret(GameObject turretPrefab) { Turret turret = turretPrefab.GetComponentInChildren <Turret>(); if (!turret) { return(false); } TurretEffects effects = turretPrefab.GetComponentInChildren <TurretEffects>(); if (!effects) { GameObject VFXObj = UnityEngine.Object.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>(VFX_PREFAB), turretPrefab.transform); VFXObj.transform.localPosition = Vector3.zero; effects = VFXObj.GetComponentInChildren <TurretEffects>(true); if (!effects) { return(false); } } effects.turret = turret; return(true); }
public static void RemoveVFX() { int modified = ForeachPrefabInFolder(TURRET_FOLDER, (turretPrefab) => { TurretEffects effects = turretPrefab.GetComponentInChildren <TurretEffects>(true); if (!effects) { return(false); } UnityEngine.Object.DestroyImmediate(effects.gameObject); return(true); }); Debug.Log("Modified " + modified + " turret prefabs: " + "Added VFX."); }