Beispiel #1
0
 public VertexColour(VertexColour vert_col)
 {
     top_left     = vert_col.top_left;
     top_right    = vert_col.top_right;
     bottom_right = vert_col.bottom_right;
     bottom_left  = vert_col.bottom_left;
 }
 public VertexColour(VertexColour vert_col)
 {
     top_left = vert_col.top_left;
     top_right = vert_col.top_right;
     bottom_right = vert_col.bottom_right;
     bottom_left = vert_col.bottom_left;
 }
Beispiel #3
0
 public void AddInLine(VertexColour vert_col)
 {
     bottom_left  += vert_col.bottom_left;
     bottom_right += vert_col.bottom_right;
     top_left     += vert_col.top_left;
     top_right    += vert_col.top_right;
 }
        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 VertexColour Sub(VertexColour vert_col)
    {
        var v_col = new VertexColour();
        v_col.bottom_left = bottom_left - vert_col.bottom_left;
        v_col.bottom_right = bottom_right - vert_col.bottom_right;
        v_col.top_left = top_left - vert_col.top_left;
        v_col.top_right = top_right - vert_col.top_right;

        return v_col;
    }
    public VertexColour Multiply(float factor)
    {
        var v_col = new VertexColour();
        v_col.bottom_left = bottom_left * factor;
        v_col.bottom_right = bottom_right * factor;
        v_col.top_left = top_left * factor;
        v_col.top_right = top_right * factor;

        return v_col;
    }
    public VertexColour Clone()
    {
        var vertex_col = new VertexColour();
        vertex_col.top_left = top_left;
        vertex_col.top_right = top_right;
        vertex_col.bottom_right = bottom_right;
        vertex_col.bottom_left = bottom_left;

        return vertex_col;
    }
	public VertexColour Add(VertexColour vert_col)
	{
		VertexColour v_col = new VertexColour();
		v_col.bottom_left = bottom_left + vert_col.bottom_left;
		v_col.bottom_right = bottom_right + vert_col.bottom_right;
		v_col.top_left = top_left + vert_col.top_left;
		v_col.top_right = top_right + vert_col.top_right;
		
		return v_col;
	}
        public static tfxJSONValue ExportData(this VertexColour vert_color)
        {
            tfxJSONObject json_data = new tfxJSONObject();

            json_data["bottom_left"]  = vert_color.bottom_left.ExportData();
            json_data["bottom_right"] = vert_color.bottom_right.ExportData();
            json_data["top_left"]     = vert_color.top_left.ExportData();
            json_data["top_right"]    = vert_color.top_right.ExportData();

            return(new tfxJSONValue(json_data));
        }
Beispiel #10
0
    public VertexColour Multiply(float factor)
    {
        VertexColour v_col = new VertexColour();

        v_col.bottom_left  = bottom_left * factor;
        v_col.bottom_right = bottom_right * factor;
        v_col.top_left     = top_left * factor;
        v_col.top_right    = top_right * factor;

        return(v_col);
    }
Beispiel #11
0
    public VertexColour Clone()
    {
        VertexColour vertex_col = new VertexColour();

        vertex_col.top_left     = top_left;
        vertex_col.top_right    = top_right;
        vertex_col.bottom_right = bottom_right;
        vertex_col.bottom_left  = bottom_left;

        return(vertex_col);
    }
