# Settings Manager
A framework for making any serializable field a setting, complete with an procedurally popuplated Settings Provider.
![in action](Documentation~/images/settings.gif)
## Quick Start
Settings are saved in `ISettingsRepository` instances. Two default implementations are provided, one for saving user settings (`UserSettingsRepository`) and one for per-project settings (`ProjectSettingsRepository`). Settings repositories are responsible for saving and loading preferences.
You may work directly with `ISettingsRepository`, or create a `Settings` instance to manage them. Creating a `Settings` is convenient because it allows you to make use of the `UserSetting` class and attribute.
The most common case will be for packages to create a `Settings` manager with two repositories, one for user settings (`SettingsScope.User`) and one for per-project settings (`SettingsScope.Project`).
Below is an example of how most packages will use this api.
```
using UnityEditor;
using UnityEditor.SettingsManagement;
using UnityEngine;
public class MySettings
{
static Settings s_SettingsInstance;
public static Settings instance
{
get
{
if(s_SettingsInstance == null)
s_SettingsInstance = new Settings("com.unity.my-package");
return s_SettingsInstance;
}
}
// Register a new SettingsProvider that will scrape the owning assembly for [UserSetting] marked fields.
[SettingsProvider]
static SettingsProvider CreateSettingsProvider()
{
var provider = new UserSettingsProvider("Preferences/My Settings",
instance,
new [] { typeof(MySettings).Assembly });
return provider;
}
}
public class Test
{
[UserSetting("User Settings", "My User Int Value")]
static UserSetting<int> userSetting = new UserSetting<int>(MySettings.instance, "MyInteger", 42, SettingsScope.User);
[UserSetting("Project Settings", "My Project Int Value")]
static UserSetting<int> projectSetting = new UserSetting<int>(MySettings.instance, "MyInteger", 42, SettingsScope.Project);
[MenuItem("Debug/Print Settings Values")]
static void PrintValues()
{
Debug.Log($"User integer is: {(int) userSetting}, and project integer is {(int) projectSetting}");
}
}
```
Values are set and retrieved using generic methods on on your `Settings` instance:
```
MySettingsManager.instance.Get<float>("myFloatValue", SettingsScopes.Project);
```
The `Settings` class will handle finding an appropriate `ISettingsRepository` for the scope (and optional repository name), while `key` and `T` are used to find the value. Setting keys are unique among types, meaning you may re-use keys as long as the setting type is different.
```
// UserSetting<T> is a wrapper class that handles saving and loading serializable values. It is compatible with the `[UserSetting]` attribute, which is used to automatically populate a settings provider.
UserSetting<int> myIntValue = new UserSetting<int>(MySettingsManager.instance, "MyIntegerKey", 42, SettingsScopes.User);
```
`UserSetting<T>` caches the current value, and keeps a copy of the default value so that it may be reset. `UserSetting<T>` fields are also eligible for use with the `[UserSetting]` attribute, which lets the `UserSettingsProvider` automatically add it to a settings inspector.
## Settings Provider
To register your settings in the `Settings Window` you can either write your own `SettingsProvider` implementation, or use the provided `UserSettingsProvider` and let it automatically create your interface.
Making use of `UserSettingsProvider` comes with many benefits, including a uniform look for your settings UI, support for search, and per-field or mass reset support.
```
using UnityEngine;
namespace UnityEditor.SettingsManagement.Examples
{
static class MySettingsProvider
{
[SettingsProvider]
static SettingsProvider CreateSettingsProvider()
{
var provider = new UserSettingsProvider("Preferences/My Settings",
MySettingsManager.instance,
new [] { typeof(MySettingsProvider).Assembly });
return provider;
}
}
}
```
To register a field with `UserSettingsProvider`, simply decorate it with `[UserSetting(string displayCategory, string key)]`. `[SettingAttribute]` is only valid for static fields.
For more complex settings that require additional UI (or simply don't have a built-in editor), you can use `UserSettingBlockAttribute`. This provides access to the settings provider GUI. See `SettingsExamples.cs` for more on this.
没有合适的资源?快使用搜索试试~ 我知道了~
Unity中使用Ultraleap的Slider组件.zip
共2000个文件
meta:482个
md:442个
bin:225个
需积分: 2 0 下载量 15 浏览量
2024-01-29
16:19:39
上传
评论
收藏 137.85MB ZIP 举报
温馨提示
Unity中使用Ultraleap的Slider组件.zip
资源推荐
资源详情
资源评论
收起资源包目录
Unity中使用Ultraleap的Slider组件.zip (2000个子文件)
011329c5448cabb594a42ebef3312405 6KB
0115d9a4221131b82c70bacc56edde29 6KB
0116694aec95b9105a850d63b97d9242 5KB
0132d61dbde7ff87fa9a2c2b69c0e78f 28KB
0139513aa5b87a5831f1a385cc65b990 12KB
013c591fb0b89168e2065d54d828a7ee 5KB
0148abcaa66eed69a0959413cded8a1b 6KB
01495f300e5e68513172562b4fdaeb1e 4KB
014b2c59132d35c5eb93698dc85acc42 19KB
014f2e8c20386b330529d3cae5d88061 5KB
015e911de5e2856f444b42f6e2e7426a 19KB
016e446e2d59b9345528de60b3f587d7 7KB
0172c05421744352c858a21f8c9051d6 5KB
01767a69cad71e7c2db952c93e4206a7 4KB
0179c53a0c9645c29927ef5eaa14e923 5KB
0194c4501fb26ce6a29482e0c4ed0ac2 5KB
01967d07c36b9015ae37d30b6888bcd4 8KB
01a2f508612789314cce164ec91b73d5 17KB
01b7bc465ecb9bf914ed986e5a76cf97 11KB
01c2ac776a4e249ac702185eeaff685b 6KB
01cafd33f1a40837974c922ba6ad3d9d 5KB
01d3a62dc2f5ed3ffcdade7837f613c4 6KB
01e07f6385d7b5bddde22e711c287312 6KB
01fb60c51b61c2dd09c406a3813387c7 9KB
1901df56e143615cd11de2346b93557f 11KB
190d9d243f36fbeb432fbfdbe1841439 22KB
192cad2885e926eb472cc37532507d7e 6KB
1944efd275b5f6c73f5b6e3587eb5c79 14KB
19483ad38e8135ad4b0c58f94ffdd021 5KB
194dd898e9425356f9976ecab0ede58a 9KB
195e52720a35ef630b336d82bbce18ac 7KB
196a19e8a11c814b6d2045423fa4e401 15KB
198211b16fe05b752a9d738458924e7b 4KB
1982cb506d8f6d1545d7ec787929b5be 5KB
1995c06811962485aebe6aa30bf1e627 15KB
19978c4976c81287e9aa23becfd36c8c 11KB
19b1b066c75227d7d71aca097079face 7KB
19c625e577db1a6128e041e4bb4699d4 19KB
19cac1188675b441f855769784e9e703 6KB
19d4152724a1a839ba0ce5d25b2e2a3a 16KB
19e11886360fd6a0c538b74dcf63f4b3 19KB
1e002ff74087be0c6454aa24b640f42e 11KB
1e12acb8f5629189cda5ff5303f91fea 10KB
1e1fe5893194a3b9a616a4a41e2803dd 5KB
1e2f85096ce4e1a6a895e1371ee11748 4KB
1e48fad4dffab413a7ebe6354c848aa2 16KB
1e7727ddb9fd6fd550b4241fc3d53bdf 20KB
1eb975c0a8e5cce281967624f8d96a5f 4KB
1ec0202fbf656587f12bd2fa3cba6c71 5KB
1ed5d4f3ce1bb35b320ef0308fa91662 9KB
1ed6fdc9d25ce6ce6b4d29d34eafe600 8KB
1ed78d6181694893f993e07c2b651a24 8KB
1ed857a20300e3603962292eef7b3539 6KB
1edc5248dd0cef1dd27f8908eb61b3f4 12KB
1ee3255d1a42e7fd6d08da668902f6b5 554B
1ef41d79eb4002487256990e324aeaea 5KB
8b03605989c8ed36746ad3f3e098dc3d 6KB
8b162490931e0678ea8ee10bb0be108b 4KB
8b2784b39904aea5b2c6de8a1a9f58a3 9KB
8b30f123ad152ba20aee7e60ebfae273 4KB
8b37f9f2d9b50fbcf710e8a208752113 6KB
8b448a5d0b4084cb46b2da063804dd56 31KB
8b4675a9ca42a5822f66a3108755e358 5KB
8b5be909c821cb41ccbcadfc37047d3d 8KB
8b775176e6e222fafd3acb75cdd690fc 4KB
8bab02d5c8fb8bca9cfedfe4bc3609d6 14KB
8bb04d008948e144416e708216ec6616 47KB
8bb1f57afdaff661d83818b1f23d49f8 5KB
8bd5bdb4cdbb791cf4a95758690922b1 5KB
8bddcbbd07a60f9736b3a7c257f6920b 5KB
8be65bba5b6fb1b7479a650ad657324d 6KB
8be9815d7d77bf119196ecf78720d8d1 5KB
8bea0b2bcb488540bb77962b9b893d1c 20KB
a1005460a50b5031396e9c7a0925e778 35KB
a10cfc89ff6e5589045d7b8076ddf5f4 5KB
a10d28a56f4cc3182a2b80f5c84d49da 5KB
a10f96a0f31f02e5527582ca542975d0 16KB
a112185435cc293bbcdca92851404a60 239KB
a11a788daca1387e2af0883033e842fd 18KB
a136397157b52b24c98a97bfd6a7742b 5KB
a1447b31ac0b7e6d9a933dd74d944a32 9KB
a144816b3f923880d553bab1ba253da7 6KB
a14b3c70314b98a3cca9dabc1643775a 18KB
a19ebe456236d12b49b42ce32f046821 4KB
a1b5bb82970e1e694f0f87637405e29d 7KB
a1bf63bc601180f5d0b0f3454de652fe 4KB
AnnotationManager 4KB
ArtifactDB-lock 8KB
Ultraleap.Tracking.PhysicalHandsExamples.asmdef 818B
LiberationSans SDF.asset 2.15MB
Now-Medium SDF.asset 2.03MB
Now-Bold SDF.asset 2.02MB
ProjectSettings.asset 20KB
EmojiOne.asset 13KB
DropCap Numbers.asset 10KB
LiberationSans SDF - Fallback.asset 9KB
Electronic Highway Sign SDF.asset 8KB
Roboto-Bold SDF.asset 8KB
Oswald Bold SDF.asset 8KB
Anton SDF.asset 8KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
望有恒
- 粉丝: 978
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功