Jump to content

[1.2.0] Toolbar 1.7.13 - Common API for draggable/resizable buttons toolbar


blizzy78

Recommended Posts

Hi Blizzy78

I'm working on two different plugins - both are near release without toolbar.

Now I tried to add toolbar but no matter what I do, I get this error..

CA0058 [B]Error Running Code Analysis[/B]
CA0058 : The referenced assembly 'aaa_Toolbar, Version=1.0.0.0, Culture=neutral' could not be found. This assembly is required for analysis and was referenced by: C:\Users\[...]Reloaded.dll.
[B][Errors and Warnings][/B] - (Global)

To clarify: It happens in all cases as soon as IButton is used. It happens in both projects independently

I tried using-dependency, only referencing and toolbarWrapper..

With depency and/or reference I get the above on the failed build - with the wrapper it builds, but the above is printed in the KSP.log

I've tried to reference different versions of the toolbar DLL - no change..

Also Google showed me clearly - I'm the only one with this problem! lol

So as a C# noob with limited debug abilities, I am at a loss..

Would you consider pointing me in a direction that helps? If you have one..

Edit: Additional info..

I am using your example codes from github..

default button.. (including the onDestroy stuff)

However - I've tried to copy/paste implementations from other plugins with the same result..

So I doubt it's a code problem on my end.. - but who knows..

Link to comment
Share on other sites

will try right away..

LOL it worked..

Man that took me the whole day.. :-)

One never stops learning.. - I've started with c# yesterday.. - so.. as noobs can be..

Thank's - I owe you one..

Link to comment
Share on other sites

Hello,

I am trying to add support for the toolbar to my plugin as instructed under "Use the Toolbar Plugin wrapper to provide optional Toolbar Plugin support".

However if I have the ToolbarWrapper.cs in my project (don't even need to try to use the toolbar), my plugin won't load and I get this error in KSP.log:


[ERR 14:26:15.363] AssemblyLoader: Exception loading 'MyPlugin': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at AssemblyLoader.LoadAssemblies () [0x00000] in <filename unknown>:0

Additional information about this exception:

System.TypeLoadException: Could not load type 'MyPlugin.ToolbarTypes' from assembly 'MyPlugin, Version=1.0.5240.24185, Culture=neutral, PublicKeyToken=null'.

System.TypeLoadException: Could not load type '<>c__DisplayClass3' from assembly 'MyPlugin, Version=1.0.5240.24185, Culture=neutral, PublicKeyToken=null'.

Any idea what could cause this?

Link to comment
Share on other sites

Hey I really love your toolbar but after I got the 23.5 ARM update it won't work alongside MechJeb. MJ is updated to the most recent 23.5 path (2.2.1) I can place the part but the MJ UI will not show up. I removed all mods and tried each one after the other with MJ and this was the only one that caused the issue. I'm not all that great at math so the MJ is almost essential for me to get past the learning curve, but it has become a big deal to me that I can't use the toolbar as well. I must sort this out! I will post there as well, I'm just reaching out seeing if someone more familiar with modding has dealt with this?

Link to comment
Share on other sites

  • 1 month later...

There seem to be some issues related to IDrawable and the latest update. I have users reporting incorrect toolbar positions and in some cases the GUI becomes nearly non-interactive if the toolbar is positioned such that the auto positioning code fails (typically when at the top of the screen, positioned between the altimeter and sides of the screen).

Here is an example:

a9eb1f5c4c.jpgd50f4e2a3d.jpg

The exact position will alternate on every right-click-open and in both cases something strange is going on because clicking buttons does nothing or (if the positioning is as the second picture) the drawable will suddenly snap to the wrong place. I want to say that the actual location checked for mouse input is lagging behind the displayed position, since you can sometimes manage to click buttons if you twitch your mouse fast enough to the right spot.

1.7.1 works fine though

Link to comment
Share on other sites

  • 2 weeks later...

Hopefully this is the right place to post this, but I'm running into odd behaviour trying to implement the ToolbarWrapper into my plugin.

I'm building my plugin to interface with Infernal Robotics (which also uses the Toolbar Wrapper). Mirroring the implementation in the TestButtons.cs into my code (without the direct dependency on Toolbar, instead using the wrapper and testing for the existence of the toolbar in much the same way sirkut does here)

I instantiated the IButton for my plugin, and added the appropriate code to my Awake() function to tie my plugin into the toolbar. All seemed to go well, until I compiled and launched the game.

Once in-game, the plugin no longer loaded, claiming an object wasn't being assigned. (Or being assigned to a null reference). Removing all references to the toolbar from my code resolved the problem.

For context, here's the relevant lines of code in the plugin:

        IButton AutoGimbalButton;
void Awake()
{
Debug.Log("[AutoGimbalManager] awake");
guiEnabled = false;
var scene = HighLogic.LoadedScene;
if (scene == GameScenes.FLIGHT)
{//Need to check at some point if we need to reload groups from vessel
}
if (ToolbarManager.ToolbarAvailable)
{
AutoGimbalButton = ToolbarManager.Instance.add("Felger", "AutoGimbalButton");
AutoGimbalButton.TexturePath = "AutoGimbal/Textures/icon_button";
AutoGimbalButton.ToolTip = "AutoGimbal Manager";
AutoGimbalButton.Visibility = new GameScenesVisibility(GameScenes.EDITOR, GameScenes.SPH, GameScenes.FLIGHT);
AutoGimbalButton.OnClick += (e) => guiEnabled = !guiEnabled;
AutoGimbalButton.Visible = true;
}
else
{
guiEnabled = true;
}
}
void OnGUI()
{
//Define the default window position, if no changes have been made:
if(windowPosn.x == 0 && windowPosn.y == 0)
{
windowPosn = new Rect(Screen.width - 300, 50, 10, 10);
}
var scene = HighLogic.LoadedScene;
if (scene == GameScenes.FLIGHT)
{
//Creates a new box, specifying the position to follow the defined position above.
if (guiEnabled)
{
windowPosn = GUILayout.Window(0, windowPosn, WindowMaker, "AutoGimbal");
}
}
}
void OnDestroy()
{
if (ToolbarManager.ToolbarAvailable)
{
AutoGimbalButton.Destroy();
}
}

As far as I can tell from following your and sirkut's code through, I shouldn't expect a problem, using the wrapper. However, in-game Infernal Robotics shows up on the toolbar, and my plugin crashes when it attempts to load.

Removing the toolbar from my plugin, it loads just fine.

Link to comment
Share on other sites

The actual log message, going back and looking for it is:

[EXC 13:25:57.696] NullReferenceException: Object reference not set to an instance of an object

In the output_log.txt:

AssemblyLoader: Exception loading 'AutoGimbal': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)

at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0

at AssemblyLoader.LoadAssemblies () [0x00000] in <filename unknown>:0

Additional information about this exception:

System.TypeLoadException: Could not load type 'AutoGimbal.ToolbarTypes' from assembly 'AutoGimbal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

System.TypeLoadException: Could not load type '<>c__DisplayClass3' from assembly 'AutoGimbal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

(Filename: C:/BuildAgent/work/d3d49558e4d408f4/artifacts/StandalonePlayerGenerated/UnityEngineDebug.cpp Line: 53)

I'm pretty inexperienced with object-oriented programming, so I'm not really sure what to make of all this.

Link to comment
Share on other sites

edit: Nevermind, PEBKAC error.

I had the state of my window state boolean backwards so when I was trying to open the window, I was closing it.

Off to actually make some progress now.

D.

Edited by Diazo
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...