Jump to content

KSPedia Creation Tutorial


DMagic

Recommended Posts

@The White Guardian Which version of Unity are you using?

As the post above yours suggests, Unity 5.4 isn't compatible with the Part Tools. Some changes were made to how Unity builds Asset Bundles which breaks the Part Tools. It's possible to create a simple script to generate the Asset Bundle, but I'm not sure if that will work correctly with KSPedia assets. It's probably best to stick with Unity 5.2 until Squad gives us new Part Tools.

Link to comment
Share on other sites

  • 1 month later...
  On 5/25/2017 at 6:46 PM, theonegalen said:

@JPLRepo, I installed the new PartTools into a new Unity Project but there's no AssetCompiler or KSPedia tools anymore. How can I make KSPedia entries?

Expand  

Yes they are in the zip. I just checked. Did you import the unity package as a custom package and ensure they are selected?

Link to comment
Share on other sites

  On 5/25/2017 at 7:23 PM, JPLRepo said:

Yes they are in the zip. I just checked. Did you import the unity package as a custom package and ensure they are selected?

Expand  

I updated Unity, and reinstalled PartTools, and now the tools show up in the editor, but the bundle isn't showing up in AssetBundles. I'm going to try to start from scratch again.

 

EDIT: Now my prefabs aren't even showing up in the KSPedia tool. Starting to get very very frustrated.

Edited by theonegalen
Link to comment
Share on other sites

  On 5/25/2017 at 7:23 PM, JPLRepo said:

Yes they are in the zip. I just checked. Did you import the unity package as a custom package and ensure they are selected?

Expand  

My Windows install of Unity 5.4.0p4 is not importing the assets properly. It seems like KSPAssetCompiler and KSPAssets are not loading.

I did a fresh install of Unity 5.4.0p4 on my OS X machine with the same result. No asset compiler.

Link to comment
Share on other sites

@JPLRepo, I uninstalled Unity completely and reinstalled 5.4.0p4, and when I import the unity package now, not only are KSPAssetCompiler and KSPAssets not loading (although they are present in the plugins folder), I am getting NRE spam in my console whenever I open the project. And now, when I install the old PartTools to a completely new Project in this perfectly fresh install of Unity, I still get the same NRE spam, and the PartTools doesn't load. Is there something really obvious that I'm missing?
 