Beispiel #12
0
    public VertexColour Sub(VertexColour vert_col)
    {
        VertexColour v_col = new VertexColour();

        v_col.bottom_left  = bottom_left - vert_col.bottom_left;
        v_col.bottom_right = bottom_right - vert_col.bottom_right;
        v_col.top_left     = top_left - vert_col.top_left;
        v_col.top_right    = top_right - vert_col.top_right;

        return(v_col);
    }
 public void ConvertFromFlatColourProg(ActionColorProgression flat_colour_progression)
 {
     m_progression         = flat_colour_progression.m_progression;
     m_ease_type           = flat_colour_progression.m_ease_type;
     m_from                = new VertexColour(flat_colour_progression.m_from);
     m_to                  = new VertexColour(flat_colour_progression.m_to);
     m_to_to               = new VertexColour(flat_colour_progression.m_to_to);
     m_to_to_bool          = flat_colour_progression.m_to_to_bool;
     m_is_offset_from_last = flat_colour_progression.m_is_offset_from_last;
     m_unique_randoms      = flat_colour_progression.m_unique_randoms;
 }
    public void CalculateProgressions(int num_progressions, VertexColour[] offset_vert_colours, Color[] offset_colours)
    {
        if (Progression == (int)ValueProgression.Eased || Progression == (int)ValueProgression.EasedCustom || Progression == (int)ValueProgression.Random || (m_is_offset_from_last && ((offset_colours != null && offset_colours.Length > 1) || (offset_vert_colours != null && offset_vert_colours.Length > 1))))
        {
            var constant_offset = (offset_colours != null && offset_colours.Length == 1) || (offset_vert_colours != null && offset_vert_colours.Length == 1);
            m_values = new VertexColour[num_progressions];

            for (var idx = 0; idx < num_progressions; idx++)
                m_values[idx] = m_is_offset_from_last ? (offset_colours != null ? new VertexColour(offset_colours[constant_offset ? 0 : idx]) : offset_vert_colours[constant_offset ? 0 : idx].Clone()) : new VertexColour(new Color(0, 0, 0, 0));
        }
        else
            m_values = new VertexColour[1] { m_is_offset_from_last ? (offset_colours != null ? new VertexColour(offset_colours[0]) : offset_vert_colours[0].Clone()) : new VertexColour(new Color(0, 0, 0, 0)) };

        if (Progression == (int)ValueProgression.Random)
            for (var idx = 0; idx < num_progressions; idx++)
                m_values[idx] = m_values[idx].Add(m_from.Add(m_to.Sub(m_from).Multiply(Random.value)));
        else if (Progression == (int)ValueProgression.Eased)
        {
            float progression;

            for (var idx = 0; idx < num_progressions; idx++)
            {
                progression = num_progressions == 1 ? 0 : idx / (num_progressions - 1f);

                if (m_to_to_bool)
                    if (progression <= 0.5f)
                        m_values[idx] = m_values[idx].Add(m_from.Add((m_to.Sub(m_from)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression / 0.5f))));
                    else
                    {
                        progression -= 0.5f;
                        m_values[idx] = m_values[idx].Add(m_to.Add((m_to_to.Sub(m_to)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression / 0.5f))));
                    }
                else
                    m_values[idx] = m_values[idx].Add(m_from.Add((m_to.Sub(m_from)).Multiply(EasingManager.GetEaseProgress(m_ease_type, progression))));
            }
        }
        else if (Progression == (int)ValueProgression.EasedCustom)
        {
            float progression;

            for (var idx = 0; idx < num_progressions; idx++)
            {
                progression = num_progressions == 1 ? 0 : idx / (num_progressions - 1f);

                m_values[idx] = m_values[idx].Add(m_from.Add((m_to.Sub(m_from)).Multiply(m_custom_ease_curve.Evaluate(progression))));
            }
        }
        else if (Progression == (int)ValueProgression.Constant)
            for (var idx = 0; idx < m_values.Length; idx++)
                m_values[idx] = m_values[idx].Add(m_from);
    }
 //triggered by the event menu button
 public void Update()
 {
     vCol       = GetComponent <VertexColour>();
     model      = new Mesh();
     MeshHolder = new GameObject();
     MeshHolder.AddComponent <MeshFilter>();
     MeshHolder.GetComponent <MeshFilter>().mesh = model;
     MeshHolder.name = name;
     model.name      = name + "MDL";
     MeshHolder.AddComponent <ControlObject>();
     MeshHolder.GetComponent <ControlObject>().setState(StateObject.GAMESTATE.DRAWWING);
     if (MeshHolder.GetComponent <MeshRenderer>() == null)
     {
         MeshHolder.gameObject.AddComponent <MeshRenderer>();
     }
 }
    public static void BFStraversal(Graph g, Vertex src, Vertex Dest)
    {
        Dictionary <Vertex, VertexColour> vertices = new Dictionary <Vertex, VertexColour>();

        foreach (Vertex v in g.getAllVertices())
        {
            if (!v.Equals(src))
            {
                vertices[v] = new VertexColour();
            }
            else
            {
                vertices[src]        = new VertexColour();
                vertices[src].color  = VertexColour.grey;
                vertices[src].dist   = 0;
                vertices[src].parent = null;
            }
        }

        Queue <Vertex> Q = new Queue <Vertex>();

        Q.Enqueue(src);

        while (Q.Count != 0)
        {
            Vertex u = Q.Dequeue();
            if (u.Equals(Dest))
            {
                return;
            }
            foreach (Edge e in g.getNeighbours(u))
            {
                Vertex v = e.getAdj();

                if (vertices[v].color.Equals(VertexColour.white))
                {
                    vertices[v].color  = VertexColour.grey;
                    vertices[v].dist   = vertices[u].dist + 1;
                    vertices[v].parent = u;
                    Q.Enqueue(v);
                }
            }

            vertices[u].color = VertexColour.black;
        }
    }
    public static void Dijsktra(Graph g, Dictionary <Vertex, VertexColour> vertices, Vertex src, Vertex dest)// O(E LogV)
    {
        PriorityQueue <Vertex, int> Q = new PriorityQueue <Vertex, int>();

        foreach (Vertex v in g.getAllVertices())        //O(V LogN)
        {
            vertices[v] = new VertexColour();           //Ꝋ(1)
            if (v.Equals(src))                          //Ꝋ(1)
            {
                vertices[v].color = VertexColour.black; //Ꝋ(1)
                vertices[v].dist  = 0;                  //Ꝋ(1)
            }
            Q.Enqueue(v, vertices[v].dist);             //O(LogN)
        }

        while (Q.Count() != 0)//O(E LogV)
        {
            //Touch every vertex only once : O(LogV)
            Vertex u = Q.Dequeue();                 //Ꝋ(1)
            vertices[u].color = VertexColour.black; //Ꝋ(1)
            if (u.Equals(dest))
            {
                return;                                              //Ꝋ(1)
            }
            foreach (Edge e in g.getNeighbours(u))                   //Ꝋ(E) " Maximum Iterations "
            {
                Vertex v         = e.getAdj();                       //Ꝋ(1)
                int    distToTry = vertices[u].dist + e.getWeight(); //Ꝋ(1)
                if (vertices[v].color.Equals(VertexColour.white) &&//Ꝋ(1)
                    vertices[v].dist > distToTry)
                {
                    Q.update_value(v, distToTry);   //Ꝋ(1)
                    vertices[v].dist   = distToTry; //Ꝋ(1)
                    vertices[v].parent = u;         //Ꝋ(1)
                }
            }
        }
    }
Beispiel #18
0
        public void RefreshDefaultTextColour(LetterSetup[] letters)
        {
            CalculateLettersToAnimate(letters);

            // 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++)
            {
                int letterIdx = m_letters_to_animate [idx];

                if (letterIdx >= letters.Length)
                {
                    break;
                }

                defaultextColours [idx] = letters[letterIdx].BaseColour;
            }

            m_defaultTextColourProgression.SetValues(defaultextColours);

            // Mark as the default colour progression
            m_defaultTextColourProgression.SetReferenceData(-1, ANIMATION_DATA_TYPE.COLOUR, true);
        }
