Ejemplo n.º 1
0
    /// <summary>
    /// Use this method to draw a button
    /// </summary>
    /// <remarks>
    /// Use this method to draw a button. To get the state of the utton use the return value of this method.
    /// </remarks>
    /// <param name="theImage">the icon inside the button (icon is before text)</param>
    /// <param name="theText">the text inside the button (text is after icon)</param>
    /// <param name="theButtonStyle">the render style of the button</param>
    /// <param name="theLayout">GUILayout options</param>
    /// <returns>returns the state of the button in this frame. returns true if the button is clicked.</returns>
    public static bool Button(Texture theImage, string theText, eStyleButton theButtonStyle, params GUILayoutOption[] theLayout)
    {
        GUIContent aGuiContent = null;

        if(theImage != null)
        {
            aGuiContent = new GUIContent(theText, theImage);
        }
        else
        {
            aGuiContent = new GUIContent(theText);
        }

        Init();

        if(itsSkinIndex == -1)
        {
            if (GUILayout.Button(aGuiContent, theLayout))
            {
                PlaySound(theButtonStyle.ToString());
                return true;
            }
        }
        else
        {
            if (GUILayout.Button(aGuiContent, GetStyleButton(theButtonStyle), theLayout))
            {
                PlaySound(theButtonStyle.ToString());
                return true;
            }
        }
        return false;
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Use this method to draw a button
 /// </summary>
 /// <remarks>
 /// Use this method to draw a button. To get the state of the utton use the return value of this method.
 /// </remarks>
 /// <param name="theImage">the icon inside the button</param>
 /// <param name="theButtonStyle">the render style of the button</param>
 /// <param name="theLayout">GUILayout options</param>
 /// <returns>returns the state of the button in this frame. returns true if the button is clicked.</returns>
 public static bool Button(Texture theImage, eStyleButton theButtonStyle, params GUILayoutOption[] theLayout)
 {
     return Button(theImage, "", theButtonStyle, theLayout);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Set click sound for buttons
 /// </summary>
 /// <param name="theButtonStyle"></param>
 /// <param name="theAudioClip"></param>
 public static void SetSoundForButton(eStyleButton theButtonStyle, AudioClip theAudioClip)
 {
     SetSound(theButtonStyle.ToString(),theAudioClip);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Use this method to draw a button
 /// </summary>
 /// <remarks>
 /// Use this method to draw a button. To get the state of the utton use the return value of this method.
 /// </remarks>
 /// <param name="theText">the text inside the button</param>
 /// <param name="theButtonStyle">the render style of the button</param>
 /// <param name="theLayout">GUILayout options</param>
 /// <returns>returns the state of the button in this frame. returns true if the button is clicked.</returns>
 public static bool Button(string theText, eStyleButton theButtonStyle, params GUILayoutOption[] theLayout)
 {
     return Button(null, theText, theButtonStyle, theLayout);
 }
Ejemplo n.º 5
0
    /// <summary>
    /// returns the requested guistyle for a button
    /// </summary>
    /// <param name="theStyleButton">the type of button style</param>
    /// <returns>returns the requested button style. Returns the default button style if no custom style was found.</returns>
    public static GUIStyle GetStyleButton(eStyleButton theStyleButton)
    {
        if(itsSkinIndex == -1)
            return GUI.skin.button;
        Init();
        if(theStyleButton == eStyleButton.eButton && itsStyleButton[itsSkinIndex] != null)
        {
            return itsStyleButton[itsSkinIndex];
        }
        else if(theStyleButton == eStyleButton.eButtonLeft && itsStyleButtonLeft[itsSkinIndex] != null)
        {
            return itsStyleButtonLeft[itsSkinIndex];
        }
        else if(theStyleButton == eStyleButton.eButtonRight && itsStyleButtonRight[itsSkinIndex] != null)
        {
            return itsStyleButtonRight[itsSkinIndex];
        }
        else if(theStyleButton == eStyleButton.eButtonTop && itsStyleButtonTop[itsSkinIndex] != null)
        {
            return itsStyleButtonTop[itsSkinIndex];
        }
        else if(theStyleButton == eStyleButton.eButtonBottom && itsStyleButtonBottom[itsSkinIndex] != null)
        {
            return itsStyleButtonBottom[itsSkinIndex];
        }
        else if(theStyleButton == eStyleButton.eButtonMiddle && itsStyleButtonMiddle[itsSkinIndex] != null)
        {
            return itsStyleButtonMiddle[itsSkinIndex];
        }

        return GUI.skin.button;
    }