My laptop crashed while adding scene manager and when I reopen the file I get this error:
The .meta file Assets/Scripts/GameManager.cs.meta does not have a valid GUID and its corresponding Asset file will be ignored. If this file is not malformed, please add a GUID, or delete the .meta file and it will be recreated correctly
I’ve tried to regenerate project files but I still could not see the canvases in Scene view and I get this error when I compile the codes again:
NullReferenceException: Object reference not set to an instance of an object
Quiz.DisplayAnswer (System.Int32 index) (at Assets/Scripts/Quiz.cs:81)
Quiz.Update () (at Assets/Scripts/Quiz.cs:58)
any suggestions about how to continue through the course?
NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.
Given your script has got no compiler errors, I assume that the references got lost in the Inspector in the Unity Editor.
If the wrong elements appear in your game window, disable game objects in your Hierarchy to figure out which game objects contain those sprites. Then check your Quiz component and the code to figure out which part controls those game objects.
If the erroris in line 81, currentQuestion is null. Where does an object get assigned to this variable? Have you already tried to add Debug.Logs to your code to see what is going on during runtime?
I’ve tried to add Debug.Logs but now I’ve got the compiler error such as this:
Assets\Scripts\Quiz.cs(38,5): error CS1585: Member modifier ‘public’ must precede the member type and name
here is my current quiz.cs code: `using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
using UnityEditor.ShaderKeywordFilter;
using UnityEngine.UIElements;
public class Quiz : MonoBehaviour
{
[Header(“Questions”)]
[SerializeField] TextMeshProUGUI questionText;
[SerializeField] List questions = new List();
}
`
I’ve added this line “[SerializeField] UnityEngine.UIElements.SliderImage” for the slider because previous error was this
how can I fix this error ?Assets\Scripts\Quiz.cs(27,22): error CS0104: ‘Image’ is an ambiguous reference between ‘UnityEngine.UI.Image’ and ‘UnityEngine.UIElements.Image’
I am totally lost within these codes and understandaing that this part of the course is too much for me I guess
Generally, if you get compiler errors, double click on the message. Then the concerning line will get highlighted. If you cannot spot any issue in that line, go a bit higher in the code. In many cases, there is just a missing semicolon or a missing or misplaced curly bracket. These mistakes are fairly annoying but they also happen to the best programmers.
I’ve managed to overcome compiling errors with specifying the UnityEngine.UI namespace for the several classes. My buttons and play function is now working in game menu but I am still not able to see any of the canvas in Scene Menu even though they are set to be visible in the inspector.