Пример #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;
    }
Пример #2
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);
 }