Jump to content

Unity/mono question


Recommended Posts

I downloaded the Unity package with mono included. Imported the parttool 0.20 stuff, created a simple model in blender, got it loading to KSP. Fine, time to add code thinks I but when I followed the wiki template it has this:

public class Testmod : PartModule

I tell it to compile it with a simple print just to get a sample dll and make sure everything is working but I get "namespace 'PartModule' could not be found". Obviously there's a tie in to a library missing but where? Nothing I read or found says anything about 'put the KSP libs here'. Or is it a reference problem?

Link to comment
Share on other sites

You need to add UnityEngine.dll and Assembly-CSharp.dll to your references.

Visual Studio: http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.80).aspx

MonoDevelop: http://stackoverflow.com/questions/6438122/how-can-i-add-a-reference-in-monodevelop

And then you can use:

using KSP;
using UnityEngine;

Or other namespaces contained in those assemblies.

Assemblies are found in (use the correct path in your system):

C:\Program Files (x86)\Steam\steamapps\common\KSP Development\KSP_Data\Managed

Link to comment
Share on other sites

Did you add references to UnityEngine.dll and Assembly-CSharp.dll

3. Click Project > Edit References and follow the steps below:

Click the .NET Assembly tab and use the navigation menu on the left to browse to your KSP installation folder.

Navigate to (<KSP>\KSP_Data\Managed) and select both Assembly-CSharp.dll and UnityEngine.dll.

Adding References

Press Add then Ok, they should now be visible under the "References" directory of your solution.

Link to comment
Share on other sites

Ok, thanks for the replies. It now says it 'build successful' but I have no idea where or if it's writing a dll file. I can't find anything :-/

PartTools in Unity writes me the new part.mu and texture straight to the KSP area and I added the script component but it's not writing anything I can see. It's also not spitting any error messages which is a plus.

Link to comment
Share on other sites

I've just finished searching my drives for the name of the dll it should be producing but there's nothing anywhere. Is there some switch to tell mono to actually produce a file? Or to tell it where to put such objects?

Link to comment
Share on other sites

And then you can use:

using KSP;
using UnityEngine;

The first line isn't doing anything, KSP is an empty namespace. Most of the KSP classes are contained in the global namespace so you'd generally only use 'using UnityEngine'.

I've just finished searching my drives for the name of the dll it should be producing but there's nothing anywhere. Is there some switch to tell mono to actually produce a file? Or to tell it where to put such objects?

If you're using the mono compiler (which is command line) then you'll need to give it an explicit place to put the output along with the other arguments. It sounds like you may actually be using MonoDevelop instead. If that's the case then you can right click on the project (not the solution), choose options and set the output location and assembly (dll) name in there.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...