Jump to content

GUI Transparency


Recommended Posts

The only way I've been able to do this is by simply replacing the Unity window background texture with something that has lower transparency. Most of the Unity default skin textures are very simple and you can create something to replicate it fairly easily (the Unity skin set is available to download on the Unity store I think, if you want to have it for reference).

Then you have to load these textures and create new GUIstyles using your new textures as a background.

There's probably some really simple way that I'm missing though...

Link to comment
Share on other sites

You can edit the texture directly (well, a copy of it). I do this in ScienceAlert (CreateReadable):

            Texture2D tex = skin.window.normal.background.CreateReadable();
windowOpacity = value;

var pixels = tex.GetPixels32();

for (int i = 0; i < pixels.Length; ++i)
pixels[i].a = (byte)(Mathf.Clamp(windowOpacity, 0, 255));

tex.SetPixels32(pixels); tex.Apply();

skin.window.onActive.background =
skin.window.onFocused.background =
skin.window.onNormal.background =
skin.window.onHover.background =
skin.window.active.background =
skin.window.focused.background =
skin.window.hover.background =
skin.window.normal.background = tex;

As DMagic suggested, editing the default skin is a bad plan. Clone it and edit that one instead.

Link to comment
Share on other sites

  • 3 weeks later...

Is it possible to build a whole new GUISkin using Unity and then use that skin in KSP? I mean I can create one in Unity easy enough but I have no idea how I wold bundle the skin and images up and then load them in KSP, if it is even doable.

Shame KSP didn't update to Unity 4.6 - and thus have the new better UI system - with KSP 0.90. Then again I certainly can't blame them for wanting to keep their engine version stable.

Link to comment
Share on other sites

Yes it's doable but you have to write it all in code. See an example in MJ https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/GuiUtils.cs#L269

4.6 was released late November, a bit to late to be used. We will most likely have it for the next release, unless 5 is out by then but I doubt that

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