Unity GameJoly API无效

时间:2016-07-24 01:07:29

标签: c# api unity3d

我试图使用GameJolt API进行Unity,并且一旦我尝试使用

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中查找了错误,但却没有提出任何问题。

1 个答案:

答案 0 :(得分:0)

Object reference not set to an instance of an object - 您正在尝试访问尚未定义的对象。查看错误所在的行,并查看正在引用的对象。它尚未设定。