private void LoadChara(string path) { var characters = GetSelectedCharacters(); if (characters.Count > 0) { MakerBridgeCore.Log("Character received"); foreach (var chara in characters) { chara.ChangeChara(path); } UpdateStateInfo(); } else { MakerBridgeCore.Log("Select a character before replacing it"); } }
private void LoadChara(string path) { var cfw = GameObject.FindObjectsOfType <CustomFileWindow>().FirstOrDefault(x => x.fwType == CustomFileWindow.FileWindowType.CharaLoad); var loadFace = true; var loadBody = true; var loadHair = true; var parameter = true; var loadCoord = true; if (cfw) { loadFace = cfw.tglChaLoadFace && cfw.tglChaLoadFace.isOn; loadBody = cfw.tglChaLoadBody && cfw.tglChaLoadBody.isOn; loadHair = cfw.tglChaLoadHair && cfw.tglChaLoadHair.isOn; parameter = cfw.tglChaLoadParam && cfw.tglChaLoadParam.isOn; loadCoord = cfw.tglChaLoadCoorde && cfw.tglChaLoadCoorde.isOn; } var chaCtrl = CustomBase.Instance.chaCtrl; var originalSex = chaCtrl.sex; chaCtrl.chaFile.LoadFileLimited(path, chaCtrl.sex, loadFace, loadBody, loadHair, parameter, loadCoord); if (chaCtrl.chaFile.GetLastErrorCode() != 0) { throw new Exception("LoadFileLimited failed"); } if (chaCtrl.chaFile.parameter.sex != originalSex) { chaCtrl.chaFile.parameter.sex = originalSex; MakerBridgeCore.Log("Warning: The character's sex has been changed to match the editor mode."); } chaCtrl.ChangeCoordinateType(true); chaCtrl.Reload(!loadCoord, !loadFace && !loadCoord, !loadHair, !loadBody); CustomBase.Instance.updateCustomUI = true; MakerBridgeCore.Log("Character received"); }
private void SaveCharacter(string path) { var characters = GetSelectedCharacters(); if (characters.Count > 0) { var empty = new Texture2D(1, 1, TextureFormat.ARGB32, false); empty.SetPixel(0, 0, Color.black); empty.Apply(); var charFile = characters[0].charInfo.chaFile; charFile.pngData = empty.EncodeToPNG(); charFile.facePngData = empty.EncodeToPNG(); using (var fileStream = new FileStream(path, FileMode.Create, FileAccess.Write)) charFile.SaveCharaFile(fileStream, true); } else { MakerBridgeCore.Log("Select a character to send to maker"); } }