- Home /
How would I make this work?
So I'm new to Unity and trying to make two scenes have a button that loads the same save file, the below code doesn't work but i need help in making it function in that way. How can i make it so that directoryPath could be different depending on what scene it is in?
string directoryPath = WorldController.Instance.FileSaveBasePath() || GameController.Instance.FileSaveBasePath();
Thanks guys
Ben
Title is not descriptive.
Code isn't in code snippet.
Even though, we wouldn't be able to answer You since "FileSaveBasePath" hides probably tons of code itself. Your question is simmilar to: "$$anonymous$$y game won't play even if I wrote: Game newGame = GameController.Play();"
Next thing, You first ask, that different scenes should load "The same save file", and later asks for "directoryPath different depending on scene". Different path probably leads to different save file.
Hi Drakonno Apologies for the ambiguity, the save file is in a single location, but usually requires a script called WorldController to access, WorldController is only available during the gameplay scene. Essentially I want to load save files from the mainmenu scene.
I would like to help you, but I really do not understand what you are trying to do with this Script. Does it throw any errors?
Hi SirZok when I try to implement this code it tells me that "operator '||' cannot be applied to operands of type 'string' and 'string'. So normally the overall idea is that the script loads a save game based on directoryPath but that can only be accessed by WorldController while in the gameplay scene, I am trying to access it while in the main menu scene and use GameController ins$$anonymous$$d of WorldController and want directoryPath to change depending on what scene it is in.
Answer by bobisgod234 · Sep 07, 2017 at 04:31 AM
Something like this?
string directoryPath;
if (inGameplayScene)
directoryPath = WorldController.Instance.FileSaveBasePath();
else
directoryPath = GameController.Instance.FileSaveBasePath();
Your answer