There are very clear issues with your script as in the error mentioned:
"Cannot implicitly convert type string to bool"
And this error has been generated by the "if" statement as it needed bool not a string, to fix it just remove the double quotes like this:
if (Score == 45)
also the same error has been casued by:
const int ScorePrefix = "Score:";
so you can remove this variable as it not used in this script or you can assign an int value to it. int is basically a number with no decimal point for example 1,2,10,489 etc. To read more about C# data types please visit here. or Here.
const int ScorePrefix = 10; //or any value which is int.*
Error # 2:
"The name 'Rust_Room' does not exist in the current context"
this is generated by this:
SceneManager.LoadScene(SceneManager.GetSceneByName(Rust_Room)().buildIndex
+ 1);
as you can see you are passing 'Rust_Room' is a 'type' while it needs name of the scene which is string.
So jut do it like this and it resolve the issue:
SceneManager.LoadScene(SceneManager.GetSceneByName("Rust_Room")().buildIndex
+ 1);
So the final script will be:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
public class Example
{
HUD hud;
int points;
const int ScorePrefix = 10; //or any value which is int.
int score;
public void LoadLevel()
{
if (Score == 45)
{
// load the nextlevel
SceneManager.LoadScene(SceneManager.GetSceneByName("Rust_Room")().buildIndex + 1);
}
}
}
By the way i will handle this situation using build index instead of name here is how i will do it:
using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
public class Example
{
HUD hud;
int points;
const int ScorePrefix = 10; //or any value which is int.
int score;
public void LoadLevel()
{
if (Score==45)
{
int currentScene = SceneManager.GetActiveScene().buildIndex + 1;
SceneManager.LoadScene(currentScene);
}
}
}
In this code i first get current scene index and then increment by 1 to get next scene index and finally loading scene with incremented index.
I hope this will help...
editfeature, which can be seen at the bottom of your question, instead of creating a new question. \$\endgroup\$