Beispiel #19
0
 public bool Equals(VertexColour otherVertexCol)
 {
     return(top_left == otherVertexCol.top_left && top_right == otherVertexCol.top_right && bottom_left == otherVertexCol.bottom_left && bottom_right == otherVertexCol.bottom_right);
 }
	public bool Equals(VertexColour otherVertexCol)
	{
		return top_left == otherVertexCol.top_left && top_right == otherVertexCol.top_right && bottom_left == otherVertexCol.bottom_left && bottom_right == otherVertexCol.bottom_right;
	}
		public void SetRandom( VertexColour random_min, VertexColour random_max, bool unique_randoms = false)
		{
			m_progression_idx = (int) ValueProgression.Random;
			m_from = random_min;
			m_to = random_max;
			m_unique_randoms = unique_randoms;
		}
 public void ConvertFromFlatColourProg(ActionColorProgression flat_colour_progression)
 {
     m_progression = flat_colour_progression.m_progression;
     m_ease_type = flat_colour_progression.m_ease_type;
     m_from = new VertexColour(flat_colour_progression.m_from);
     m_to = new VertexColour(flat_colour_progression.m_to);
     m_to_to = new VertexColour(flat_colour_progression.m_to_to);
     m_to_to_bool = flat_colour_progression.m_to_to_bool;
     m_is_offset_from_last = flat_colour_progression.m_is_offset_from_last;
     m_unique_randoms = flat_colour_progression.m_unique_randoms;
 }
 public ActionVertexColorProgression(VertexColour start_colour)
 {
     m_from = start_colour.Clone();
     m_to = start_colour.Clone();
     m_to_to = start_colour.Clone();
 }
		public override void OnInspectorGUI ()
		{
//			DrawDefaultInspector();
			
			textfx_instance = (TextFxNative)target;
			
			m_old_text = textfx_instance.m_text;
			m_old_display_axis = textfx_instance.m_display_axis;
			m_old_text_anchor = textfx_instance.m_text_anchor;
			m_old_text_alignment = textfx_instance.m_text_alignment;
			m_old_char_size = textfx_instance.m_character_size;
			m_old_textColour = textfx_instance.m_textColour;
			m_old_vertexColour = textfx_instance.m_textColourGradient.Clone();
			m_old_use_gradients = textfx_instance.m_use_colour_gradient;
			m_old_textColour = textfx_instance.m_textColour;
			m_old_line_height = textfx_instance.m_line_height_factor;
			m_old_px_offset = textfx_instance.m_px_offset;
			m_old_baseline_override = textfx_instance.m_override_font_baseline;
			m_old_font_baseline = textfx_instance.m_font_baseline_override;
			m_old_max_width = textfx_instance.m_max_width;
			
			if(GUI.changed)
			{
				return;
			}

			
			EditorGUILayout.LabelField("Font Setup Data", EditorStyles.boldLabel);
			
	#if !UNITY_3_5
			textfx_instance.m_font = EditorGUILayout.ObjectField(new GUIContent("Font (.ttf, .dfont, .otf)", "Your font file to use for this text."), textfx_instance.m_font, typeof(Font), true) as Font;
			if(GUI.changed && textfx_instance.m_font != null)
			{
				textfx_instance.gameObject.GetComponent<Renderer>().material = textfx_instance.m_font.material;
				textfx_instance.m_font_material = textfx_instance.m_font.material;
				textfx_instance.SetText(textfx_instance.m_text);
			}
	#endif
			
			textfx_instance.m_font_data_file = EditorGUILayout.ObjectField(new GUIContent("Font Data File", "Your Bitmap font text data file."), textfx_instance.m_font_data_file, typeof(TextAsset), true) as TextAsset;
			if(GUI.changed && textfx_instance.m_font_data_file != null && textfx_instance.m_font_material != null)
			{
				// Wipe the old character data hashtable
				textfx_instance.ClearFontCharacterData();
				textfx_instance.SetText(textfx_instance.m_text);
				return;
			}
			textfx_instance.m_font_material = EditorGUILayout.ObjectField(new GUIContent("Font Material", "Your Bitmap font material"), textfx_instance.m_font_material, typeof(Material), true) as Material;
			if(GUI.changed && textfx_instance.m_font_data_file != null && textfx_instance.m_font_material != null)
			{
				// Reset the text with the new material assigned.
				textfx_instance.gameObject.GetComponent<Renderer>().material = textfx_instance.m_font_material;
				textfx_instance.SetText(textfx_instance.m_text);
				return;
			}
			EditorGUILayout.Separator();
			
			EditorGUILayout.LabelField(new GUIContent("Text", "The text to display."), EditorStyles.boldLabel);
			textfx_instance.m_text = EditorGUILayout.TextArea(textfx_instance.m_text, GUILayout.Width(Screen.width - 25));
			EditorGUILayout.Separator();
			
			EditorGUILayout.LabelField("Text Settings", EditorStyles.boldLabel);
			EditorGUILayout.BeginHorizontal ();

			if(textfx_instance.m_use_colour_gradient)
			{
				EditorGUILayout.BeginVertical ();
				EditorGUILayout.BeginHorizontal ();
				textfx_instance.m_textColourGradient.top_left = EditorGUILayout.ColorField("Colour", textfx_instance.m_textColourGradient.top_left);
				textfx_instance.m_textColourGradient.top_right = EditorGUILayout.ColorField(textfx_instance.m_textColourGradient.top_right, GUILayout.Width(53));
				EditorGUILayout.EndHorizontal ();
				EditorGUILayout.BeginHorizontal ();
				textfx_instance.m_textColourGradient.bottom_left = EditorGUILayout.ColorField(" ", textfx_instance.m_textColourGradient.bottom_left);
				textfx_instance.m_textColourGradient.bottom_right = EditorGUILayout.ColorField(textfx_instance.m_textColourGradient.bottom_right, GUILayout.Width(53));
				EditorGUILayout.EndHorizontal ();
				EditorGUILayout.EndVertical ();
			}
			else
			{
				textfx_instance.m_textColour = EditorGUILayout.ColorField("Colour", textfx_instance.m_textColour);//, GUILayout.Width(260));
			}
			GUILayout.FlexibleSpace ();
			EditorGUILayout.LabelField ("Use Gradient?", GUILayout.Width(100));
			textfx_instance.m_use_colour_gradient = EditorGUILayout.Toggle (textfx_instance.m_use_colour_gradient, GUILayout.Width(20));
			GUILayout.FlexibleSpace ();
			EditorGUILayout.EndHorizontal ();

			textfx_instance.m_display_axis = (TextDisplayAxis) EditorGUILayout.EnumPopup(new GUIContent("Display Axis", "Denotes whether to render the text horizontally or vertically."), textfx_instance.m_display_axis);
			textfx_instance.m_text_anchor = (TextAnchor) EditorGUILayout.EnumPopup(new GUIContent("Text Anchor", "Defines the anchor point about which the text is rendered"), textfx_instance.m_text_anchor);
			textfx_instance.m_text_alignment = (TextAlignment) EditorGUILayout.EnumPopup(new GUIContent("Text Alignment", "Defines the alignment of the text, just like your favourite word processor."), textfx_instance.m_text_alignment);
			textfx_instance.m_character_size = EditorGUILayout.FloatField(new GUIContent("Character Size", "Specifies the size of the text."), textfx_instance.m_character_size);
			textfx_instance.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."), textfx_instance.m_line_height_factor);
			EditorGUILayout.BeginHorizontal();
			textfx_instance.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."), textfx_instance.m_override_font_baseline);
			if(textfx_instance.m_override_font_baseline)
			{
				textfx_instance.m_font_baseline_override = EditorGUILayout.FloatField(new GUIContent("Font Baseline Offset", ""), textfx_instance.m_font_baseline_override);
			}
			EditorGUILayout.EndHorizontal();
			textfx_instance.m_px_offset = EditorGUILayout.Vector2Field("Letter Spacing Offset", textfx_instance.m_px_offset);
			textfx_instance.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."), textfx_instance.m_max_width);
			EditorGUILayout.Separator();
			
			EditorGUILayout.Separator();
			EditorGUILayout.Separator();

			if (GUI.changed)
			{
				EditorUtility.SetDirty(textfx_instance);
			}
			
			if(m_old_char_size != textfx_instance.m_character_size ||
			   m_old_textColour != textfx_instance.m_textColour ||
			   !m_old_vertexColour.Equals(textfx_instance.m_textColourGradient) ||
			   m_old_use_gradients != textfx_instance.m_use_colour_gradient ||
				m_old_display_axis != textfx_instance.m_display_axis ||
			   	m_old_line_height != textfx_instance.m_line_height_factor ||
				m_old_max_width != textfx_instance.m_max_width ||
				!m_old_text.Equals(textfx_instance.m_text)	||
				m_old_text_alignment != textfx_instance.m_text_alignment ||
				m_old_text_anchor != textfx_instance.m_text_anchor ||
				m_old_px_offset != textfx_instance.m_px_offset ||
				m_old_baseline_override != textfx_instance.m_override_font_baseline || 
				(textfx_instance.m_override_font_baseline && m_old_font_baseline != textfx_instance.m_font_baseline_override))
			{
				textfx_instance.SetText(textfx_instance.m_text);
			}

			GUILayout.Space(10);
			
			GUILayout.Label ("TextFx", EditorStyles.boldLabel);
			
			if (GUILayout.Button("Open Animation Editor", GUILayout.Width(150)))
			{
				EditorWindow.GetWindow(typeof(TextEffectsManager));
			}
		}
		public void ConvertFromFlatColourProg(ActionColorProgression flat_colour_progression)
		{
			m_progression_idx = flat_colour_progression.Progression;
			m_ease_type = flat_colour_progression.EaseType;
			m_from = new VertexColour(flat_colour_progression.ValueFrom);
			m_to = new VertexColour(flat_colour_progression.ValueTo);
			m_to_to = new VertexColour(flat_colour_progression.ValueThen);
			m_to_to_bool = flat_colour_progression.UsingThirdValue;
			m_is_offset_from_last = flat_colour_progression.IsOffsetFromLast;
			m_unique_randoms = flat_colour_progression.UniqueRandom;
		}
		public VertexColour GetValue(List<LetterAction> all_letter_actions, int progression_idx, ActionColorProgression defaultAnimColourProg) 
		{
			VertexColour colValue = new VertexColour (Color.clear);
			
			if((m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE || m_value_state == PROGRESSION_VALUE_STATE.REFERENCE))
			{
				ActionColorProgression offsetProgression = m_offset_progression.GetColourProg(all_letter_actions, defaultAnimColourProg);

				if(offsetProgression != null)
				{
					colValue = offsetProgression.GetValue(all_letter_actions, progression_idx, defaultAnimColourProg);
					
					if(m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE && m_override_alpha)
						colValue.ClearAlpha();
				}
			}
			
			if(m_value_state == PROGRESSION_VALUE_STATE.OFFSET_FROM_REFERENCE || m_value_state == PROGRESSION_VALUE_STATE.UNIQUE)
			{
				int num_vals = m_values.Length;
				if(num_vals > 1 && progression_idx < num_vals)
				{
					colValue = colValue.Add( m_values[progression_idx] );
				}
				else if(num_vals==1)
				{
					colValue = colValue.Add( m_values[0] );
				}
				else
				{
					colValue = colValue.Add(new VertexColour(Color.clear) );
				}
			}

			return colValue;
		}
		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 ActionVertexColorProgression(VertexColour start_colour)
 {
     m_from  = start_colour.Clone();
     m_to    = start_colour.Clone();
     m_to_to = start_colour.Clone();
 }
		public void SetEased( VertexColour eased_from, VertexColour eased_to, VertexColour eased_then, EasingEquation easing_function)
		{
			m_progression_idx = (int) ValueProgression.Eased;
			m_from = eased_from;
			m_to = eased_to;
			m_to_to = eased_then;
			m_to_to_bool = true;
			m_ease_type = easing_function;
		}
		public void SetEased( VertexColour eased_from, VertexColour eased_to, VertexColour eased_then)
		{
			SetEased (eased_from, eased_to, eased_then, m_ease_type);
		}
