Complie Error - Magic Numbers 2D

Hello,
Don’t see the compile error in my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{

public void LoadNextScene()
{
    int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
    SceneManager.LoadScene(currentSceneIndex + 1);
}

}

SO I can’t link script to button.
See my post here with screen shots - Script Compile Error - Magic Numbers UI - Unity Courses / Ask - GameDev.tv
Thanks,
Mike

Hi,

Did you attach the SceneLoader script to a game object? If so, does the OnClick field of the Button reference that game object? Assigning the script directly does not work.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms