《我的來世是個(gè)包裹》開發(fā)日志0208
1)修復(fù)了一些音效和界面BUG。
2)解決了“歷史對話消息”里滾動區(qū)域長度和內(nèi)容不匹配的問題。
一開始我完全不知道怎么辦才好,然后我想U(xiǎn)GUI里應(yīng)該有對應(yīng)的屬性可以讀到??墒菄鴥?nèi)訪問UNITYAPI官網(wǎng)特別慢,我于是在代碼里DEBUG查看幾個(gè)可疑的變量:
Debug.Log("flexibleHeight = "+historySentenceParaText.flexibleHeight);
? ? ? ? Debug.Log("GetPixelAdjustedRect = " + historySentenceParaText.GetPixelAdjustedRect());
? ? ? ? Debug.Log("pixelsPerUnit = " + historySentenceParaText.pixelsPerUnit);
? ? ? ? Debug.Log("preferredHeight = " + historySentenceParaText.preferredHeight);
通過在運(yùn)行時(shí)暫停對比組件屬性,結(jié)果發(fā)現(xiàn)<Text>().preferredHeight是文字區(qū)域的實(shí)際像素高度。
知道了這個(gè)就好辦了。我只需:
historySentencePara.GetComponent<RectTransform>().sizeDelta = new Vector2(500, historySentenceParaText.preferredHeight);
就能動態(tài)調(diào)整區(qū)域了。
然后是默認(rèn)焦點(diǎn)問題,這個(gè)暫時(shí)不緊急,以后再優(yōu)化。