Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Can't access string in another script

$
0
0
I'm trying to let the user choose which seed the game will load as their level, but I can't access the variable for some reason. What am I doing wrong?? public class SeedNumberScript : MonoBehaviour { public string stringToEdit = "Enter A Seed Number"; void OnGUI() { stringToEdit = GUI.TextField(new Rect(10, 10, 200, 20), stringToEdit, 25); if(GUI.Button(new Rect(10,400,1200,100), "Enter The World")) { Application.LoadLevel("NewIdeas&Tests"); } } } Second Script void Start () { SeedNumberScript.stringToEdit == Random.seed; for(int z = 0; z < GameHeight; z++) { for(int x = 0 ; x < GameWidth; x++) { float rnd = Random.value; if(rnd <0.25f) { Instantiate(TileOne, new Vector3(x,0,z), Quaternion.identity); } else if(rnd <0.5f) { Instantiate(TileTwo, new Vector3(x,0,z), Quaternion.identity); } else { Instantiate(TileThree, new Vector3(x,0,z), Quaternion.identity); } } } } } I'm trying to access the String in the first scrip with the second script. I keep getting Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>