void UpdateFunction()
		{
			m_time_delta = Time.realtimeSinceStartup - m_old_time;
			
			if(m_previewing_anim && !m_paused)
			{
				if(font_manager == null)
				{
					font_manager = (EffectManager)target;
				}
				
				if(m_time_delta > 0 && !font_manager.UpdateAnimation(m_time_delta) && font_manager.ParticleEffectManagers.Count == 0)
				{
					m_previewing_anim = false;
				}
				
				if(font_manager.ParticleEffectManagers.Count > 0)
					SceneView.RepaintAll();
			}
			
			if(m_set_text_delay > 0)
			{
				m_set_text_delay -= m_time_delta;
				
				if(m_set_text_delay <= 0)
				{
					m_set_text_delay = 0;
					
					font_manager.SetText(font_manager.m_text);
				}
			}
			
			m_old_time = Time.realtimeSinceStartup;
		}
		public ParticleEffectInstanceManager(EffectManager effect_manager, Mesh character_mesh, bool letter_flipped, ParticleEffectSetup effect_setup, AnimationProgressionVariables progression_vars, AnimatePerOptions animate_per, ParticleEmitter particle_emitter = null, ParticleSystem particle_system = null)
		{
			m_particle_emitter = particle_emitter;
			m_particle_system = particle_system;
			m_letter_mesh = character_mesh;
			m_letter_flipped = letter_flipped;
			m_follow_mesh = effect_setup.m_follow_mesh;
			m_duration = effect_setup.m_duration.GetValue(progression_vars, animate_per);
			m_delay = effect_setup.m_delay.GetValue(progression_vars, animate_per);
			m_position_offset = effect_setup.m_position_offset.GetValue(progression_vars, animate_per);
			m_rotation_offset = Quaternion.Euler(effect_setup.m_rotation_offset.GetValue(progression_vars, animate_per));
			m_rotate_with_letter = effect_setup.m_rotate_relative_to_letter;
			m_effect_manager_handle = effect_manager;
			m_active = false;

			if(m_particle_emitter != null)
			{
				m_transform = m_particle_emitter.transform;

				m_particle_emitter.emit = true;
				m_particle_emitter.enabled = false;
			}
			else if(m_particle_system != null)
			{
				m_transform = m_particle_system.transform;

				m_particle_system.playOnAwake = false;
				m_particle_system.Play();
	#if !UNITY_3_5 && UNITY_EDITOR
				p_system_timer = 0;
	#endif
			}
		}
		public override void OnInspectorGUI ()
		{
	//		DrawDefaultInspector();
			
			font_manager = (EffectManager)target;
			
			m_old_text = font_manager.m_text;
			m_old_display_axis = font_manager.m_display_axis;
			m_old_text_anchor = font_manager.m_text_anchor;
			m_old_text_alignment = font_manager.m_text_alignment;
			m_old_char_size = font_manager.m_character_size;
			m_old_line_height = font_manager.m_line_height_factor;
			m_old_px_offset = font_manager.m_px_offset;
			m_old_baseline_override = font_manager.m_override_font_baseline;
			m_old_font_baseline = font_manager.m_font_baseline_override;
			m_old_max_width = font_manager.m_max_width;
			
			if(GUI.changed)
			{
				return;
			}

			GUILayout.Space(10);

			EditorGUILayout.LabelField("Import Preset Effect", EditorStyles.boldLabel);

			EditorGUILayout.BeginHorizontal();
			m_selected_animation_idx = EditorGUILayout.Popup(m_selected_animation_idx, TextFxAnimationConfigs.m_config_list.GetArrayOfFirstEntries());

			if(GUI.changed)
			{
				EditorPrefs.SetInt("SelectedTextFxAnim", m_selected_animation_idx);
			}

			if(GUILayout.Button("Apply"))// && EditorUtility.DisplayDialog("Import TextFx Animation", "Are you sure you want to import this \"" + 
			                              //                               TextFxAnimationConfigs.m_config_list.GetArrayOfFirstEntries()[m_selected_animation_idx] +
			                              //                               "\" effect?", "Import", "Cancel"))
			{
				if(!TextFxAnimationConfigs.m_config_list[m_selected_animation_idx,1].Equals(""))
				{
					font_manager.ImportData(TextFxAnimationConfigs.m_config_list[m_selected_animation_idx,1]);
					Debug.Log("TextFx animation '" + TextFxAnimationConfigs.m_config_list[m_selected_animation_idx,0] + "' imported");
				}
			}
			EditorGUILayout.EndHorizontal();

			GUILayout.Space(10);


			
			EditorGUILayout.LabelField("Font Setup Data", EditorStyles.boldLabel);
			
	#if !UNITY_3_5
			font_manager.m_font = EditorGUILayout.ObjectField(new GUIContent("Font (.ttf, .dfont, .otf)", "Your font file to use for this text."), font_manager.m_font, typeof(Font), true) as Font;
			if(GUI.changed && font_manager.m_font != null)
			{
				font_manager.gameObject.GetComponent<Renderer>().material = font_manager.m_font.material;
				font_manager.m_font_material = font_manager.m_font.material;
				font_manager.SetText(font_manager.m_text, true);
			}
	#endif
			
			font_manager.m_font_data_file = EditorGUILayout.ObjectField(new GUIContent("Font Data File", "Your Bitmap font text data file."), font_manager.m_font_data_file, typeof(TextAsset), true) as TextAsset;
			if(GUI.changed && font_manager.m_font_data_file != null && font_manager.m_font_material != null)
			{
				// Wipe the old character data hashtable
				font_manager.ClearFontCharacterData();
				font_manager.SetText(font_manager.m_text, true);
				return;
			}
			font_manager.m_font_material = EditorGUILayout.ObjectField(new GUIContent("Font Material", "Your Bitmap font material"), font_manager.m_font_material, typeof(Material), true) as Material;
			if(GUI.changed && font_manager.m_font_data_file != null && font_manager.m_font_material != null)
			{
				// Reset the text with the new material assigned.
				font_manager.gameObject.GetComponent<Renderer>().material = font_manager.m_font_material;
				font_manager.SetText(font_manager.m_text, true);
				return;
			}
			EditorGUILayout.Separator();
			
			EditorGUILayout.LabelField(new GUIContent("Text", "The text to display."), EditorStyles.boldLabel);
			font_manager.m_text = EditorGUILayout.TextArea(font_manager.m_text, GUILayout.Width(Screen.width - 25));
			EditorGUILayout.Separator();
			
			EditorGUILayout.LabelField("Text Settings", EditorStyles.boldLabel);
			font_manager.m_display_axis = (TextDisplayAxis) EditorGUILayout.EnumPopup(new GUIContent("Display Axis", "Denotes whether to render the text horizontally or vertically."), font_manager.m_display_axis);
			font_manager.m_text_anchor = (TextAnchor) EditorGUILayout.EnumPopup(new GUIContent("Text Anchor", "Defines the anchor point about which the text is rendered"), font_manager.m_text_anchor);
			font_manager.m_text_alignment = (TextAlignment) EditorGUILayout.EnumPopup(new GUIContent("Text Alignment", "Defines the alignment of the text, just like your favourite word processor."), font_manager.m_text_alignment);
			font_manager.m_character_size = EditorGUILayout.FloatField(new GUIContent("Character Size", "Specifies the size of the text."), font_manager.m_character_size);
			font_manager.m_line_height_factor = EditorGUILayout.FloatField(new GUIContent("Line Height", "Defines the height of the text lines, based on the tallest line. If value is 2, the lines will be spaced at double the height of the tallest line."), font_manager.m_line_height_factor);
			EditorGUILayout.BeginHorizontal();
			font_manager.m_override_font_baseline = EditorGUILayout.Toggle(new GUIContent("Override Font Baseline?", "Allows you to manually set a baseline y-offset for the font to be rendered to."), font_manager.m_override_font_baseline);
			if(font_manager.m_override_font_baseline)
			{
				font_manager.m_font_baseline_override = EditorGUILayout.FloatField(new GUIContent("Font Baseline Offset", ""), font_manager.m_font_baseline_override);
			}
			EditorGUILayout.EndHorizontal();
			font_manager.m_px_offset = EditorGUILayout.Vector2Field("Letter Spacing Offset", font_manager.m_px_offset);
			font_manager.m_max_width = EditorGUILayout.FloatField(new GUIContent("Max Width", "Defines the maximum width of the text, and breaks the text onto new lines to keep it within this maximum."), font_manager.m_max_width);
			EditorGUILayout.Separator();
			
			EditorGUILayout.LabelField("Effect Settings", EditorStyles.boldLabel);
			EditorGUILayout.BeginHorizontal();
			font_manager.m_begin_on_start = EditorGUILayout.Toggle(new GUIContent("Play On Start", "Should this effect be automatically triggered when it's first started in the scene?"), font_manager.m_begin_on_start);
			if(font_manager.m_begin_on_start)
			{
				font_manager.m_begin_delay = EditorGUILayout.FloatField(new GUIContent("Delay", "How much the effect is delayed after first being started."), font_manager.m_begin_delay);
				if(font_manager.m_begin_delay < 0)
				{
					font_manager.m_begin_delay = 0;
				}
			}
			EditorGUILayout.EndHorizontal();
			font_manager.m_animation_speed_factor = EditorGUILayout.FloatField("Animation Speed Factor", font_manager.m_animation_speed_factor);
			font_manager.m_on_finish_action = (ON_FINISH_ACTION) EditorGUILayout.EnumPopup(new GUIContent("On Finish Action", "What should happen when the effect finishes?"), font_manager.m_on_finish_action);
			
			EditorGUILayout.Separator();
			EditorGUILayout.Separator();
			
			EditorGUILayout.BeginHorizontal();
			if(GUILayout.Button(!m_previewing_anim || m_paused ? "Play" : "Pause"))
			{
				if(m_previewing_anim)
				{
					m_paused = !m_paused;
					font_manager.Paused = m_paused;
				}
				else
				{
					m_previewing_anim = true;
					
					font_manager.PlayAnimation();
					m_paused = false;
					font_manager.Paused = false;
				}
			
				m_old_time = Time.realtimeSinceStartup;
			}
			if(GUILayout.Button("Reset"))
			{
				m_paused = false;
				m_previewing_anim = false;
				font_manager.ResetAnimation();
				
				SceneView.RepaintAll();
			}
			EditorGUILayout.EndHorizontal();
			
			// Render continue animation buttons
			if(font_manager.Playing)
			{
				EditorGUILayout.BeginHorizontal();
				
				if(font_manager.NumAnimations > 1)
				{
					int continue_count = 0;
					LetterAnimation animation;
					for(int anim_idx=0; anim_idx < font_manager.NumAnimations; anim_idx++)
					{
						animation = font_manager.GetAnimation(anim_idx);
						if(animation.CurrentAnimationState == LETTER_ANIMATION_STATE.WAITING)
						{
							if(GUILayout.Button("Continue[" + (continue_count+1) + "]"))
							{
								font_manager.ContinueAnimation(continue_count);
							}
						}
						continue_count ++;
					}
				}
				
				EditorGUILayout.EndHorizontal();
			}
			
			if (GUI.changed)
			{
				EditorUtility.SetDirty(font_manager);
			}
			
			if(m_old_char_size != font_manager.m_character_size ||
				m_old_display_axis != font_manager.m_display_axis ||
			   	m_old_line_height != font_manager.m_line_height_factor ||
				m_old_max_width != font_manager.m_max_width ||
				!m_old_text.Equals(font_manager.m_text)	||
				m_old_text_alignment != font_manager.m_text_alignment ||
				m_old_text_anchor != font_manager.m_text_anchor ||
				m_old_px_offset != font_manager.m_px_offset ||
				m_old_baseline_override != font_manager.m_override_font_baseline || 
				(font_manager.m_override_font_baseline && m_old_font_baseline != font_manager.m_font_baseline_override))
			{
				font_manager.SetText(font_manager.m_text);
			}

			GUILayout.Space(3);

			GUILayout.BeginHorizontal();
			GUIStyle style = new GUIStyle(EditorStyles.miniButton);

			if(GUILayout.Button(new GUIContent("Copy [S]", "Soft Copy this TextEffect animation configuration, not including any Text settings."), style))
			{
				string json_data = font_manager.ExportData();
				EditorGUIUtility.systemCopyBuffer = json_data;
				EditorPrefs.SetString("EffectExport", json_data);
				Debug.Log("Soft Copied " + font_manager.name);
			}
			if(GUILayout.Button(new GUIContent("Copy [H]", "Hard Copy this TextEffect animation configuration, including all Text settings."), style))
			{
				string json_data = font_manager.ExportData(hard_copy: true);
				EditorGUIUtility.systemCopyBuffer = json_data;
				EditorPrefs.SetString("EffectExport", json_data);
				Debug.Log("Hard Copied " + font_manager.name);
			}
			if(GUILayout.Button(new GUIContent("Paste", "Paste a copied TextEffect animation configuration onto this effect."), style))
			{
				if(EditorPrefs.HasKey("EffectExport"))
				{
					font_manager.ImportData(EditorPrefs.GetString("EffectExport"), true);
					Debug.Log("Pasted onto " + font_manager.name);
				}
			}
			GUILayout.EndHorizontal();

			GUILayout.Space(3);
			
			if (GUILayout.Button("Open Animation Editor"))
			{
				EditorWindow.GetWindow(typeof(TextEffectsManager));
			}
			
			if(font_manager.HasAudioParticleChildInstances)
			{
				GUILayout.Space(15);
				
				if (GUILayout.Button("Clear Audio/Particle Instances"))
				{
					font_manager.ClearCachedAudioParticleInstances();
				}
			}
		}
		void OnSceneGUI()
		{
			if(font_manager == null)
				font_manager = (EffectManager) target;
			
			if(font_manager.NumAnimations == 0)
				return;
			
			bool edit_detected = false;
			int edited_action = -1;
			int start_end_state = 0;
			int action_idx = 0;
			Vector3 position_offset = font_manager.transform.position;
			
			LetterAnimation letter_animation;
			for(int anim_idx=0; anim_idx < font_manager.NumAnimations; anim_idx++)
			{
				letter_animation = font_manager.GetAnimation(anim_idx);
				action_idx= 0;
				
				LetterAction action;
				for(int idx=0; idx < letter_animation.NumActions; idx++)
				{
					action = letter_animation.GetAction(idx);
					
					if(action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX && action.m_start_pos.BezierCurve.EditorVisible)
					{
						action.m_start_pos.BezierCurve.OnSceneGUI(position_offset, font_manager.Scale);
		
						if(!edit_detected && GUI.changed)
						{
							edit_detected = true;
							
							edited_action = action_idx;
							start_end_state = 0;
						}
					}
					
					if(action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX && action.m_end_pos.BezierCurve.EditorVisible)
					{
						action.m_end_pos.BezierCurve.OnSceneGUI(position_offset, font_manager.Scale);
						
						if(!edit_detected && GUI.changed)
						{
							edit_detected = true;
							
							edited_action = action_idx;
							start_end_state = 1;
						}
					}
					
					action_idx++;
				}
			}
			
			if(edit_detected)
			{
				font_manager.SetAnimationState(edited_action, start_end_state, true);
			}
		}
