Unity3d開發之十四:unity3d長string格式化,並且滑動顯示,指定替換文字內容
unity3d長string格式化,並且滑動顯示,指定替換文字內容
長文字顯示-----------------------------------------------------------------------------
宣告一個string型別,記住格式 @“文字 ”:
例項如下:
string detail = @"
1 .This activity is valid from {0} to {1}. You have to use {2} App Client (the ""App"")to join in this activity.
2 .During the activity, you may get different kinds of Puzzles and redeem them for the following rewards:
{3}
3 .During the activity, you may get the Puzzles in the following ways:
(1) Bubble for Puzzles.You may get random Puzzles when take part in Bubble for Puzzles.There are six Bubbles at the same time displayed in applicable page as well as the kind of the Puzzle(s) you may get for each Bubble.You may choose the Bubble you want and watch a video from the beginning to the end according to the instruction to get a random number of the Puzzle(s) of such kind. Please note that if you close the App Or turn off the screen before you finish watching the video, you will get nothing;
(2) Luck Spin.You may get random Puzzles when you spin in the Lucky Spin.To get a chance of spin, you shall watch a video from the beginning to the end according to the instruction.
4 .The ways you get the Puzzles, the number of Puzzles you get in each way and the rewards may be changed from time to time. Please refer to the activity page in the App to check the latest activity details.
5 .When you redeem for a reward (except for the Coins), you must fill in your shipping information accurately, otherwise you are solely responsible for the failure of reward delivery.We will confirm your shipping information within 7 working days.After our confirmation, the reward will be delivered to you in several days. You need to abide by all applicable laws and take responsibility for tax declaration and payment.
6 .Please note that upon the end of the activity, any unredeemed Puzzles will be cleared up and no compensation will be made to you.
7 .We will not provide any after-sales services for the rewards you get in the App. If you have any question about the rewards, please contact the applicable manufacturer.
8 .In the event of any force majeure event or any change of circumstance that we cannot control(including but not limited to strikes, act of God, policy changes, act of governmental, cyberattack and system failure) leading to the cessation or adjustment of any activity, please understand that we are not obligated to make any compensation to you, nor shall we undertake any liability whatsoever.In the event of any failure to whatsoever.In the event of any failure to participate in any activity due to your improper operation, network failure, failure of telecom operator or any third party reasons, we are not obligated to make any compensation, nor shall we undertake any legal liability whatsoever.
9 .Please strictly abide by the activity rules.If any cheating or violation is found(including but not limited to using illegal tools to decode our services and hackings), measures will be taken including but not limited to disqualification from taking part in this activity, redeeming for any rewards, getting any redeemed reward and/or using the App, under which circumstance, no compensation in any form will be made to you and we also reserve the right to require you to return any rights, interests and rewards that you have received.
10 .To the extent permitted by the applicable law, we have the right to make adjustments to the activity rules at any time, and we will send prior notice in the App if we decide to make significant adjustment. The adjustment will take effect at the time of the release of the notice or the time specified in the notice. If you do not agree with any adjustments please do not join in this activity anymore.
11 .We reserve the right to interpret the activity rules to the extent permitted by applicable laws and regulations.
12 .Our End User License Agreement and Privacy Policy shall also be applicable to this activity.In case of any difference and inconsistency between the policies and any specific activity rules, the specific activity rules shall prevail in terms of this activity.
13 .If you have any questions or disputes arising out of or in relation to the rules this activity or the App please contact us by emailing at {4}.
14 .Apple is not involved in any way with this activity.
";
展示:
m_Email.text = m_DetailData.email;
滑動顯示-----------------------------------------------------------------------------
新增滑動列表:
為滑動列表新增自動擴充的元件:
為文字框新增自動擴充元件:
程式碼裡面匹配文字框高度和滑動列表高度,這裡需要注意的就是需要用協程做個延時,0.1s就行,不然會有匹配不了高度的bug,這可能是unity自帶的毛病:
StartCoroutine(TimeUtlis.Delay(() =>
{
float height = m_Texts.GetComponent<RectTransform>().rect.height;
m_content.GetComponent<RectTransform>().SetHeight(height);
}));
替換指定文字-----------------------------------------------------------------------------
主要使用的是 string.Format(替換的文字,文字中的指定位置{0},文字中的指定位置{1},文字中的指定位置{2},文字中的指定位置{3},文字中的指定位置{4})
類似:
如果需要手動換行,在指定位置使用 \n即可!
string detailText = "";
for (int i = 0; i < m_DetailData.detailItemDatas.Count; i++)
{
detailText += "("+(i+1)+")" +" Redeem " + m_DetailData.detailItemDatas[i].target +" " + m_DetailData.detailItemDatas[i].title+ " Puzzles for a " + m_DetailData.detailItemDatas[i].title+"; \n";
}
m_Texts.text = string.Format(detail, m_DetailData.startDate, m_DetailData.endDate, m_DetailData.name, detailText, m_DetailData.email);
相關文章
- 替換文字檔案中指定的內容
- linux替換文字內容Linux
- JavaScript 替換字串全部指定內容JavaScript字串
- Sql Server 替換某一列中指定的文字內容SQLServer
- vim 清空內容和替換文字
- JAVA編輯word替換指定內容,解決插入圖片顯示不全問題Java
- javascript如何替換字串中的指定內容JavaScript字串
- js替換字串中的所有指定內容JS字串
- Flex佈局-垂直居中並換行顯示內容Flex
- css文字超出div隱藏剩下內容並顯示省略號CSS
- excel替換指定列的文字Excel
- QT之——QTableWidget拖拽單元格並替換內容(進階)QT
- jQuery實現的將指定元素中的內容替換jQuery
- js實現的替換字串中的全部指定內容JS字串
- idea替換內容快捷鍵 idea怎麼替換掉所選的文字Idea
- linux批量替換指定資料夾中所有檔案的指定內容Linux
- vim內替換檔案內容
- 如何將一個數字轉換為字串並且按照指定格式顯示?--TO_CHAR字串
- Python提取文字指定內容Python
- css文字超出2行就隱藏並且顯示省略號CSS
- Python 查詢PDF中的指定文字並高亮顯示Python
- unity3d學校的課程內容有哪些?Unity3D
- js控制文字內容過多時候點選展開方式顯示全部內容demoJS
- css記錄1:文字塊內超長只顯示一行,且超過寬度顯示為省略號CSS
- 有什麼方法可以自動合併視訊並替換音訊內容音訊
- js實現的對字串中的指定內容進行替換操作JS字串
- Linux給檔案內容每行指定字元資料脫敏替換Linux字元
- 【SQL*Plus】列格式化命令之 “NUL[L] text”——定製NULL的顯示內容SQLNull
- 當內容超出最大的長度的時候,使用CSS使文字顯示省略號CSS
- DataView:利用RowDataBound來轉換要顯示的內容View
- mysql 如何替換資料表欄位字串中指定單詞的內容MySql字串
- RecyclerView 滑動之後顯示資料錯亂View
- Jmeter二次開發函式 - 文字替換JMeter函式
- chm 檔案開啟只顯示目錄,不顯示內容
- [Unity3D]Unity3D遊戲開發之Lua與遊戲的不解之緣終結篇:UniLua熱更新全然解讀Unity3D遊戲開發
- webView文字長按顯示英文WebView
- 複習Linux如何顯示檔案指定行數的內容Linux
- 【iOS開發】UIScrollView看不到內容、UIScrollView不能滑動iOSUIView