Announcement

Collapse
No announcement yet.

Help creating custom GUI Buttons

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help creating custom GUI Buttons

    Hi all,
    I'm trying to make some custom buttons for my menu pages, but having some troubles.
    I want my buttons to switch images when you mouse over them, and then swap back to their original image when you move your mouse off of it. As well as change image when you actually click on a button.
    I've tried a couple things, one was having two images, and having one start off as hidden, and then appear when you mouse over, but when you move the mouse off the button, the image that I "unhid" doesn't disappear, even though I tell it to.
    Does anyone know how to do this?

    #2
    You have to make a new Style, and add it to your GUIController. There may be some examples under the existing styles, I can't remember. Anyway, there's an image property in them that lets you set an image for each state.

    Comment


      #3
      I was looking at that.
      The only problem is that I have a different image for each of my buttons.

      Comment


        #4
        Just make a new style for each one.

        Comment


          #5
          Or you can change that component's Image[1] (I think that's rollover or "watched" image) after the style has been defined.

          EDIT: I misspoke. I meant to say, once the style can been set, you can change the instance's properties. Not change GUIComponent.Image[1], but GUIComponet.Style.Image[1]. I'm pretty sure, this works fine.

          Comment


            #6
            Originally posted by SuperApe View Post
            EDIT: I misspoke. I meant to say, once the style can been set, you can change the instance's properties. Not change GUIComponent.Image[1], but GUIComponet.Style.Image[1]. I'm pretty sure, this works fine.
            Yup, works nicely. Thanks.

            Comment


              #7
              Revise:
              Changing GUIComponent.Style.Images[1] works, but will use that same image for each button.
              So it looks like I'll have to make a separate style for each button

              Comment


                #8
                Let's be sure you know what I'm saying, I've been using this properly for the last couple days at work:

                If you have
                Code:
                var GUIButton MyButton1, MyButton2;
                and in your default properties, or and early function call, you've defined the style (same GUIStyle name) to the buttons, you should be able to then (after the style instance is set)
                Code:
                MyButton1.Style.Image[1] = Texture'somethingcool';
                MyButton2.Style.Image[1] = Texture'somethingelse';
                They should show two different images on "roll over" or watched.

                Comment


                  #9
                  Yup.
                  Well, I'm not doing in in the default properties of the MainMenu, but I'm doing it inside my GUIButton class's InitComponent().

                  Comment


                    #10
                    Well, I don't know what to tell you. I've modified other properties of the GUIStyle instance with no problems. Hope it works out.

                    Comment

                    Working...
                    X