Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

setchi/uGUI-Hypertext

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uGUI-Hypertext license Release

UnityEngine.UI.Text で任意の部分文字列をクリック可能にするコンポーネントです。English (by Google Translate)

screencast

public class RegexExample : MonoBehaviour
{
    [SerializeField] RegexHypertext text = default;

    const string RegexUrl = @"https?://(?:[!-~]+\.)+[!-~]+";
    const string RegexHashtag = @"[\s^][##]\w+";

    void Start()
    {
        text.OnClick(RegexUrl, Color.cyan, url => Debug.Log(url));
        text.OnClick(RegexHashtag, Color.green, hashtag => Debug.Log(hashtag));
    }
}

導入

Releases から Hypertext.unitypackage をダウンロードして Unity Project にインポートします。

サンプル

Hypertext/Examples に正規表現によるパターンマッチで任意の部分文字列をクリック可能にする実装例があるので参考にしてください。

使い方

HypertextBase を継承したクラスを作成し、OnClick メソッドを使って任意の部分文字列がクリックされた時のコールバックを登録できます。詳細はサンプルの RegexHypertext を参考にしてください。

/// <summary>
/// 指定した部分文字列にクリックイベントを登録します
/// </summary>
/// <param name="startIndex">部分文字列の開始文字位置</param>
/// <param name="length">部分文字列の長さ</param>
/// <param name="color">部分文字列につける色</param>
/// <param name="onClick">部分文字列がクリックされたときのコールバック</param>
protected void OnClick(int startIndex, int length, Color color, Action<string> onClick)

開発環境

Unity 2019.2.10f1

Author

setchi

License

MIT

Packages

No packages published

Contributors 2

  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.