- Home /
Question by
Quest_for_stuff · Apr 28, 2020 at 02:23 AM ·
parameterspoolingparameterpoolonenable
How to pass parameters to an object with an object pooling system?
Hi,
I have a gameObject (pfDamagePopup) that have a TextMeshPro Component to it. When an ennemy is hit, the damage is linked to the textMeshPro and shows up. Because there is a lot of ennemy, I use a pooling system. The pooling system takes a Type of GameObject so I can create multiple pool of different type of GameObject.
So, I can sucessfully Enable the gameDamagePopup in the position that I want, and then edit it like that :
DamagePopup damagePopup = EasyObjectPool.instance.GetObjectFromPool("DamagePopup", spawnPopup, Quaternion.identity).GetComponent<DamagePopup>();
damagePopup.damageFinal = 2; //It's late to change the value of my damagePopup, because the function have already been called and the object already appeared, I cannot call it before, so I don't really know what to do.
On my DamagePopup script :
private TextMeshPro text;
private void OnEnable()
{
text.SetText(damageFinal.ToString());
}
I'm not sure how I'm suppose to pass parameters like this damage parameters. I could edit the pooling system, but then I would need to make a DamagePopUp Pool System, and not a GameObject Pool System that give me less flexibility.
Thank you for any help!
Comment