Jump to content

Advanced part highlighting.


taniwha

Recommended Posts

el-stakes.jpg

Ever thought your part highlighting needed a little more oomf? Ever wanted to use 0.90's new highlighting? Well, want no more, it is actually quite easy:

(excerpted from Extraplantary Launchpads' survey stake code)


using HighlightingSystem;
...
public void Highlight (bool on)
{
if (on) {
if (highlighter == null) {
var color = StakeColors[use];
var model = part.FindModelTransform("model");
highlighter = model.gameObject.AddComponent<Highlighter>();
highlighter.ConstantOn (color);
part.SetHighlightColor (color);
part.SetHighlight (true, false);
}
} else {
if (highlighter != null) {
part.SetHighlightDefault ();
DestroyImmediate (highlighter);
highlighter = null;
}
}
}

The HighlightingSystem is in Assembly-CSharp-firstpass.

A big gotcha is you are allowed only one highlighter component on a model: KSP will complain and shutdown all the highlighters. However, this means only that you need to keep track of whether you have already added one, and that it may cause some minor trouble when KSP wants to highlight parts.

It seems there are a few modes to the highlighter (flashing etc), but I haven't explored them.

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