Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with enums

Discussion in 'Scripting' started by witcher101, Jul 26, 2016.

  1. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    I have a enum of items;
    public enum items{lamps,mines,chair};
    public items myitems;

    I wana increment myitems value whenevr i press E
    So when i press E 1st myitems should be mines then after again E press it should bechair and so on.
    How do i do this??

    Thanks
     
  2. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    try something like this:

    Code (csharp):
    1.  
    2. myItems = items.lamps;
    3. int temp = (int)myItems ;
    4. myItems = (items)(temp+1);
    5.