Thanks for the responses guys, really appreciate it.
I've updated my code a little, and finally figured out I was using the wrong debug window *dumbass* lol. I was using the one in the Alt+F12 menu, but discovered the Alt+f2 window this morning, which is far more helpful.
So the code is here, the problems are listed below (there is only one that I can see, well two, but we'll come to the second one in due time :))
using UnityEngine;
using KSP.IO;
using System.Collections.Generic;
namespace TMS_Module_001
{
[KSPAddon(KSPAddon.Startup.SpaceCentre, true)]
public class TMS_Module_001 : MonoBehaviour
{
public void Awake()
{
// Create a new blank vessel
Vessel newVessel = new Vessel();
// Add a part to the vessel
Debug.Log("getPartInfoByName");
AvailablePart avParts = PartLoader.getPartInfoByName("GearFixed");
Debug.Log("Instantiate");
//UnityEngine.Object obj = UnityEngine.Object.Instantiate(avParts.partPrefab);
if (avParts != null)
{
UnityEngine.Object obj = Instantiate(avParts.partPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity);
Debug.Log("newPart");
Part newPart = (Part)obj;
Debug.Log("rootPart ; parts.Add()");
newPart.gameObject.name = "TMS_Module_001";
newPart.partInfo = avParts;
newVessel.rootPart = newPart;
newVessel.parts = new List<Part>();
newVessel.parts.Add(newPart);
// Set vessel parameters
Debug.Log("Set vessel params");
Debug.Log("-----------------");
Debug.Log("Set vessel name");
if (newVessel != null)
{
newVessel.name = "TMS_Module_001";
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set Landed status");
if (newVessel != null)
{
newVessel.Landed = true;
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set Splashed status");
if (newVessel != null)
{
newVessel.Splashed = false;
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set LandedAt status");
if (newVessel != null)
{
newVessel.landedAt = string.Empty;
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set Landed status");
if (newVessel != null)
{
newVessel.situation = Vessel.Situations.LANDED;
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set vessel type");
if (newVessel != null)
{
newVessel.vesselType = VesselType.Debris;
}
else
{
Debug.Log("Vessel is Empty");
}
Debug.Log("Set vessel Position");
if (newVessel != null)
{
newVessel.transform.position = new Vector3(5f, 0f, 5f);
}
else
{
Debug.Log("Vessel is Empty");
}
newVessel.GoOffRails();
newVessel.Load();
}
else
{
print("Part Not Found");
}
}
}
}
After a little more poking around I decided to go with the KSPAddon bit, and the code executes exactly when I want it to, which is great. (yes I realise that my module will spawn every time I go to the space center at the moment, but I'll be adding a check to see if the object already exists when I finally get it to spawn.
So onto the main problem. According to the Log, the 'newVessel' Vessel, never gets populated. As you can see I've added a bunch of debug commands to see what's going on and each line prints out the debug info (Vessel is Empty) So right off the bat there's nothing there which is stopping pretty much everything else, and I can't seem to figure out the problem.
Any insight would be greatly appreciated.
Thanks
TheMightySpud