playMaker

Author Topic: Multiple vs. Single Arrays  (Read 1312 times)

DABYX

  • Playmaker Newbie
  • *
  • Posts: 8
Multiple vs. Single Arrays
« on: November 03, 2021, 05:59:31 PM »
Hi all,

A very simple question which may not really have a single case answer...

I'm currently creating GameObjects from a 'template object' with a few array lists attatched. Once it has finished doing what it needs to I then destroy these array lists. This is per gameobject.

If I was to instead have the arrays in a different single GameObject, called Arrays or something, and reference that instead would this be better for optimisation or worse?

I imagine better but I'm unsure if getting array data from other objects is a higher memory hit than from itself.

Cheers :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Multiple vs. Single Arrays
« Reply #1 on: November 04, 2021, 04:59:46 PM »
Hi.
If the objects need to use the same array data, it is probably best to have a 'Data' gameobject.

You can set this 'Data' Object as a Global Variable which makes it easy to access from prefabs.
And you can use that 'Data' Object for other variables as well, not only for array lists.

DABYX

  • Playmaker Newbie
  • *
  • Posts: 8
Re: Multiple vs. Single Arrays
« Reply #2 on: November 06, 2021, 03:38:17 AM »
Hey djdino,

I see thanks! I thought that might be the case but wasn't sure as I was destroying them after creation the other way.

Thanks a lot for your help!  ;D