void Start()
    {
        TheBuilderSettings      = FindObjectOfType <BuilderSettings>();
        TheRoot                 = FindObjectOfType <BuilderRoot>();
        TheBoxCollider          = GetComponent <BoxCollider>();
        TheBuilderAdjacentCheck = GetComponent <BuilderAdjacentCheck>();

        UpdateStartingColor();
    }
    //Save ship to binary file
    public void Save()
    {
        BinaryFormatter formater = new BinaryFormatter();
        //Create file
        FileStream stream = new FileStream(Application.dataPath + "/../" + "/ShipSaves" + "/" + TheBuilderSettings.ShipName, FileMode.Create);

        //Get all blocks
        BuilderRoot theBuilderRoot = ShipRoot.GetComponent <BuilderRoot>();

        theBuilderRoot.AdjacentCheck();
        theBuilderRoot.ClearAllRedBlocks();
        List <ShipBlockData> blocks = new List <ShipBlockData>();

        for (int i = 0; i < theBuilderRoot.AllChilds.Count; i++)
        {
            blocks.Add(new ShipBlockData(theBuilderRoot.AllChilds[i]));
        }
        //Get all block connections
        //Each child
        for (int i = 0; i < theBuilderRoot.AllChilds.Count; i++)
        {
            BuilderAdjacentCheck theBuilderAdjacentCheck = theBuilderRoot.AllChilds[i].GetComponent <BuilderAdjacentCheck>();
            //Each child's adjacent block
            for (int j = 0; j < theBuilderAdjacentCheck.AdjacentBlocks.Count; j++)
            {
                //Loop through each ship child
                for (int k = 0; k < theBuilderRoot.AllChilds.Count; k++)
                {
                    //If there was a match for one of the adjacent blocks
                    if (theBuilderAdjacentCheck.AdjacentBlocks[j] == theBuilderRoot.AllChilds[k])
                    {
                        blocks[i].Connections[j] = blocks[k];
                    }
                }
            }
        }

        //The whole ship's information
        ShipData theShipData = new ShipData(blocks.ToArray(), TheBuilderSettings.ShipName);

        //Write to file
        formater.Serialize(stream, theShipData);
        stream.Close();
    }
    //Load ship from a binary file
    public void Load(string FileName)
    {
        //Checks if the file exists
        if (File.Exists(Application.dataPath + "/../" + "/ShipSaves" + "/" + FileName))
        {
            BinaryFormatter formater = new BinaryFormatter();
            //Open file
            FileStream stream = new FileStream(Application.dataPath + "/../" + "/ShipSaves" + "/" + FileName, FileMode.Open);

            //Obtain the saved data
            ShipData theShipData = formater.Deserialize(stream) as ShipData;
            stream.Close();

            //Load
            NameText.text = FileName;
            BuilderRoot theBuilderRoot = ShipRoot.GetComponent <BuilderRoot>();
            //Clear existing ship
            theBuilderRoot.ClearAllBlocks();

            //Create new ship using the saved data
            for (int i = 0; i < theShipData.Parts.Length; i++)
            {
                for (int j = 0; j < ShipParts.Count; j++)
                {
                    if (theShipData.Parts[i].Name == ShipParts[j].name)
                    {
                        GameObject spawnedShipPart = Instantiate(ShipParts[j], Vector3.zero, Quaternion.identity);
                        spawnedShipPart.name                       = ShipParts[j].name;
                        spawnedShipPart.transform.parent           = ShipRoot.transform;
                        spawnedShipPart.transform.localPosition    = new Vector3(theShipData.Parts[i].Position[0], theShipData.Parts[i].Position[1], theShipData.Parts[i].Position[2]);
                        spawnedShipPart.transform.localEulerAngles = new Vector3(theShipData.Parts[i].Rotation[0], theShipData.Parts[i].Rotation[1], theShipData.Parts[i].Rotation[2]);
                        theBuilderRoot.AllChilds.Add(spawnedShipPart);
                    }
                }
            }
        }
    }
 void Start()
 {
     TheBuilderSettings = FindObjectOfType <BuilderSettings>();
     TheRoot            = FindObjectOfType <BuilderRoot>();
 }