Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AM_1 · Jun 30, 2014 at 03:04 PM · c#editorjavamanaged

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:

  • Java code (Internals.java)

  • C# code (InternalsImpl.cs)

  • How Unity looks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AM_1 · Jul 01, 2014 at 02:32 PM 0
Share

bump. Anyone have a clue to what's happening?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges