2016-07-24 50 views
0

我嘗試使用統一的API GameJolt,並當我嘗試使用團結GameJoly API不工作

GameJolt.UI.Manager.Instance.ShowSignIn(); 

它給了我這樣的:

Error

這裏是Manager.cs代碼:

using GameJolt.UI.Controllers; 
using UnityEngine; 
using System; 

namespace GameJolt.UI 
{ 
    [RequireComponent(typeof(Animator))] 
    public class Manager : GameJolt.API.Core.MonoSingleton<Manager> 
    { 
     #region Init 
     SignInWindow signinWindow; 
     TrophiesWindow trophiesWindow; 
     LeaderboardsWindow leaderboardsWindow; 
     Behaviours.NotificationCentre notificationCentre; 

     override protected void Init() 
     { 
      var animator = GetComponent<Animator>(); 
      notificationCentre = animator.GetBehaviour<Behaviours.NotificationCentre>(); 

      // GetComponentInChildren does not look in inactive childrens. 
      // GetComponentsInChildren does look in inactive children but would alocate memory. 
      // Instead, looping over childrens for what we need. 
      foreach (Transform children in transform) 
      { 
       if (signinWindow == null) 
       { 
        signinWindow = children.GetComponent<SignInWindow>(); 
        if (signinWindow != null) 
        { 
         signinWindow.Init(animator); 
        } 
       } 

       if (trophiesWindow == null) 
       { 
        trophiesWindow = children.GetComponent<TrophiesWindow>(); 
        if (trophiesWindow != null) 
        { 
         trophiesWindow.Init(animator); 
        } 
       } 

       if (leaderboardsWindow == null) 
       { 
        leaderboardsWindow = children.GetComponent<LeaderboardsWindow>(); 
        if (leaderboardsWindow != null) 
        { 
         leaderboardsWindow.Init(animator); 
        } 
       } 
      } 
     } 
     #endregion Init 

     #region SignIn 
     public void ShowSignIn() 
     { 
      ShowSignIn(null); 
     } 

     public void ShowSignIn(Action<bool> callback) 
     { 
      signinWindow.Show(callback); 
     } 
     #endregion SignIn 

     #region Trophies 
     public void ShowTrophies() 
     { 
      ShowTrophies(null); 
     } 

     public void ShowTrophies(Action<bool> callback) 
     { 
      trophiesWindow.Show(callback); 
     } 
     #endregion Trophies 

     #region Leaderboards 
     public void ShowLeaderboards() 
     { 
      ShowLeaderboards(null); 
     } 

     public void ShowLeaderboards(Action<bool> callback) 
     { 
      leaderboardsWindow.Show(callback); 
     } 
     #endregion Leaderboards 

     #region Notifications 
     public void QueueNotification(string text) 
     { 
      var notification = new Objects.Notification(text); 
      QueueNotification(notification); 
     } 

     public void QueueNotification(string text, Sprite image) 
     { 
      var notification = new Objects.Notification(text, image); 
      QueueNotification(notification); 
     } 

     public void QueueNotification(Objects.Notification notification) 
     { 
      notificationCentre.QueueNotification(notification); 
     } 
     #endregion Notidications 
    } 
} 

這裏是我的代碼:

using UnityEngine; 
using UnityEngine.SceneManagement; 
using System.Collections; 

public class Menu : MonoBehaviour { 

    // Use this for initialization 
    void Start() { 
     GameJolt.API.SessionStatus 
    } 

    // Update is called once per frame 
    void Update() { 

    } 

    public void StartGame() { 
     SceneManager.LoadScene ("level1"); 
    } 

    public void Quit() { 
     Application.Quit(); 
    } 

    public void Settings() { 


    } 

    public void Credits() { 
     SceneManager.LoadScene ("Credits"); 
    } 

    public void MainMenu() { 
     SceneManager.LoadScene ("Main Menu"); 
    } 
} 

我擡頭看了谷歌的錯誤,但什麼也沒有提出。

回答

0

Object reference not set to an instance of an object - 您正嘗試訪問尚未定義的對象。查看錯誤信息,並查看正在引用的對象。它尚未設置。

+0

我更新了我的代碼 – spacegeek224

+0

看看第一個錯誤,它說沒有'Gamejolt.API.Manager'的實例。仔細檢查你在遊戲場景中是否有這個功能。 – ihavemorealts