Example #5
0
		// Animates the letter mesh and return the current action index in use
		public LETTER_ANIMATION_STATE AnimateMesh(	bool force_render,
													float timer,
													TextAnchor text_anchor,
													int lowest_action_progress,
													LetterAnimation animation,
													AnimatePerOptions animate_per,
													float delta_time,
													EffectManager effect_manager)
		{
			
			m_last_animate_per = animate_per;
			m_effect_manager_handle = effect_manager;
			
			if(animation.NumActions > 0 && m_anim_state_vars.m_action_index < animation.NumActions)
			{
				if(!m_anim_state_vars.m_active && !force_render)
				{
					return LETTER_ANIMATION_STATE.STOPPED;
				}
				
				if(m_anim_state_vars.m_action_index != m_anim_state_vars.m_prev_action_index)
				{
					SetCurrentLetterAction(animation.GetAction(m_anim_state_vars.m_action_index), animate_per);
					
					m_anim_state_vars.m_started_action = false;
				}
				else if(m_current_letter_action == null)
				{
					SetCurrentLetterAction(animation.GetAction(m_anim_state_vars.m_action_index), animate_per);
				}
				
				m_anim_state_vars.m_prev_action_index = m_anim_state_vars.m_action_index;
				
				if(force_render)
				{
					SetupMesh(m_current_letter_action, m_anim_state_vars.m_action_index > 0 ? animation.GetAction(m_anim_state_vars.m_action_index-1) : null, m_anim_state_vars.m_action_progress, m_progression_variables, animate_per, m_anim_state_vars.m_linear_progress, m_effect_manager_handle);
				}
				
				if(m_anim_state_vars.m_waiting_to_sync)
				{
					if(m_current_letter_action.m_action_type == ACTION_TYPE.BREAK)
					{
						if(!force_render && m_anim_state_vars.m_break_delay > 0)
						{
							m_anim_state_vars.m_break_delay -= delta_time;
							
							if(m_anim_state_vars.m_break_delay <= 0)
							{
								ContinueAction(timer, animation, animate_per);
								
								return LETTER_ANIMATION_STATE.PLAYING;
							}
						}
						
						return LETTER_ANIMATION_STATE.WAITING;
					}
					else if(lowest_action_progress < m_anim_state_vars.m_action_index_progress)
					{
						return LETTER_ANIMATION_STATE.PLAYING;
					}
					else if(!force_render)
					{
						m_anim_state_vars.m_waiting_to_sync = false;
						
						// reset timer offset to compensate for the sync-up wait time
						m_anim_state_vars.m_timer_offset = timer;
					}
				}
				else if(!force_render && (m_current_letter_action.m_action_type == ACTION_TYPE.BREAK || (!m_anim_state_vars.m_reverse && m_current_letter_action.m_force_same_start_time && lowest_action_progress < m_anim_state_vars.m_action_index_progress)))
				{
					// Force letter to wait for rest of letters to be in sync
					m_anim_state_vars.m_waiting_to_sync = true;
					
					m_anim_state_vars.m_break_delay = Mathf.Max(m_current_letter_action.m_duration_progression.GetValue(m_progression_variables, animate_per), 0);
					
					return LETTER_ANIMATION_STATE.PLAYING;
				}
				
				
				if(force_render)
				{
					return m_anim_state_vars.m_active ? LETTER_ANIMATION_STATE.PLAYING : LETTER_ANIMATION_STATE.STOPPED;
				}
				
				m_anim_state_vars.m_action_progress = 0;
				m_anim_state_vars.m_linear_progress = 0;
				
				m_action_timer = timer - m_anim_state_vars.m_timer_offset;
				
				if((m_anim_state_vars.m_reverse || m_action_timer > m_action_delay))
				{
					m_anim_state_vars.m_linear_progress = (m_action_timer - (m_anim_state_vars.m_reverse ? 0 : m_action_delay)) / m_action_duration;
					
					if(m_anim_state_vars.m_reverse)
					{
						if(m_action_timer >= m_action_duration)
						{
							m_anim_state_vars.m_linear_progress = 0;
						}
						else
						{
							m_anim_state_vars.m_linear_progress = 1 - m_anim_state_vars.m_linear_progress;
						}
					}
					
					
					if(!m_anim_state_vars.m_started_action)
					{
						// Trigger any action onStart audio or particle effects
						
						TriggerAudioEffect(animate_per, PLAY_ITEM_EVENTS.ON_START);
						
						TriggerParticleEffects(animate_per, PLAY_ITEM_EVENTS.ON_START);
						
						m_anim_state_vars.m_started_action = true;
					}
					
					
					m_anim_state_vars.m_action_progress = EasingManager.GetEaseProgress(m_current_letter_action.m_ease_type, m_anim_state_vars.m_linear_progress);
					
					if((!m_anim_state_vars.m_reverse && m_anim_state_vars.m_linear_progress >= 1) || (m_anim_state_vars.m_reverse && m_action_timer >= m_action_duration + m_action_delay))
					{
						m_anim_state_vars.m_action_progress = m_anim_state_vars.m_reverse ? 0 : 1;
						m_anim_state_vars.m_linear_progress = m_anim_state_vars.m_reverse ? 0 : 1;
						
						if(!m_anim_state_vars.m_reverse && m_anim_state_vars.m_action_index != -1)
						{
							TriggerParticleEffects(animate_per, PLAY_ITEM_EVENTS.ON_FINISH);
							
							TriggerAudioEffect(animate_per, PLAY_ITEM_EVENTS.ON_FINISH);
						}
						
						int prev_action_idx = m_anim_state_vars.m_action_index;
						float prev_delay = m_action_delay;
						
						// Set next action index
						SetNextActionIndex(animation);
						
						if(m_anim_state_vars.m_active)
						{
							if(!m_anim_state_vars.m_reverse)
							{
								m_anim_state_vars.m_started_action = false;
							}
							
							if(!m_anim_state_vars.m_reverse && m_anim_state_vars.m_action_index_progress > m_anim_state_vars.m_action_index)
							{
								// Repeating the action again; check for unqiue random variable requests.
								animation.GetAction(m_anim_state_vars.m_action_index).SoftReset(animation.GetAction(prev_action_idx), m_progression_variables, animate_per, m_anim_state_vars.m_action_index == 0);
							}
							else if(m_anim_state_vars.m_reverse)
							{
								animation.GetAction(m_anim_state_vars.m_action_index).SoftResetStarts(animation.GetAction(prev_action_idx), m_progression_variables, animate_per);
							}
							
							// Add to the timer offset
							m_anim_state_vars.m_timer_offset += prev_delay + m_action_duration;
							
							if(prev_action_idx != m_anim_state_vars.m_action_index)
							{
								UpdateLoopList(animation);
							}
							else
							{
								SetCurrentLetterAction(animation.GetAction(m_anim_state_vars.m_action_index), animate_per);
							}
						}
					}
				}
				
				SetupMesh(m_current_letter_action, m_anim_state_vars.m_action_index > 0 ? animation.GetAction(m_anim_state_vars.m_action_index-1) : null, m_anim_state_vars.m_action_progress, m_progression_variables, animate_per, m_anim_state_vars.m_linear_progress, m_effect_manager_handle);
			}
			else
			{
				// no actions found for this letter. Position letter in its default position
				if(mesh_verts == null || mesh_verts.Length == 0)
					mesh_verts = new Vector3[4];
				
				for(int idx=0; idx < 4; idx++)
				{
					mesh_verts[idx] = m_base_vertices[idx] + m_base_offset;
				}
				m_mesh.vertices = mesh_verts;
				
				m_anim_state_vars.m_active = false;
			}
			
			return m_anim_state_vars.m_active ? LETTER_ANIMATION_STATE.PLAYING : LETTER_ANIMATION_STATE.STOPPED;
		}
