Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Radio Button Inspector?

Discussion in 'Scripting' started by leegod, Jul 23, 2010.

  1. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,487
    var abc : float = 0;

    This can be adjusted at inspector.

    Also int too.

    And boolean generate checkbox.


    Then is there no radio button?
     
  2. ThatHomelessGuy

    ThatHomelessGuy

    Joined:
    Jun 28, 2010
    Posts:
    348
    Public var abc : float = 0;
    Methinks
    also make sure it is declared correctly within the function
     
  3. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,487
    Sorry but you don't understand what I mean.
     
  4. AkilaeTribe

    AkilaeTribe

    Joined:
    Jul 4, 2010
    Posts:
    1,149
    I haven't too (that's why I said nothing). Be more precise, please.
     
  5. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,487
    var that can generate Radio button at the inspector.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There isn't any "radio button" variable type, because that would mean that the value of the variable would depend on and be affected by the value of other variables, which doesn't make much sense in a programming environment.

    --Eric
     
  7. VCCGeek

    VCCGeek

    Joined:
    Nov 17, 2009
    Posts:
    89
    I think I know what he wants. He's not looking for a radio button data type. He has a variable of enumerated type, and wants to select the value using a radio button instead of the drop list in the inspector. I think this can be done using an editor script, but I'm not too sure how to mimic radio button behaviour with the existing GUI controls. I think it just does checkboxes.

    I could be wrong, though.
     
  8. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I think he was looking for something like this?!?


    Code (CSharp):
    1.  
    2. bool bToggleState = fontType == FontType.UnityFont;
    3. bToggleState = GUILayout.Toggle( bToggleState, "Unity Font", (GUIStyle)"Radio" );
    4. if( bToggleState ) fontType = FontType.UnityFont;
    5.  
    6. bToggleState = fontType == FontType.BitmapFont;
    7. bToggleState = GUILayout.Toggle( bToggleState, "Bitmap Font", (GUIStyle)"Radio" );
    8. if( bToggleState ) fontType = FontType.BitmapFont;
    9.  
    Sorry for Necro, but i looked around and didnt find a solution either. I hope someone running a search finds this a viable solution. ;)
     
    Last edited: Nov 17, 2014