Beispiel #31
0
    void SetupMesh(LetterAction letter_action, float action_progress, bool first_action_call, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress)
    {
        if(first_action_call || !letter_action.StaticPosition || !letter_action.StaticRotation || !letter_action.StaticScale)
        {
            Vector3[] mesh_verts = new Vector3[4];
            for(int idx=0; idx < 4; idx++)
            {
                // rotate vertices
                // handle letter anchor x-offset
                Vector3 anchor_offset = Vector3.zero;
                if(letter_action.m_letter_anchor == TextAnchor.UpperRight || letter_action.m_letter_anchor == TextAnchor.MiddleRight || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(m_width, 0, 0);
                }
                else if(letter_action.m_letter_anchor == TextAnchor.UpperCenter || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.LowerCenter)
                {
                    anchor_offset += new Vector3(m_width / 2, 0, 0);
                }

                // handle letter anchor y-offset
                if(letter_action.m_letter_anchor == TextAnchor.MiddleLeft || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.MiddleRight)
                {
                    anchor_offset += new Vector3(0, m_height / 2, 0);
                }
                else if(letter_action.m_letter_anchor == TextAnchor.LowerLeft || letter_action.m_letter_anchor == TextAnchor.LowerCenter || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(0, m_height, 0);
                }

                mesh_verts[idx] = m_base_vertices[idx];

                mesh_verts[idx] -= anchor_offset;

                // Scale verts
        //				if(first_action_call) // || !letter_action.StaticScale)
        //				{
                    Vector3 from_scale = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
                    Vector3 to_scale = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

                    if(letter_action.m_scale_axis_ease_data.m_override_default)
                    {
                        mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                        new Vector3(	EffectManager.FloatLerp(from_scale.x, to_scale.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
                                                        EffectManager.FloatLerp(from_scale.y, to_scale.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
                                                        EffectManager.FloatLerp(from_scale.z, to_scale.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress))));
                    }
                    else
                    {
                        mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                            EffectManager.Vector3Lerp(
                            from_scale,
                            to_scale,
                            action_progress)
                            );
                    }
        //				}

                // Rotate vert
        //				if(first_action_call) // || !letter_action.StaticRotation)
        //				{
                    Vector3 from_rotation = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
                    Vector3 to_rotation = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

                    if(letter_action.m_rotation_axis_ease_data.m_override_default)
                    {
                        mesh_verts[idx] = 	Quaternion.Euler
                                            (
                                                EffectManager.FloatLerp(from_rotation.x, to_rotation.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
                                                EffectManager.FloatLerp(from_rotation.y, to_rotation.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
                                                EffectManager.FloatLerp(from_rotation.z, to_rotation.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
                                            ) * mesh_verts[idx];;
                    }
                    else
                    {
                        mesh_verts[idx] = Quaternion.Euler(
                                                    EffectManager.Vector3Lerp(
                                                        from_rotation,
                                                        to_rotation,
                                                        action_progress)
                                                    )
                                                    * mesh_verts[idx];
                    }
        //				}

                mesh_verts[idx] += anchor_offset;

                // translate vert
                Vector3 from_pos = (!letter_action.m_start_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_start_pos.GetValue(progression_variables, animate_per);
                Vector3 to_pos = (!letter_action.m_end_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_end_pos.GetValue(progression_variables, animate_per);

                if(letter_action.m_position_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] += new Vector3(	EffectManager.FloatLerp(from_pos.x, to_pos.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
                                                    EffectManager.FloatLerp(from_pos.y, to_pos.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
                                                    EffectManager.FloatLerp(from_pos.z, to_pos.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
                }
                else
                {
                    mesh_verts[idx] += EffectManager.Vector3Lerp(
                        from_pos,
                        to_pos,
                        action_progress);
                }

            }
            m_mesh.vertices = mesh_verts;
        }

        if(first_action_call || !letter_action.StaticColour)
        {
            if(letter_action.m_use_gradient_start || letter_action.m_use_gradient)
            {
                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 || letter_action.m_use_gradient)
            {
                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)
                };
            }
        }
    }
		public override void ImportData(Boomlagoon.JSON.JSONObject json_data)
		{
			m_from = json_data["m_from"].Obj.JSONtoVertexColour();
			m_to = json_data["m_to"].Obj.JSONtoVertexColour();
			m_to_to = json_data["m_to_to"].Obj.JSONtoVertexColour();

			if(json_data.ContainsKey("m_use_colour_gradients"))
				m_use_colour_gradients = json_data["m_use_colour_gradients"].Boolean;
			else
				m_use_colour_gradients = false;

			if(json_data.ContainsKey("m_override_alpha"))
				m_override_alpha = json_data["m_override_alpha"].Boolean;
			else
				m_override_alpha = false;
			
			ImportBaseData(json_data);
		}
    public override void ImportData(JSONObject json_data)
    {
        m_from = json_data["m_from"].Obj.JSONtoVertexColour();
        m_to = json_data["m_to"].Obj.JSONtoVertexColour();
        m_to_to = json_data["m_to_to"].Obj.JSONtoVertexColour();

        ImportBaseData(json_data);
    }
//		public void ImportLegacyData(string data_string)
//		{
//			KeyValuePair<string, string> value_pair;
//			List<object> obj_list = data_string.StringToList(';',':');
//			
//			foreach(object obj in obj_list)
//			{
//				value_pair = (KeyValuePair<string, string>) obj;
//				
//				switch(value_pair.Key)
//				{
//				case "m_from": m_from = value_pair.Value.StringToVertexColor('|','<','^'); break;
//				case "m_to": m_to = value_pair.Value.StringToVertexColor('|','<','^'); break;
//				case "m_to_to": m_to_to = value_pair.Value.StringToVertexColor('|','<','^'); break;
//					
//				default :
//					ImportBaseLagacyData(value_pair); break;
//				}
//			}
//		}

		public void ImportLegacyData(string data_string)
		{
			KeyValuePair<string, string> value_pair;
			List<object> obj_list = data_string.StringToList(';',':');
			
			foreach(object obj in obj_list)
			{
				value_pair = (KeyValuePair<string, string>) obj;
				
				switch(value_pair.Key)
				{
				case "m_from": m_from = new VertexColour( value_pair.Value.StringToColor('|','<')); break;
				case "m_to": m_to = new VertexColour( value_pair.Value.StringToColor('|','<')); break;
				case "m_to_to": m_to_to = new VertexColour(value_pair.Value.StringToColor('|','<')); break;
					
				default :
					ImportBaseLagacyData(value_pair); break;
				}
			}
		}
        public override void OnInspectorGUI()
        {
            // Draw TextFx inspector section
            TextFxBaseInspector.DrawTextFxInspectorSection(this, animationManager);

//			DrawDefaultInspector();

            textfx_instance = (TextFxNative)target;

            m_old_text              = textfx_instance.m_text;
            m_old_display_axis      = textfx_instance.m_display_axis;
            m_old_text_anchor       = textfx_instance.m_text_anchor;
            m_old_text_alignment    = textfx_instance.m_text_alignment;
            m_old_char_size         = textfx_instance.m_character_size;
            m_old_textColour        = textfx_instance.m_textColour;
            m_old_vertexColour      = textfx_instance.m_textColourGradient.Clone();
            m_old_use_gradients     = textfx_instance.m_use_colour_gradient;
            m_old_textColour        = textfx_instance.m_textColour;
            m_old_line_height       = textfx_instance.m_line_height_factor;
            m_old_px_offset         = textfx_instance.m_px_offset;
            m_old_baseline_override = textfx_instance.m_override_font_baseline;
            m_old_font_baseline     = textfx_instance.m_font_baseline_override;
            m_old_max_width         = textfx_instance.m_max_width;

            if (GUI.changed)
            {
                return;
            }


            EditorGUILayout.LabelField("Font Setup Data", EditorStyles.boldLabel);

        #if !UNITY_3_5
            textfx_instance.m_font = EditorGUILayout.ObjectField(new GUIContent("Font (.ttf, .dfont, .otf)", "Your font file to use for this text."), textfx_instance.m_font, typeof(Font), true) as Font;
            if (GUI.changed && textfx_instance.m_font != null)
            {
                textfx_instance.gameObject.GetComponent <Renderer>().material = textfx_instance.m_font.material;
                textfx_instance.m_font_material = textfx_instance.m_font.material;
                textfx_instance.SetText(textfx_instance.m_text);
            }
        #endif

            textfx_instance.m_font_data_file = EditorGUILayout.ObjectField(new GUIContent("Font Data File", "Your Bitmap font text data file."), textfx_instance.m_font_data_file, typeof(TextAsset), true) as TextAsset;
            if (GUI.changed && textfx_instance.m_font_data_file != null && textfx_instance.m_font_material != null)
            {
                // Wipe the old character data hashtable
                textfx_instance.ClearFontCharacterData();
                textfx_instance.SetText(textfx_instance.m_text);
                return;
            }
            textfx_instance.m_font_material = EditorGUILayout.ObjectField(new GUIContent("Font Material", "Your Bitmap font material"), textfx_instance.m_font_material, typeof(Material), true) as Material;
            if (GUI.changed && textfx_instance.m_font_data_file != null && textfx_instance.m_font_material != null)
            {
                // Reset the text with the new material assigned.
                textfx_instance.gameObject.GetComponent <Renderer>().material = textfx_instance.m_font_material;
                textfx_instance.SetText(textfx_instance.m_text);
                return;
            }
            EditorGUILayout.Separator();

            EditorGUILayout.LabelField(new GUIContent("Text", "The text to display."), EditorStyles.boldLabel);
            textfx_instance.m_text = EditorGUILayout.TextArea(textfx_instance.m_text, GUILayout.Width(Screen.width - 25));
            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("Text Settings", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal();

            if (textfx_instance.m_use_colour_gradient)
            {
                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal();
                textfx_instance.m_textColourGradient.top_left  = EditorGUILayout.ColorField("Colour", textfx_instance.m_textColourGradient.top_left);
                textfx_instance.m_textColourGradient.top_right = EditorGUILayout.ColorField(textfx_instance.m_textColourGradient.top_right, GUILayout.Width(53));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.BeginHorizontal();
                textfx_instance.m_textColourGradient.bottom_left  = EditorGUILayout.ColorField(" ", textfx_instance.m_textColourGradient.bottom_left);
                textfx_instance.m_textColourGradient.bottom_right = EditorGUILayout.ColorField(textfx_instance.m_textColourGradient.bottom_right, GUILayout.Width(53));
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            else
            {
                textfx_instance.m_textColour = EditorGUILayout.ColorField("Colour", textfx_instance.m_textColour);                //, GUILayout.Width(260));
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.LabelField("Use Gradient?", GUILayout.Width(100));
            textfx_instance.m_use_colour_gradient = EditorGUILayout.Toggle(textfx_instance.m_use_colour_gradient, GUILayout.Width(20));
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            textfx_instance.m_display_axis       = (TextDisplayAxis)EditorGUILayout.EnumPopup(new GUIContent("Display Axis", "Denotes whether to render the text horizontally or vertically."), textfx_instance.m_display_axis);
            textfx_instance.m_text_anchor        = (TextAnchor)EditorGUILayout.EnumPopup(new GUIContent("Text Anchor", "Defines the anchor point about which the text is rendered"), textfx_instance.m_text_anchor);
            textfx_instance.m_text_alignment     = (TextAlignment)EditorGUILayout.EnumPopup(new GUIContent("Text Alignment", "Defines the alignment of the text, just like your favourite word processor."), textfx_instance.m_text_alignment);
            textfx_instance.m_character_size     = EditorGUILayout.FloatField(new GUIContent("Character Size", "Specifies the size of the text."), textfx_instance.m_character_size);
            textfx_instance.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."), textfx_instance.m_line_height_factor);

            EditorGUILayout.BeginHorizontal();
            textfx_instance.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."), textfx_instance.m_override_font_baseline);
            if (textfx_instance.m_override_font_baseline)
            {
                textfx_instance.m_font_baseline_override = EditorGUILayout.FloatField(new GUIContent("Font Baseline Offset", ""), textfx_instance.m_font_baseline_override);
            }
            EditorGUILayout.EndHorizontal();

            textfx_instance.m_px_offset = EditorGUILayout.Vector2Field("Letter Spacing Offset", textfx_instance.m_px_offset);
            textfx_instance.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."), textfx_instance.m_max_width);

            if (GUI.changed)
            {
                EditorUtility.SetDirty(textfx_instance);
            }

            if (m_old_char_size != textfx_instance.m_character_size ||
                m_old_textColour != textfx_instance.m_textColour ||
                !m_old_vertexColour.Equals(textfx_instance.m_textColourGradient) ||
                m_old_use_gradients != textfx_instance.m_use_colour_gradient ||
                m_old_display_axis != textfx_instance.m_display_axis ||
                m_old_line_height != textfx_instance.m_line_height_factor ||
                m_old_max_width != textfx_instance.m_max_width ||
                !m_old_text.Equals(textfx_instance.m_text) ||
                m_old_text_alignment != textfx_instance.m_text_alignment ||
                m_old_text_anchor != textfx_instance.m_text_anchor ||
                m_old_px_offset != textfx_instance.m_px_offset ||
                m_old_baseline_override != textfx_instance.m_override_font_baseline ||
                (textfx_instance.m_override_font_baseline && m_old_font_baseline != textfx_instance.m_font_baseline_override))
            {
                textfx_instance.SetText(textfx_instance.m_text);
            }
        }
		public bool DrawQuickEditorGUI(PresetEffectSetting effect_setting, float gui_x_offset, ref float gui_y_offset, bool ignore_gui_changes)
		{
			VertexColour colorFrom = new VertexColour (), colorTo = new VertexColour (), colorThen = new VertexColour ();

			EditorGUI.LabelField (new Rect (gui_x_offset, gui_y_offset, 300, LINE_HEIGHT), effect_setting.m_setting_name);
			
			gui_y_offset += LINE_HEIGHT;
			gui_x_offset += 15;

			if(!m_use_colour_gradients)
			{
				colorFrom.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueFrom.top_left);
				gui_x_offset += 45;
			}
			else
			{
				colorFrom.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueFrom.top_left);
				colorFrom.bottom_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueFrom.bottom_left);
				gui_x_offset += 45;
				colorFrom.top_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueFrom.top_right);
				colorFrom.bottom_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueFrom.bottom_right);

				gui_x_offset += 45;
			}


			if(Progression == (int) ValueProgression.Eased || Progression == (int) ValueProgression.EasedCustom || Progression == (int) ValueProgression.Random)
			{
				EditorGUI.LabelField (new Rect (gui_x_offset + 5, gui_y_offset + (m_use_colour_gradients ? 10 : 0), 20, LINE_HEIGHT), "->", EditorStyles.boldLabel);

				gui_x_offset += 35;
				
				if(!m_use_colour_gradients)
				{
					colorTo.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueTo.top_left);
					gui_x_offset += 45;
				}
				else
				{
					colorTo.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueTo.top_left);
					colorTo.bottom_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueTo.bottom_left);
					gui_x_offset += 45;
					colorTo.top_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueTo.top_right);
					colorTo.bottom_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueTo.bottom_right);
					gui_x_offset += 45;
				}
				
				if(Progression == (int) ValueProgression.Eased && m_to_to_bool)
				{
					EditorGUI.LabelField (new Rect (gui_x_offset + 5, gui_y_offset + (m_use_colour_gradients ? 10 : 0), 20, LINE_HEIGHT), "->", EditorStyles.boldLabel);
					
					gui_x_offset += 35;

					if(!m_use_colour_gradients)
					{
						colorThen.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueThen.top_left);
						gui_x_offset += 45;
					}
					else
					{
						colorThen.top_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueThen.top_left);
						colorThen.bottom_left = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueThen.bottom_left);
						gui_x_offset += 45;
						colorThen.top_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset, LINE_HEIGHT*2, LINE_HEIGHT), ValueThen.top_right);
						colorThen.bottom_right = EditorGUI.ColorField(new Rect(gui_x_offset, gui_y_offset + LINE_HEIGHT, LINE_HEIGHT*2, LINE_HEIGHT), ValueThen.bottom_right);
						gui_x_offset += 45;
					}
				}
			}

			if(m_use_colour_gradients)
				gui_y_offset += 2 * LINE_HEIGHT;
			else
				gui_y_offset += LINE_HEIGHT;


			if(GUI.changed && !ignore_gui_changes)
			{
				if(Progression == (int) ValueProgression.Constant)
					SetConstant(colorFrom);
				else if(Progression == (int) ValueProgression.Eased)
				{
					if(m_to_to_bool)
						SetEased(colorFrom, colorTo, colorThen);
					else
						SetEased(colorFrom, colorTo);
				}
				else if(Progression == (int) ValueProgression.Random)
					SetRandom(colorFrom, colorTo);
				else if(Progression == (int) ValueProgression.EasedCustom)
					SetEasedCustom(colorFrom, colorTo);
				
				return true;
			}
			
			return false;
		}
    public void CalculateUniqueRandom(AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, VertexColour[] offset_colours)
    {
        int progression_idx = GetProgressionIndex(progression_variables, animate_per);
        bool constant_offset = offset_colours != null && offset_colours.Length == 1;

        m_values[progression_idx] = m_is_offset_from_last ? offset_colours[constant_offset ? 0 : progression_idx].Clone() : new VertexColour(new Color(0,0,0,0));
        m_values[progression_idx] = m_values[progression_idx].Add(m_from.Add(m_to.Sub(m_from).Multiply(UnityEngine.Random.value)));
    }
