Oculus entitlement gear vr - unity3d

I am developing a game for Gear VR in Unity 5.6.1p1 with Oculus Utils 1.9.0. It is on technical review now on developer console. However I keep getting entitlement error even after adding it to the project.
Here is their explanation:
It appears that your app does not support entitlement checks to prevent unauthorized use of your content. Documentation on how to add entitlement checks can be found here: https://developer.oculus.com/documentation/platform/latest/concepts/pgsg-get-started-with-sdk/
And here is my entitlement code:
public class PlatformManager : MonoBehaviour
{
public static bool entitled = false;
private static PlatformManager s_instance;
private ulong m_myID;
private string m_myOculusID;
void Awake()
{
if(s_instance != null)
{
Destroy(gameObject);
return;
}
s_instance = this;
DontDestroyOnLoad(gameObject);
Core.Initialize();
}
private void Start()
{
entitled = false;
Entitlements.IsUserEntitledToApplication().OnComplete(IsEntitledCallback);
}
void IsEntitledCallback(Message msg)
{
if(msg.IsError)
{
entitled = false;
TerminateWithError(msg);
return;
}
entitled = true;
Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
}
public static void TerminateWithError(Message msg)
{
Debug.Log("Error: " + msg.GetError().Message);
UnityEngine.Application.Quit();
}
void GetLoggedInUserCallback(Message<User> msg)
{
if(msg.IsError)
{
TerminateWithError(msg);
return;
}
m_myID = msg.Data.ID;
m_myOculusID = msg.Data.OculusID;
}
}
I am not doing anything with ID after entitling. Should I do something? Is there a mistake in my code? I do get true value after entitling.

My app has passed entitlement check and techical review. The code was good, but I had to add a message to let the user know that he is not entitled, and then exit the app.

Related

Rank reaches -1 in google play services (Unity)

