#KSC Toolbar Icon not appearing

1 messages · Page 1 of 1 (latest)

dapper sable
#

I tried coding my own mod, but my template doesn't even work (I'm just trying to see an option for my mod in the Appbar):

public override void OnInitialized()
    {
        ...
        // Create the window
        var myFirstWindow = Window.Create(windowOptions, myFirstWindowUxml);
        // Add a controller for the UI to the window's game object
        var myFirstWindowController = myFirstWindow.gameObject.AddComponent<MyFirstWindowController>();

        // Register Flight AppBar button
        Appbar.RegisterAppButton(
            ModName,
            ToolbarFlightButtonID,
            AssetManager.GetAsset<Texture2D>($"{ModGuid}/images/icon.png"),
            isOpen => myFirstWindowController.IsWindowOpen = isOpen
        );

        // Register OAB AppBar Button
        Appbar.RegisterOABAppButton(
            ModName,
            ToolbarOabButtonID,
            AssetManager.GetAsset<Texture2D>($"{ModGuid}/images/icon.png"),
            isOpen => myFirstWindowController.IsWindowOpen = isOpen
        );

        // Register KSC AppBar Button
        Appbar.RegisterKSCAppButton(
            ModName,
            ToolbarKscButtonID,
            AssetManager.GetAsset<Texture2D>($"{ModGuid}/images/icon.png"),
            () => myFirstWindowController.IsWindowOpen = !myFirstWindowController.IsWindowOpen
        );
    }

However it's displayed as active in the mods menu. Is there some way I can debug stuff or does someone see the issue by any chance?

hollow salmon
#

Probably the first thing to do is set up visual studio debugging if you haven't already. It'll save a ton of time troubleshooting issues.

dapper sable
#

I use Rider for development and have debugging enabled. However this is not connected to my game in any way. Do you know how I could achieve this?

hollow salmon
#

🤔 Not sure about rider.
For VS/VSCode debugging requires a unity specific plugin.

#

(general dotnet debugger won't really work)

#

But to set it up on the game end, you basically replace the exe and UnityEngine.dll with the development build versions

dapper sable
#

Yes, it should be enabled.

#

But I don't start the game from Unity. Or is that even possible?

dapper sable
weak sequoia
#

you need to convert your game to a debug build first, then Rider will recognize it as an instance of the Unity Player and let you debug it

#

you can use this guide, just with Unity version 2022.3.5 instead of 2019

#

(just the "Modifying KSP for profiling/debugging" section, the rest below is not necessary)

dapper sable
#

Thanks a lot for this awesome guide! I'll make sure to follow it.

#

Thanks a lot again, both of you. Now I can actually see my errors 🙃

[Error  :KSP2 Fuel Miner] System.IndexOutOfRangeException: Unable to find asset at path "fuelminer/fuelminer_ui/ui/myfirstwindow/myfirstwindow.uxml"
  at SpaceWarp.API.Assets.AssetManager.GetAsset[T] (System.String path) [0x0004d] in <752af44b027e46fc8eaee088be79ca82>:0 
  at FuelMiner.FuelMinerPlugin.OnInitialized () [0x0001b] in C:\Users\verox\Dokumente\KSP\FuelMiner\src\FuelMiner\FuelMinerPlugin.cs:45 
  at SpaceWarp.Patching.LoadingActions.InitializeModAction.DoAction (System.Action resolve, System.Action`1[T] reject) [0x0000d] in <752af44b027e46fc8eaee088be79ca82>:0

If the ticket is solved, should I just hit the reaction on the thread?