Jump to content

Detecting and modifying the RDController Instance


Recommended Posts

Hi, I've been trying to modify the UI for the R&D screen (resizing the grid) but I'm having trouble using RDController, which I believe is what controls the screen. It seems like whenever I try to use it, it's not instantiated.

Since R&D is part of SpaceCentre, I've tried with both of these game events:

GameEvents.onGUIRnDComplexSpawn.Add(researchControl);
GameEvents.onShowUI.Add(researchCanvas);

void researchCanvas()
        {
            Debug.Log("researchCanvas " + Time.realtimeSinceStartup);
            if (RDController.Instance != null)
            {
                Debug.Log("ShowUI RDController " + Time.realtimeSinceStartup);
            }
        }
void researchControl()
        {
            Debug.Log("resizeCanvas " + Time.realtimeSinceStartup);
			if (RDController.Instance != null)
            {
                Debug.Log("RnDComplexSpawn RDController " + Time.realtimeSinceStartup);
            }
			
// This stuff works but I want RDController
            Debug.Log("Add 100 Science " + Time.realtimeSinceStartup);
            ResearchAndDevelopment.Instance.SetScience(100, TransactionReasons.None);
            Debug.Log(ResearchAndDevelopment.Instance.Science);

            Debug.Log("Scale " + UIMasterController.Instance.uiScale);
        }

Looking at the console, RnDComplexSpawn runs before I get the message [UIMasterController]:ShowUI, so that's why I tried checking for onShowUI, but that still runs after ComplexSpawn and before the UIMasterController message. If I try using RDController in either of them, I get a nullReferenceException.

Edit: Actually, I can see researchCanvas() running with an instanced RDController, but only when I exit the R&D building. Perhaps I have to wait for something else?

I can use ResearchAndDevelopment, but that only has operations for the actual science and experiments.

I can also reach UIMasterController, but can't see any way to use it to detect RDController.

Edited by IC-Adel
Link to comment
Share on other sites

Thanks, that worked.

It seems the size is controlled by RDController.Instance.gridArea.gridBackground.sizeDelta.

Although I'm having trouble with the zoom, as it snaps to the center of the older sized grid, I guess the gridArea.scrollRect needs to be resized, too, or maybe it has something to do with gridArea CalculateSnapBounds(), CenterOfGrid() or Snap().  Setting the max and min zoom to 1 doesn't solve it, either, as the snap still gets called for any zoom input.

Guess I'll have to do some more digging.

 

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...