升级6.4.升级水,升级天气

This commit is contained in:
2026-04-05 00:26:54 +08:00
parent 63bc9b5536
commit 5f7cbfb713
635 changed files with 34718 additions and 22567 deletions

View File

@@ -30,7 +30,7 @@ namespace WaveHarmonic.Crest.Attributes
/// <summary>
/// Override this method to customise the label.
/// </summary>
internal virtual GUIContent BuildLabel(GUIContent label) => label;
internal virtual GUIContent BuildLabel(SerializedProperty property, GUIContent label, DecoratedDrawer drawer) => label;
/// <summary>
/// Override this method to make your own IMGUI based GUI for the property.
@@ -55,7 +55,7 @@ namespace WaveHarmonic.Crest.Attributes
/// <summary>
/// Override this method to customise the label.
/// </summary>
internal virtual GUIContent BuildLabel(GUIContent label) => label;
internal virtual GUIContent BuildLabel(SerializedProperty property, GUIContent label, DecoratedDrawer drawer) => label;
/// <summary>
/// Override this method to additively change the appearance of a decorated field.
@@ -83,6 +83,37 @@ namespace WaveHarmonic.Crest.Attributes
namespace WaveHarmonic.Crest
{
sealed class CustomField : DecoratedProperty
{
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
if (drawer._Inspector == null)
{
return;
}
drawer._Inspector.OnCustomField(position, property, label, drawer);
}
}
sealed class CustomLabel : Decorator
{
public override bool AlwaysVisible => false;
internal override GUIContent BuildLabel(SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
label = base.BuildLabel(property, label, drawer);
if (drawer._Inspector == null) return label;
label = drawer._Inspector.OnCustomLabel(property, label, drawer);
return label;
}
internal override void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
// Empty
}
}
/// <summary>
/// Renders the property using EditorGUI.PropertyField.
/// </summary>
@@ -142,11 +173,48 @@ namespace WaveHarmonic.Crest
}
}
sealed class Order : Decorator
{
public override bool AlwaysVisible => true;
public readonly string _Target;
public readonly Placement _Placement;
public enum Placement
{
Heading,
Below,
Above,
}
public Order(string target, Placement placement = Placement.Heading)
{
_Target = target;
_Placement = placement;
}
}
/// <summary>
/// Renders foldout without the foldout.
/// </summary>
sealed class Stripped : DecoratedProperty
{
public enum Style
{
None,
PlatformTab,
}
readonly bool _KeepIndent;
readonly Style _Style;
public Stripped(Style style = Style.None, bool indent = false)
{
_KeepIndent = indent;
_Style = style;
}
internal override bool NeedsControlRectangle(SerializedProperty property) => false;
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
@@ -155,11 +223,33 @@ namespace WaveHarmonic.Crest
DecoratedDrawer.s_TemporaryColor = true;
DecoratedDrawer.s_PreviousColor = GUI.color;
if (_Style == Style.PlatformTab)
{
EditorGUI.indentLevel += 1;
EditorGUILayout.LabelField(label);
EditorGUI.indentLevel -= 1;
}
GUI.color = new(0, 0, 0, 0);
EditorGUI.indentLevel -= 1;
if (!_KeepIndent) EditorGUI.indentLevel -= 1;
EditorGUI.PropertyField(position, property, label, true);
EditorGUI.indentLevel += 1;
if (!_KeepIndent) EditorGUI.indentLevel += 1;
if (_Style == Style.PlatformTab)
{
EditorGUILayout.Space(4);
EditorGUILayout.EndBuildTargetSelectionGrouping();
}
}
}
sealed class PlatformTabs : DecoratedProperty
{
static readonly GUIContent s_DefaultTab = new(EditorGUIUtility.IconContent("d_Settings").image, "Default");
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
property.intValue = Editor.Reflected.EditorGUILayout.BeginBuildTargetSelectionGrouping(s_DefaultTab);
}
}
@@ -370,7 +460,7 @@ namespace WaveHarmonic.Crest
property.floatValue = Mathf.Max(_Minimum, property.floatValue);
break;
case SerializedPropertyType.Integer:
property.floatValue = Mathf.Max((int)_Minimum, property.intValue);
property.intValue = Mathf.Max((int)_Minimum, property.intValue);
break;
case SerializedPropertyType.Vector2:
var vector2Value = property.vector2Value;
@@ -621,29 +711,15 @@ namespace WaveHarmonic.Crest
sealed class InlineToggle : DecoratedProperty
{
// Add extra y offset. Needed for foldouts in foldouts so far.
readonly bool _Fix;
public InlineToggle(bool fix = false)
{
_Fix = fix;
}
internal override bool NeedsControlRectangle(SerializedProperty property)
{
return false;
}
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
var r = position;
r.x -= 16f;
// Align with Space offset.
if (drawer.Space > 0) r.y += drawer.Space + 2f;
if (_Fix) r.y += EditorGUIUtility.singleLineHeight + 2f;
// Seems to be needed.
// Prevent click events blocking next property.
r.width = 16f * (1f + EditorGUI.indentLevel);
r.height = EditorGUIUtility.singleLineHeight;
// Hide text.
label.text = "";
using (new EditorGUI.PropertyScope(r, label, property))
@@ -654,6 +730,9 @@ namespace WaveHarmonic.Crest
property.boolValue = EditorGUI.Toggle(r, property.boolValue);
EditorGUI.EndProperty();
}
// Pull up next property. Extra space might be margin/padding.
GUILayout.Space(-(EditorGUIUtility.singleLineHeight + 2f));
}
}
@@ -859,9 +938,9 @@ namespace WaveHarmonic.Crest
_Label = label;
}
internal override GUIContent BuildLabel(GUIContent label)
internal override GUIContent BuildLabel(SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
{
label = base.BuildLabel(label);
label = base.BuildLabel(property, label, drawer);
label.text = _Label;
return label;
}
@@ -877,7 +956,7 @@ namespace WaveHarmonic.Crest
/// </summary>
sealed class Heading : Decorator
{
readonly GUIContent _Text;
public readonly GUIContent _Text;
readonly string _HelpLink;
readonly Style _Style;
readonly bool _AlwaysVisible;