public void ImportData(string data, TextFxAnimationManager.PresetAnimationSection animationSection, PRESET_ANIMATION_SECTION section, bool force_clear_old_audio_particles = false) { if(force_clear_old_audio_particles) ClearCachedAudioParticleInstances(true); int num_actions_added = 0; int num_loops_added = 0; int insert_action_index = 0; int insert_loop_index = 0; if(section == PRESET_ANIMATION_SECTION.MAIN) { insert_action_index = m_preset_intro.m_start_action + m_preset_intro.m_num_actions + (m_preset_intro.m_active ? 1 : 0); insert_loop_index = m_preset_intro.m_start_loop + m_preset_intro.m_num_loops; } else if(section == PRESET_ANIMATION_SECTION.OUTRO) { insert_action_index = m_preset_main.m_start_action + m_preset_main.m_num_actions + (m_preset_main.m_active ? 1 : 0); insert_loop_index = m_preset_main.m_start_loop + m_preset_main.m_num_loops; } Boomlagoon.JSON.JSONObject json_data = Boomlagoon.JSON.JSONObject.Parse(data, true); if(json_data != null) { if(m_master_animations == null || m_master_animations.Count == 0) m_master_animations = new List<LetterAnimation>(){ new LetterAnimation() }; m_master_animations[0].ImportPresetSectionData(json_data["LETTER_ANIMATIONS_DATA"].Obj, m_letters, insert_action_index, insert_loop_index, ref num_actions_added, ref num_loops_added, m_animation_interface_reference.AssetNameSuffix); animationSection.m_preset_effect_settings = new List<PresetEffectSetting>(); // Import any Quick setup settings info if(json_data.ContainsKey("PRESET_EFFECT_SETTINGS")) { PresetEffectSetting effectSetting; foreach(Boomlagoon.JSON.JSONValue effectSettingData in json_data["PRESET_EFFECT_SETTINGS"].Array) { effectSetting = new PresetEffectSetting(); effectSetting.ImportData(effectSettingData.Obj); animationSection.m_preset_effect_settings.Add(effectSetting); } } } else { // Import string is not valid JSON, therefore assuming it is in the legacy data import format. Debug.LogError("TextFx animation import failed. Non-valid JSON data provided"); // this.ImportLegacyData(data); // // m_preset_effect_settings = new List<PresetEffectSetting>(); } if(!Application.isPlaying && m_animation_interface_reference.Text.Equals("")) m_animation_interface_reference.SetText("TextFx"); PrepareAnimationData (); ResetAnimation(); // Update mesh m_animation_interface_reference.UpdateTextFxMesh(MeshVerts, MeshColours); SceneView.RepaintAll(); animationSection.m_num_actions = num_actions_added; animationSection.m_num_loops = num_loops_added; }
public void ImportData(string data, bool force_clear_old_audio_particles = false) { if(force_clear_old_audio_particles) ClearCachedAudioParticleInstances(true); Boomlagoon.JSON.JSONObject json_data = Boomlagoon.JSON.JSONObject.Parse(data, true); if(json_data != null) { m_animate_per = (AnimatePerOptions) (int) json_data["m_animate_per"].Number; if(json_data.ContainsKey("m_begin_delay")) m_begin_delay = (float) json_data["m_begin_delay"].Number; if(json_data.ContainsKey("m_begin_on_start")) m_begin_on_start = json_data["m_begin_on_start"].Boolean; if(json_data.ContainsKey("m_on_finish_action")) m_on_finish_action = (ON_FINISH_ACTION) (int) json_data["m_on_finish_action"].Number; if(json_data.ContainsKey("m_time_type")) m_time_type = (AnimationTime) (int) json_data["m_time_type"].Number; m_master_animations = new List<LetterAnimation>(); LetterAnimation letter_anim; foreach(Boomlagoon.JSON.JSONValue animation_data in json_data["LETTER_ANIMATIONS_DATA"].Array) { letter_anim = new LetterAnimation(); letter_anim.ImportData(animation_data.Obj, m_animation_interface_reference.AssetNameSuffix); m_master_animations.Add(letter_anim); } #if UNITY_EDITOR m_preset_effect_settings = new List<PresetEffectSetting>(); // Import any Quick setup settings info if(json_data.ContainsKey("PRESET_EFFECT_SETTINGS")) { PresetEffectSetting effectSetting; foreach(Boomlagoon.JSON.JSONValue effectSettingData in json_data["PRESET_EFFECT_SETTINGS"].Array) { effectSetting = new PresetEffectSetting(); effectSetting.ImportData(effectSettingData.Obj); m_preset_effect_settings.Add(effectSetting); } } #endif } else { // Import string is not valid JSON, therefore assuming it is in the legacy data import format. Debug.LogError("TextFx animation import failed. Non-valid JSON data provided"); this.ImportLegacyData(data); #if UNITY_EDITOR m_preset_effect_settings = new List<PresetEffectSetting>(); #endif } if(!Application.isPlaying && m_animation_interface_reference.Text.Equals("")) m_animation_interface_reference.SetText("TextFx"); PrepareAnimationData (); ResetAnimation(); // Update mesh m_animation_interface_reference.UpdateTextFxMesh(MeshVerts, MeshColours); #if UNITY_EDITOR SceneView.RepaintAll(); #endif }
// Used for importing a preset animation section's data, to have its animation edited in the editor, or have its quick-edit settings edited public void ImportPresetAnimationSectionData(string data, bool force_clear_old_audio_particles = false) { if(force_clear_old_audio_particles) ClearCachedAudioParticleInstances(true); Boomlagoon.JSON.JSONObject json_data = Boomlagoon.JSON.JSONObject.Parse(data, true); if(json_data != null) { m_master_animations = new List<LetterAnimation>(); LetterAnimation letter_anim = new LetterAnimation(); letter_anim.ImportPresetSectionData(json_data["LETTER_ANIMATIONS_DATA"].Obj, m_letters, m_animation_interface_reference.AssetNameSuffix); m_master_animations.Add(letter_anim); m_preset_effect_settings = new List<PresetEffectSetting>(); // Import any Quick setup settings info if(json_data.ContainsKey("PRESET_EFFECT_SETTINGS")) { PresetEffectSetting effectSetting; foreach(Boomlagoon.JSON.JSONValue effectSettingData in json_data["PRESET_EFFECT_SETTINGS"].Array) { effectSetting = new PresetEffectSetting(); effectSetting.ImportData(effectSettingData.Obj); m_preset_effect_settings.Add(effectSetting); } } } else { // Import string is not valid JSON, therefore assuming it is in the legacy data import format. Debug.LogError("TextFx animation import failed. Non-valid JSON data provided"); } if(!Application.isPlaying && m_animation_interface_reference.Text.Equals("")) m_animation_interface_reference.SetText("TextFx"); PrepareAnimationData (); ResetAnimation(); // Update mesh m_animation_interface_reference.UpdateTextFxMesh(MeshVerts, MeshColours); SceneView.RepaintAll(); }