Search Unity

cant clear list (SOLVED)

Discussion in 'Scripting' started by LadyLegend, Oct 18, 2017.

  1. LadyLegend

    LadyLegend

    Joined:
    Oct 6, 2017
    Posts:
    50
    Hi, Ive created a list OnEnable(){} and every time the game object gets activated it adds the list again as a duplicate. Now that isn't the problem. The problem is I want to clear the list On Disable(){} but it doesn't work. Nothing happens when I use:
    List.Clear();
    List = new List<string>();

    Screen Shot 2017-10-18 at 1.47.45 PM.png
     

    Attached Files:

  2. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    How are you confirming the contents of the list? I don't see anything that removes existing options from stock before adding new ones from StockList so I'd hazard a guess that you are clearing the list but not clearing the old list values out of whatever stock is.
     
  3. LadyLegend

    LadyLegend

    Joined:
    Oct 6, 2017
    Posts:
    50
    my list is generated by finding game objects with tags and adding them to a dropdown menu.
    all that works fine. I just cant clear those previous values as you say. I don't have an issue with the repopulating just the clearing.

    the On disable() is where I need to clear the list and it doesn't work.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    LadyLegend and KelsoMRK like this.
  5. LadyLegend

    LadyLegend

    Joined:
    Oct 6, 2017
    Posts:
    50
    I swear I really need to just ask for help here instead google SUCKS lol :):D Thank you so much!!!!