public void ImportData(JSONObject jsonData) { m_setting_name = jsonData ["name"].Str; m_data_type = (ANIMATION_DATA_TYPE)((int)jsonData ["data_type"].Number); m_animation_idx = (int)jsonData ["anim_idx"].Number; m_action_idx = (int)jsonData ["action_idx"].Number; if (jsonData.ContainsKey("startState")) { m_startState = jsonData["startState"].Boolean; } }
ActionFloatProgression GetFloatVariable(ANIMATION_DATA_TYPE type, LetterAction letterAction) { switch (type) { case ANIMATION_DATA_TYPE.DURATION: return(letterAction.m_duration_progression); case ANIMATION_DATA_TYPE.DELAY: return(letterAction.m_delay_progression); default: return(null); } }
ActionVector3Progression GetVector3Variable(ANIMATION_DATA_TYPE type, LetterAction letterAction) { switch (type) { case ANIMATION_DATA_TYPE.GLOBAL_ROTATION: return(m_startState ? letterAction.m_global_start_euler_rotation : letterAction.m_global_end_euler_rotation); case ANIMATION_DATA_TYPE.LOCAL_ROTATION: return(m_startState ? letterAction.m_start_euler_rotation : letterAction.m_end_euler_rotation); case ANIMATION_DATA_TYPE.POSITION: return(m_startState ? letterAction.m_start_pos : letterAction.m_end_pos); case ANIMATION_DATA_TYPE.GLOBAL_SCALE: return(m_startState ? letterAction.m_global_start_scale : letterAction.m_global_end_scale); case ANIMATION_DATA_TYPE.LOCAL_SCALE: return(m_startState ? letterAction.m_start_scale : letterAction.m_end_scale); default: return(null); } }
public void PrepareData(TextFxAnimationManager anim_manager, LetterSetup[] letters, ANIMATION_DATA_TYPE what_to_update, int num_words, int num_lines, AnimatePerOptions animate_per) { if (letters == null || letters.Length == 0) { return; } if (m_letters_to_animate == null || what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.ANIMATE_ON) { CalculateLettersToAnimate(letters); } if (what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.COLOUR || m_defaultTextColourProgression == null) { // Set values for default text colour progression VertexColour[] defaultextColours = new VertexColour[m_letters_to_animate.Count]; for (int idx = 0; idx < m_letters_to_animate.Count; idx++) { defaultextColours[idx] = letters[m_letters_to_animate[idx]].BaseColour; } m_defaultTextColourProgression.SetValues(defaultextColours); // Mark as the default colour progression m_defaultTextColourProgression.SetReferenceData(-1, ANIMATION_DATA_TYPE.COLOUR, true); } // Prepare progression data in all actions LetterAction letter_action; LetterAction prev_action = null; bool prev_action_end_state = true; for (int action_idx = 0; action_idx < m_letter_actions.Count; action_idx++) { letter_action = m_letter_actions[action_idx]; letter_action.PrepareData(anim_manager, ref letters, this, action_idx, what_to_update, m_letters_to_animate.Count, m_num_white_space_chars_to_include, num_words, num_lines, prev_action, animate_per, m_defaultTextColourProgression, prev_action_end_state); if (letter_action.m_action_type == ACTION_TYPE.ANIM_SEQUENCE) { // Set default previous action settings prev_action_end_state = true; prev_action = letter_action; } // Check for reverse loops, and how the animation should progress from there foreach (ActionLoopCycle loop_cycle in m_loop_cycles) { if (loop_cycle.m_end_action_idx == action_idx && loop_cycle.m_loop_type == LOOP_TYPE.LOOP_REVERSE && !loop_cycle.m_finish_at_end) { prev_action = m_letter_actions[loop_cycle.m_start_action_idx]; prev_action_end_state = false; } } } }
public void PrepareData(TextFxAnimationManager anim_manager, ref LetterSetup[] letters, LetterAnimation animation_ref, int action_idx, ANIMATION_DATA_TYPE what_to_update, int num_letters, int num_white_space_chars_to_include, int num_words, int num_lines, LetterAction prev_action, AnimatePerOptions animate_per, ActionColorProgression defaultTextColour, bool prev_action_end_state = true) { // Set progression reference datas m_start_colour.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.COLOUR, true); m_start_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_ROTATION, true); m_start_pos.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.POSITION, true); m_start_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_SCALE, true); m_global_start_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_ROTATION, true); m_global_start_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_SCALE, true); m_end_colour.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.COLOUR, false); m_end_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_ROTATION, false); m_end_pos.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.POSITION, false); m_end_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.LOCAL_SCALE, false); m_global_end_euler_rotation.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_ROTATION, false); m_global_end_scale.SetReferenceData(action_idx, ANIMATION_DATA_TYPE.GLOBAL_SCALE, false); // Prepare Data if(what_to_update == ANIMATION_DATA_TYPE.DURATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_duration_progression.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_duration_progression.AnimatePer, m_duration_progression.OverrideAnimatePerOption)); if((what_to_update == ANIMATION_DATA_TYPE.AUDIO_EFFECTS || what_to_update == ANIMATION_DATA_TYPE.ALL) && m_audio_effects != null) { foreach(AudioEffectSetup effect_setup in m_audio_effects) { effect_setup.m_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_delay.AnimatePer, effect_setup.m_delay.OverrideAnimatePerOption)); effect_setup.m_offset_time.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_offset_time.AnimatePer, effect_setup.m_offset_time.OverrideAnimatePerOption)); effect_setup.m_volume.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_volume.AnimatePer, effect_setup.m_volume.OverrideAnimatePerOption)); effect_setup.m_pitch.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_pitch.AnimatePer, effect_setup.m_pitch.OverrideAnimatePerOption)); } } if((what_to_update == ANIMATION_DATA_TYPE.PARTICLE_EFFECTS || what_to_update == ANIMATION_DATA_TYPE.ALL) && m_particle_effects != null) { foreach(ParticleEffectSetup effect_setup in m_particle_effects) { effect_setup.m_position_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_position_offset.AnimatePer, effect_setup.m_position_offset.OverrideAnimatePerOption), null); effect_setup.m_rotation_offset.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_rotation_offset.AnimatePer, effect_setup.m_rotation_offset.OverrideAnimatePerOption), null); effect_setup.m_delay.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_delay.AnimatePer, effect_setup.m_delay.OverrideAnimatePerOption)); effect_setup.m_duration.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, effect_setup.m_duration.AnimatePer, effect_setup.m_duration.OverrideAnimatePerOption)); } } if(m_action_type == ACTION_TYPE.BREAK) { if(prev_action != null) { m_start_colour.SetValueReference(prev_action_end_state ? prev_action.m_end_colour : prev_action.m_start_colour); m_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_end_euler_rotation : prev_action.m_start_euler_rotation ); m_start_pos.SetValueReference( prev_action_end_state ? prev_action.m_end_pos : prev_action.m_start_pos ); m_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_end_scale : prev_action.m_start_scale ); m_global_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_global_end_euler_rotation : prev_action.m_global_start_euler_rotation ); m_global_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_global_end_scale : prev_action.m_global_start_scale ); } m_end_colour.SetValueReference(m_start_colour); m_end_euler_rotation.SetValueReference(m_start_euler_rotation ); m_end_pos.SetValueReference( prev_action.m_start_pos ); m_end_scale.SetValueReference( prev_action.m_start_scale ); m_global_end_euler_rotation.SetValueReference(prev_action.m_global_start_euler_rotation ); m_global_end_scale.SetValueReference( prev_action.m_global_start_scale ); return; } if (animation_ref.m_letters_to_animate_option != LETTERS_TO_ANIMATE.ALL_LETTERS || (((ValueProgression)m_delay_progression.Progression) != ValueProgression.Eased && ((ValueProgression)m_delay_progression.Progression) != ValueProgression.EasedCustom)) m_delay_with_white_space_influence = false; if(what_to_update == ANIMATION_DATA_TYPE.DELAY || what_to_update == ANIMATION_DATA_TYPE.ALL) m_delay_progression.CalculateProgressions(GetProgressionTotal(num_letters + (m_delay_with_white_space_influence ? num_white_space_chars_to_include : 0), num_words, num_lines, animate_per, m_delay_progression.AnimatePer, m_delay_progression.OverrideAnimatePerOption)); if(what_to_update == ANIMATION_DATA_TYPE.COLOUR || what_to_update == ANIMATION_DATA_TYPE.ALL) { if(m_offset_from_last && prev_action != null) { m_start_colour.SetValueReference(prev_action_end_state ? prev_action.m_end_colour : prev_action.m_start_colour ); } else { m_start_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_start_colour.AnimatePer, m_start_colour.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_colour : defaultTextColour, prev_action == null || m_colour_transition_active); } m_end_colour.CalculateProgressions(GetProgressionTotal(num_letters, num_words, num_lines, animate_per, m_end_colour.AnimatePer, m_end_colour.OverrideAnimatePerOption), m_start_colour, prev_action == null || m_colour_transition_active); } if(m_offset_from_last && prev_action != null) { if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_pos.SetValueReference( prev_action_end_state ? prev_action.m_end_pos : prev_action.m_start_pos ); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_end_euler_rotation : prev_action.m_start_euler_rotation ); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_end_scale : prev_action.m_start_scale ); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_euler_rotation.SetValueReference( prev_action_end_state ? prev_action.m_global_end_euler_rotation : prev_action.m_global_start_euler_rotation ); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_scale.SetValueReference( prev_action_end_state ? prev_action.m_global_end_scale : prev_action.m_global_start_scale ); } else { float[] start_pos_curve_letter_progressions = null; if( ( what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL ) && m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX) { // Pre calculate letter progression values based on letter spacing start_pos_curve_letter_progressions = m_start_pos.BezierCurve.GetLetterProgressions(anim_manager, ref letters, m_letter_anchor_start); } if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_pos.CalculatePositionProgressions( anim_manager, animation_ref, ref start_pos_curve_letter_progressions, letters, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_pos.AnimatePer, m_start_pos.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_pos : null, prev_action == null || m_position_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_euler_rotation.AnimatePer, m_start_euler_rotation.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_euler_rotation : null, m_start_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_start_pos.BezierCurve : null, prev_action == null || m_local_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_start_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_start_scale.AnimatePer, m_start_scale.OverrideAnimatePerOption), prev_action != null ? prev_action.m_end_scale : null, prev_action == null || m_local_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_euler_rotation.CalculateRotationProgressions(ref start_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_start_euler_rotation.AnimatePer, m_global_start_euler_rotation.OverrideAnimatePerOption), prev_action != null ? prev_action.m_global_end_euler_rotation : null, null, prev_action == null || m_global_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_start_scale.CalculateProgressions( GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_start_scale.AnimatePer, m_global_start_scale.OverrideAnimatePerOption), prev_action != null ? prev_action.m_global_end_scale : null, prev_action == null || m_global_scale_transition_active); } float[] end_pos_curve_letter_progressions = null; if( ( what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL ) && m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX) { // Pre calculate letter progression values based on letter spacing end_pos_curve_letter_progressions = m_end_pos.BezierCurve.GetLetterProgressions(anim_manager, ref letters, m_letter_anchor_end); } if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_pos.CalculatePositionProgressions(anim_manager, animation_ref, ref end_pos_curve_letter_progressions, letters, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_pos.AnimatePer, m_end_pos.OverrideAnimatePerOption), m_start_pos, prev_action == null || m_position_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_euler_rotation.AnimatePer, m_end_euler_rotation.OverrideAnimatePerOption), m_start_euler_rotation, m_end_pos.Progression == ActionPositionVector3Progression.CURVE_OPTION_INDEX ? m_end_pos.BezierCurve : null, prev_action == null || m_local_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.LOCAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_end_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_end_scale.AnimatePer, m_end_scale.OverrideAnimatePerOption), m_start_scale, prev_action == null || m_local_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_ROTATION || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_end_euler_rotation.CalculateRotationProgressions(ref end_pos_curve_letter_progressions, GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_end_euler_rotation.AnimatePer, m_global_end_euler_rotation.OverrideAnimatePerOption), m_global_start_euler_rotation, null, prev_action == null || m_global_rotation_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.GLOBAL_SCALE || what_to_update == ANIMATION_DATA_TYPE.ALL) m_global_end_scale.CalculateProgressions(GetProgressionTotal(num_letters + num_white_space_chars_to_include, num_words, num_lines, animate_per, m_global_end_scale.AnimatePer, m_global_end_scale.OverrideAnimatePerOption), m_global_start_scale, prev_action == null || m_global_scale_transition_active); if(what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.POSITION || what_to_update == ANIMATION_DATA_TYPE.LETTER_ANCHOR || what_to_update == ANIMATION_DATA_TYPE.ALL) CalculateLetterAnchorOffset(); }
public void SetReferenceData(int actionIdx, ANIMATION_DATA_TYPE data_type, bool startState) { m_reference_data.m_action_index = actionIdx; m_reference_data.m_data_type = data_type; m_reference_data.m_start_state = startState; }
public bool UpdateMesh(bool use_timer, bool force_render, int action_idx, float action_progress, float delta_time = 0) { bool all_letter_anims_finished = true; if(m_current_mesh_verts == null || m_current_mesh_verts.Length != m_num_meshes * 4) { m_current_mesh_verts = new Vector3[m_num_meshes * 4]; m_current_mesh_colours = new Color[m_num_meshes * 4]; // Initialise values Vector3[] base_verts; int mesh_idx = 0; for (int letter_idx = 0; letter_idx < m_letters.Length; letter_idx++) { if(!m_letters[letter_idx].StubInstance) { base_verts = m_letters[letter_idx].BaseVertices; m_current_mesh_verts[mesh_idx * 4] = base_verts[0]; m_current_mesh_verts[mesh_idx * 4 + 1] = base_verts[1]; m_current_mesh_verts[mesh_idx * 4 + 2] = base_verts[2]; m_current_mesh_verts[mesh_idx * 4 + 3] = base_verts[3]; m_current_mesh_colours[mesh_idx * 4] = Color.white; m_current_mesh_colours[mesh_idx * 4 + 1] = Color.white; m_current_mesh_colours[mesh_idx * 4 + 2] = Color.white; m_current_mesh_colours[mesh_idx * 4 + 3] = Color.white; mesh_idx++; } } } LetterSetup letter_setup; if(m_master_animations != null) { bool all_letter_anims_waiting; bool all_letter_anims_waiting_infinitely; bool all_letter_anims_continuing_finished; int lowest_action_progress = -1; int last_letter_idx; foreach(LetterAnimation animation in m_master_animations) { last_letter_idx = -1; all_letter_anims_waiting = true; all_letter_anims_waiting_infinitely = true; all_letter_anims_continuing_finished = true; foreach(int letter_idx in animation.m_letters_to_animate) { // two of the same letter index next to each other. Or idx out of bounds. if(letter_idx == last_letter_idx || letter_idx >= m_letters.Length) { continue; } letter_setup = m_letters[letter_idx]; if(lowest_action_progress == -1 || letter_setup.ActionProgress < lowest_action_progress) { lowest_action_progress = letter_setup.ActionProgress; } // Initialise values with exisiting mesh data Vector3[] letter_verts = new Vector3[]{ m_current_mesh_verts[letter_setup.MeshIndex*4], m_current_mesh_verts[letter_setup.MeshIndex*4 + 1], m_current_mesh_verts[letter_setup.MeshIndex*4 + 2], m_current_mesh_verts[letter_setup.MeshIndex*4 + 3]}; Color[] letter_colours = new Color[]{ m_current_mesh_colours[letter_setup.MeshIndex*4], m_current_mesh_colours[letter_setup.MeshIndex*4 + 1], m_current_mesh_colours[letter_setup.MeshIndex*4 + 2], m_current_mesh_colours[letter_setup.MeshIndex*4 + 3]}; if(use_timer) { letter_setup.AnimateMesh(this, force_render, m_animation_timer, m_lowest_action_progress, animation, m_animate_per, delta_time, ref letter_verts, ref letter_colours); LETTER_ANIMATION_STATE anim_state = letter_setup.CurrentAnimationState; if(anim_state != LETTER_ANIMATION_STATE.CONTINUING_FINISHED) all_letter_anims_continuing_finished = false; if(anim_state == LETTER_ANIMATION_STATE.STOPPED) { lowest_action_progress = letter_setup.ActionProgress; } else { all_letter_anims_finished = false; } if(anim_state != LETTER_ANIMATION_STATE.WAITING_INFINITE) { all_letter_anims_waiting_infinitely = false; } if(anim_state != LETTER_ANIMATION_STATE.WAITING && anim_state != LETTER_ANIMATION_STATE.WAITING_INFINITE) { all_letter_anims_waiting = false; } } else { letter_setup.SetMeshState(this, Mathf.Clamp(action_idx, 0, animation.NumActions-1), action_progress, animation, m_animate_per, ref letter_verts, ref letter_colours); } // Update the verts for this letter for(int idx=0; idx < 4; idx++) m_current_mesh_verts[letter_setup.MeshIndex*4 + idx] = letter_verts[idx]; // m_colourVertMapping = new int[]{1,0,3,2}; // Set Colours for(int idx=0; idx < 4; idx++) m_current_mesh_colours[letter_setup.MeshIndex*4 + idx] = letter_colours[m_colourVertMapping[idx]]; last_letter_idx = letter_idx; } // Set animation state if(animation.m_letters_to_animate.Count > 0) { if(use_timer) { if(animation.CurrentAnimationState == LETTER_ANIMATION_STATE.CONTINUING) { if(all_letter_anims_continuing_finished) { animation.CurrentAnimationState = LETTER_ANIMATION_STATE.PLAYING; m_runtime_animation_speed_factor = 1; // Set all letters to PLAYING state foreach(int letter_idx in animation.m_letters_to_animate) { m_letters[letter_idx].SetPlayingState(); } // Important to update the lowest action progress to the same consistent value, so that subsequent ForceSameStart actions will work properly m_lowest_action_progress = m_letters[0].ActionProgress; // Fire off callback if(m_animation_continue_callback != null) m_animation_continue_callback(m_letters[0].ActionIndex); m_animation_continue_callback = null; } } else if(all_letter_anims_waiting_infinitely) animation.CurrentAnimationState = LETTER_ANIMATION_STATE.WAITING_INFINITE; else if(all_letter_anims_waiting) animation.CurrentAnimationState = LETTER_ANIMATION_STATE.WAITING; else if(!all_letter_anims_finished) animation.CurrentAnimationState = LETTER_ANIMATION_STATE.PLAYING; } } else { // No letters in this animation, so mark as STOPPED animation.CurrentAnimationState = LETTER_ANIMATION_STATE.STOPPED; } if(lowest_action_progress > m_lowest_action_progress) { m_lowest_action_progress = lowest_action_progress; } } } m_what_just_changed = ANIMATION_DATA_TYPE.NONE; return all_letter_anims_finished; }
public void SetAnimationState(int action_idx, float action_progress, bool update_action_values = false, ANIMATION_DATA_TYPE edited_data = ANIMATION_DATA_TYPE.ALL, bool update_mesh = false) { if(update_action_values) { // Calculate action progression values PrepareAnimationData(edited_data); } UpdateMesh(false, true, action_idx, action_progress); if(update_mesh) { m_animation_interface_reference.UpdateTextFxMesh( MeshVerts, MeshColours); } }
// Calculates values for all animation state progressions using current field values. public void PrepareAnimationData(ANIMATION_DATA_TYPE what_to_update = ANIMATION_DATA_TYPE.ALL) { // Debug.Log ("PrepareAnimationData () " + what_to_update); if(m_master_animations != null) { foreach(LetterAnimation animation in m_master_animations) { animation.PrepareData(this, m_letters, what_to_update, 1, 1, m_animate_per); // Requires info about number letters, words, lines etc } if(Playing) { m_what_just_changed = what_to_update; } } }
void AnimationSectionSet(TextFxAnimationManager.PRESET_ANIMATION_SECTION section, int animIndex, bool restartAnimation = false) { if (m_activeSectionIndex >= 0 && m_activeSectionIndex != (int)section) { CloseAnimationSection(m_activeSectionIndex); } // Disable any previous setting section objects for this animaction Section RecycleSectionSettingComponents((int)section); m_floatVariableSettingsInUse[(int)section] = new List <FloatVariableSetting>(); m_vector3VariableSettingsInUse[(int)section] = new List <Vector3VariableSetting>(); m_toggleVariableSettingsInUse[(int)section] = new List <ToggleVariableSetting>(); m_colourVariableSettingsInUse[(int)section] = new List <ColourVariableSetting>(); // Setup the animation section on the effect instance m_effect.AnimationManager.SetQuickSetupSection(section, m_animSectionDropdowns[(int)section].options[animIndex].text, forceClearOldAudioParticles: false); // Set the section as focused/selected if (m_activeSectionIndex >= 0) { m_sectionHeaderImages[m_activeSectionIndex].color = SECTION_ACTIVE_COLOUR; } if (animIndex > 0) { m_sectionHeaderImages[(int)section].color = SECTION_SELECTED_COLOUR; m_activeSectionIndex = (int)section; m_sectionsActive[m_activeSectionIndex] = true; } else { m_sectionHeaderImages[(int)section].color = SECTION_INACTIVE_COLOUR; m_sectionsActive[(int)section] = false; if (m_activeSectionIndex >= 0) { if (m_activeSectionIndex == (int)section) { m_activeSectionIndex = -1; } } } TextFxAnimationManager.PresetAnimationSection animation_section = m_animationSections[(int)section]; int sectionSiblingIndexOffset = m_animSectionTransforms[(int)section].GetSiblingIndex(); int settingIdx = 0; RectTransform settingTransform; foreach (PresetEffectSetting effectSetting in animation_section.m_preset_effect_settings) { settingTransform = null; switch (effectSetting.m_data_type) { case ANIMATION_DATA_TYPE.DELAY: case ANIMATION_DATA_TYPE.DURATION: // Grab a float variable component FloatVariableSetting floatVarSetting = m_floatVariableSettingsPool.GetObject(); m_floatVariableSettingsInUse[(int)section].Add(floatVarSetting); floatVarSetting.transform.SetParent(m_menuSectionsContainer); ANIMATION_DATA_TYPE dataType = effectSetting.m_data_type; floatVarSetting.Setup(effectSetting, effectSetting.GetSettingData(m_effect.AnimationManager, animation_section.m_start_action, animation_section.m_start_loop), () => { m_effect.AnimationManager.PrepareAnimationData(dataType); if (dataType == ANIMATION_DATA_TYPE.DURATION) { m_effect.AnimationManager.PrepareAnimationData(ANIMATION_DATA_TYPE.DELAY); } }, false); settingTransform = (floatVarSetting.transform as RectTransform); break; case ANIMATION_DATA_TYPE.GLOBAL_ROTATION: case ANIMATION_DATA_TYPE.LOCAL_ROTATION: case ANIMATION_DATA_TYPE.POSITION: case ANIMATION_DATA_TYPE.GLOBAL_SCALE: case ANIMATION_DATA_TYPE.LOCAL_SCALE: // Grab a Vector3 variable component Vector3VariableSetting vector3VarSetting = m_vector3VariableSettingsPool.GetObject(); m_vector3VariableSettingsInUse[(int)section].Add(vector3VarSetting); vector3VarSetting.transform.SetParent(m_menuSectionsContainer); ANIMATION_DATA_TYPE vecDataType = effectSetting.m_data_type; vector3VarSetting.Setup(effectSetting, effectSetting.GetSettingData(m_effect.AnimationManager, animation_section.m_start_action, animation_section.m_start_loop), () => { m_effect.AnimationManager.PrepareAnimationData(vecDataType); }, false); settingTransform = (vector3VarSetting.transform as RectTransform); break; case ANIMATION_DATA_TYPE.COLOUR: ColourVariableSetting colourVarSetting = m_colourVariableSettingsPool.GetObject(); m_colourVariableSettingsInUse[(int)section].Add(colourVarSetting); colourVarSetting.transform.SetParent(m_menuSectionsContainer); settingTransform = (colourVarSetting.transform as RectTransform); ANIMATION_DATA_TYPE colDataType = ANIMATION_DATA_TYPE.COLOUR; colourVarSetting.Setup(effectSetting, effectSetting.GetSettingData(m_effect.AnimationManager, animation_section.m_start_action, animation_section.m_start_loop), () => { m_effect.AnimationManager.PrepareAnimationData(colDataType); }, false); break; case ANIMATION_DATA_TYPE.DELAY_EASED_RANDOM_SWITCH: ToggleVariableSetting toggleVarSetting = m_toggleVariableSettingsPool.GetObject(); m_toggleVariableSettingsInUse[(int)section].Add(toggleVarSetting); toggleVarSetting.transform.SetParent(m_menuSectionsContainer); effectSetting.m_setting_name = "Randomised?"; toggleVarSetting.Setup(effectSetting, effectSetting.GetSettingData(m_effect.AnimationManager, animation_section.m_start_action, animation_section.m_start_loop), null, false); settingTransform = (toggleVarSetting.transform as RectTransform); break; default: settingIdx--; break; } if (settingTransform != null) { settingTransform.SetSiblingIndex(sectionSiblingIndexOffset + 1 + settingIdx); settingTransform.localPosition = new Vector3(settingTransform.localPosition.x, settingTransform.localPosition.y, 0); settingTransform.localScale = Vector3.one; } settingIdx++; } // Add in the Exit Delay option if (animIndex > 0) { ToggleVariableSetting toggleVarSetting = m_toggleVariableSettingsPool.GetObject(); m_toggleVariableSettingsInUse[(int)section].Add(toggleVarSetting); FloatVariableSetting floatVarSetting = m_floatVariableSettingsPool.GetObject(); m_floatVariableSettingsInUse[(int)section].Add(floatVarSetting); toggleVarSetting.transform.SetParent(m_menuSectionsContainer); RectTransform exitDelayTransform = (toggleVarSetting.transform as RectTransform); exitDelayTransform.SetSiblingIndex(sectionSiblingIndexOffset + 1 + settingIdx); exitDelayTransform.localPosition = new Vector3(exitDelayTransform.localPosition.x, exitDelayTransform.localPosition.y, 0); exitDelayTransform.localScale = Vector3.one; List <PresetEffectSetting.VariableStateListener> stateListeners = new List <PresetEffectSetting.VariableStateListener>() { new PresetEffectSetting.VariableStateListener() { m_startToggleValue = animation_section.m_exit_pause, m_onToggleStateChangeCallback = (bool state) => { animation_section.SetExitPauseState(m_effect.AnimationManager, state); floatVarSetting.SubSettingSetActive(state); } } }; toggleVarSetting.Setup("Exit Delay", stateListeners, null, false); settingIdx++; floatVarSetting.transform.SetParent(m_menuSectionsContainer); exitDelayTransform = (floatVarSetting.transform as RectTransform); exitDelayTransform.SetSiblingIndex(sectionSiblingIndexOffset + 1 + settingIdx); exitDelayTransform.localPosition = new Vector3(exitDelayTransform.localPosition.x, exitDelayTransform.localPosition.y, 0); exitDelayTransform.localScale = Vector3.one; floatVarSetting.Setup("Duration", new List <PresetEffectSetting.VariableStateListener>() { new PresetEffectSetting.VariableStateListener() { m_startFloatValue = animation_section.m_exit_pause_duration, m_onFloatStateChangeCallback = (float fVal) => { animation_section.SetExitPauseDuration(m_effect.AnimationManager, fVal); } } }, null, true); floatVarSetting.SubSettingSetActive(animation_section.m_exit_pause); } // Reset Play button text m_playButtonText.text = "Play"; HideContinueButton(); if (restartAnimation) { PlayAnimation(); } }
public void ImportData(JSONObject jsonData) { m_setting_name = jsonData ["name"].Str; m_data_type = (ANIMATION_DATA_TYPE) ((int) jsonData ["data_type"].Number); m_animation_idx = (int) jsonData ["anim_idx"].Number; m_action_idx = (int) jsonData ["action_idx"].Number; if(jsonData.ContainsKey("startState")) m_startState = jsonData["startState"].Boolean; }
void DrawEffectEditorPanel() { float gui_x_offset = 10; float gui_y_offset = WINDOW_BORDER_TOP; m_playbackButtonsScrollPosition = GUI.BeginScrollView (new Rect (0, 0, Instance.position.width - COPY_PASTE_SECTION_WIDTH, PLAYBACK_SECTION_HEIGHT), m_playbackButtonsScrollPosition, new Rect (0, 0, m_playbackButtonsAreaWidth, 40)); // if(GUI.Button(new Rect(gui_x_offset, gui_y_offset, PLAYBACK_BUTTONS_WIDTH, PLAYBACK_BUTTONS_HEIGHT), new GUIContent(!m_previewing_anim || m_paused ? "Play" : "Pause", (!m_previewing_anim || m_paused ? "Play" : "Pause") + " this animation sequence."))) if(GUI.Button(new Rect(gui_x_offset, gui_y_offset, 40, PLAYBACK_BUTTONS_HEIGHT), !m_previewing_anim || m_paused ? m_play_button_texture : m_pause_button_texture)) { if(m_previewing_anim) { PauseEditorAnimation(); } else { PlayEditorAnimation(); } } gui_x_offset += PLAYBACK_BUTTONS_WIDTH + 10; if(GUI.Button(new Rect(gui_x_offset, gui_y_offset, PLAYBACK_BUTTONS_WIDTH, PLAYBACK_BUTTONS_HEIGHT), m_reset_button_texture)) { if(m_textfx_animation_interface == null) return; m_paused = false; m_previewing_anim = false; m_animation_manager.ResetAnimation(); m_textfx_animation_interface.UpdateTextFxMesh(m_animation_manager.MeshVerts, m_animation_manager.MeshColours); SceneView.RepaintAll(); } gui_x_offset = (PLAYBACK_BUTTONS_WIDTH * 3); if(m_animation_manager.Playing) { // Draw divider line TextFxHelperMethods.DrawGUILine(new Rect(PLAYBACK_BUTTONS_WIDTH * 3 - 10, WINDOW_BORDER_TOP, 0, PLAYBACK_BUTTONS_HEIGHT), Color.gray, 3); m_playbackButtonsAreaWidth = PLAYBACK_BUTTONS_WIDTH * 2 + 20; // Continue Past Break Button if(GUI.Button(new Rect(gui_x_offset, gui_y_offset, PLAYBACK_BUTTONS_WIDTH, PLAYBACK_BUTTONS_HEIGHT), m_continue_button_texture)) { m_animation_manager.ContinuePastBreak(m_editor_continue_animation_index); // Debug.Log("Editor ContinuePastBreak"); } gui_x_offset += PLAYBACK_BUTTONS_WIDTH + 10; // Continue Past Loop Button if(GUI.Button(new Rect(gui_x_offset, gui_y_offset, PLAYBACK_BUTTONS_WIDTH, PLAYBACK_BUTTONS_HEIGHT), m_continue_past_loop_button_texture)) { m_animation_manager.ContinuePastLoop(m_editor_continue_animation_index, m_editor_continue_type, m_editor_continue_lerp_duration, m_editor_continue_pass_next_infinite_loop, m_editor_continue_shorten_interim_loops, m_editor_continue_anim_speed_override); // Debug.Log("Editor ContinuePastLoop"); // PauseEditorAnimation(); } gui_x_offset += PLAYBACK_BUTTONS_WIDTH + 10; m_playbackButtonsAreaWidth += PLAYBACK_BUTTONS_WIDTH + 10; } else m_playbackButtonsAreaWidth = PLAYBACK_BUTTONS_WIDTH * 2 + 20; #if ANIM_DESIGN_DEV_TOOLS // TODO: Display this info in a sensible non-cluttered/confusing way. gui_x_offset += 10; string[] anim_idx_select_array = new string[m_animation_manager.m_master_animations.Count]; for(int anim_idx=0; anim_idx < anim_idx_select_array.Length; anim_idx++) anim_idx_select_array[anim_idx] = "" + anim_idx; EditorGUI.LabelField (new Rect (gui_x_offset, WINDOW_BORDER_TOP - 5, 40, LINE_HEIGHT), "Anim"); m_editor_continue_animation_index = EditorGUI.Popup (new Rect (gui_x_offset + 45, WINDOW_BORDER_TOP - 5, 35, LINE_HEIGHT), m_editor_continue_animation_index, anim_idx_select_array); if(m_editor_continue_type == ContinueType.None) m_editor_continue_type = ContinueType.EndOfLoop; m_editor_continue_type = (ContinueType) (1 + EditorGUI.Popup (new Rect (gui_x_offset + 90, WINDOW_BORDER_TOP - 5, 80, LINE_HEIGHT), ((int) m_editor_continue_type) - 1, new string[]{"Instant", "End Of Loop"})); EditorGUI.LabelField (new Rect (gui_x_offset, WINDOW_BORDER_TOP + 12, 70, LINE_HEIGHT), "Exit Infinite"); m_editor_continue_pass_next_infinite_loop = EditorGUI.Toggle (new Rect (gui_x_offset + 74, WINDOW_BORDER_TOP + 12, 20, LINE_HEIGHT), m_editor_continue_pass_next_infinite_loop); if(m_editor_continue_type == ContinueType.Instant) { EditorGUI.LabelField (new Rect (gui_x_offset, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 60, LINE_HEIGHT), "Lerp Time"); m_editor_continue_lerp_duration = EditorGUI.FloatField (new Rect (gui_x_offset + 65, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 30, 15), m_editor_continue_lerp_duration); } else if(m_editor_continue_type == ContinueType.EndOfLoop) { EditorGUI.LabelField (new Rect (gui_x_offset, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 74, LINE_HEIGHT), "Anim Speed"); m_editor_continue_anim_speed_override = EditorGUI.FloatField (new Rect (gui_x_offset + 75, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 20, 15), m_editor_continue_anim_speed_override); EditorGUI.LabelField (new Rect (gui_x_offset + 100, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 70, LINE_HEIGHT), "Trim Loops"); m_editor_continue_shorten_interim_loops = EditorGUI.Toggle (new Rect (gui_x_offset + 175, WINDOW_BORDER_TOP + LINE_HEIGHT + 8, 20, 15), m_editor_continue_shorten_interim_loops); } #endif GUI.EndScrollView (); // Draw copy/paste section divider line TextFxHelperMethods.DrawGUILine(new Rect(Instance.position.width - COPY_PASTE_SECTION_WIDTH + 5, 2, 0, PLAYBACK_BUTTONS_HEIGHT + 20), Color.gray, 3); GUIStyle style = new GUIStyle(EditorStyles.miniButton); style.fontSize = 10; // COPY_PASTE_SECTION_WIDTH gui_x_offset = Instance.position.width - COPY_PASTE_SECTION_WIDTH + 13; // if(GUI.Button(new Rect(gui_x_offset, 3, 70, 20), new GUIContent("Copy [S]", "Soft Copy this TextEffect animation configuration, not including any Text settings."), style)) // { // string json_data = m_animation_manager.ExportData(); // EditorGUIUtility.systemCopyBuffer = json_data; // EditorPrefs.SetString("EffectExport", json_data); // Debug.Log("Soft Copied " + m_textfx_animation_interface.GameObject.name); // } if(GUI.Button(new Rect(gui_x_offset, WINDOW_BORDER_TOP, 40, 40), m_copy_button_texture)) { string json_data = m_animation_manager.ExportData(hard_copy: true); EditorGUIUtility.systemCopyBuffer = json_data; EditorPrefs.SetString("EffectExport", json_data); Debug.Log("Hard Copied " + m_textfx_animation_interface.GameObject.name); } if(GUI.Button(new Rect(gui_x_offset + 45, WINDOW_BORDER_TOP, 40, 40), m_paste_button_texture)) { if(EditorPrefs.HasKey("EffectExport")) { m_animation_manager.ImportData(EditorPrefs.GetString("EffectExport"), true); Debug.Log("Pasted onto " + m_textfx_animation_interface.GameObject.name); } } // if(GUI.Button(new Rect(gui_x_offset + 90, WINDOW_BORDER_TOP, 40, 40), m_save_button_texture)) // { // // SAVE animations data to a txt file // string json_data = m_animation_manager.ExportData(hard_copy: true); // // m_animation_manager.m_effect_name = TextFxHelperMethods.SaveEffect(m_animation_manager.m_effect_name, json_data); // // EditorToolsHelper.RewriteImportEffectNames(); // // AssetDatabase.Refresh(); // // LoadInPresetAnimationNames(); // // GUI.FocusControl(""); // } // Draw Playback button section divider TextFxHelperMethods.DrawGUILine(new Rect(0, PLAYBACK_SECTION_HEIGHT - 3, Instance.position.width, 0), Color.gray, 5); gui_y_offset += 55; m_editor_section_idx = GUI.Toolbar(new Rect(0, gui_y_offset, Instance.position.width, LINE_HEIGHT), m_editor_section_idx, new string[]{"Quick Setup", "Full Editor"}); //, EditorStyles.toolbarButton); if(GUI.changed) return; gui_y_offset += 25; ignore_gui_change = false; noticed_gui_change = false; edited_action_idx = -1; m_edited_data = ANIMATION_DATA_TYPE.NONE; if(m_editor_section_idx == 0) { DrawQuickSetupPanel(gui_y_offset); } else { DrawFullEditorPanel(gui_y_offset); } }
bool CheckGUIChange(int action_idx, bool start_state, ANIMATION_DATA_TYPE edited_data_type = ANIMATION_DATA_TYPE.NONE, bool forceChange = false) { if (forceChange || (!ignore_gui_change && !noticed_gui_change && GUI.changed)) { if(forceChange) ignore_gui_change = false; noticed_gui_change = true; edited_action_idx = action_idx; editing_start_state = start_state; m_edited_data = edited_data_type; return true; } return false; }
bool CheckGUIChange(ANIMATION_DATA_TYPE edited_data_type = ANIMATION_DATA_TYPE.NONE, bool forceChange = false) { return CheckGUIChange(m_animation_manager.EditorActionIdx, m_animation_manager.EditorActionProgress == 0 ? true : false, edited_data_type, forceChange); }
public void PrepareData(TextFxAnimationManager anim_manager, LetterSetup[] letters, ANIMATION_DATA_TYPE what_to_update, int num_words, int num_lines, AnimatePerOptions animate_per) { if(letters == null || letters.Length == 0) { return; } if(m_letters_to_animate == null || what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.ANIMATE_ON) { CalculateLettersToAnimate(letters); } if(what_to_update == ANIMATION_DATA_TYPE.ALL || what_to_update == ANIMATION_DATA_TYPE.COLOUR || m_defaultTextColourProgression == null) { // Set values for default text colour progression VertexColour[] defaultextColours = new VertexColour[m_letters_to_animate.Count]; for(int idx = 0; idx < m_letters_to_animate.Count; idx++) { defaultextColours[idx] = letters[m_letters_to_animate[idx]].BaseColour; } m_defaultTextColourProgression.SetValues(defaultextColours); // Mark as the default colour progression m_defaultTextColourProgression.SetReferenceData(-1, ANIMATION_DATA_TYPE.COLOUR, true); } // Prepare progression data in all actions LetterAction letter_action; LetterAction prev_action = null; bool prev_action_end_state = true; for(int action_idx = 0; action_idx < m_letter_actions.Count; action_idx ++) { letter_action = m_letter_actions[action_idx]; letter_action.PrepareData(anim_manager, ref letters, this, action_idx, what_to_update, m_letters_to_animate.Count, m_num_white_space_chars_to_include, num_words, num_lines, prev_action, animate_per, m_defaultTextColourProgression, prev_action_end_state); if(letter_action.m_action_type == ACTION_TYPE.ANIM_SEQUENCE) { // Set default previous action settings prev_action_end_state = true; prev_action = letter_action; } // Check for reverse loops, and how the animation should progress from there foreach(ActionLoopCycle loop_cycle in m_loop_cycles) { if(loop_cycle.m_end_action_idx == action_idx && loop_cycle.m_loop_type == LOOP_TYPE.LOOP_REVERSE && !loop_cycle.m_finish_at_end) { prev_action = m_letter_actions[loop_cycle.m_start_action_idx]; prev_action_end_state = false; } } } }