private void SetupIcon(ScriptableText sct) { if (sct.UseIcon) { switch (sct.Alignment) { case ScriptableText.IconAlignment.Left: IconLeft.enabled = true; IconRight.enabled = false; break; case ScriptableText.IconAlignment.Right: IconLeft.enabled = false; IconRight.enabled = true; break; } this.IconLeft.color = sct.IconColor; this.IconRight.color = sct.IconColor; this.IconLeft.sprite = sct.Icon; this.IconRight.sprite = sct.Icon; IconRightSize.preferredWidth = sct.IconSize.x; IconRightSize.preferredHeight = sct.IconSize.y; IconLeftSize.preferredWidth = sct.IconSize.x; IconLeftSize.preferredHeight = sct.IconSize.y; } }
public void InitializeStackingScriptableText(int listPosition, Vector3 pos, string value, string name) { if (m_stackingText.ContainsKey(name) == true) { if (!m_stackingText[name].gameObject.activeInHierarchy) { m_stackingText.Remove(name); } } ScriptableText sct = m_textTypeList.ScriptableTextTyps[listPosition]; if (m_stackingText.ContainsKey(name) == false) { //Get the position from an activ and ready to use GameObject int poolArrayIndex = GetIndex(listPosition); //prepare start Positions // call Initialize Mehtod ScriptableTextComponent scriptableTextComponent = m_objectPool[listPosition].Component[poolArrayIndex]; scriptableTextComponent.Initialize(sct, pos, value, m_targetCamera); m_stackingText.Add(name, scriptableTextComponent); } else { m_stackingText[name].SetStackValue(sct, value, pos); } }
private void SetPosition(ScriptableText sct, Vector3 pos) { if (m_onScreen) { this.m_startPosition = sct.ScreenOffset; } else { this.m_startPosition = pos + sct.WorldOffset; } }
public void SetStackValue(ScriptableText sct, string value, Vector3 pos) { m_timer = 0; SetValue(sct, value); if (m_onScreen) { this.m_startPosition = sct.ScreenOffset; } else { this.m_startPosition = pos + sct.WorldOffset; } }
private void SetupOutline(ScriptableText sct) { if (sct.UseOutline) { this.m_outline.enabled = sct.UseOutline; this.m_outline.effectColor = sct.OutlineColor; this.m_outline.effectDistance = sct.OutlineEffectDistance; } else { this.m_outline.enabled = sct.UseOutline; } }
void SetValue(ScriptableText sct, string value) { if (sct.StackValues) { if (float.TryParse(value, out float result) == true) { m_tempValue += float.Parse(value); Text.text = m_tempValue.ToString(); } else { Debug.LogWarning( "ScriptableText : StackingValues, cant stack strings with floats, please check Input Values."); } } else { Text.text = value; } }
private void SetupBackground(ScriptableText sct) { if (sct.UseBackground) { //Set Anchor,Pivot to center Background.sprite = sct.Background; Background.color = sct.BackgroundColor; BackgroundSize.preferredWidth = sct.BackgroundSize.x; BackgroundSize.preferredHeight = sct.BackgroundSize.y; SetTextPosition(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f)); Background.enabled = true; } else { BackgroundSize.preferredWidth = Text.preferredWidth; BackgroundSize.preferredHeight = Text.preferredHeight; } }
/// <summary> /// Initialize the Floating Text Component. /// </summary> /// <param Name="sct">To get alle the Information.</param> /// <param Name="pos">Start at this point.</param> /// <param Name="sctText">See this on Screen.</param> /// <param Name="targetCam">Main Camera, need this to convert World to Screen point</param> public ScriptableTextComponent Initialize(ScriptableText sct, Vector3 pos, string sctText, Camera targetCam) { SetCamera(targetCam); SetupOutline(sct); SetupText(sct); SetupIcon(sct); SetupComponent(sct); SetPosition(sct, pos); SetValue(sct, sctText); SetupBackground(sct); StartCoroutine(AnimateTextComponent()); return(this); }
void SetupComponent(ScriptableText sct) { //Font Size from ScriptableText as ref / start point for Lerp this.m_fontSize = sct.FontSize; //Amount to increase the Text Size this.m_amount = sct.IncreaseAmount + sct.FontSize; //set the Text size this.Text.fontSize = sct.FontSize; //set Color Gradient this.m_colorGradient = sct.ColorGradient; //set Animation Curve for Fonz size Animation this.m_fontSizeAnimCurve = sct.FontSizeAnimation; //set animationCurve this.m_animCurveX = sct.AnimCurveX; this.m_animCurveY = sct.AnimCurveY; //set Animation Length //---Explanation Ternary if (XCurveTime > YCurveTime) animDuration = XCurveTime else animDuration = YCurveTime this.m_animDuration = sct.AnimCurveX.keys[sct.AnimCurveX.length - 1].time >= sct.AnimCurveY.keys[sct.AnimCurveY.length - 1].time ? sct.AnimCurveX.keys[sct.AnimCurveX.length - 1].time : sct.AnimCurveY.keys[sct.AnimCurveY.length - 1].time; this.m_onScreen = sct.RenderMode == ScriptableText.TextRenderMode.ScreenSpace; this.m_stack = sct.StackValues; //Override the current animDuration with the Activation Time from the Inspector if (m_stack) { m_sct = sct; m_animDuration = sct.ActivationTime; } m_currentPosition = m_startPosition; this.m_animationDirection = sct.AnimationDirection; //set Text m_tempValue = 0; }
private void SetupText(ScriptableText sct) { this.Text.font = sct.Font; }