public static IEnumerator createNewHairMenu(string hairMenuFileName, List <HairLengthTargetObj> listTarget, MenuObj menu, bool useExistingLengths)
        {
            //Delete Existing
            if (File.Exists(Path.Combine(newMenuPath, hairMenuFileName)))
            {
                UnityEngine.Debug.Log("Deleting old Menu");
                File.Delete(Path.Combine(newMenuPath, hairMenuFileName));
            }

            //Write new
            using (BinaryWriter binaryWriter = new BinaryWriter(File.Open(Path.Combine(newMenuPath, "Ext_" + hairMenuFileName), FileMode.OpenOrCreate)))
            {
                List <string> sliderNames = new List <string>();

                //Write the header
                binaryWriter.Write(menu.header.CM3D2_MENU);
                binaryWriter.Write(menu.header.temp1);
                binaryWriter.Write(menu.header.temp2);
                binaryWriter.Write(menu.header.temp3);
                binaryWriter.Write(menu.header.temp4);
                binaryWriter.Write(menu.header.temp5);
                binaryWriter.Write(menu.header.temp6);

                //Write the commands
                for (int i = 0; i < menu.commands.Count; i++)
                {
                    MenuCommandObj command = menu.commands[i];

                    //Special case for the length sliders - need to adjust the data
                    if (command.stringCom.Equals("length"))
                    {
                        if (useExistingLengths)
                        {
                            //Write the byte indicating size of params
                            binaryWriter.Write(command.byt);

                            string sliderName = command.stringList[2];
                            while (sliderNames.Contains(sliderName))
                            {
                                sliderName += "_";
                            }
                            sliderNames.Add(sliderName);

                            //Write out commands
                            for (int j = 0; j < command.nativeStrings.Count; j++)
                            {
                                if (j != 2)
                                {
                                    //Normal Param
                                    binaryWriter.Write(command.nativeStrings[j]);
                                }
                                else
                                {
                                    //Slider
                                    binaryWriter.Write(sliderName);
                                }
                            }
                        }
                    }
                    else
                    {
                        //Write the byte indicating size of params
                        binaryWriter.Write(command.byt);

                        //Write out normal commands
                        for (int j = 0; j < command.nativeStrings.Count; j++)
                        {
                            binaryWriter.Write(command.nativeStrings[j]);
                        }
                    }
                }

                //Add the hair length options
                if (listTarget != null)
                {
                    for (int i = 0; i < listTarget.Count; i++)
                    {
                        binaryWriter.Write(Convert.ToByte(11));
                        binaryWriter.Write("length");
                        binaryWriter.Write(menu.category);
                        binaryWriter.Write("髪" + i);
                        binaryWriter.Write("fbrother");
                        binaryWriter.Write(listTarget[i].trTarget);
                        binaryWriter.Write(listTarget[i].vScaleMin.x.ToString("N1"));
                        binaryWriter.Write(listTarget[i].vScaleMin.y.ToString("N1"));
                        binaryWriter.Write(listTarget[i].vScaleMin.z.ToString("N1"));
                        binaryWriter.Write(listTarget[i].vScaleMax.x.ToString("N1"));
                        binaryWriter.Write(listTarget[i].vScaleMax.y.ToString("N1"));
                        binaryWriter.Write(listTarget[i].vScaleMax.z.ToString("N1"));
                    }
                }

                //Write the end
                binaryWriter.Write(Convert.ToByte('\u0000'));
            }

            //Add the new menu to the file system
            UnityEngine.Debug.Log("Adding new Menu to MOD file system: Ext_" + hairMenuFileName);
            GameUty.FileSystemMod.FileOpen(Path.Combine(newMenuPath, "Ext_" + hairMenuFileName));

            yield return(null);
        }
        private static MenuObj getMenu(string menuFileName)
        {
            //UnityEngine.Debug.Log("Fetching Menu " + menuFileName);

            MenuObj menu = new MenuObj();

            byte[] cd;
            using (AFileBase afileBase = GameUty.FileOpen(menuFileName, (AFileSystemBase)null))
            {
                if (afileBase != null && afileBase.IsValid())
                {
                    //UnityEngine.Debug.Log("Reading bytes");

                    cd = afileBase.ReadAll();

                    using (BinaryReader binaryReader = new BinaryReader((Stream) new MemoryStream(cd), Encoding.UTF8))
                    {
                        //Useless header info???
                        //UnityEngine.Debug.Log("Reading header");
                        menu.header.CM3D2_MENU = binaryReader.ReadString();
                        menu.header.temp1      = binaryReader.ReadInt32();
                        menu.header.temp2      = binaryReader.ReadString();
                        menu.header.temp3      = binaryReader.ReadString();
                        menu.header.temp4      = binaryReader.ReadString();
                        menu.header.temp5      = binaryReader.ReadString();
                        menu.header.temp6      = binaryReader.ReadInt32();

                        bool end = false;

                        //UnityEngine.Debug.Log("Reading commands");
                        //Blocks
                        do
                        {
                            MenuCommandObj command = new MenuCommandObj();
                            string         str4;
                            do
                            {
                                byte byt = binaryReader.ReadByte();
                                command.byt = byt;
                                int num2 = (int)byt;

                                str4 = string.Empty;
                                if (num2 != 0)
                                {
                                    for (int index = 0; index < num2; ++index)
                                    {
                                        string str = binaryReader.ReadString();
                                        command.nativeStrings.Add(str);
                                        str4 = str4 + "\"" + str + "\" ";
                                    }
                                }
                                else
                                {
                                    end = true;
                                }
                            }while (str4 == string.Empty && !end);

                            if (!end)
                            {
                                string   stringCom  = UTY.GetStringCom(str4);
                                string[] stringList = UTY.GetStringList(str4);

                                command.stringCom  = stringCom;
                                command.stringList = stringList;
                                menu.commands.Add(command);

                                if (stringCom.Equals("category"))
                                {
                                    //Get the category
                                    menu.category = stringList[1];
                                }
                            }
                        }while (!end);
                    }
                }
                else
                {
                    if (afileBase == null)
                    {
                        UnityEngine.Debug.Log("Split Hair Sliders: null AFileBase");
                    }
                    else
                    {
                        if (!afileBase.IsValid())
                        {
                            UnityEngine.Debug.Log("Split Hair Sliders: invalid AFileBase");
                        }
                    }
                }
            }

            return(menu);
        }