CurrentPage is NULL

I’m trying to create a tutorial with the tutorial authoring package. Usually this is a pleasant experience, however today it just won’t work right.

When I press a tutorial from my tutorial container, it should open the first page, but the whole day, no matter what I try, it keeps giving a Null Reference Exception. I have tried with different scriptable objects, reinstalling the tutorial framework, installing different tutorials to see if the problem persists (it does) - nothing works.

The full stack trace is below but basically: TutorialController.DeInitializeTutorial calls CurrentTutorial.CurrentPage, which throws a null reference exception. I could fix it but then the problem will just persist in other projects I’d imagine. I have added no code of my own yet, I first wanted to write my whole tutorial out. The tutorial I’m switching to has pages assigned: this is not my first tutorial, I know how to set them up.

This stupid grmlbrmtlbmr bug has unfortunately ruined all my productivity for the day and I can’t continue until it is fixed. I welcome any advice as to how to approach this issue.

Unity 2022.2.2
Tutorial Framework 3.1.3
(likely irrelevant) Tutorial Authoring Tools 1.2.2

I was creating the tutorial on a separate branch on our project, but making it in an entirely different project sidesteps the issue. It’s not a great solution, but it works.

Edit:
Nevermind, it broke on this new project as well.

Is there a github where I can create PRs?

The project is not developed in public GitHub but you should be able to open a bug report using the regular Unity bug tracker and it should make its way to the current maintainers of the packages.

Did you ever get this figured out? I was making good headway on a tutorial when I now am getting this as well. It seems to have started as soon as I right-clicked on one of my TutorialPages and hit the Properties option to open it in a floating window so I didn’t have to try and keep going back and forth between inspectors. Ever since I did that, I am getting the same TutorialController null reference exception.

No amount of editor restarts, reimporting of the package, etc, seems to fix it.

If there is no clear resolution, I will probably just see if I can make a copy of the package for the time being and fix it locally so I can at least continue on.

— Edit
I got it working again by making it a local package, then adding additional checks in each place there ended up being an error. This was the final one I got to in which it let me reset the status of the tutorials and the whole thing started working again.

I have pages with no Paragraphs because for some steps in my tutorial I create a new blank page and hijack the rootVisualElement using the ‘Shown’ events and add my own elements. There are no error checks in a number of places in which there probably should.

// TutorialPage.cs 
internal void ResetUserProgressAndCompletionCriteria()
{
    // Added the following check
    if (Paragraphs == null || Paragraphs.Count == 0) { return; }
 
    foreach (var paragraph in Paragraphs)
    {
        if (paragraph.Type != ParagraphType.Instruction) { continue; }
        foreach (var criterion in paragraph.Criteria)
        {
            if (criterion != null && criterion.Criterion != null)
            {
                criterion.Criterion.Completed.RemoveAllListeners();
                criterion.Criterion.Invalidated.RemoveAllListeners();
                criterion.Criterion.StopTesting();
                criterion.Criterion.ResetCompletionState();
            }
        }
    }
 
    HasMovedToNextPage = false;
}

Then I also added the following, as I didn’t realize that I had deleted a TutorialPage to use a different type and it left a blank entry in that sections main tutorial asset.

// Tutorial.cs      
internal void RaisePageInitiated(TutorialPage page, int index)
{
    // Added the following check
    if (!page)
    {
        Debug.LogError("TutorialPage is null. Check the Tutorial asset.");
#if UNITY_EDITOR
        EditorGUIUtility.PingObject(this);
#endif
        return;
    }

    page.Initiate();
    PageInitiated?.Invoke(this, page, index);
}

Hopefully if anyone else comes across this issue, it might help.

1 Like

I wish we could just contribute for this very reason.
Here’s a nice tip:

// change this:
        Debug.LogError("TutorialPage is null. Check the Tutorial asset.");
        #if UNITY_EDITOR
        EditorGUIUtility.PingObject(this);
        #endif

// to this:
        Debug.LogError("TutorialPage is null. Check the Tutorial asset.", this);

This makes it so the object gets pinged once you click on the error in the console and more closely follows Unity standards.

Yeah, good call. You are definitely right. I was just in a rush to get it figured out so I could keep at it and not lose steam, lol.