Jump to content

Request: Font Outline mod to make text more readable


Recommended Posts

I've found reading nodes incredibly hard, if not impossible when using Scatterer, or other visual enhancement mods like EVE or SVE. It would help very much to have a font outline in game to add contrast between the font color and a planet's surface.

Here is an image of Kerbin using Scatterer and SVE. The font is virtually unreadable. I simply can't use Scatterer anymore because of this issue.

Spoiler

2DK7CAr.jpg

And a mock-up of what it would look like if an outline was applied to the font:

Spoiler

9jXsDbB.jpg

I looked into this for several weeks, but I am no programmer, so I can't execute this myself. Heck, I don't even know if it's possible in the Unity 5 engine. I just thought I would post a request here as a last ditch effort to work towards getting something that I think everyone would use, though no one has realized the need yet.

Thanks for reading.

Link to comment
Share on other sites

It would be nice, but I usually just rotate the map when that happens, also changing the UI size can help (some of them like 120% seem to result in very unreadable text others like 140% are very readable though you may need a mod to shrink some things like the Navball).  But if it can be done you bet I'd sign up!

Link to comment
Share on other sites

7 hours ago, Fictitious1267 said:

I looked into this for several weeks, but I am no programmer, so I can't execute this myself. Heck, I don't even know if it's possible in the Unity 5 engine. I just thought I would post a request here as a last ditch effort to work towards getting something that I think everyone would use, though no one has realized the need yet.

Thanks for reading.

Adding an outline to a Text is possible and quite easy to do. You just need to add an Outline component to the Text object. The stock one or one of those available in Unity UI extension

The "complex" part is finding the object you want to add the outline to. I guess something related to OrbitRenderer

 

Link to comment
Share on other sites

On 6/13/2016 at 6:28 PM, Fictitious1267 said:

I looked into this for several weeks, but I am no programmer, so I can't execute this myself. Heck, I don't even know if it's possible in the Unity 5 engine. I just thought I would post a request here as a last ditch effort to work towards getting something that I think everyone would use, though no one has realized the need yet.

It's actually rather straightforward. The prefab that gets used for all the mouseover-type stuff in the MapView is exposed so you can just slip in an Outline component onto the text portion of that and bam, instant text outlines. This is all the code you'd need to get a basic effect like you want:

using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace MapViewOutline
{
    
    [KSPAddon(KSPAddon.Startup.Flight, true)]
    class AddOutlineToMapViewTextInFlight : AddOutlineToMapViewText
    {
    }


    [KSPAddon(KSPAddon.Startup.TrackingStation, true)]
    class AddOutlinetoMapViewInTrackingStation : AddOutlineToMapViewText
    {
    }

    
    abstract class AddOutlineToMapViewText : MonoBehaviour
    {
        private const float HorizontalEffect = 0.8f;
        private const float VerticalEffect = 0.8f;
        private readonly Color _color = Color.black;

        private static bool _ranFlag = false;

        private void Start()
        {
            if (!_ranFlag) AddOutline();
            _ranFlag = true;
            Destroy(gameObject);
        }


        private void AddOutline()
        {
            // Search for "Caption" text. There's only one. Use version of GetComponents that searches inactive GO like this prefab
            var text = MapView.UINodePrefab.GetComponentsInChildren<Text>(true).FirstOrDefault();

            if (text == null)
            {
                Debug.LogError("Didn't find expected Text component in UINodePrefab: can't add outline");
                return;
            }

            var outline = text.gameObject.AddComponent<Outline>();
            outline.effectColor = _color;
            outline.effectDistance = new Vector2(HorizontalEffect, VerticalEffect);
            outline.useGraphicAlpha = true;
        }
    }
}

83a12fba46.png384550cce9.png

These screenshots have outlines in red rather than black because it's much easier to tell it's working in stock conditions

Edited by xEvilReeperx
Swapped KSPAddon.Startup somehow
Link to comment
Share on other sites

I submitted it as a suggestion for the stock game. However, the thread was deleted. I guess a mod is the only way.

I managed to make a build that works and looks great. I'll upload it soon.

I wanted to thank you all for the help. I'm not much of a programmer, but with all your help, I managed to make this work. Especially xEvilReeperx, you're code worked perfectly. Thanks.

Edited by Fictitious1267
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...