Jump to content

Changing scenes


Recommended Posts

Hi.

Is anyone has any idea how to change scene on the fly (ex: from SpaceCenter to LaunchPad) ?

I tried to load a new game with "Game.Load()", after reading an existing save with "GamePersistence.LoadGameCfg()" method. Existing save was taken in the LaunchPad with an active vessel (starting scene is 7 = FLIGHT).

The game loading works perfectly but scene remains in SpaceCenter.

I tried:

"HighLogic.LoadScene", game crash.

"HighLogic.bufferedLoad", nothing happens.

Thank you for answers.

Link to comment
Share on other sites

So, thanks to QuickGo mode code, i've found this:

static IEnumerator loadScene(GameScenes scenes , EditorFacility facility = EditorFacility.None) {
	yield return new WaitForEndOfFrame();
	HighLogic.LoadScene(scenes);
}

It seems working cause loading screen appears, but scene returns to SpaceCenter.

Log says there's no vessel in AssemblyShip, so i've tried to focus on landed vessel with this:

DebugFunctions.SendLog("Searching vessels");
foreach (Vessel vessel in FlightGlobals.Vessels ) {
	DebugFunctions.SendLog("Vessel found");
	if ( vessel.vesselType == VesselType.Ship ) {
		if ( !vessel.loaded ) {
			DebugFunctions.SendLog("Vessel not loaded, loading..");
			vessel.Load();
		}
		if ( vessel.LandedInKSC ) {
			DebugFunctions.SendLog("Vessel landed");
			FlightGlobals.SetActiveVessel(vessel);
		}
		else {
			DebugFunctions.SendLog("Vessel not landed");
 		}
	}
	else
		DebugFunctions.SendLog("Vessel not a ship");
	}
	scenario.StartCoroutine(loadScene(GameScenes.FLIGHT));

Her's log:

Quote

[LOG 18:06:01.465]  Searching vessels.
[LOG 18:06:01.465]  Vessel found.
[LOG 18:06:01.465]  Vessel not a ship.
[LOG 18:06:01.466]  Vessel found.
[LOG 18:06:01.466]  Vessel not loaded, loading...
[LOG 18:06:01.486] [Untitled Space Craft]: landed - waiting for ground contact to resume physics...
[LOG 18:06:01.496] Vessel landed.
[EXC 18:06:01.500] NullReferenceException: Object reference not set to an instance of an object
    Vessel.AttachPatchedConicsSolver ()
    CustomTutorialFramework.LoadGame (CustomTutorialCollection.CustomTutorial customTutorial)
    CustomTutorialFramework.LaunchTutorial (CustomTutorialCollection.CustomTutorial customTutorial)
    CustomTutorialCollection.TutorialMenuWindow.DetailsFill (Int32 windowID)
    UnityEngine.GUILayout+LayoutedWindow.DoWindow (Int32 windowID)
    UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style)

I can't fond out how to solve this. Maybe it's not a solution to load LaunchPad scene...

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...