I made a simple game in unity, and I implemented google play services using This Plugin and I have encountered some issue which I can't find any solution simply by searching on google btw I have already read the docs and made a custom skin/ui for my leaderboard as this and this works fine (that not registered text is intentional) but the issue I am getting is that some of my tester can't even login to google play and some can
and even one of them got a rank of -1 see this, idk how this happened but we can't access the database to edit the data manually(or without editing code/creating new leaderboard).
the codes I am using:-
This one is for authenticating and loading the leaderboard
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using UnityEngine.SocialPlatforms;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using TMPro;
using System;
public class GPauth : MonoBehaviour
{
public bool IsConnected = false;
public GameObject Lockbtn;
public Button btn;
public Transform EntryContainer;
public Transform EntryTemplate;
public float TemplateHeight = 300f;
public TextMeshProUGUI PlayerName;
public TextMeshProUGUI PlayerRank;
public TextMeshProUGUI PlayerScore;
GooglePlayData data;
PlayerData playerData;
public GameObject scroeDisplay;
public GameObject newtya;
public GameObject mainMenu;
public GameObject lbUI;
[SerializeField] private AudioSource LockSFX;
[SerializeField] private Animator LockAnime;
[SerializeField] private AudioSource source;
private bool LeaderboardDataHasFilled;
private void Start()
{
playerData = SaveSystem.LoadPlayer();
data = SaveSystem.LoadConsole();
if(data == null || playerData == null || playerData.HasPlayed == false)
{
Lockbtn.SetActive(true);
SaveSystem.SaveConsole(this);
return;
}
else
{
IsConnected = data.connectedToGooglePlay;
}
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate();
AuthenticateUser();
LeaderboardDataHasFilled = false;
}
private void AuthenticateUser()
{
PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}
private void ProcessAuthentication(SignInStatus status)
{
if (status == SignInStatus.Success)
{
IsConnected = true;
}
else IsConnected = false;
SaveSystem.SaveConsole(this);
}
public void ShowLeaderboard()
{
if(data == null || playerData == null || playerData.HasPlayed == false)
{
LockSFX.Play();
LockAnime.SetBool("Start", true);
Invoke("resetLockAnime", 0.1f);
}
else
{
source.Play();
if (!IsConnected) AuthenticateUser();
else LeaderboardUI();
}
}
private void resetLockAnime()
{
LockAnime.SetBool("Start", false);
}
private void LeaderboardUI()
{
scroeDisplay.SetActive(false);
mainMenu.SetActive(false);
newtya.SetActive(false);
lbUI.SetActive(true);
if (LeaderboardDataHasFilled) return;
PlayGamesPlatform.Instance.LoadScores(
GPGSIds.leaderboard_newtya,
LeaderboardStart.TopScores,
10,
LeaderboardCollection.Public,
LeaderboardTimeSpan.AllTime,
(data) =>
{
if (data == null)
{
Debug.LogError("Data Was Null");
return;
}
/*Public Leaderboard database logic starts here*/
// get scores
IScore[] scores = data.Scores;
// get user ids
string[] userIds = new string[scores.Length];
for (int i = 0; i < scores.Length; i++)
{
userIds[i] = scores[i].userID;
}
// forward scores with loaded profiles
Social.LoadUsers(userIds, profiles => DisplayLeaderboardEntries(scores, profiles, data.PlayerScore));
/*Public Leaderboard database logic Ends here*/
if (data.PlayerScore == null)
{
Debug.Log("Data.PlayerScore was null");
PlayerName.text = "Not registered";
return;
}
if (data.PlayerScore.userID == null)
{
Debug.Log("Data.PlayerScore.UserID was null");
PlayerName.text = "Not registered";
return;
}
IScore pScore = data.PlayerScore;
string userId = data.PlayerScore.userID;
string[] PlayerIDS = new string[] { userId };
Social.LoadUsers(PlayerIDS, profiles => PlayerScoreSetup(pScore, profiles));
});
LeaderboardDataHasFilled = true;
}
private void PlayerScoreSetup(IScore data, IUserProfile[] profiles)
{
PlayerName.text = profiles[0].userName.ToString();
PlayerScore.text = data.formattedValue.ToString();
PlayerRank.text = data.rank.ToString();
}
private void DisplayLeaderboardEntries(IScore[] scores, IUserProfile[] profiles, IScore playerData)
{
EntryTemplate.gameObject.SetActive(false);
for (int i = 0; i < profiles.Length; i++)
{
Transform entryTransform = Instantiate(EntryTemplate, EntryContainer);
RectTransform entryRectTransform = entryTransform.GetComponent<RectTransform>();
entryRectTransform.anchoredPosition = new Vector2(0, -TemplateHeight * i);
entryRectTransform.gameObject.SetActive(true);
TextMeshProUGUI txRank = entryRectTransform.Find("RankTXT").GetComponent<TextMeshProUGUI>();
TextMeshProUGUI txName = entryRectTransform.Find("NameTXT").GetComponent<TextMeshProUGUI>();
TextMeshProUGUI txScore = entryRectTransform.Find("ScoreTXT").GetComponent<TextMeshProUGUI>();
txRank.text = scores[i].rank.ToString();
txName.text = profiles[i].userName.ToString();
txScore.text = scores[i].formattedValue.ToString();
}
}
}
and this one runs when player loses to upload the score
long scoreforlb = Convert.ToInt64(HighScore);
Social.ReportScore(scoreforlb, GPGSIds.leaderboard_newtya, UpdateLeaderboard);
//to check if score was reported or not
private void UpdateLeaderboard(bool success)
{
if (success) Debug.Log("Success");
else Debug.Log("err");
}
I have already implemented some checks to prevent above code to run if user isnot connect to google play games.
Any help will be very appreciable.
In my experience '-1' rank is caused by player's Google Play profile's Game Activity being set to private.
Players have the option to set this preference during initial creation of google play games account, or they can change it later in the play games app ('Game Activity' setting under 'Profile and privacy').
One solution (which I used) is to show a help button (to players with -1 rank) which shows a message box explaining why the rank is not available and how the player can set their profile to public if they want to see their rank.
Regarding the login problem, you can see the reason for login failure in the SignInStatus returned in authentication callback, which might point out the issue.
Also check to see if the tester is able to sign into other games which use google play games, to make sure it is not a device/account issue.

