private static void ExtendedSceneSave(string path) { try { Dictionary <string, object> ExtendedData = new Dictionary <string, object>(); List <AnimationControllerInfo> AnimationControllerInfoList = new List <AnimationControllerInfo>(); foreach (var IKObj in IKObjectInfoList) { AnimationControllerInfoList.Add(new AnimationControllerInfo { CharDicKey = IKObj.CharacterKey, ItemDicKey = IKObj.ObjectKey, IKPart = IKObj.IKPart }); } if (AnimationControllerInfoList.Count == 0) { ExtendedSave.SetSceneExtendedDataById(PluginName, null); } else { ExtendedData.Add("AnimationInfo", AnimationControllerInfoList.Select(x => x.Serialize()).ToList()); ExtendedSave.SetSceneExtendedDataById(PluginName, new PluginData { data = ExtendedData }); } Logger.Log(LogLevel.Debug, "Saved KK_AnimationController animations"); } catch (Exception ex) { Logger.Log(LogLevel.Error | LogLevel.Message, "Could not save KK_AnimationController animations."); Logger.Log(LogLevel.Error, ex.ToString()); } }
/// <summary> /// Save your custom data to the scene under the ID you specified when registering this controller. /// </summary> /// <param name="data">Your custom data to be written to the scene. Can be null to remove the data.</param> public void SetExtendedData(PluginData data) { if (ExtendedDataId == null) { throw new ArgumentException(nameof(ExtendedDataId)); } ExtendedSave.SetSceneExtendedDataById(ExtendedDataId, data); }
protected override void OnSceneSave() { //Clear out the old style data PluginData OldData = ExtendedSave.GetSceneExtendedDataById(PluginNameInternal); if (OldData != null) { OldData = null; } ExtendedSave.SetSceneExtendedDataById(PluginNameInternal, new PluginData { data = null }); }
// Token: 0x06000007 RID: 7 RVA: 0x000021D8 File Offset: 0x000003D8 private static void ExtendedSceneSave(string path) { try { Logger.Log(LogLevel.Info, string.Format("Start saving VMDPlay info into scene data: {0}", path)); PluginData pluginData = new PluginData(); XmlDocument xmlDocument = new XmlDocument(); XmlDeclaration newChild = xmlDocument.CreateXmlDeclaration("1.0", "utf-8", null); xmlDocument.AppendChild(newChild); XmlElement xmlElement = xmlDocument.CreateElement("VMDPlaySaveData"); xmlDocument.AppendChild(xmlElement); KKVMDPlayExtSavePlugin.OnSave(xmlElement); pluginData.data["xml"] = KKVMDPlayExtSavePlugin.GetExtDataAsBytes(xmlDocument); ExtendedSave.SetSceneExtendedDataById("KKVMDPlayExtSave", pluginData); Logger.Log(LogLevel.Info, string.Format("Save completed: {0}", path)); } catch (Exception ex) { Logger.Log(LogLevel.Error, string.Format("Failed to load data. {0}", ex.StackTrace)); } }
public static void RegisterSaveEvent() { ExtendedSave.SceneBeingSaved += path => { ExtendedSave.SetSceneExtendedDataById(StudioCharaLightLinkedToCamera.GUID, new PluginData() { data = new System.Collections.Generic.Dictionary <string, object> { { "locked", Locked ? "true" : "false" }, { "attachedLightAngle", new System.Collections.Generic.Dictionary <string, float> { { "x", ComputeAngle.AttachedLightEuler.x }, { "y", ComputeAngle.AttachedLightEuler.y } } }, { "attachedCameraAngle", new System.Collections.Generic.Dictionary <string, float> { { "x", ComputeAngle.AttachedCameraEuler.x }, { "y", ComputeAngle.AttachedCameraEuler.y } } } }, version = 3 }); Logger.LogDebug("Scene Saved"); }; ExtendedSave.SceneBeingLoaded += path => { PluginData pd = ExtendedSave.GetSceneExtendedDataById(StudioCharaLightLinkedToCamera.GUID); if (null != pd && pd.version == 3 && pd.data.TryGetValue("locked", out object l) && l is string boolstring && pd.data.TryGetValue("attachedLightAngle", out object lig) && pd.data.TryGetValue("attachedCameraAngle", out object cam)) { System.Collections.Generic.Dictionary <string, float> ligAngle = lig.ToDictionary <string, float>(); System.Collections.Generic.Dictionary <string, float> camAngle = cam.ToDictionary <string, float>(); ToggleLocked(boolstring == "true"); ComputeAngle.AttachedLightEuler = new Vector2(ligAngle["x"], ligAngle["y"]); ComputeAngle.AttachedCameraEuler = new Vector2(camAngle["x"], camAngle["y"]); Logger.LogDebug("Scene Load PluginData"); }
//Clear out the old style data protected override void OnSceneSave() => ExtendedSave.SetSceneExtendedDataById(PluginNameInternal, new PluginData { data = null });