# Settings Manager
A framework for making any serializable field a setting, complete with an procedurally populated 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.
没有合适的资源?快使用搜索试试~ 我知道了~
Unity3d大二下课设(上课跟随项目).rar
共2000个文件
meta:728个
md:438个
png:156个
需积分: 0 0 下载量 78 浏览量
2024-07-15
18:24:01
上传
评论
收藏 525.49MB RAR 举报
温馨提示
Unity3d大二下课设(上课跟随项目).rar
资源推荐
资源详情
资源评论
收起资源包目录
Unity3d大二下课设(上课跟随项目).rar (2000个子文件)
idle.anim 5KB
SafeBoxDoor_Open.anim 5KB
close.anim 5KB
open.anim 5KB
SafeBoxDoor_Close.anim 1KB
SafeBox_Idle.anim 1KB
SafeBoxDoor.anim 1KB
LightingData.asset 83KB
Night.asset 25KB
PP low.asset 22KB
ProjectSettings.asset 22KB
LightingData.asset 18KB
LightingData.asset 14KB
QualitySettings.asset 6KB
InputManager.asset 6KB
GraphicsSettings.asset 2KB
Physics2DSettings.asset 2KB
NavMeshAreas.asset 1KB
MemorySettings.asset 1KB
DynamicsManager.asset 1KB
UnityConnectSettings.asset 1KB
EditorSettings.asset 970B
PackageManagerSettings.asset 951B
AudioManager.asset 416B
TagManager.asset 378B
VFXManager.asset 308B
TimeManager.asset 202B
VersionControlSettings.asset 188B
EditorBuildSettings.asset 160B
XRSettings.asset 158B
PresetManager.asset 146B
ClusterInputManager.asset 114B
SupercyanShaderLighting.cginc 1KB
ThirdPersonAnimatorController.controller 21KB
FreeZombieController.controller 8KB
Zombie_AC.controller 6KB
Door.controller 6KB
Safe_Door.controller 4KB
COMIntegration.cpp 14KB
DOTweenModuleUI.cs 42KB
DOTweenModuleUnityVersion.cs 18KB
DOTweenModulePhysics.cs 14KB
WaypointCircuit.cs 13KB
DOTweenModulePhysics2D.cs 12KB
FirstPersonController.cs 10KB
RigidbodyFirstPersonController.cs 9KB
DOTweenModuleAudio.cs 9KB
ThirdPersonCharacter.cs 7KB
AutoMobileShaderSwitch.cs 7KB
TimedObjectActivator.cs 7KB
DOTweenModuleEPOOutline.cs 7KB
DOTweenModuleUtils.cs 7KB
WaypointProgressTracker.cs 7KB
CrossPlatformInputInitialize.cs 5KB
SimpleMouseRotator.cs 4KB
DOTweenModuleSprite.cs 4KB
MouseLook.cs 4KB
ActivateTrigger.cs 3KB
DragRigidbody.cs 3KB
ZombieCharacterControl.cs 3KB
PlatformSpecificContent.cs 3KB
ThirdPersonUserControl.cs 3KB
FOVKick.cs 2KB
BallUserControl.cs 2KB
HeadBob.cs 2KB
CurveControlledBob.cs 2KB
Ball.cs 2KB
ParticleSystemDestroyer.cs 2KB
AlphaButtonClickMask.cs 2KB
SmoothFollow.cs 2KB
DynamicShadowSettings.cs 2KB
ObjectResetter.cs 2KB
ZombieFree.cs 1KB
AICharacterControl.cs 1KB
CameraRefocus.cs 1KB
AutoMoveAndRotate.cs 1KB
LerpControlledBob.cs 1KB
FPSCounter.cs 1KB
SimpleActivatorMenu.cs 1KB
ZombieCameraLogic.cs 824B
TimedObjectDestructor.cs 588B
EventSystemChecker.cs 542B
ForcedReset.cs 507B
FollowTarget.cs 360B
Assembly-CSharp-firstpass.csproj 68KB
Assembly-CSharp-Editor-firstpass.csproj 68KB
MathNet.Numerics.dll 1.52MB
DOTween.dll 172KB
DOTweenEditor.dll 69KB
ReflectionProbe-0.exr 232KB
ReflectionProbe-1.exr 130KB
ReflectionProbe-0.exr 127KB
Lightmap-0_comp_light.exr 26KB
Throws.fbx 6.86MB
HumanoidCrouch.fbx 5.17MB
HumanoidIdle.fbx 1.35MB
HumanoidStandTurn.fbx 1.08MB
HumanoidRun.fbx 950KB
HumanoidJumpAndFall.fbx 935KB
Skeleton@Idle.FBX 830KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
蓝裕安
- 粉丝: 617
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功