提问者:小点点

获取错误CS1955:不可调用的成员'SceneManager'不能像方法一样使用


我试图在玩家触发丢失条件时重新加载场景(Dieeng),以便创建一个各种检查点系统。这个游戏是一个FPS btw的情况下,是相关的。

以下是相关代码:

string m_SceneToLoad;

.

void Update()
    {
        if (gameIsEnding)
        {
            float timeRatio = 1 - (m_TimeLoadEndGameScene - Time.time) / endSceneLoadDelay;
            endGameFadeCanvasGroup.alpha = timeRatio;

            AudioUtility.SetMasterVolume(1 - timeRatio);

            // See if it's time to load the end scene (after the delay)
            if (Time.time >= m_TimeLoadEndGameScene)
            {
                SceneManager.LoadScene(m_SceneToLoad);
                gameIsEnding = false;
            }
        }
        else
        {
            if (m_ObjectiveManager.AreAllObjectivesCompleted())
                EndGame(true);

            // Test if player died
            if (m_Player.isDead)
                EndGame(false);
        }
    }

.

void EndGame(bool win)
    {
        // unlocks the cursor before leaving the scene, to be able to click buttons
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;

        // Remember that we need to load the appropriate end scene after a delay
        gameIsEnding = true;
        endGameFadeCanvasGroup.gameObject.SetActive(true);
        if (win)
        {
            m_SceneToLoad = winSceneName;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay + delayBeforeFadeToBlack;

            // play a sound on win
            var audioSource = gameObject.AddComponent<AudioSource>();
            audioSource.clip = victorySound;
            audioSource.playOnAwake = false;
            audioSource.outputAudioMixerGroup = AudioUtility.GetAudioGroup(AudioUtility.AudioGroups.HUDVictory);
            audioSource.PlayScheduled(AudioSettings.dspTime + delayBeforeWinMessage);

            // create a game message
            var message = Instantiate(WinGameMessagePrefab).GetComponent<DisplayMessage>();
            if (message)
            {
                message.delayBeforeShowing = delayBeforeWinMessage;
                message.GetComponent<Transform>().SetAsLastSibling();
            }
        }
        else
        {
            
            Scene scene = SceneManager().GetActiveScene;
            m_SceneToLoad = scene.name;
            m_TimeLoadEndGameScene = Time.time + endSceneLoadDelay;
        }
    }

我不明白为什么我得到的错误。请帮忙。编辑:错误出现在这一行:Scene场景=SceneManager()。GetActiveScene;


共1个答案

匿名用户

SceneManager是一种类型而不是属性<代码>场景管理器。GetActiveScene()但是它是一个静态方法。。。

应该是

var scene = SceneManager.GetActiveScene();