Example #6
0
		void SetupMesh(LetterAction letter_action, LetterAction prev_action, float action_progress, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress, EffectManager effect_manager)
		{	
			// construct current anchor offset vector
			m_anchor_offset = letter_action.AnchorOffsetStart;
			m_anchor_offset = new Vector3(	m_anchor_offset.x * m_width, 
											letter_action.m_letter_anchor_start == (int) TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_start == (int) TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_start == (int) TextfxTextAnchor.BaselineRight 
												? 0		// zero because letters are based around the baseline already.
												: (effect_manager.IsFontBaseLineSet 
														? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height)
														: (m_anchor_offset.y * m_height)),	// Legacy effect support when baseline isn't already set.
											0);
			
			if(letter_action.m_letter_anchor_2_way)
			{
				m_anchor_offset = letter_action.AnchorOffsetEnd;
				m_anchor_offset = Vector3.Lerp(	m_anchor_offset,
												new Vector3(
													m_anchor_offset.x * m_width,
													letter_action.m_letter_anchor_end == (int) TextfxTextAnchor.BaselineLeft || letter_action.m_letter_anchor_end == (int) TextfxTextAnchor.BaselineCenter || letter_action.m_letter_anchor_end == (int) TextfxTextAnchor.BaselineRight
														? 0		// zero because letters are based around the baseline already.
														: (effect_manager.IsFontBaseLineSet
																? (effect_manager.FontBaseLine + m_y_offset) - (m_anchor_offset.y * -m_height)
																: (m_anchor_offset.y * m_height)),	// Legacy effect support when baseline isn't already set.
													0),
												action_progress);
			}
			
			
			// Calculate Scale Vector
			from_vec = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
			to_vec = letter_action.m_end_scale.GetValue(progression_variables, animate_per);
			
			if(letter_action.m_scale_axis_ease_data.m_override_default)
			{
				m_letter_scale = new Vector3(	EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
												EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
												EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress)));
			}
			else
			{
				m_letter_scale = EffectManager.Vector3Lerp(
												from_vec,
												to_vec,
												action_progress);
			}
			
			// Calculate Rotation
			from_vec = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
			to_vec = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);
			
			if(letter_action.m_rotation_axis_ease_data.m_override_default)
			{
				m_letter_rotation =	Quaternion.Euler
									(
										EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
										EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
										EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
									);
			}
			else
			{
				m_letter_rotation = Quaternion.Euler(
											EffectManager.Vector3Lerp(
												from_vec,
												to_vec,
												action_progress)
											);
			}
			
			
			// Calculate Position
			if(letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_offset_from_last && prev_action != null && prev_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
				from_vec = new Vector3(-m_anchor_offset.x,m_base_offset.y,0);
			else if(letter_action.m_start_pos.ForcePositionOverride)
				from_vec = new Vector3(-m_anchor_offset.x,0,0);
			else
				from_vec = BaseOffset;
			
			from_vec += letter_action.m_start_pos.GetValue(progression_variables, animate_per);
			
			if(letter_action.m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX || (letter_action.m_end_pos.IsOffsetFromLast && letter_action.m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX))
				to_vec = new Vector3(-m_anchor_offset.x,m_base_offset.y,0);
			else if(letter_action.m_end_pos.ForcePositionOverride)
				to_vec = new Vector3(-m_anchor_offset.x,0,0);
			else
				to_vec = BaseOffset;
			
			to_vec += letter_action.m_end_pos.GetValue(progression_variables, animate_per);
			
			if(letter_action.m_position_axis_ease_data.m_override_default)
			{
				m_letter_position = new Vector3(	EffectManager.FloatLerp(from_vec.x, to_vec.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
													EffectManager.FloatLerp(from_vec.y, to_vec.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
													EffectManager.FloatLerp(from_vec.z, to_vec.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
			}
			else
			{
				m_letter_position = EffectManager.Vector3Lerp(
					from_vec, 
					to_vec,
					action_progress);
			}
			
			// Calculate letter center position
			m_letter_center = new Vector3(m_width / 2, m_height/2, 0);
			m_letter_center -= m_anchor_offset;
			m_letter_center = Vector3.Scale(m_letter_center, m_letter_scale);
			m_letter_center = m_letter_rotation	* m_letter_center;
			m_letter_center += m_anchor_offset + m_letter_position;
			
			
			if(mesh_verts == null || mesh_verts.Length == 0)
				mesh_verts = new Vector3[4];
			for(int idx=0; idx < 4; idx++)
			{
				mesh_verts[idx] = m_base_vertices[idx];
				
				// normalise vert position to the anchor point before scaling and rotating.
				mesh_verts[idx] -= m_anchor_offset;
				
				// Scale verts
				mesh_verts[idx] = Vector3.Scale(mesh_verts[idx], m_letter_scale);
				
				// Rotate vert
				mesh_verts[idx] = m_letter_rotation	* mesh_verts[idx];
				
				mesh_verts[idx] += m_anchor_offset;
				
				// translate vert
				mesh_verts[idx] += m_letter_position;
			}
			m_mesh.vertices = mesh_verts;
			
			
			
			// Sort out letters colour
			if(letter_action.m_use_gradient_start)
			{
				start_colour = letter_action.m_start_vertex_colour.GetValue(progression_variables, animate_per);
			}
			else
			{
				start_colour = new VertexColour(letter_action.m_start_colour.GetValue(progression_variables, animate_per));
			}
			
			if(letter_action.m_use_gradient_end)
			{
				end_colour = letter_action.m_end_vertex_colour.GetValue(progression_variables, animate_per);
			}
			else
			{
				end_colour = new VertexColour(letter_action.m_end_colour.GetValue(progression_variables, animate_per));
			}
			
			if(!m_flipped)
			{
				m_mesh.colors = new Color[]{ 
					Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress), 
					Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress), 
					Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress), 
					Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress)};
			}
			else
			{
				m_mesh.colors = new Color[]{
					Color.Lerp(start_colour.top_left, end_colour.top_left, action_progress),
					Color.Lerp(start_colour.bottom_left, end_colour.bottom_left, action_progress),
					Color.Lerp(start_colour.bottom_right, end_colour.bottom_right, action_progress),
					Color.Lerp(start_colour.top_right, end_colour.top_right, action_progress)
				};
			}
		}
