- Home /
Error when extending IKVM class in C# script
Background:
have a complex library in Java which uses dynamic class loaders and security managers, so it would be hard for me to completely rewrite in C#. Instead, I used IKVM to convert the Java .jar files into managed C# .dlls. I Googled for "unity ikvm" and I see that other people have been able to use IKVM dlls in Unity just by putting them in their assets folder:
http://answers.unity3d.com/questions/15308/can-i-access-java-code-from-unity.html
http://forum.unity3d.com/threads/building-project-with-ikvm-dlls-inside.101097
I tried these methods and the worked for me - with one problem.
I can access Java classes with no problem in a C# script like this:
java.lang.Object a = new SomeJavaClassThatHasBeenCovertedByIKVM();
I can not extend Java classes.
For example, I have a class like this in Java:
public abstract class Internals {
public abstract int getWeaponHealth(Weapon weapon);
// ...
}
I converted this into a dll using IKVM, and in Unity tried tried to make a script that implements it:
public class InternalsImpl : Internals {
public override int getWeaponHealth(Weapon weapon) {
return 0;
}
}
The code compiles, but when I try and play the game, Unity Editor seems to mess up. None of the images or the GUI of the Inspector is shown correctly, and I get the following errors:
KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.String,UnityEditor.BaseHierarchySort].get_Item (System.String key) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
ArgumentException: Getting control 0's position in a group with only 0 controls when doing Repaint Aborting
Question:
ow do I stop these errors. They won't go away unity I delete the InternalsImpl.cs script. Basically, how do I extend a IKVM class without all these errors.
(Before you ask, yes, the library must be in Java.)
More:
mages of what's happening:
Your answer
Follow this Question
Related Questions
Script Editors for Unity 3 Answers
Initialising List array for use in a custom Editor 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
cannot change variables on scriptableobject asset in editor 1 Answer