Beispiel #38
0
    void SetupMesh(LetterAction letter_action, float action_progress, bool first_action_call, AnimationProgressionVariables progression_variables, AnimatePerOptions animate_per, float linear_progress)
    {
        if (first_action_call || !letter_action.StaticPosition || !letter_action.StaticRotation || !letter_action.StaticScale)
        {
            Vector3[] mesh_verts = new Vector3[4];
            for (int idx = 0; idx < 4; idx++)
            {
                // rotate vertices
                // handle letter anchor x-offset
                Vector3 anchor_offset = Vector3.zero;
                if (letter_action.m_letter_anchor == TextAnchor.UpperRight || letter_action.m_letter_anchor == TextAnchor.MiddleRight || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(m_width, 0, 0);
                }
                else if (letter_action.m_letter_anchor == TextAnchor.UpperCenter || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.LowerCenter)
                {
                    anchor_offset += new Vector3(m_width / 2, 0, 0);
                }

                // handle letter anchor y-offset
                if (letter_action.m_letter_anchor == TextAnchor.MiddleLeft || letter_action.m_letter_anchor == TextAnchor.MiddleCenter || letter_action.m_letter_anchor == TextAnchor.MiddleRight)
                {
                    anchor_offset += new Vector3(0, m_height / 2, 0);
                }
                else if (letter_action.m_letter_anchor == TextAnchor.LowerLeft || letter_action.m_letter_anchor == TextAnchor.LowerCenter || letter_action.m_letter_anchor == TextAnchor.LowerRight)
                {
                    anchor_offset += new Vector3(0, m_height, 0);
                }

                mesh_verts[idx] = m_base_vertices[idx];

                mesh_verts[idx] -= anchor_offset;

                // Scale verts
//				if(first_action_call) // || !letter_action.StaticScale)
//				{
                Vector3 from_scale = letter_action.m_start_scale.GetValue(progression_variables, animate_per);
                Vector3 to_scale   = letter_action.m_end_scale.GetValue(progression_variables, animate_per);

                if (letter_action.m_scale_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                                    new Vector3(EffectManager.FloatLerp(from_scale.x, to_scale.x, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_x_ease, linear_progress)),
                                                                EffectManager.FloatLerp(from_scale.y, to_scale.y, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_y_ease, linear_progress)),
                                                                EffectManager.FloatLerp(from_scale.z, to_scale.z, EasingManager.GetEaseProgress(letter_action.m_scale_axis_ease_data.m_z_ease, linear_progress))));
                }
                else
                {
                    mesh_verts[idx] = Vector3.Scale(mesh_verts[idx],
                                                    EffectManager.Vector3Lerp(
                                                        from_scale,
                                                        to_scale,
                                                        action_progress)
                                                    );
                }
