Files
MinFt/Client/LocalPackages/SoftMaskForUGUI-3.5.0/Runtime/Internal/Utilities/PowerRangeAttribute.cs
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

59 lines
2.0 KiB
C#

using System;
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
namespace Coffee.UISoftMaskInternal
{
[AttributeUsage(AttributeTargets.Field)]
[Conditional("UNITY_EDITOR")]
public sealed class PowerRangeAttribute : PropertyAttribute
{
public readonly float min;
public readonly float max;
public readonly float power;
public PowerRangeAttribute(float min, float max, float power)
{
this.min = min;
this.max = max;
this.power = power;
}
}
#if UNITY_EDITOR
[CustomPropertyDrawer(typeof(PowerRangeAttribute))]
internal sealed class RangeDrawer : PropertyDrawer
{
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
{
var labelWidth = EditorGUIUtility.labelWidth;
var attr = (PowerRangeAttribute)attribute;
label = EditorGUI.BeginProperty(r, label, property);
EditorGUI.BeginChangeCheck();
var rSlider = new Rect(r.x + labelWidth + 1, r.y, r.width - labelWidth - 57, r.height);
var powValue = Mathf.Log(property.floatValue, attr.power);
var powMin = Mathf.Log(attr.min, attr.power);
var powMax = Mathf.Log(attr.max, attr.power);
powValue = GUI.HorizontalSlider(rSlider, powValue, powMin, powMax);
if (EditorGUI.EndChangeCheck())
{
property.floatValue = Mathf.Clamp(Mathf.Pow(attr.power, powValue), attr.min, attr.max);
}
EditorGUI.BeginChangeCheck();
EditorGUIUtility.labelWidth = r.width - 53;
var newValue = EditorGUI.FloatField(r, label, property.floatValue);
if (EditorGUI.EndChangeCheck())
{
property.floatValue = Mathf.Clamp(newValue, attr.min, attr.max);
}
EditorGUI.EndProperty();
EditorGUIUtility.labelWidth = labelWidth;
}
}
#endif
}