Unity & PhotonEngine. After scene reaload Joining to Lobby, CreateRoom and JoinRandom functions called repeatedly

I ran into a problem in the last step of a test project using Photon Network. When you first connect and join the room, everything goes without errors. However, after completing the match, exiting the room, and using LoadScene(), errors appear:
JoinLobby operation (229) not called because client is not connected or not yet ready, client state: JoiningLob <- in OnConnectedToMaster()
Through experience, I realized that the ConnectUsingSettings() methods and other Photon methods are called multiple times. But the connection to the lobby happens and I can create a room, but I immediately encounter MissingReferenceException errors.
I've seen a solution from guys who ran into this very same problem. The problems arose because of the events. Wherever this could happen, I unsubscribed from the events, but that doesn't help. What else can cause such problems, because I obviously missed something that prevents me from completely closing the scene during the transition?
Sorry for my language, used Google Translate
Code:
LobbyManager.cs
private void StartConnect()
{
PhotonNetwork.NickName = master.GameSettings.NickName;
PhotonNetwork.GameVersion = master.GameSettings.NickName;
PhotonNetwork.ConnectUsingSettings();
PhotonNetwork.AutomaticallySyncScene = true;
}
public override void OnConnectedToMaster()
{
Debug.Log("Connected to server");
if(!PhotonNetwork.InLobby) PhotonNetwork.JoinLobby();
}
public override void OnJoinedLobby()
{
onConnected.Invoke();//This use for show UIElements on Canvas
}
JoinRandomRoom class
public void OnClick_JoinRandomRoom()
{
if (!PhotonNetwork.IsConnected) return;
if (GameModeGlobalData.SelectedGameMode != null)
{
SetRoomOptions();
PhotonNetwork.JoinRandomRoom(expectedRoomProperties, GameModeGlobalData.SelectedGameMode.MaxPlayers);
}
}
public override void OnJoinRandomFailed(short returnCode, string message)
{
Debug.Log("Join random failed: " + message + ". Room will be created...");
_createRoomMenu.CreateAndJoinRoom();
}
public void SetRoomOptions()
{
expectedRoomProperties[RoomData.GAME_MODE] = GameModeGlobalData.SelectedGameMode.GameModeName;
}
private void OnDisable()
{
ShowPanels.RemoveAllListeners();
}
And CreateRoom.cs
private ExitGames.Client.Photon.Hashtable _roomCustomProperties = new ExitGames.Client.Photon.Hashtable();
public void CreateAndJoinRoom()
{
if (!PhotonNetwork.IsConnected) return;
if (GameModeGlobalData.SelectedGameMode != null)
{
RoomOptions roomOptions = GetCustomRoomOptions();
roomOptions.CleanupCacheOnLeave = true;
PhotonNetwork.CreateRoom(randomRoomName, roomOptions);
}
}
public RoomOptions GetCustomRoomOptions()
{
RoomOptions options = new RoomOptions();
options.MaxPlayers = _maxPlayer;
options.IsOpen = true;
options.IsVisible = true;
string[] roomProperties = new string[]{ RoomData.GAME_MODE };
_roomCustomProperties[RoomData.GAME_MODE] = GameModeGlobalData.SelectedGameMode.GameModeName;
options.CustomRoomPropertiesForLobby = roomProperties;
options.CustomRoomProperties = _roomCustomProperties;
return options;
}
The project has grown, and I blame myself for not testing it at the very beginning. Didn't think there would be problems at this stage
Sorry for this post. Its resolved. For those who may encounter this in the future, in addition to unsubscribing from events, check all classes that inherit from MonoBehaviourPunCallbacks for overridden OnDisable() methods.
Like this:
public override void OnDisable()
{
base.OnDisable();
}
This in turn will call the
PhotonNetwork.RemoveCallbackTarget(this);
Also, from the documentation:
Do not add new MonoBehaviour.OnEnable or MonoBehaviour.OnDisable. Instead, you should override those and call base.OnEnable and base.OnDisable.
I forgot about it and used MonoBehaviour.OnDisable.

