Jump to content

Setting GameObject inactive in editor preview


Recommended Posts

Hello, and good evening! I'm at it again, messing with things I don't understand yet. It's how we learn, right?...

So, I've got a marker object in a part that I'd like to only appear in the editor. I naively thought I might get away with disabling the marker GO before hitting the part tools export button and enabling again with a little code (which I can do as a plain old PartModule no problem).

Unsurprisingly, that doesn't work and the marker still shows up in the editor pane. I think I need to poke some things about in a non-PartModule (probably Part class?) sort of fashion to be able to achieve this. Pointers for where to start greatly appreciated, I've only ever worked with PartModules so far.

Thank you, as ever.

Link to comment
Share on other sites

I put a few print statements in here and there, it doesn't look like OnStart runs until the part is picked, so the object still shows up in the part picker pane. It's not the end of the world, but I have some other projects which would benefit from being able to manipulate what's visible in the picker icon.

Link to comment
Share on other sites

If you're trying to hide something from the part icon panel, tag it with Icon_Hidden. Then you can use JDP's advice.

The thing you see in the panel is [a clone of] AvailablePart.iconPrefab, a stripped-down version of AvailablePart.partPrefab. Logic and other unnecessary components are stripped from it--that's why you don't see any reaction from your PartModule. You'd want to add MonoBehaviours to it if you want some special logic to run

Link to comment
Share on other sites

You come to the rescue again! Should have thought of Icon_Hidden, thats nice and simple :) As JDP says, I can control things with some logic in OnStart from there. Cheers for the tips on the prefabs, I'll file that away for future reference.

Thank you, both.

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