移除水
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d4feed62e65f34662aea25208d1ce0bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,29 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest.Attributes;
|
||||
using WaveHarmonic.Crest.Editor;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
sealed class Embedded : DecoratedProperty
|
||||
{
|
||||
internal EmbeddedAssetEditor _Editor;
|
||||
readonly int _BottomMargin;
|
||||
|
||||
public Embedded(int margin = 0)
|
||||
{
|
||||
_Editor = new();
|
||||
_BottomMargin = margin;
|
||||
}
|
||||
|
||||
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
|
||||
{
|
||||
_Editor.DrawEditorCombo(label, drawer, property, "asset", _BottomMargin);
|
||||
}
|
||||
|
||||
internal override bool NeedsControlRectangle(SerializedProperty property) => false;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c024c6def66044f1cb4783f23a050bec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,72 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest.Attributes;
|
||||
using WaveHarmonic.Crest.Editor;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
sealed class HelpBox : Decorator
|
||||
{
|
||||
// Define our own as Unity's won't be available in builds.
|
||||
public enum MessageType
|
||||
{
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
}
|
||||
|
||||
public string _Message;
|
||||
public MessageType _MessageType;
|
||||
public Visibility _Visibility;
|
||||
|
||||
public enum Visibility
|
||||
{
|
||||
Always,
|
||||
PropertyEnabled,
|
||||
PropertyDisabled,
|
||||
}
|
||||
|
||||
readonly GUIContent _GuiContent;
|
||||
|
||||
public override bool AlwaysVisible => false;
|
||||
|
||||
public HelpBox(string message, MessageType messageType = MessageType.Info, Visibility visibility = Visibility.Always)
|
||||
{
|
||||
_Message = message;
|
||||
_MessageType = messageType;
|
||||
_Visibility = visibility;
|
||||
_GuiContent = new(message);
|
||||
}
|
||||
|
||||
internal override void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
|
||||
{
|
||||
if (_Visibility == Visibility.PropertyEnabled && !GUI.enabled || _Visibility == Visibility.PropertyDisabled && GUI.enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Enable rich text in help boxes. Store original so we can revert since this might be a "hack".
|
||||
var style = GUI.skin.GetStyle("HelpBox");
|
||||
var styleRichText = style.richText;
|
||||
style.richText = true;
|
||||
|
||||
var height = style.CalcHeight(_GuiContent, EditorGUIUtility.currentViewWidth);
|
||||
if (height <= EditorGUIUtility.singleLineHeight)
|
||||
{
|
||||
// This gets internal layout of the help box right but breaks down if multiline.
|
||||
height += style.padding.horizontal + style.lineHeight;
|
||||
}
|
||||
|
||||
// Always get a new control rect so we don't have to deal with positions and offsets.
|
||||
position = EditorGUILayout.GetControlRect(true, height, style);
|
||||
// + 1 maps our MessageType to Unity's.
|
||||
EditorGUI.HelpBox(position, _Message, (UnityEditor.MessageType)_MessageType + 1);
|
||||
|
||||
// Revert skin since it persists.
|
||||
style.richText = styleRichText;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49c68d73fb5ce4690a444ab84a0abc8e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,25 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a custom link to Crest's documentation for the help URL button.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Enum, AllowMultiple = false)]
|
||||
sealed class HelpURL : HelpURLAttribute
|
||||
{
|
||||
public HelpURL(string path = "") : base(GetPageLink(path))
|
||||
{
|
||||
// Blank.
|
||||
}
|
||||
|
||||
public static string GetPageLink(string path)
|
||||
{
|
||||
return "https://docs.crest.waveharmonic.com/" + path;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f113b211b4a014cf19cf7828018f49d0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,18 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest.Attributes;
|
||||
using WaveHarmonic.Crest.Editor;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
sealed class Layer : DecoratedProperty
|
||||
{
|
||||
internal override void OnGUI(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
|
||||
{
|
||||
property.intValue = EditorGUI.LayerField(position, label, property.intValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a25b1272591fc4fd6a34265f20064746
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,33 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using System;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
sealed class OnChange : Attribute
|
||||
{
|
||||
public Type Type { get; }
|
||||
public bool SkipIfInactive { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Register an instance method as an OnChange handler.
|
||||
/// </summary>
|
||||
public OnChange(bool skipIfInactive = true)
|
||||
{
|
||||
SkipIfInactive = skipIfInactive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a static method as an OnChange handler.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to target.</param>
|
||||
/// <param name="skipIfInactive">Skip this handler if component is inactive.</param>
|
||||
public OnChange(Type type, bool skipIfInactive = true)
|
||||
{
|
||||
Type = type;
|
||||
SkipIfInactive = skipIfInactive;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75d2e7be9abf446048de686f69cb485c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,213 +0,0 @@
|
||||
// Crest Water System
|
||||
// Copyright © 2024 Wave Harmonic. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using WaveHarmonic.Crest.Attributes;
|
||||
using WaveHarmonic.Crest.Editor;
|
||||
|
||||
namespace WaveHarmonic.Crest
|
||||
{
|
||||
sealed class Predicated : Decorator
|
||||
{
|
||||
enum Mode
|
||||
{
|
||||
Property,
|
||||
Member,
|
||||
Type,
|
||||
RenderPipeline,
|
||||
}
|
||||
|
||||
readonly Mode _Mode;
|
||||
|
||||
readonly bool _Inverted;
|
||||
readonly bool _Hide;
|
||||
|
||||
readonly string _PropertyName;
|
||||
readonly object _DisableValue;
|
||||
|
||||
readonly Type _Type;
|
||||
readonly MemberInfo _Member;
|
||||
|
||||
readonly RenderPipeline _RenderPipeline;
|
||||
|
||||
/// <summary>
|
||||
/// The field with this attribute will be drawn enabled/disabled based on return of method.
|
||||
/// </summary>
|
||||
/// <param name="type">The type to call the method on. Must be either a static type or the type the field is defined on.</param>
|
||||
/// <param name="member">Member name. Method must match signature: bool MethodName(Component component). Can be any visibility and static or instance.</param>
|
||||
/// <param name="disableValue"></param>
|
||||
/// <param name="inverted">Flip behaviour - for example disable if a bool field is set to true (instead of false).</param>
|
||||
/// <param name="hide">Hide this component in the inspector.</param>
|
||||
public Predicated(Type type, string member, object disableValue, bool inverted = false, bool hide = false)
|
||||
{
|
||||
_Mode = Mode.Member;
|
||||
_Inverted = inverted;
|
||||
_Hide = hide;
|
||||
_Type = type;
|
||||
_DisableValue = disableValue;
|
||||
_Member = _Type.GetMember(member, Helpers.s_AnyMethod)[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable/Disable field depending on the current type of the component.
|
||||
/// </summary>
|
||||
/// <param name="type">If a component of this type is not attached to this GameObject, disable the GUI (or enable if inverted is true).</param>
|
||||
/// <param name="inverted">Flip behaviour - for example disable if a bool field is set to true (instead of false).</param>
|
||||
/// <param name="hide">Hide this component in the inspector.</param>
|
||||
public Predicated(Type type, bool inverted = false, bool hide = false)
|
||||
{
|
||||
_Mode = Mode.Type;
|
||||
_Inverted = inverted;
|
||||
_Hide = hide;
|
||||
_Type = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The field with this attribute will be drawn enabled/disabled based on another field. For example can be used
|
||||
/// to disable a field if a toggle is false.
|
||||
/// </summary>
|
||||
/// <param name="property">The name of the other property whose value dictates whether this field is enabled or not.</param>
|
||||
/// <param name="inverted">Flip behaviour - for example disable if a bool field is set to true (instead of false).</param>
|
||||
/// <param name="disableValue">If the field has this value, disable the GUI (or enable if inverted is true).</param>
|
||||
/// <param name="hide">Hide this component in the inspector.</param>
|
||||
public Predicated(string property, bool inverted = false, object disableValue = null, bool hide = false)
|
||||
{
|
||||
_Mode = Mode.Property;
|
||||
_Inverted = inverted;
|
||||
_Hide = hide;
|
||||
_PropertyName = property;
|
||||
_DisableValue = disableValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Field is predicated (enabled/shown) on which render pipeline is active.
|
||||
/// </summary>
|
||||
/// <param name="rp">Enable if this render pipeline is active.</param>
|
||||
/// <param name="inverted">Invert behaviour.</param>
|
||||
/// <param name="hide">Hide instead of disable.</param>
|
||||
public Predicated(RenderPipeline rp, bool inverted = false, bool hide = false)
|
||||
{
|
||||
_Mode = Mode.RenderPipeline;
|
||||
_Inverted = inverted;
|
||||
_Hide = hide;
|
||||
_RenderPipeline = rp;
|
||||
}
|
||||
|
||||
public override bool AlwaysVisible => true;
|
||||
|
||||
public bool GUIEnabled(SerializedProperty property)
|
||||
{
|
||||
return _Inverted != property.propertyType switch
|
||||
{
|
||||
// Enable GUI if int value of field is not equal to 0, or whatever the disable-value is set to
|
||||
SerializedPropertyType.Integer => property.intValue != ((int?)_DisableValue ?? 0),
|
||||
// Enable GUI if disable-value is 0 and field is true, or disable-value is not 0 and field is false
|
||||
SerializedPropertyType.Boolean => property.boolValue ^ (((int?)_DisableValue ?? 0) != 0),
|
||||
SerializedPropertyType.Float => property.floatValue != ((float?)_DisableValue ?? 0),
|
||||
SerializedPropertyType.String => property.stringValue != ((string)_DisableValue ?? ""),
|
||||
// Must pass nameof enum entry as we are comparing names because index != value.
|
||||
SerializedPropertyType.Enum => property.enumNames[property.enumValueIndex] != ((string)_DisableValue ?? ""),
|
||||
SerializedPropertyType.ObjectReference => property.objectReferenceValue != null,
|
||||
SerializedPropertyType.ManagedReference => property.managedReferenceValue != null,
|
||||
_ => throw new ArgumentException($"Crest.Predicated: property type on <i>{property.serializedObject.targetObject}</i> not implemented yet: {property.propertyType}."),
|
||||
};
|
||||
}
|
||||
|
||||
internal override void Decorate(Rect position, SerializedProperty property, GUIContent label, DecoratedDrawer drawer)
|
||||
{
|
||||
var enabled = true;
|
||||
|
||||
if (_Mode == Mode.Property)
|
||||
{
|
||||
var propertyPath = _PropertyName;
|
||||
|
||||
if (property.depth > 0)
|
||||
{
|
||||
// Get the property path so we can find it from the serialized object.
|
||||
propertyPath = $"{string.Join(".", property.propertyPath.Split(".", StringSplitOptions.None)[0..^1])}.{propertyPath}";
|
||||
}
|
||||
|
||||
// Get the other property to be the predicate for the enabled/disabled state of this property.
|
||||
// Do not use property.FindPropertyRelative as it does not work with nested properties.
|
||||
// Try and find the nested property first and then fallback to the root object.
|
||||
var otherProperty = property.serializedObject.FindProperty(propertyPath) ?? property.serializedObject.FindProperty(_PropertyName);
|
||||
Debug.AssertFormat(otherProperty != null, "Crest.Predicated: {0} or {1} property on {2} ({3}) could not be found!", propertyPath, _PropertyName, property.serializedObject.targetObject.GetType(), property.name);
|
||||
|
||||
if (otherProperty != null)
|
||||
{
|
||||
enabled = GUIEnabled(otherProperty);
|
||||
}
|
||||
}
|
||||
else if (_Mode == Mode.Member)
|
||||
{
|
||||
// Static is both abstract and sealed: https://stackoverflow.com/a/1175950
|
||||
object @object = _Type.IsAbstract && _Type.IsSealed ? null : property.serializedObject.targetObject;
|
||||
|
||||
// If this is a nested type, grab that type. This may not be suitable in all cases.
|
||||
if (property.depth > 0)
|
||||
{
|
||||
// Get the property path so we can find it from the serialized object.
|
||||
var propertyPath = string.Join(".", property.propertyPath.Split(".", StringSplitOptions.None)[0..^1]);
|
||||
|
||||
var otherProperty = property.serializedObject.FindProperty(propertyPath);
|
||||
|
||||
@object = otherProperty.propertyType switch
|
||||
{
|
||||
SerializedPropertyType.ManagedReference => otherProperty.managedReferenceValue,
|
||||
SerializedPropertyType.Generic => otherProperty.boxedValue,
|
||||
_ => @object,
|
||||
};
|
||||
}
|
||||
|
||||
if (_Member is PropertyInfo autoProperty)
|
||||
{
|
||||
// == operator does not work.
|
||||
enabled = autoProperty.GetValue(@object).Equals(_DisableValue);
|
||||
}
|
||||
else if (_Member is MethodInfo method)
|
||||
{
|
||||
enabled = method.Invoke(@object, new object[] { }).Equals(_DisableValue);
|
||||
}
|
||||
|
||||
if (_Inverted) enabled = !enabled;
|
||||
}
|
||||
else if (_Mode == Mode.Type)
|
||||
{
|
||||
var type = property.serializedObject.targetObject.GetType();
|
||||
|
||||
// If this is a nested type, grab that type. This may not be suitable in all cases.
|
||||
if (property.depth > 0)
|
||||
{
|
||||
// Get the property path so we can find it from the serialized object.
|
||||
var propertyPath = string.Join(".", property.propertyPath.Split(".", StringSplitOptions.None)[0..^1]);
|
||||
|
||||
var otherProperty = property.serializedObject.FindProperty(propertyPath);
|
||||
|
||||
type = otherProperty.propertyType switch
|
||||
{
|
||||
SerializedPropertyType.ManagedReference => otherProperty.managedReferenceValue.GetType(),
|
||||
SerializedPropertyType.Generic => otherProperty.boxedValue.GetType(),
|
||||
_ => type,
|
||||
};
|
||||
}
|
||||
|
||||
var enabledByTypeCheck = _Type.IsAssignableFrom(type);
|
||||
if (_Inverted) enabledByTypeCheck = !enabledByTypeCheck;
|
||||
enabled = enabledByTypeCheck && enabled;
|
||||
}
|
||||
else if (_Mode == Mode.RenderPipeline)
|
||||
{
|
||||
enabled = RenderPipelineHelper.RenderPipeline == _RenderPipeline != _Inverted;
|
||||
}
|
||||
|
||||
// Keep current disabled state.
|
||||
GUI.enabled &= enabled;
|
||||
|
||||
// Keep previous hidden state.
|
||||
DecoratedDrawer.s_HideInInspector = DecoratedDrawer.s_HideInInspector || (_Hide && !enabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a36938141700f4f47b31f7565311ace0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user