Jump to content

Loading question - how to stop all resources for a part from loading?


Recommended Posts

Is it sufficient to simply rename or delete the .cfg file for a part, or do I need to also rename the .mu file for that part?

Also, how can I easily get the name of the mu file from the AvailablePart class, and, if possible, how can I get a list of the texture files used by that mu file?

 

Edited by linuxgurugamer
Link to comment
Share on other sites

2 hours ago, linuxgurugamer said:

Is it sufficient to simply rename or delete the .cfg file for a part, or do I need to also rename the .mu file for that part?

Also, how can I easily get the name of the mu file from the AvailablePart class, and, if possible, how can I get a list of the texture files used by that mu file?

 

Made some progress, I figured out that the model name is either the model name (specified as a model in the cfg), or, taking the full configFileFullName, deleting the last item in that (the actual file name) and appending the mesh name

I could also use the partURL, and delete the last two parts to get a relative patch name

So all I need now is to get a list of the textures, and their paths (to the texture file).

And, if you have a better way to get the path to the model (.mu) file, I'd love to hear it

 

I also can now get the model from the game database by accessing the GameDatabase.Instance.databaseModel

 

Edited by linuxgurugamer
Link to comment
Share on other sites

KSP loads all assets before it loads configs, so there's not really a way to prevent them from loading without knowing beforehand and deleting/renaming them.

A part may actually come from multiple .mu files using MODEL nodes.

For textures, you can access them through the renderers, something like this:

HashSet<string> textureNames = new HashSet<string>();

foreach (MeshRenderer renderer in part.FindModelComponents<MeshRenderer>())
{
	textureNames.Add(renderer.sharedMaterial.GetTexture("_MainTex").name);
}

Using a HashSet to avoid duplicates (HashSet represents a set of unordered unique elements).

Edited by blowfish
GetComponentsInChildren -> FIndModelComponents avoids picking up part's children
Link to comment
Share on other sites

  • 2 weeks later...
On 9/11/2016 at 1:39 AM, blowfish said:

For textures, you can access them through the renderers, something like this:

I have a very similar problem I'm trying to solve, and your code example is pretty similar to what I'm trying to do, i.e. using part.GetComponentsInChildren<MeshRenderer>().

Except when I do that, I get all the meshes on this part and all its child parts, not just on this part itself.

How can I get just the meshes on the specified part?  (I tried calling GetComponents instead of GetComponentsInChildren, but that finds nothing at all.)

Link to comment
Share on other sites

53 minutes ago, Snark said:

I have a very similar problem I'm trying to solve, and your code example is pretty similar to what I'm trying to do, i.e. using part.GetComponentsInChildren<MeshRenderer>().

Except when I do that, I get all the meshes on this part and all its child parts, not just on this part itself.

How can I get just the meshes on the specified part?  (I tried calling GetComponents instead of GetComponentsInChildren, but that finds nothing at all.)

Right, you probably want part.FindModelComponents<MeshRenderer>

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