Example #7
0
		public void SetMeshState(int action_idx, float action_progress, LetterAnimation animation, AnimatePerOptions animate_per, EffectManager effect_manager)
		{
			if(action_idx >= 0 && action_idx < animation.NumActions)
			{
				SetupMesh(animation.GetAction(action_idx), action_idx > 0 ? animation.GetAction(action_idx-1) : null, Mathf.Clamp(action_progress, 0,1), m_progression_variables, animate_per, Mathf.Clamp(action_progress, 0,1), effect_manager);
			}
			else
			{
				// action not found for this letter. Position letter in its default position
				
				if(mesh_verts == null || mesh_verts.Length == 0)
					mesh_verts = new Vector3[4];
				
				for(int idx=0; idx < 4; idx++)
				{
					mesh_verts[idx] = m_base_vertices[idx] + m_base_offset;
				}
				m_mesh.vertices = mesh_verts;
				m_mesh.colors = new Color[]{Color.white, Color.white, Color.white, Color.white};
			}
		}
Example #8
0
		public void Init(EffectManager effect_manager)
		{
			if(m_mesh != null)
				mesh_verts = m_mesh.vertices;
			
			m_effect_manager_handle = effect_manager;
			
			// Set default values
			if(mesh_verts != null && mesh_verts.Length == 4)
			{
				m_letter_center = (mesh_verts[0] + mesh_verts[1] + mesh_verts[2] + mesh_verts[3]) / 4;
			}
			
			m_letter_scale = Vector3.one;
			m_letter_rotation = Quaternion.identity;
		}
