Jump to content

Would like to use stock icons, how?


Recommended Posts

I'm writing a mod which (among other things) changes the vessel type in a dialog, similar to the way you change the vessel name/type while in flight.

I'd like to use the same icons (I think they are the same as in the mapview), but haven't yet found a way to do so.

Does anyone have any ideas how to do that?

 

Thanks in advance

 

LGG

Link to comment
Share on other sites

The vessel type icons? The texture atlas can be found in MapView.OrbitIconsMap. Though you'll need to verify that the texture has actually been loaded before doing anything with it.

The other problem here is that all of the textures are found on a single, unreadable atlas. You can pretty easily draw textures from an atlas, using GUI.DrawTextureWithTexCoords, but if you want to do anything that requires the individual textures (like make them the background for a button) it's a bit more of a pain.

CapCom does this with textures from the Mission Control Center atlas; this is something similar, and will give you a texture that you can read and use to make smaller, individual textures out of.

		Texture original = MapView.OrbitIconsMap;
		if (original == null)
		{
			return;
		}
		Texture2D newTex = new Texture2D(original.width, original.height);
		var rt = RenderTexture.GetTemporary(original.width, original.height, , RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB, 1);
		Graphics.Blit(original, rt);
		RenderTexture.active = rt;
		newTex.ReadPixels(new Rect(, , original.width, original.height), , );
		RenderTexture.active = null;
		RenderTexture.ReleaseTemporary(rt);
		rt = null;
		original = null;
		newTex.Apply();

 

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