Compilation errors with Menu Framework

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Sala
Posts: 2
Joined: Sun Sep 12, 2021 7:37 pm

Compilation errors with Menu Framework

Post by Sala »

Hi! First of all, thanks for the great product. Everything has been going great so far with the integration.

I'm trying out the Menu Framework from the extras, and am getting some errors with the compilation.

Image

Code: Select all

error CS0123: No overload for 'OnSceneLoaded' matches delegate 'UnityAction<Scene, LoadSceneMode>'

Code: Select all

error CS1061: 'Scene' does not contain a definition for 'buildIndex' and no accessible extension method 'buildIndex' accepting a first argument of type 'Scene' could be found (are you missing a using directive or an assembly reference?)
Image

Now, I'm unsure if the errors in the code are from the other scripts not loading properly, or vice versa if the scripts are somehow not compiling properly in Unity because of the error.

I recently had to reinstall Windows due to a drive failure, and while I was able to backup everything beforehand, I wonder if I'm not missing a critical .net component on top of everything?

Regardless, I think the scene.buildIndex should be replaced by scene.GetActiveScene() now yeah?

I'm just not sure then on what to do about the Scenemanager.sceneloaded += OnSceneLoaded

I'm still learning C#, so if I'm overlooking some absolutely obvious mechanic of the language, please excuse me. Nonetheless, thank you for your time in looking over this.
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Compilation errors with Menu Framework

Post by Tony Li »

Hi,

What version of Unity are you using?

Does your project have a script named SceneManager that isn't in a namespace? It's a good idea to define types inside namespaces. For example, this script is in a namespace:

Code: Select all

using UnityEngine;

namespace Sala
{
    public class MyScript : MonoBehaviour
    {
    }
}
On the other hand, this is not in a namespace:

Code: Select all

using UnityEngine;

public class MyMisbehavingScript : MonoBehaviour
{
}
(Technically it's in a default namespace named 'global::', but for all intents we can say no namespace.)

If your project has a script named SceneManager that isn't in a namespace, it can cause problems since the Menu Framework won't know whether it should refer to UnityEngine.SceneManagement.SceneManager or your own (global::) SceneManager.
Sala
Posts: 2
Joined: Sun Sep 12, 2021 7:37 pm

Re: Compilation errors with Menu Framework

Post by Sala »

I do not have a Scenemanager.cs in the global namespace... but I do have a Scene.cs in it! It for sure interfered with the "Scene scene" line. Thank you so much for the help. It was an old script that needed purging in any case. I removed it, and everything works, everything compiles.

Thanks for the succinct response! I will also make sure that we properly use namespaces in our code, never struck me as a need before (but our previous projects were -quite- small).

The team and I appreciate.

Oh, for information purposes: we are using Unity 2020.3.12.f1 (LTS)
User avatar
Tony Li
Posts: 22158
Joined: Thu Jul 18, 2013 1:27 pm

Re: Compilation errors with Menu Framework

Post by Tony Li »

Happy to help! I'm glad you found the root cause.
Post Reply