BITFALL/Assets/BITKit/Unity/Scripts/Components/SetRenderScale.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using UnityEngine.UIElements;
namespace BITKit
{
public class SetRenderScale : Provider<float>
{
public UniversalRenderPipelineAsset asset;
public override float Get()
{
return asset.renderScale;
}
public override void Set(float t)
{
asset.renderScale = t;
}
}
#if UNITY_EDITOR
[UnityEditor.CustomEditor(typeof(SetRenderScale))]
public class SetRenderScaleInspector : BITInspector<SetRenderScale>
{
public override VisualElement CreateInspectorGUI()
{
2023-12-15 00:08:02 +08:00
FillDefaultInspector();
2023-06-08 14:09:50 +08:00
var slider = root.Create<Slider>();
slider.SetValueWithoutNotify(agent.asset.renderScale);
slider.label = "渲染倍数";
slider.showInputField=true;
slider.RegisterValueChangedCallback(OnValueUpdate);
return root;
}
void OnValueUpdate(ChangeEvent<float> newValueEvent)
{
BITAppForUnity.ThrowIfNotPlaying();
agent.Set(newValueEvent.newValue);
}
}
#endif
}