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
		}
	private IEnumerator TimeDelay(float delay, AnimationTime time_type)
	{
		if (time_type == AnimationTime.GAME_TIME)
			yield return new WaitForSeconds(delay);
		else
		{
			float timer = 0;
			var last_time = Time.realtimeSinceStartup;
			float delta_time;
			while (timer < delay)
			{
				delta_time = Time.realtimeSinceStartup - last_time;
				if (delta_time > 0.1f)
					delta_time = 0.1f;
				timer += delta_time;
				last_time = Time.realtimeSinceStartup;
				yield return false;
			}
		}
	}
Example #4
0
    void OnGUI()
    {
        if (IsDebugMode)
        {
            GUILayout.Label("IsAnimating " + IsAnimating.ToString() + " - Time: " + AnimationTime.ToString());
            GUILayout.Label("DebugRotation: " + DebugRotation.ToString());

            GUILayout.Label("Animation Clip: " + MyAnimation.name + " [" + MyAnimation.length + "]");
            GUILayout.Label("Bones To animate: " + BoneReferences.Count + " with " + MyBones.Count + " instructions");
            GUILayout.Label("Bounds: " + MyAnimation.localBounds.ToString());
            for (int i = 0; i < BoneReferences.Count; i++)
            {
                if (BoneReferences[i])
                {
                    GUILayout.Label(i + ":" + BoneReferences[i].name);
                }
                else
                {
                    GUILayout.Label(i + ": Is Null..");
                }
            }
            if (Input.GetKey(KeyCode.X))
            {
                for (int i = 0; i < MyBones.Count; i += 4)
                {
                    if (i + 3 < MyBones.Count)
                    {
                        GUILayout.Label("[" + i + "]:[" + MyBones[i].PropertyName + "]"
                                        + "\t[" + (i + 1) + "]:[" + MyBones[i + 1].PropertyName + "]"
                                        + "\t[" + (i + 2) + "]:[" + MyBones[i + 2].PropertyName + "]"
                                        + "\t[" + (i + 3) + "]:[" + MyBones[i + 3].PropertyName + "]");
                    }
                }
            }
            else if (Input.GetKey(KeyCode.Z))
            {
                for (int i = 0; i < MyBones.Count; i += 4)
                {
                    if (i + 3 < MyBones.Count)
                    {
                        GUILayout.Label("[" + i + "]:[" + MyBones[i].MyBindedObject.name + "]"
                                        + "\t[" + (i + 1) + "]:[" + MyBones[i + 1].MyBindedObject.name + "]"
                                        + "\t[" + (i + 2) + "]:[" + MyBones[i + 2].MyBindedObject.name + "]"
                                        + "\t[" + (i + 3) + "]:[" + MyBones[i + 3].MyBindedObject.name + "]");
                    }
                }
            }
            else
            {
                GUILayout.Label("Curves");
                for (int i = 0; i < MyBones.Count; i += 4)
                {
                    if (i + 3 < MyBones.Count)
                    {
                        //GUILayout.Label (MyBones[i].GetLabel());
                        GUILayout.Label(RoundTo2Dec(MyBones[i].MyCurve.Evaluate(AnimationTime)).ToString()
                                        + "\t" + RoundTo2Dec(MyBones[i + 1].MyCurve.Evaluate(AnimationTime)).ToString()
                                        + "\t" + RoundTo2Dec(MyBones[i + 2].MyCurve.Evaluate(AnimationTime)).ToString()
                                        + "\t" + RoundTo2Dec(MyBones[i + 3].MyCurve.Evaluate(AnimationTime)).ToString()
                                        );
                    }
                }
            }

            /*for (int i = 0; i < MyAnimation.events.Length; i++)
             * {
             *      GUILayout.Label(MyAnimation.events[i].functionName);
             * }*/

            /*for (int i = 0; i < MyCurveBindings.Length; i++)  {
             *      GUILayout.Label("CurveBinding: " + MyCurveBindings[i].propertyName +
             *                      ":" + MyCurveBindings[i].path);
             *                     // + ":" + MyCurveBindings[i].isPPtrCurve);
             * }*/
        }
    }