Jump to content

UI Creation


Recommended Posts

Hello all,

Just a quick question : is there a way to create our UI with unity (I mean forms, button, stuff like that) or do you have to code it completely (which is a pain since you have to test each new version by launching the game for each simple modification) ?

Is there something dealing with this somewhere ? I searched but no luck here...

Edited by Yzangard
Link to comment
Share on other sites

You need asset bundle to do that, and it requires unity pro.

Thank you for your reply,

let's say I have it, how to get this asset ?

- - - Updated - - -

This is my main problem so far, ui coding is a very special challenge...

Link to comment
Share on other sites

This is my main problem so far, ui coding is a very special challenge...

That's one way of putting it...

The only real advice I have is using GUILayout over GUI unless you need to control placement in some way it won't allow, and to break it down into functions wherever possible (particularly anything that's repeated more than once like a label + textbox placed horizontally. I don't know how much frustration that particular change saved me, but it's a lot).

Edited by Crzyrndm
Link to comment
Share on other sites

  • 3 months later...

I have the exact same problem here, that every little change in the UI requires me to recompile and launch the game. I think I found a nice approach to that but was not able to make it work. Maybe someone here knows how to do it.

I created a new Unity Project with a new C# file in the Asset Folder. I decorated the class in there with the [ExecuteInEditMode] flag and created the OnGUI method. With this approach I can now see the UI in Unity when I click the play button in the scene Screen. The problem I have is, that I did not found a way to import the HighLogic class from KSP to this empty project, to do the usual GUI.skin = HighLogic.Skin in the beginning of the OnGUI method. I tried to copy the Assembly-CSharp from KSP_Data to the Assets/Plugin/X86 folder, but this did not work. When I now hit the play button I can see Errors in the console, that tell me, that no compiler was found for the assembly. Does someone know, how I can tell Unity, that this assembly should not be compiled, but only be loaded?

When this works I could create the basic layout including colors, margins, borders, padding from Unity with hard coded placeholder texts. After that I would simply copy all the code to my plugin and replace the placeholder with live data from my PartModule.

Link to comment
Share on other sites

You have to use the same version of unity as KSP 1.0.2 uses, which I think you can find out by looking at the properties of the UnityEngine.dll.

I also think you have to put it in Assets/Plugins/x86/Assembly-CSharp.dll. Caps and spelling matter. Not sure if you were just paraphrasing, but the spelling/caps does matter.

It's probably mostly the unity version, unless you have the correct unity version, in which case I'm clueless. :P

Link to comment
Share on other sites

I did not try that but even if you make it work I doubt it will help for your need. A lot of the game object have their default values deserialized from the game asset at loading.

This is the case with HighLogic.Skin.

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...