#well i want to add messages to it when

1 messages · Page 1 of 1 (latest)

languid fossil
#

Then in that case, with the approach I suggested if the list already had 8 elements and new on is being added, you can remove it immediately

somber coyote
#

sorry here;s the updated script

#

Also i know what a struct is, but what do you mean by "wrapper"?

languid fossil
#

Wrapper is basically an object to used to bundle things together with a single reference, at a high level. You can wrap functionlity or objects.

In this case you actually already have one! The Message class is essentially a wrapper to bundle your text mesh object and the string containing the message.

#

If you add an additional variable to track time in some way, you can use that time to decide when you destroy the message instead of using the delayed Destroy call

somber coyote
#

Ahhh i see what you mean

#

essentially make my own little timer to have more control

languid fossil
#

exactly. That way if you need to immediately destroy the message, you can do that since you'll still have a reference to the object

somber coyote
#

hmmm

#

i think i actually just solved my issue lol

#

all i did was add this check to update:

//Make sure msgList is empty
if(msgList.Count > 0)
{
  if(msgList[0].textObj == null)
     msgList.Remove(msgList[0]);
  }

and this to the end consoleMessage() func:

Destroy(msgList.Last().textObj.gameObject, 3);