public void SetTextWithEllipsis(Text textComponent, string value)
{
var generator = new TextGenerator();
var rectTransform = textComponent.GetComponent<RectTransform>();
var settings = textComponent.GetGenerationSettings(rectTransform.rect.size);
generator.Populate(value, settings);
var characterCountVisible = generator.characterCountVisible;
var updatedText = value;
if (value.Length > characterCountVisible)
{
updatedText = value.Substring(0, characterCountVisible - 3);
updatedText += "…";
}
textComponent.text = updatedText;
}
Example:
Transform tt = gameObject.transform.Find("Text");
SetTextWithEllipsis(tt.gameObject.GetComponent<Text>(), "fffffffffffffffffffffffff");
2019年8月26日 星期一
中英文 符號 對照
’ | Apostrophe | 撇號 |
() | Bracket (英式) / Parentheses (美式) | 括號 |
: | Colon | 冒號 |
, | Comma | 逗號 |
- | Dash | 破折號 |
… | Ellipsis | 省略號 |
! | Exclamation Mark (英式) / Point (美式) | 感嘆號 |
. | Full Stop (英式) / Period (美式) | 句號 |
《 》 | Guillemet | 書名號 |
– | Hyphen | 連字號 |
? | Question Mark | 問號 |
"" | Quotation Mark | 引號 |
; | Semicolon | 分號 |
/ | Slash | 斜線 |
2019年8月21日 星期三
[C#, unity] Fixed: The name instantiate' does not exist in the current context
Transform cloneTransform = m_fields.GetChild(nColumn).GetChild(nIndex);
Transform tempTransform = Instantiate(cloneTransform).transform;
tempTransform.SetParent(m_fields.GetChild(nColumn));
tempTransform.localPosition = Vector3.zero;
tempTransform.localRotation = Quaternion.identity;
tempTransform.localScale = Vector3.one;
Answer:
Transform tempTransform = GameObject.Instantiate(cloneTransform).transform;
Transform tempTransform = Instantiate(cloneTransform).transform;
tempTransform.SetParent(m_fields.GetChild(nColumn));
tempTransform.localPosition = Vector3.zero;
tempTransform.localRotation = Quaternion.identity;
tempTransform.localScale = Vector3.one;
Answer:
Transform tempTransform = GameObject.Instantiate(cloneTransform).transform;
訂閱:
文章 (Atom)