《我的来世是个包裹》开发日志0208
1)修复了一些音效和界面BUG。
2)解决了“历史对话消息”里滚动区域长度和内容不匹配的问题。
一开始我完全不知道怎么办才好,然后我想UGUI里应该有对应的属性可以读到。可是国内访问UNITYAPI官网特别慢,我于是在代码里DEBUG查看几个可疑的变量:
Debug.Log("flexibleHeight = "+historySentenceParaText.flexibleHeight);
Debug.Log("GetPixelAdjustedRect = " + historySentenceParaText.GetPixelAdjustedRect());
Debug.Log("pixelsPerUnit = " + historySentenceParaText.pixelsPerUnit);
Debug.Log("preferredHeight = " + historySentenceParaText.preferredHeight);
通过在运行时暂停对比组件属性,结果发现<Text>().preferredHeight是文字区域的实际像素高度。
知道了这个就好办了。我只需:
historySentencePara.GetComponent<RectTransform>().sizeDelta = new Vector2(500, historySentenceParaText.preferredHeight);
就能动态调整区域了。
然后是默认焦点问题,这个暂时不紧急,以后再优化。