Jump to content

Disable the particle emitter in editor


Recommended Posts

Is there a way to disable the particle emitter in editor?

svutbVb.png

        if (HighLogic.LoadedSceneIsEditor)
        {
            ABTransform.gameObject.SetActive(false);

        }

The code can only disable when you drag it out, it still shows up in the components list, is there a away to hide it?

Link to comment
Share on other sites

On 2016/2/20 at 0:01 AM, xEvilReeperx said:

Add the Icon_Hidden tag to the particle emitter's GameObject inside Unity before exporting it

CurRuwx.png

I set it like this, but it doesn't work.

Maybe I have to deactivate Emit and activate again?

Link to comment
Share on other sites

Looks like it's an oversight in KSP. Particle[Emitter/Animator/Renderer] components work with Icon_Hidden but KSPParticleEmitter and probably SkinnedMeshRenderer do not. The Icon_Only tag functions normally.

Well, easily fixed in code:

[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class FixIconHiddenBug : LoadingSystem
{
    private static bool _hasRun = false;
    private const string IconHiddenTag = "Icon_Hidden";

    private void Start()
    {
        if (_hasRun)
        {
            Destroy(gameObject);
            return;
        }
            
        FindObjectOfType<LoadingScreen>().loaders.Add(this);
    }

    public override bool IsReady()
    {
        return _hasRun;
    }

    public override void StartLoad()
    {
        _hasRun = true;

        var startTime = Time.realtimeSinceStartup;

        foreach (
            var iconGo in PartLoader.LoadedPartsList.Where(ap => ap.iconPrefab != null).Select(ap => ap.iconPrefab))
        {
            PartLoader.StripTaggedTransforms(iconGo.transform, IconHiddenTag);
        }

        print("Finished fixing tags in " + (Time.realtimeSinceStartup - startTime).ToString("F3") + " sec");
    }

    public override string ProgressTitle()
    {
        return "Fixing icon tags";
    }
}

Edit: Just so nobody is surprised by it, this will delete any tagged GO and its children

Edited by xEvilReeperx
Link to comment
Share on other sites

On 2/22/2016 at 0:04 AM, xEvilReeperx said:

Looks like it's an oversight in KSP. Particle[Emitter/Animator/Renderer] components work with Icon_Hidden but KSPParticleEmitter and probably SkinnedMeshRenderer do not. The Icon_Only tag functions normally.

Well, easily fixed in code:


[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class FixIconHiddenBug : LoadingSystem
{
    private static bool _hasRun = false;
    private const string IconHiddenTag = "Icon_Hidden";

    private void Start()
    {
        if (_hasRun)
        {
            Destroy(gameObject);
            return;
        }
            
        FindObjectOfType<LoadingScreen>().loaders.Add(this);
    }

    public override bool IsReady()
    {
        return _hasRun;
    }

    public override void StartLoad()
    {
        _hasRun = true;

        var startTime = Time.realtimeSinceStartup;

        foreach (
            var iconGo in PartLoader.LoadedPartsList.Where(ap => ap.iconPrefab != null).Select(ap => ap.iconPrefab))
        {
            PartLoader.StripTaggedTransforms(iconGo.transform, IconHiddenTag);
        }

        print("Finished fixing tags in " + (Time.realtimeSinceStartup - startTime).ToString("F3") + " sec");
    }

    public override string ProgressTitle()
    {
        return "Fixing icon tags";
    }
}

Edit: Just so nobody is surprised by it, this will delete any tagged GO and its children

Does the normal Unity Particle Emitter works in KSP? I think it doesn't work in some older versions.

Thank you for your code!

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