//				}

                // Rotate vert
//				if(first_action_call) // || !letter_action.StaticRotation)
//				{
                Vector3 from_rotation = letter_action.m_start_euler_rotation.GetValue(progression_variables, animate_per);
                Vector3 to_rotation   = letter_action.m_end_euler_rotation.GetValue(progression_variables, animate_per);

                if (letter_action.m_rotation_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] = Quaternion.Euler
                                      (
                        EffectManager.FloatLerp(from_rotation.x, to_rotation.x, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_x_ease, linear_progress)),
                        EffectManager.FloatLerp(from_rotation.y, to_rotation.y, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_y_ease, linear_progress)),
                        EffectManager.FloatLerp(from_rotation.z, to_rotation.z, EasingManager.GetEaseProgress(letter_action.m_rotation_axis_ease_data.m_z_ease, linear_progress))
                                      ) * mesh_verts[idx];;
                }
                else
                {
                    mesh_verts[idx] = Quaternion.Euler(
                        EffectManager.Vector3Lerp(
                            from_rotation,
                            to_rotation,
                            action_progress)
                        )
                                      * mesh_verts[idx];
                }
//				}

                mesh_verts[idx] += anchor_offset;

                // translate vert
                Vector3 from_pos = (!letter_action.m_start_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_start_pos.GetValue(progression_variables, animate_per);
                Vector3 to_pos   = (!letter_action.m_end_pos.m_force_position_override ? m_base_offset : Vector3.zero) + letter_action.m_end_pos.GetValue(progression_variables, animate_per);

                if (letter_action.m_position_axis_ease_data.m_override_default)
                {
                    mesh_verts[idx] += new Vector3(EffectManager.FloatLerp(from_pos.x, to_pos.x, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_x_ease, linear_progress)),
                                                   EffectManager.FloatLerp(from_pos.y, to_pos.y, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_y_ease, linear_progress)),
                                                   EffectManager.FloatLerp(from_pos.z, to_pos.z, EasingManager.GetEaseProgress(letter_action.m_position_axis_ease_data.m_z_ease, linear_progress)));
                }
                else
                {
                    mesh_verts[idx] += EffectManager.Vector3Lerp(
                        from_pos,
                        to_pos,
                        action_progress);
                }
            }
            m_mesh.vertices = mesh_verts;
        }


        if (first_action_call || !letter_action.StaticColour)
        {
            if (letter_action.m_use_gradient_start || letter_action.m_use_gradient)
            {
                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 || letter_action.m_use_gradient)
            {
                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)
                };
            }
        }
    }
		public void SetEasedCustom ( VertexColour eased_from, VertexColour eased_to)
		{
			SetEasedCustom (eased_from, eased_to, m_custom_ease_curve);
		}
		public void SetConstant( VertexColour constant_value )
		{
			m_progression_idx = (int) ValueProgression.Constant;
			m_from = constant_value;
		}
