示例#1
0
	public void ImportData(string data, bool force_clear_old_audio_particles = false)
	{
		if (force_clear_old_audio_particles)
			ClearCachedAudioParticleInstances(true);

		var json_data = JSONObject.Parse(data, true);

		if (json_data != null)
		{
			m_animate_per = (AnimatePerOptions)(int)json_data["m_animate_per"].Number;
			m_display_axis = (TextDisplayAxis)(int)json_data["m_display_axis"].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_character_size"))
				m_character_size = (float)json_data["m_character_size"].Number;
			if (json_data.ContainsKey("m_line_height"))
				m_line_height_factor = (float)json_data["m_line_height"].Number;
			if (json_data.ContainsKey("m_max_width"))
				m_max_width = (float)json_data["m_max_width"].Number;
			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_px_offset"))
				m_px_offset = json_data["m_px_offset"].Obj.JSONtoVector2();
//			if(json_data.ContainsKey("m_text")) m_text = json_data["m_text"].Str;
			if (json_data.ContainsKey("m_text_alignment"))
				m_text_alignment = (TextAlignment)(int)json_data["m_text_alignment"].Number;
			if (json_data.ContainsKey("m_text_anchor"))
				m_text_anchor = (TextAnchor)(int)json_data["m_text_anchor"].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 (var animation_data in json_data["LETTER_ANIMATIONS_DATA"].Array)
			{
				letter_anim = new LetterAnimation();
				letter_anim.ImportData(animation_data.Obj);
				m_master_animations.Add(letter_anim);
			}
		}
		else
		// Import string is not valid JSON, therefore assuming it is in the legacy data import format.
			this.ImportLegacyData(data);

		if (!Application.isPlaying && m_text.Equals(""))
			m_text = "TextFx";

		if (!m_text.Equals(""))
			SetText(m_text);

		ResetAnimation();
	}
		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
		}