#SceneManager.LoadScene return issue?

1 messages · Page 1 of 1 (latest)

tulip lichen
#

Here's the full code as promised, Thanks!

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

public class mainMenuManager : MonoBehaviour
{
    //Variables
    public Animator mainMenuAnimator;
    public GameObject menuSceneStuff;
    public Scene gameLevel;

    public saveDetails saveDetails;
    public saveDetails playerDetails;
    
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void MoveToLevelMap(){
        Debug.Log("clicked play button, will now move to level map");
        mainMenuAnimator.SetBool("slideIn", false);
        mainMenuAnimator.SetBool("slideOut", true);
    }
    public void MoveToMainMenu(){
        Debug.Log("clicked play button, will now move to main menu");
        mainMenuAnimator.SetBool("slideIn", true);
        mainMenuAnimator.SetBool("slideOut", false);
    }

    public void attemptToLoadLevel(string sceneName){
        gameLevel = SceneManager.LoadScene(sceneName, LoadSceneMode.Additive); //load the scene
        menuSceneStuff.SetActive(false); //disable the menu stuff, but keep them active as using these to store info and save data and etc
        playerDetails = GameObject.FindGameObjectWithTag("Player").GetComponent<saveDetails>();
    }

    public void attemptToUnloadLevel(){
        saveDetails = playerDetails; //grab player details (coin count, health, etc)

        UnloadSceneAsync(gameLevel); //pseudo, yeah
    }
}
#

Unity's giving me the error Assets\Scripts\mainMenu\mainMenuManager.cs(42,21): error CS0029: Cannot implicitly convert type 'void' to 'UnityEngine.SceneManagement.Scene'so i'm not sure if it's me being stupid haha

slow coral
tulip lichen
#

oh? Thanks! I'll give it a shot now, thanks a million!!

#

aah, that's magic, thank you!!!! that'd been beatin my ass for hours!!!