使用Unity 5.4和FB SDK 7.9我想使用onclick按钮功能来运行方法Share。这个方法有很多参数,所以我需要在代码中而不是在检查器中创建onclick功能。我收到错误的意外符号链接参数期待'。'到底是怎么回事?我该如何解决这个问题?
public class FBScript : MonoBehaviour {
public Button PostBtn;
void Start() {
Button btn = PostBtn.GetComponent<Button>();
btn.onClick.AddListener(delegate {
Share(string linkParameter, string namerParameter, string captionParameter, string descriptionParameter, string pictureParameter, string redirectParameter);
});
}
void Awake () {
FB.Init(SetInit, OnHideUnity);
}
void SetInit () {
if (FB.IsLoggedIn) {
Debug.Log("FB is Logged In");
} else {
Debug.Log("FB is not Logged In");
}
}
void OnHideUnity(bool isGameShown) {
if (!isGameShown) {
Time.timeScale = 0;
} else {
Time.timeScale = 1;
}
}
public void FBLogin() {
List<string> permissions = new List<string>();
permissions.Add("public_profile");
FB.LogInWithReadPermissions(permissions, AuthCallBack);
}
void AuthCallBack(ILoginResult result) {
if (result.Error != null) {
Debug.Log(result.Error);
} else {
if (FB.IsLoggedIn) {
Debug.Log("FB is Logged In");
} else {
Debug.Log("FB is not Logged In");
}
}
}
private const string FACEBOOK_APP_ID = "999999999999999";
private const string FACEBOOK_URL = "http://www.facebook.com/dialog/feed";
public void Share(string linkParameter, string namerParameter, string captionParameter, string descriptionParameter, string pictureParameter, string redirectParameter) {
Application.OpenURL(FACEBOOK_URL + "?app_id=" + FACEBOOK_APP_ID +
"&link=" + WWW.EscapeURL(linkParameter) +
"&name=" + WWW.EscapeURL(namerParameter) +
"&caption=" + WWW.EscapeURL(captionParameter) +
"&description=" + WWW.EscapeURL(descriptionParameter) +
"&picture=" + WWW.EscapeURL(pictureParameter) +
"&redirect_url=" + WWW.EscapeURL(redirectParameter));
}
}