NullReferenceException: Object reference not set to an instance of an object
UrlDir+<get_AllConfigs>d__53.MoveNext ()
UrlDir+<GetConfigs>d__55.MoveNext ()
System.Collections.Generic.List`1[UrlDir+UrlConfig].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[UrlDir+UrlConfig]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
KSPPartTools.GameDatabase.GetConfigs (System.String typeName)
KSPPartTools.PartToolsWindow.DrawSpaces ()
KSPPartTools.PartToolsWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

I hate to turn this thread into a PartTools support thread. Is there a better place we can do this?

Edited by theonegalen
Link to comment
Share on other sites

  • 1 month later...
  On 5/30/2017 at 2:43 PM, theonegalen said:

@JPLRepo, I uninstalled Unity completely and reinstalled 5.4.0p4, and when I import the unity package now, not only are KSPAssetCompiler and KSPAssets not loading (although they are present in the plugins folder), I am getting NRE spam in my console whenever I open the project. And now, when I install the old PartTools to a completely new Project in this perfectly fresh install of Unity, I still get the same NRE spam, and the PartTools doesn't load. Is there something really obvious that I'm missing?
 

NullReferenceException: Object reference not set to an instance of an object
UrlDir+<get_AllConfigs>d__53.MoveNext ()
UrlDir+<GetConfigs>d__55.MoveNext ()
System.Collections.Generic.List`1[UrlDir+UrlConfig].AddEnumerable (IEnumerable`1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128)
System.Collections.Generic.List`1[UrlDir+UrlConfig]..ctor (IEnumerable`1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65)
KSPPartTools.GameDatabase.GetConfigs (System.String typeName)
KSPPartTools.PartToolsWindow.DrawSpaces ()
KSPPartTools.PartToolsWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

I hate to turn this thread into a PartTools support thread. Is there a better place we can do this?

Expand  

 

Link to comment
Share on other sites

  • 1 month later...

@SuperNaturalCD Did you apply the changes to the prefab? The object you are editing and the prefab saved on the disk are two separate things, any changes made in the editor have to be applied to the prefab, either by dragging the object into the folder again, which will create a new prefab, or just click the "Apply" button in the top-right.

Link to comment
Share on other sites

  • 3 weeks later...

@linuxgurugamer All of this comes from Unity 5.2 and the 1.1 (?) Part Tools. 

With Unity 5.4 (the current version for KSP 1.2 and 1.3) you'll need the latest Part Tools (changes to Unity's Asset Builder methods prevent the old Part Tools from working in 5.4).

I haven't installed or tried to use the 5.4 Part Tools, but I'm not aware of any difference in how KSPedia entries are handled.

Link to comment
Share on other sites

  On 8/20/2017 at 3:47 PM, DMagic said:

any changes made in the editor have to be applied to the prefab, either by dragging the object into the folder again, which will create a new prefab, or just click the "Apply" button in the top-right.

Expand  

Every time I want to make changes I have been deleting the prefab in question, updating the Asset Compiler and KSPedia in the KSPAssets to basically rid the bundle of that prefab completely, then reassigning the new prefab into the asset bundle and then reupdating and reassigning all the categories and screens in the KSPedia tool. Its very long winded.

What and where is this Apply button you speak of?

Link to comment
Share on other sites

  On 8/20/2017 at 3:47 PM, DMagic said:

@SuperNaturalCD Did you apply the changes to the prefab? The object you are editing and the prefab saved on the disk are two separate things, any changes made in the editor have to be applied to the prefab, either by dragging the object into the folder again, which will create a new prefab, or just click the "Apply" button in the top-right.

Expand  

 

  On 9/5/2017 at 5:35 PM, Poodmund said:

Every time I want to make changes I have been deleting the prefab in question, updating the Asset Compiler and KSPedia in the KSPAssets to basically rid the bundle of that prefab completely, then reassigning the new prefab into the asset bundle and then reupdating and reassigning all the categories and screens in the KSPedia tool. Its very long winded.

What and where is this Apply button you speak of?

Expand  

FML! i've also done that hundreds of times, i'd also like to know where this apply button is lol.

Link to comment
Share on other sites

In the first image of the tutorial you can see the Apply button in the top right of the Inspector window along the right.

For the button to be there you have to drag the object down to your Project folder, then select the object again from the Hierarchy window (the thing you dragged into the folder). Then when you change something you can press the Apply button to update the prefab.

Keep in mind that this does not update any actual text changes in the final KSPedia entry. I think this is mentioned briefly in the tutorial.The Part Tools reads the actual text from an XML file in your Unity project folder (I'm not sure about the exact name or location of the file). The only way to update the XML file without going through the whole process with setting up the KSPedia pages is to manually update the text in the XML file.

Applying the changes will affect everything else: images, image size, text box size, font size, style, etc... just not the actual text. The text changes are updated in the prefab (the file stored on disk, as opposed to the object in the Hierarchy window, which is stored somewhere in the scene file), just not in the xml file.

It's possible that this is fixed in the 5.4 Part Tools.

Link to comment
Share on other sites

  • 2 months later...

Has anybody managed to get this to work with Unity 5.4.0p4 and the latest PartTools (and the work-around for loading TextMeshPro)?

I've gotten as far as creating a couple of pages following these instructions, but I can't get it to generate the final Asset Bundle.

Firstly, the Asset Compiler is showing -all- files in the project when I "View" my Bundle, not just the ones I tagged. I can manually edit the XML to remove all files except the ones I want, but the next time I "Update" the Bundle, it re-adds all the other files.

Then when I try to "Build" the Asset Bundle it indicates that it completes successfully (AssetCompiler: Finished building 1 asset bundles), but there's never an actual output file generated.

I don't know Unity well enough to trouble-shoot what could be wrong so any hints and tips (or requests for more information) welcome.

 

EDIT: Huh; ok, so creating a brand-new project, dragging-and-dropping all relevant bits from the old project (fonts, prefabs, etc) into the new project, and it works now. *scratches head*

Edited by micha
Link to comment
Share on other sites

Ok, a couple of pointers/additions which stumped me for a bit; especially setting up Unity.

When setting up your KSPedia Unity 5.4.0p4 project you have to add the following before you can get started:

  1. The correct PartTools package for Unity 5.4.0p4 - get it from this forum thread.
  2. TextMesh Pro - get it from the Asset Store within Unity. The free one will do.
  3. The patch to get TMP working (linked from the same thread as the PartTools package)
  4. The built-in fonts - "Amaranth-Bold" and "OpenSans-Regular" (You don't need to add these to your Asset Bundle).
  5. Restart Unity after doing the above!


Apart from that the OP's post is still accurate, except when adding images to your KSPedia articles.

Do NOT add "Panel -> UI -> Image". When adding images, make sure you add a "Panel -> UI -> Raw Image", then select the image file you imported into Unity for the texture. This drastically reduces filesize for your resulting KSPedia files as well as runtime resources.

Also, for larger KSPedia's, it may be useful to split it into several files. Simply create more than one asset bundle; either one per page, or one per sub-section as you see fit, then assign the various prefabs and other assets to each asset bundle. You can still use the same categories, just don't assign a prefab to the top-level category.

EDIT: The last paragraph may not be correct; it worked for 2 files, but more than that breaks the KSPedia in-game; still experimenting.

Edited by micha
Link to comment
Share on other sites

I've never actually used Unity 5.4 for KSPedia, only for regular UI and shader work. 

I'd never considered that Raw Images would be better suited for entries. The difference is that Images use sprites while Raw Images use any kind of texture, so I'm not sure why one would have a larger file size that the other, but that's good to know.

For anyone wondering about Images vs Raw Images for regular UI's, you generally shouldn't use Raw Images, since each instance generates an extra draw call. Only use them to avoid frequent Texture to Sprite conversions using the expensive Sprite.Create method (SCANsat uses Raw Images for its map textures but regular Images for all of the other UI elements). But for KSPedia draw calls don't really matter, since aren't really doing anything else at the same time.

Link to comment
Share on other sites

  On 11/18/2017 at 3:11 PM, DMagic said:

I'd never considered that Raw Images would be better suited for entries. The difference is that Images use sprites while Raw Images use any kind of texture, so I'm not sure why one would have a larger file size that the other, but that's good to know.

Expand  

Not sure either; but I found a reference about it being very expensive to create the sprites (both CPU as well as RAM) on every draw and it being better if you just want to draw a texture to use the raw images. Can't find the reference again now.
It's also possible re filesize that I forgot to uncheck the "Generate Mipmap" bit for the sprites; I can experiment more.

Another general question to the KSPedia creators: what's a good way/utility of making the stock-alike white lines at 45̈/90deg and image borders that link text to images in KSPedia entries? I've noticed a couple of mods have the same look.

Link to comment
Share on other sites

@micha Creating sprites at runtime is definitely expensive, but if done in Unity it's already taken care of by the time it's displayed in KSP.

For lines like these:

DPbx23v.png

I just do them in Photoshop with the the line tool. You can hold ctrl, or alt, or something to make them snap to 45o increments. They don't always come out perfect, if you look closely you can see the gaps between some of the segments, and it's also a pain because any time you need to move the text you have to move the lines around, too, but it works well enough for me.

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