@@ -49,6 +49,22 @@ public virtual void InitializeScreen(GameObject partialScreen)
4949
5050 public PixelText secondaryInfoDisplayer ;
5151
52+ public AscensionMenuScreenTransition transitionController ;
53+
54+ private static void CleanupGameObject ( GameObject obj , AscensionMenuScreenTransition transition , bool destroy = true )
55+ {
56+ MainInputInteractable intact = obj . GetComponent < MainInputInteractable > ( ) ;
57+ if ( intact != null )
58+ transition . screenInteractables . Remove ( intact ) ;
59+ transition . onEnableRevealedObjects . Remove ( obj ) ;
60+
61+ foreach ( Transform child in obj . transform )
62+ CleanupGameObject ( child . gameObject , transition , destroy : false ) ;
63+
64+ if ( destroy )
65+ GameObject . Destroy ( obj ) ;
66+ }
67+
5268 public static AscensionRunSetupScreenBase BuildScreen ( Type screenType , AscensionMenuScreens . Screen previousScreen , AscensionMenuScreens . Screen nextScreen )
5369 {
5470 // Create the new screen
@@ -71,6 +87,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
7187 controller . screenTitle = textHeader . GetComponent < PixelText > ( ) ;
7288 controller . screenTitle . SetText ( Localization . ToUpper ( Localization . Translate ( controller . headerText ) ) ) ;
7389
90+ controller . transitionController = screenObject . GetComponent < AscensionMenuScreenTransition > ( ) ;
91+
7492 // Check to see if we need the card information displayer
7593 GameObject footer = screenObject . transform . Find ( "Footer" ) . gameObject ;
7694 footer . SetActive ( true ) ;
@@ -99,8 +117,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
99117 {
100118 InscryptionAPIPlugin . Logger . LogDebug ( $ "Destroying unwanted card information displayer") ;
101119 // Destroy the card text displayer and footer low line
102- GameObject . Destroy ( cardTextDisplayer ) ;
103- GameObject . Destroy ( footerLowline ) ;
120+ CleanupGameObject ( cardTextDisplayer , controller . transitionController ) ;
121+ CleanupGameObject ( footerLowline , controller . transitionController ) ;
104122
105123 InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating new information displayer") ;
106124 GameObject newInfoDisplayer = GameObject . Instantiate ( textHeader ) ;
@@ -122,10 +140,6 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
122140 // Sort out the unlocks block
123141 InscryptionAPIPlugin . Logger . LogDebug ( $ "Handling card panel") ;
124142 controller . cardPanel = screenObject . transform . Find ( "Unlocks" ) . gameObject ;
125- if ( controller . showCardDisplayer )
126- controller . cardPanel . transform . localPosition = new Vector3 ( 0f , 0.2f , 0f ) ;
127- else
128- GameObject . Destroy ( controller . cardPanel ) ;
129143
130144 // Clone the challenge information from a challenge screen
131145 InscryptionAPIPlugin . Logger . LogDebug ( $ "Creating challenge text header") ;
@@ -174,6 +188,8 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
174188 controller . rightButton = screenObject . transform . Find ( "Unlocks/ScreenAnchor/PageRightButton" ) . gameObject . GetComponent < MainInputInteractable > ( ) ;
175189 if ( controller . showCardPanel )
176190 {
191+ controller . cardPanel . transform . localPosition = new Vector3 ( 0f , 0.2f , 0f ) ;
192+
177193 InscryptionAPIPlugin . Logger . LogDebug ( $ "Reassigning left/right scroll buttons") ;
178194 controller . leftButton . CursorSelectStarted = controller . LeftButtonClicked ;
179195 controller . rightButton . CursorSelectStarted = controller . RightButtonClicked ;
@@ -210,14 +226,15 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
210226
211227 Transform lockTexture = card . gameObject . transform . Find ( "Locked" ) ;
212228 if ( lockTexture != null )
213- GameObject . Destroy ( lockTexture . gameObject ) ;
229+ CleanupGameObject ( lockTexture . gameObject , controller . transitionController ) ;
214230 }
215231 }
216232 else
217233 {
218234 InscryptionAPIPlugin . Logger . LogDebug ( $ "Destroying scroll buttons") ;
219- GameObject . Destroy ( controller . leftButton . gameObject ) ;
220- GameObject . Destroy ( controller . rightButton . gameObject ) ;
235+ CleanupGameObject ( controller . cardPanel , controller . transitionController ) ;
236+ CleanupGameObject ( controller . leftButton . gameObject , controller . transitionController ) ;
237+ CleanupGameObject ( controller . rightButton . gameObject , controller . transitionController ) ;
221238
222239 controller . leftButton = null ;
223240 controller . rightButton = null ;
@@ -234,7 +251,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
234251 InscryptionAPIPlugin . Logger . LogDebug ( $ "Adding continue button") ;
235252 GameObject continuePrefab = Resources . Load < GameObject > ( "prefabs/ui/ascension/ascensionmenucontinuebutton" ) ;
236253 GameObject continueButton = GameObject . Instantiate ( continuePrefab , screenObject . transform ) ;
237- continueButton . transform . localPosition = new Vector3 ( 2.15f , 1.13f , 0f ) ;
254+ // continueButton.transform.localPosition = new Vector3(2.15f, 1.13f, 0f);
238255
239256 controller . continueButton = continueButton . GetComponent < AscensionMenuInteractable > ( ) ;
240257
@@ -249,7 +266,7 @@ public static AscensionRunSetupScreenBase BuildScreen(Type screenType, Ascension
249266
250267 // Let the base class do its magic
251268 InscryptionAPIPlugin . Logger . LogDebug ( $ "Calling screen implementation to finish creating screen UI elements") ;
252- controller . InitializeScreen ( screenObject ) ;
269+ controller . InitializeScreen ( screenObject ) ;
253270
254271 // And we're done
255272 InscryptionAPIPlugin . Logger . LogDebug ( $ "Done building screen") ;
@@ -423,6 +440,15 @@ public void DisplayChallengeInfo(string message, int points, bool immediate=fals
423440 challengeHeaderDisplay . UpdateText ( ) ;
424441 }
425442
443+ public override void OnEnable ( )
444+ {
445+ // Set all the viewport camera stuff
446+ foreach ( var vrp in this . gameObject . GetComponentsInChildren < ViewportRelativePosition > ( ) )
447+ vrp . viewportCam = Camera . main ;
448+
449+ base . OnEnable ( ) ;
450+ }
451+
426452 public void DisplayChallengeInfo ( AscensionChallenge challenge , bool immediate = false )
427453 {
428454 AscensionChallengeInfo info = AscensionChallengesUtil . GetInfo ( challenge ) ;
0 commit comments