Jump to content

Part.partName just returns "Part"


Recommended Posts

I am trying display a list of parts but when I try to use Part.partName it just says "Part" for all of them.

Here is what I have

using System;
using System.Collections.Generic;
using UnityEngine;
using KSP;

namespace AutoAbortSystem
{
    public class ModuleAAS : PartModule
    {
        List<ModuleAAS> AASmodules = new List<ModuleAAS>();
        List<Part> parts = new List<Part>();
        public void Start()
        {

        }

        public void Update()
        {
            parts.Clear();
            AASmodules.Clear();
            foreach(Part part in FlightGlobals.ActiveVessel.parts)
            {
                parts.Add(part);
                if (part.gameObject.GetComponent<ModuleAAS>()) AASmodules.Add(part.GetComponent<ModuleAAS>());
            }
        }

        public void OnGUI()
        {
            if(this == AASmodules.ToArray()[0]) GUILayout.Window(616173, new Rect(100,100,350,800), window, "Automatic Abort System", HighLogic.Skin.window);
        }

        public void window(int windowID)
        {
            foreach (Part part in parts)
            {
                if (part != this.part) GUILayout.Label(part.partName);
                else GUILayout.Label(part.partName + " (active)");
            }
        }

        public void OnDestroy()
        {
            AASmodules.Remove(this);
        }


    }
}

4W5v48y.png

Am I doing something wrong or is this a bug?

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