給NGUI 提供支援英文單詞換行功能

2021-07-05 03:30:01 字數 1204 閱讀 8519

ngui 的原始版本是不支援英文單詞換行的,他的判斷是針對乙個乙個字元的。但是現在我們遊戲有這個需求,就是當換行的位置是乙個單詞的時候,就把這個單詞放到下一行顯示。如下:

**修改前:this is ngui font br

eak

修改後:this is ngui font

break**

查閱ngui**後發現,可以找到uifont這個類有個 wraptext 函式 ,該函式的作用是給乙個string 使用ngui的規則進行wrap。其中如果使用者使用了行寬(max width)這個 這個引數後,當字元超過了行寬就會換行了(比如:使用前的顯示)。

所以我們就要在這個地方進行設定

int offsetspaceidx = 0;

public

string

wraptext(string text, float maxwidth, int maxlinecount, bool encoding, symbolstyle symbolstyle)

remainingwidth -= glyphwidth;

// 第② :記錄空格的位置

#if language_en

if(text[offset]==' ')

#endif

// 第② end

// doesn't fit?

if (remainingwidth < 0)

else

}#endif

// 第③ end

// can't start a new line

if (lineisempty || !multiline || linecount == maxlinecount)

endline(ref sb);

// start a brand-new line

lineisempty = true;

++linecount;

if (ch == ' ')

else

previouschar = 0;

}else

}else previouschar = ch;

// advance the offset past the symbol

if (!dynamic && symbol != null)

}return sb.tostring();

}

BitBucket提供Git支援

在收購bitbucket一週年的時候,atlassian宣布 除了長期以來一直支援的hg儲存庫之外,bitbucket將提供git儲存庫支援。u0026 xd n 部落格中明確表明 這不表示將不支援mercurial,實際上,今年早些時候google code決定支援git,這些說明有些版本控制系統...

給tornado新增dbutils支援

開啟tornado的database.py模組找到reconnect函式 新增dbutils資料池支援後 如下 def reconnect self closes the existing database connection and re opens it.self.close try pool...

使用谷歌提供的支援庫 Android

android支援庫提供了乙個jar檔案 裡面包含api庫 允許開發者在較早期的android版本中使用一些最新的android apis 比如支援庫中提供了乙個版本的 fragment api 當你在開發時在專案中匯入此jar包,你就可以在android 1.6 api level 4 或者更高版...