Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
NAMM

Junior Member
Registered:
Posts: 21
Reply with quote  #1 

Good morning everyone,

After 4.6 with the new UI system I wanted to update my poor menu design taking advantage on the new and improved Unity UI.

My old version is this one

Capture.PNG  And my new one will be something like this : 

Capture2.PNG The problem is that I can only make the "Start Game" button work (load the scene of the game). 

I am having trouble in the Rate ( redirect to playstore), MoreGames (redirect to developer page) and Leaderboards (from google services) . 

Has anyone been able to make this work ? If so, can you shed some light on how you did it ?


The source code I have been using is:

using UnityEngine;

using System.Collections;

using GooglePlayGames;

using UnityEngine.SocialPlatforms;

using Chartboost;

 

public class MenuCs : MonoBehaviour

{

private Ray ray;

private RaycastHit hit;

public TextMesh bScore;

private string leaderboard = "(private_info)"; 

 

void Start(){

PlayGamesPlatform.Activate();

}

 

void Awake(){

bScore.text = "Score: " + PlayerPrefs.GetInt("bScore");

 

CBBinding.init("(private_info)", "(private_info)");

//ChartBoostBinding.init ( "CHARTBOOST_APP_ID", "CHARTBOOST_APP_SIGNATURE" );

CBBinding.cacheInterstitial( "default" );

CBBinding.cacheMoreApps();

 

}

 

void StartGame(){

Debug.Log("Start Game");

Application.LoadLevel(1);

}

 

void RateGame(){

#if UNITY_ANDROID

Application.OpenURL("https://play.google.com/store/apps/details?id=com.namm.EndlessPlatformer");

#elif UNITY_IPHONE

Application.OpenURL("itms-apps://itunes.apple.com/app/idYOUR_ID");

#endif

}

 

void MoreApps(){

CBBinding.showMoreApps();

Debug.Log("More Games");

}

 

void Leaderboards(){

 

Social.localUser.Authenticate((bool success) =>{

 

 

if (success)

{

 

Debug.Log("You've successfully logged in!");

 

Social.ReportScore(PlayerPrefs.GetInt("bScore"), leaderboard, (bool worked) =>

                  {

if (worked)

{

((PlayGamesPlatform)Social.Active).ShowLeaderboardUI(leaderboard);

}

else{Debug.Log("Fail");}

});

 

 

 

} else

 

{

 

Debug.Log("Login failed for some reason");

}

});

 

}

 

 

void Update(){

 

}

}

 
----
Any help will be greatly apreciated! 


0
captainprice

Junior Member
Registered:
Posts: 20
Reply with quote  #2 

Hi @NAMM

I am not sure if you already know this

Here is how i would do it.

1) First just select the button you want to work with -> On its Inspector menu Scroll down below to find this Component 
see image below

onClick1.PNG    

2) now GO to that gameobject on which you have attached your script 

lets say 'ScriptManager'

Drag that object and paste it on ' None ' above  and from that drop down select 'Editor and Runtime'.

3) now in your script ( have not done this before just a guess )

public void CallRateButton()
{
     // Logic to call the Url goes here 
}

4) Go again to that button and from this dropdown select the function ( in this case CallRateButton ) and select it.

onCLick.PNG 
in your case GameHandler.SelectObject will look like MenuCs.CallRateButton()

 

I Hope this helps



__________________
love you all, Happy coding [comp]
Captainprice..
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.