2016-07-24 2 views
0

Я пытаюсь использовать GameJolt API для Unity, и как только я пытаюсь использоватьUnity 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 
    } 
} 

И вот мой код Menu.cs:

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"); 
    } 
} 

Я искал ошибку в Google, но ничего не придумал.

ответ

0

Object reference not set to an instance of an object - Вы пытаетесь получить доступ к объекту, который еще не определен. Посмотрите на строки, в которых включена ошибка, и посмотрите, на какой объект ссылаются. Он еще не установлен.

+0

Я обновил свой код – spacegeek224

+0

Глядя на первую ошибку, он говорит, что нет экземпляра 'Gamejolt.API.Manager'. Дважды проверьте, что у вас это в игровой сцене. – ihavemorealts

Смежные вопросы