Example #9
0
		public void Recycle(string character, int letter_idx, Mesh mesh, Vector3 base_offset, ref CustomCharacterInfo char_info, int line_num, int word_idx, EffectManager effect_manager)
		{
			m_character = character;
			m_mesh = mesh;
			m_base_offset = base_offset;
			m_effect_manager_handle = effect_manager;
			
			m_progression_variables = new AnimationProgressionVariables(letter_idx, word_idx, line_num);
			
			SetupLetterMesh(ref char_info);
			
			if(m_flipped)
			{
				// flip UV coords in x axis.
				m_mesh.uv = new Vector2[] {mesh.uv[3], mesh.uv[2], mesh.uv[1], mesh.uv[0]};
			}
			
			m_current_letter_action = null;
		}
Example #10
0
		public LetterSetup(string character, int letter_idx, Mesh mesh, Vector3 base_offset, ref CustomCharacterInfo char_info, int line_num, int word_idx, EffectManager effect_manager)
		{
			m_character = character;
			m_mesh = mesh;
			m_base_offset = base_offset;
			m_effect_manager_handle = effect_manager;
			
			m_progression_variables = new AnimationProgressionVariables(letter_idx, word_idx, line_num);
			
			m_anim_state_vars = new AnimationStateVariables();
			m_anim_state_vars.m_active_loop_cycles = new List<ActionLoopCycle>();
			
			SetupLetterMesh(ref char_info);
			
			if(m_flipped)
			{
				// flip UV coords in x axis.
				m_mesh.uv = new Vector2[] {mesh.uv[3], mesh.uv[2], mesh.uv[1], mesh.uv[0]};
			}
		}
		void DrawGUIWindow(out int edited_action, out bool start_of_action)
		{
			// Set out parameters to a default value
			start_of_action = true;
			edited_action= -1;
			
			// Check whether a EffectManager object is selected
			if(Selection.gameObjects.Length == 1)
			{
				font_manager = Selection.gameObjects[0].GetComponent<EffectManager>();
			}
			
			if(font_manager == null)
			{
				return;
			}
			
			DrawEffectEditorPanel();
			
			if(!ignore_gui_change)
			{
				start_of_action = editing_start_state;
				edited_action = edited_action_idx;
			}
				
			return;
		}