Skip to content

Instantly share code, notes, and snippets.

@dskjal
Last active September 22, 2016 21:07
Show Gist options
  • Select an option

  • Save dskjal/21c4310e0d0bbb6cdf8e247b81c28ed6 to your computer and use it in GitHub Desktop.

Select an option

Save dskjal/21c4310e0d0bbb6cdf8e247b81c28ed6 to your computer and use it in GitHub Desktop.
uGUI で禁則処理
// BEGIN MIT LICENSE BLOCK //
//
// Copyright (c) 2016 dskjal
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
//
// END MIT LICENSE BLOCK //
var warps = ",)]}、〕〉》」』】〙〗〟’”⦆»‐゠–〜~?!‼⁇⁈⁉・:;/。.";
var hasWarp = true;
while(hasWarp){
// 改行位置を取得するコード(省略)
var lines = generator.lines;
hasWarp = false;
// 行頭に禁則文字があるとき,そのひとつ前に改行を入れる
// 文の冒頭の禁則文字はどうしようもない
for(var i = 1; i < lines.Count; ++i) {
if( warps.Contains(t.text[ lines[i].startCharIdx ]) ){
// 禁則文字があった
t.text = t.text.Insert(Lines[i].startCharIdx - 1, System.Environment.NewLine);
hasWarp = true;
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment