2016-07-24 9 views
0

Ich versuche, die GameJolt API für die Einheit zu verwenden, und sobald ich versucheUnity GameJoly API funktioniert nicht

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

zu verwenden Es gibt mir dies:

Error

Hier ist der Code für 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 
    } 
} 

Und hier ist mein Code für Menu.cs:

Ich habe den Fehler in Google nachgeschlagen, habe aber nichts gefunden.

Antwort

0

Object reference not set to an instance of an object - Sie versuchen, auf ein Objekt zuzugreifen, das noch nicht definiert wurde. Schauen Sie in die Zeilen, in denen der Fehler auftritt, und sehen Sie, auf welches Objekt verwiesen wird. Es wurde noch nicht festgelegt.

+0

Ich habe meinen Code aktualisiert – spacegeek224

+0

Mit Blick auf den ersten Fehler, es heißt, es gibt keine Instanz von 'Gamejolt.API.Manager'. Überprüfen Sie, ob Sie das in der Spielszene haben. – ihavemorealts

Verwandte Themen