• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

unobtanium

Recruit
6 Badges
Apr 2, 2015
7
0
  • Cities: Skylines
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Surviving Mars
  • Stellaris: Distant Stars
Hello :)

I am working on an UI mod and learning as i go. I am using the mod ModTools by nlight to get insight of all the objects and structure.

One of the first step i have to do is searching for specific UIPanels. They are the ones who appear in the top left and show produced sliders with electricity, water, healthcare, ect.

I am searching through UIPanels with the following method/function:
Code:
var components = UnityEngine.Object.FindObjectsOfType<UIPanel>();
foreach (var c in components)
            {
                if (c.cachedName == panelName || c.name == panelName)
                    return c;
            }
return null;

Problem is: It doesnt seem to find any of the required objects e.g.:
(Library) ElectricityInfoViewPanel
(Library) FireSafetyInfoViewPanel
(Library) CrimeInfoViewPanel
ect.

Every else UIPanel object got found, only the (Library) ones dont.

While writing this i might have found the reason why: Are these UIPanels created AFTER the mod is loaded? If so, is there a way to get access to the objects or a workaround?
On second thought: This cant be, because i can find these Panels through searching for children objects (e.g. ElectricityMeter) and going up the structure with '.parent'

(I require the visibility, and position and size of these objects.)

edit: Like i said i can search the UIPanels by their children objects. However these children have to be unique. The problem in this case are Health and Crime. Both have the object with the name 'SafetyMeter' which makes it very difficult to obtain these two objects. The only way to fix this would be by checking their parents names if they are the correct UIPanel. This is probably the solution for now until i find a better way of doing it (or maybe you have an idea).

Thank your for reading this. Hopefully someone has some insight into this :p
unobtanium
 
Last edited:
I would try something like searching under the UIView instead of unity engine.

UIPanel load2 = UIView.GetAView().FindUIComponent<UIPanel>("LoadPanel(Clone)");

returns a panel, not sure if it's the one you're looking for. FindUIComponent uses the cachedname. I used dotPeek and ModTools to reverse engineer this, fwiw.
 
Thank you very much. This was the solution i was looking for.
Also thank you for mentioning dotPeek. Going to take a look at it to better understand everything. ModTools only offers limited insight but is nice to adjust variables in realtime.