how to make this code in google play closed test

this code is perfectly working in unity editor but when I try it in google play closed test it does not work because there are no ad displayed so my bool to pause my player stay true and the player did not move
public class InterstitialAd : MonoBehaviour
{
public string androidAdUnitId;
public string iosAdUnitId;
IInterstitialAd interstitialAd;
async void Start()
{
// Initialize the package to access API
await UnityServices.InitializeAsync();
// Instantiate an interstitial ad object with platform
if (Application.platform == RuntimePlatform.Android)
{
interstitialAd = MediationService.Instance.CreateI
}
else if (Application.platform == RuntimePlatform.IPhon
{
interstitialAd = MediationService.Instance.CreateI
}
if UNITY_EDITOR
else
{
interstitialAd = MediationService.Instance.CreateI
}
endif
// Subscribe callback methods to load events:
interstitialAd.OnLoaded += AdLoaded;
interstitialAd.OnFailedLoad += AdFailedToLoad;
// Subscribe callback methods to show events:
interstitialAd.OnShowed += AdShown;
interstitialAd.OnFailedShow += AdFailedToShow;
interstitialAd.OnClosed += AdClosed;
interstitialAd.Load();
Debug.Log("try LoadAd");
}
private void AdClosed(object sender, EventArgs e)
{
Debug.Log("Ad has closed");
StartBTNBehaviour.pause = false; //this bool control the player movement false = player
//move
// Execute logic after an ad has been closed.
}
public void ShowAd()
{
// Ensure the ad has loaded, then show it.
Debug.Log("try ShowAd");
if (interstitialAd.AdState == AdState.Loaded)
{
interstitialAd.Show();
Debug.Log("ShowAd");
}
else
{
Debug.Log("Failed ShowAd");
StartBTNBehaviour.pause = false; //added to test
}
so my problem is no ads in google closed test which make my pause bool not changed

Photon, PlayFab, & Unity3D - Players not appearing to one another after joining Photon Room

I am working on a multiplayer game in Unity which is using Playfab and the Authentication and Photon which is hosting the multiplayer. I can successfully get players into the same room and I can load the scene after players 'join' the room, however, when 2 players are in the same room, they can not see each other.
This is my authentication service:
public class LoginWithCustomID : MonoBehaviour
{
private string _playFabPlayerIdCache;
private bool _isNewAccount;
private string _playerName;
// Use this to auth normally for PlayFab
void Awake()
{
PhotonNetwork.autoJoinLobby = false;
PhotonNetwork.automaticallySyncScene = true;
DontDestroyOnLoad(gameObject);
authenticateWithPlayfab();
}
private void authenticateWithPlayfab()
{
var request = new LoginWithCustomIDRequest
{
CustomId = "CustomId123",
CreateAccount = true,
InfoRequestParameters = new GetPlayerCombinedInfoRequestParams()
{
GetUserAccountInfo = true,
ProfileConstraints = new PlayerProfileViewConstraints()
{ ShowDisplayName = true }
}
};
PlayFabClientAPI.LoginWithCustomID(request, requestPhotonToken, OnLoginFailure);
}
private void requestPhotonToken(LoginResult result)
{
PlayerAccountService.loginResult = result;
_playFabPlayerIdCache = result.PlayFabId;
_playerName = result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName;
if (result.NewlyCreated)
{
_isNewAccount = true;
setupNewPlayer(result);
}
PlayFabClientAPI.GetPhotonAuthenticationToken(new GetPhotonAuthenticationTokenRequest()
{
PhotonApplicationId = "photonId123"
}, AuthenticateWithPhoton, OnLoginFailure);
}
private void setupNewPlayer(LoginResult result)
{
PlayFabClientAPI.UpdateUserData(
new UpdateUserDataRequest()
{
Data = new Dictionary<string, string>()
{
{ "Level", "1" },
{ "xp", "0" }
}
}, success =>
{
Debug.Log("Set User Data");
}, failure =>
{
Debug.Log("Failed to set User Data..");
}
);
}
private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult result)
{
Debug.Log("Photon token acquired: " + result.PhotonCustomAuthenticationToken);
var customAuth = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };
customAuth.AddAuthParameter("username", _playFabPlayerIdCache);
customAuth.AddAuthParameter("token", result.PhotonCustomAuthenticationToken);
PhotonNetwork.AuthValues = customAuth;
setNextScene();
}
private void setNextScene()
{
if(_isNewAccount || _playerName == null)
{
SceneManager.LoadSceneAsync("CreatePlayerName", LoadSceneMode.Single);
}
else
{
SceneManager.LoadSceneAsync("LandingScene", LoadSceneMode.Single);
}
}
private void OnLoginFailure(PlayFabError error)
{
Debug.LogWarning("something went wrong in auth login");
Debug.LogError("Here's some debug info:");
Debug.LogError(error.GenerateErrorReport());
}
}
}
This all works and a player is logged into PlayFab, as well as Photon I would assume if I got the Photon auth token. This brings me to my landing scene, which is essentially a place for an authenticated user to click a button to join a random room via Photon:
public static GameManager instance;
public static GameObject localPlayer;
private void Awake()
{
if (instance != null)
{
DestroyImmediate(instance);
return;
}
DontDestroyOnLoad(gameObject);
instance = this;
PhotonNetwork.automaticallySyncScene = true;
}
// Use this for initialization
void Start()
{
PhotonNetwork.ConnectUsingSettings("A_0.0.1");
}
public void JoinGame()
{
RoomOptions ro = new RoomOptions();
ro.MaxPlayers = 4;
PhotonNetwork.JoinOrCreateRoom("Test Room 2", ro, null);
}
public override void OnJoinedRoom()
{
Debug.Log("Joined Room!");
if (PhotonNetwork.isMasterClient)
{
PhotonNetwork.LoadLevel("Test_Map1");
}
}
private void OnLevelWasLoaded(int level)
{
if (!PhotonNetwork.inRoom)
return;
localPlayer = PhotonNetwork.Instantiate(
"Player",
new Vector3(0, 1f, 0),
Quaternion.identity,
0);
}
public void LeaveRoom()
{
PhotonNetwork.LeaveRoom();
SceneManager.LoadScene("LandingScene", LoadSceneMode.Single);
}
This loads the scene that I named "Test_scene1" successfully and I show within my scene, the room name and number of active players in the room. When I do a run and build, I get a user's playerPrefab to load into the room. When I run the game through unity, I can get a second player to log into the room. The problem is, the players do not see eachother and I can not figure out why that is. I am following the PLayerfab/Photon tutorials on their respective sites, but I can't find anything that I did wrong in either one.
From what I read, it looks like my instantiate method might be wrong but I'm not sure why. Below is my player Prefab showing the components attached to it:
I apologize for this huge question, I just wanted to provide as much information as I could.
This question was answered by the OP on PlayFab forums here.

facebook login with unity jumping to first scene in editor

I am having a strange issue when trying to test the Facebook sdk(login) in Unity Editor. The login procedure works fine, but after successfully logging in (pasting the token generator) , Facebook throws me back in to my first scene instead of staying in the same scene, where the login procedure was started.
Any ideas why this is happening?
Update: Strangly enough, this only happens when "maximize on play" is enabled.
Update: Code snipet:
public class UserManager : MonoBehaviour {
public Button fbLoginButton;
public Text errorSuccessText;
public void Start() {
fbLoginButton.interactable = false;
FB.Init (OnFBInitComplete);
fbLoginButton.onClick.AddListener (() => SubmitFBInfo ());
}
private void OnFBInitComplete() {
fbLoginButton.interactable = true;
}
private void SubmitFBInfo() {
FB.Login("email,publish_actions", FBLoginCallback);
}
private void FBLoginCallback(FBResult result) {
if (FB.IsLoggedIn) {
errorSuccessText.text = "Logged In with Facebook";
}
}