1
This commit is contained in:
44
Unity/Scripts/Components/SetRenderScale.cs
Normal file
44
Unity/Scripts/Components/SetRenderScale.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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()
|
||||
{
|
||||
FillDefaultInspector(root, serializedObject, true);
|
||||
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user