Jump to content

Doesn't KSP.IO support Binary Data?


Recommended Posts

Just questioning conventions; but if KSP.IO can be used to read Binary Data, what is the point of using UnityEngine.WWW?

http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.LoadImage.html

I mean, they even have an interface for it!

And yeah... Byte[] KSP.IO.File.ReadAllBytes(String filename, Vessel flight)

Edited by Fel
Link to comment
Share on other sites

Other than having to parse in as WWW, then output into the correct format (which can be done before packaging)

WWW img = new WWW(string.Format("file://{0}/HrmHaystack/images/{1}", KSPUtil.ApplicationRootPath.Replace("\\", "/"), filename));
Texture2D temp = new Texture2D(32, 32, TextureFormat.ARGB32, false);
img.LoadImageIntoTexture(temp);
KSP.IO.File.WriteAllBytes<HSBehaviour>(temp.EncodeToPNG(), filename, null);

I encounter no issues with doing

targ.LoadImage(KSP.IO.File.ReadAllBytes<HSBehaviour>(filename, null));

*Using haystack because I am lazy and wanted a simple example to test on

Link to comment
Share on other sites

surely using WWW is just bad practice? the potential overhead and security implications etc... best just to avoid altogether.

KSP.IO is restricted to the PluginData directory so while it's great for storing and loading your own stuff if you want to share data between plugins or something else that requires access to a different part of the KSP directory it's of no use.

It should definitely be the primary choice though.

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