Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skibitsky/string-formatter
👨👩👧 Format strings with HTML-like tags (Unity's Rich Text) in LINQ fashion
https://github.com/skibitsky/string-formatter
csharp rich-text unity upm-package
Last synced: about 1 month ago
JSON representation
👨👩👧 Format strings with HTML-like tags (Unity's Rich Text) in LINQ fashion
- Host: GitHub
- URL: https://github.com/skibitsky/string-formatter
- Owner: skibitsky
- License: mit
- Created: 2021-03-28T12:32:21.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-14T09:19:11.000Z (almost 2 years ago)
- Last Synced: 2024-01-28T23:38:18.372Z (10 months ago)
- Topics: csharp, rich-text, unity, upm-package
- Language: C#
- Homepage:
- Size: 19.5 KB
- Stars: 18
- Watchers: 6
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# String Formatter [![openupm](https://img.shields.io/npm/v/com.skibitsky.string-formatter?label=openupm®istry_uri=https://package.openupm.com)](https://openupm.com/packages/com.skibitsky.string-formatter/)
> Format strings with HTML-like tags (Unity's Rich Text) in LINQ fashion## Usage
```csharp
// Without String Formatter
Debug.Log($"Player's name: {name}");// With String Formatter
Debug.Log($"Player's name: {name.Bold().Italic().Size(16).Red()});// Reuse
var nameFormat = new FormattedStringBuilder().Bold().Italic().Size(16).Red();
Debug.Log($"Player One name: {nameFormat.Appy(name1)});
Debug.Log($"Player Two name: {nameFormat.Appy(name2)});// Extend
public static FormattedStringBuilder Dead(this FormattedStringBuilder source)
{
source.Append("Player "); // Add before string. Used for opening tags
source.PushToEnd(" is dead!"); // Add after string. Used for closing tags
return source.Bold().Italic(); // Also make string bold and italic
}
public static FormattedStringBuilder Dead(this string source) => new FormattedStringBuilder(source).Dead();```
## Installation
### Install via OpenUPM
The package is available on the [openupm registry](https://openupm.com). It's recommended to install it via [openupm-cli](https://github.com/openupm/openupm-cli).
```
openupm add com.skibitsky.string-formatter
```### Install via Git URL
Open *Packages/manifest.json* with your favorite text editor. Add the following line to the dependencies block.
{
"dependencies": {
"com.skibitsky.string-formatter": "https://github.com/skibitsky/string-formatter.git"
}
}Notice: Unity Package Manager records the current commit to a lock entry of the *manifest.json*. To update to the latest version, change the hash value manually or remove the lock entry to resolve the package.
"lock": {
"com.skibitsky.string-formatter": {
"revision": "master",
"hash": "..."
}
}