Google+ Button

+1 annotations from your users can help their social connections find your site or app and can influence search positioning. Learn more about how Google uses social connections in search.

Creating the Plus Button.

Following code snippet will show how to create the Plus Button:

AN_PlusButton PlusButton;
string PlusUrl = "https://unionassets.com/";
PlusButton =  new AN_PlusButton(PlusUrl, AN_PlusBtnSize.SIZE_STANDARD, AN_PlusBtnAnnotation.ANNOTATION_BUBBLE);

 

In order to create Plus button we need to provide valid URL, button, and annotation type.

Alavalible sizes can be founded in the AN_PlusBtnSize enum.

public enum AN_PlusBtnSize {
	SIZE_SMALL = 0,
	SIZE_MEDIUM = 1,
	SIZE_TALL = 2,
	SIZE_STANDARD = 3

}

 

Available annotation options can be founded in the AN_PlusBtnAnnotation enum.

public enum AN_PlusBtnAnnotation {
	ANNOTATION_NONE = 0,
	ANNOTATION_BUBBLE = 1,
	ANNOTATION_INLINE = 2
}

 

he following tables shows examples of size and annotation values. Specifying a height in the button's container that is shorter than the shortest supported height renders the button using the shortest supported height. Other heights render the largest button that will fit, and will vertically center that icon in the requested space. If enough space is available horizontally, the buttons also render a "bubble", as shown below, containing the total number of +1's for that page.

Size and Annotation

Example

Button Width (px)

Max width (px)

Button Height (px)

small (none)

24

15

small (bubble)

70

15

medium (none)

32

20

medium (bubble)

90

20

standard (none)

38

24

standard (bubble)

106

24

tall (none)

50

20

tall (bubble)

50

60

 

You can read more here about buttons and annotations size.

Then we can specify button position using Anchors:

PlusButton.SetGravity(TextAnchor.UpperLeft);
PlusButton.SetGravity(TextAnchor.UpperRight);
PlusButton.SetGravity(TextAnchor.UpperCenter)
PlusButton.SetGravity(TextAnchor.MiddleLeft);

//.. etc

 

Or we can set the x/y coords with:

PlusButton.SetPosition(100, 100);

 

SetGravity and SetPosition can be used anytime to change button position in runtime

The AN_PlusButton class also contains following methods and properties:

public class AN_PlusButton {
    public void SetGravity(TextAnchor btnAnchor)
	public void SetPosition(int btnX, int btnY)
	public void Show() 
	public void Hide() 
	public void Refresh()

	public int ButtonId {get;}
	public int x
	public int y
	public bool IsShowed
	public TextAnchor anchor 
}

 

Following code snippet shows how to find out if player click Plus Button:

AN_PlusButton PlusButton;
PlusButton =  new AN_PlusButton(PlusUrl, AN_PlusBtnSize.SIZE_STANDARD, AN_PlusBtnAnnotation.ANNOTATION_BUBBLE);
PlusButton.SetPosition(Random.Range(0, Screen.width), Random.Range(0, Screen.height));
PlusButton.ButtonClicked += ButtonClicked;


private void ButtonClicked () {
	AndroidMessage.Create("Click Detected", "Plus Button Click Detected");
}

 

Use of the +1 Button is subject to the Google+ Platform Buttons Policy

The full API use example can be founded under PlusButtonExample example scene.