Beispiel #41
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.m_force_position_override)
        {
            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.m_force_position_override)
        {
            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)
            };
        }
    }
		public void SetEasedCustom ( VertexColour eased_from, VertexColour eased_to, AnimationCurve easing_curve)
		{
			m_progression_idx = (int) ValueProgression.EasedCustom;
			m_from = eased_from;
			m_to = eased_to;
			m_to_to_bool = false;
			
			m_custom_ease_curve = easing_curve;
		}
		public void SetValues( VertexColour[] colValues)
		{
			m_values = colValues;
			m_progression_idx = (int) ValueProgression.Eased;
		}
Beispiel #44
0
    private 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)
            ScaleLocal = 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
            ScaleLocal = 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)
            RotationLocal = 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
            RotationLocal = 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
        CenterLocal = new Vector3(m_width / 2, m_height / 2, 0);
        CenterLocal -= m_anchor_offset;
        CenterLocal = Vector3.Scale(CenterLocal, ScaleLocal);
        CenterLocal = RotationLocal * CenterLocal;
        CenterLocal += m_anchor_offset + m_letter_position;

        if (mesh_verts == null || mesh_verts.Length == 0)
            mesh_verts = new Vector3[4];
        for (var 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], ScaleLocal);

            // Rotate vert
            mesh_verts[idx] = RotationLocal * 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.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.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) };
    }