Assets\Scripts\GameControl.cs(114,9): error CS0120: An object reference is required for the non-static field, method, or property 'PlayFabManager.SendLeaderboard(int)'
Doesn't make sense because neither of them are static.
public void PlayerWin() { playingUI.SetActive(false); winMenu.SetActive(true); Cursor.lockState = CursorLockMode.None; camAnimator.SetTrigger("RunEnd"); PlayFabManager.SendLeaderboard(TimerController.timeScore); }
It's having a problem with the bottom line starting with "PlayFabManager..." Here is the code its referencing:
public void SendLeaderboard(int time) { var request = new UpdatePlayerStatisticsRequest { Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = (levelName), Value = time } } }; PlayFabClientAPI.UpdatePlayerStatistics(request, OnLeaderboardUpdate, OnError); }
Any help would be much appreciated I have no idea what to do, tried referencing objects and making them static and it just gave more errors.
Answer by Ivan Cai · Jun 21, 2021 at 09:22 AM
As your PlayFabManager class inherits from MonoBehaviour, this script needs to be attached to a game object. Then you need to get a reference to the the PlayFabManager component.
PlayFabManager playfabMananger = GameObject.Find("PlayFabManager").GetComponent<PlayFabManager>();
The above will work if your game object is called " PlayFabManager ", swap this for the name of your object if it is called something else.
Then playfabMananger.SendLeaderboard(int); will now work. I find a related thread that can help you.