Flatkit 추가 및 설정

This commit is contained in:
2026-01-25 11:27:33 +09:00
parent 05233497e7
commit cf16910a32
1938 changed files with 408633 additions and 244 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9d1648975e29ba54481f19aa7539ab1c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 16d050bfac257df498255636ad99d37e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class AllowNestingAttribute : DrawerAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d41033588633c0748a924eeea5313ea5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using UnityEngine;
namespace ExternPropertyAttributes
{
/// <summary>
/// Base class for all drawer attributes
/// </summary>
public class DrawerAttribute : PropertyAttribute, ICustomAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 66d036b307b3107418ba774dfd3e818c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ExpandableAttribute : DrawerAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 314ef976403cc5842881edcfed0f1e40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
public class HorizontalLineAttribute : DrawerAttribute
{
public const float DefaultHeight = 2.0f;
public const EColor DefaultColor = EColor.Gray;
public float Height { get; private set; }
public EColor Color { get; private set; }
public HorizontalLineAttribute(float height = DefaultHeight, EColor color = DefaultColor)
{
Height = height;
Color = color;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b942633f200f69f49a31450e425db6f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using System;
namespace ExternPropertyAttributes
{
public enum EInfoBoxType
{
Normal,
Warning,
Error
}
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
public class InfoBoxAttribute : DrawerAttribute
{
public string Text { get; private set; }
public EInfoBoxType Type { get; private set; }
public InfoBoxAttribute(string text, EInfoBoxType type = EInfoBoxType.Normal)
{
Text = text;
Type = type;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbcde02eaf845fd4b823aa7ccbae1588
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class MinMaxSliderAttribute : DrawerAttribute
{
public float MinValue { get; private set; }
public float MaxValue { get; private set; }
public MinMaxSliderAttribute(float minValue, float maxValue)
{
MinValue = minValue;
MaxValue = maxValue;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ead25217ddcef344dab100d8b6641ff5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ReadOnlyAttribute : DrawerAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d4d4bae540e3e9f48909d2a390998f9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ShowAssetPreviewAttribute : DrawerAttribute
{
public const int DefaultWidth = 64;
public const int DefaultHeight = 64;
public int Width { get; private set; }
public int Height { get; private set; }
public ShowAssetPreviewAttribute(int width = DefaultWidth, int height = DefaultHeight)
{
Width = width;
Height = height;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 340df9cb5dee2d64f89acb3fd58af4e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c0169dd5aba03e743b0311ae2a672aec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System;
namespace ExternPropertyAttributes
{
public enum EButtonEnableMode
{
/// <summary>
/// Button should be active always
/// </summary>
Always,
/// <summary>
/// Button should be active only in editor
/// </summary>
Editor,
/// <summary>
/// Button should be active only in playmode
/// </summary>
Playmode
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ButtonAttribute : SpecialCaseDrawerAttribute
{
public string Text { get; private set; }
public EButtonEnableMode SelectedEnableMode { get; private set; }
public ButtonAttribute(string text = null, EButtonEnableMode enabledMode = EButtonEnableMode.Always)
{
this.Text = text;
this.SelectedEnableMode = enabledMode;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e02c075671e4a234c96a584345b055f7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class ShowNativePropertyAttribute : SpecialCaseDrawerAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b22b57b309721b144b4086092d9965c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ShowNonSerializedFieldAttribute : SpecialCaseDrawerAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b1abdd5e77f173449a3508745e6d1a32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using System;
namespace ExternPropertyAttributes
{
public class SpecialCaseDrawerAttribute : Attribute, ICustomAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dba47e6e2c880004b803951104500510
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
{
"reference": "GUID:15fc0a57446b3144c949da3e2b9737a9"
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a7954c598f36eff428bb843e12eaf350
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using System;
namespace ExternPropertyAttributes
{
public interface ICustomAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2a5f904a436562b4dad68bb37ccb3c3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 01d53b0a195098f4b823e1d308fbb58d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class BoxGroupAttribute : MetaAttribute, IGroupAttribute
{
public string Name { get; private set; }
public BoxGroupAttribute(string name = "")
{
Name = name;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d04d1942f9b70894c92eaee83e9af181
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class DisableIfAttribute : EnableIfAttributeBase
{
public DisableIfAttribute(string condition)
: base(condition)
{
Inverted = true;
}
public DisableIfAttribute(EConditionOperator conditionOperator, params string[] conditions)
: base(conditionOperator, conditions)
{
Inverted = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 975b077d0d0dcb34ab2e872b70be1753
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class EnableIfAttribute : EnableIfAttributeBase
{
public EnableIfAttribute(string condition)
: base(condition)
{
Inverted = false;
}
public EnableIfAttribute(EConditionOperator conditionOperator, params string[] conditions)
: base(conditionOperator, conditions)
{
Inverted = false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9695a8313ceea2f40b543814a1fb56f3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System;
namespace ExternPropertyAttributes
{
public abstract class EnableIfAttributeBase : MetaAttribute
{
public string[] Conditions { get; private set; }
public EConditionOperator ConditionOperator { get; private set; }
public bool Inverted { get; protected set; }
public EnableIfAttributeBase(string condition)
{
ConditionOperator = EConditionOperator.And;
Conditions = new string[1] { condition };
}
public EnableIfAttributeBase(EConditionOperator conditionOperator, params string[] conditions)
{
ConditionOperator = conditionOperator;
Conditions = conditions;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c03fbbacfaf22f54eadf82c0208e9f4a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class FoldoutAttribute : MetaAttribute, IGroupAttribute
{
public string Name { get; private set; }
public FoldoutAttribute(string name)
{
Name = name;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 40af823beacb51148bcd32967a2956f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class HideIfAttribute : ShowIfAttributeBase
{
public HideIfAttribute(string condition)
: base(condition)
{
Inverted = true;
}
public HideIfAttribute(EConditionOperator conditionOperator, params string[] conditions)
: base(conditionOperator, conditions)
{
Inverted = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5a6b7cd40c24854c8b2ec2fe46500eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using UnityEngine;
namespace ExternPropertyAttributes
{
public interface IGroupAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd019b11493832547b4bec1fdf0f61a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class LabelAttribute : MetaAttribute
{
public string Label { get; private set; }
public LabelAttribute(string label)
{
Label = label;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 32017a84d90bd8842bf40ff4e4e6c1ec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using System;
namespace ExternPropertyAttributes
{
public class MetaAttribute : Attribute, ICustomAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56cddb9b014f8c2469fda1d2599c5d1f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
public class OnValueChangedAttribute : MetaAttribute
{
public string CallbackName { get; private set; }
public OnValueChangedAttribute(string callbackName)
{
CallbackName = callbackName;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac282fd1dd4fbe44fb4bb8234544cb7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
public class ShowIfAttribute : ShowIfAttributeBase
{
public ShowIfAttribute(string condition)
: base(condition)
{
Inverted = false;
}
public ShowIfAttribute(EConditionOperator conditionOperator, params string[] conditions)
: base(conditionOperator, conditions)
{
Inverted = false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c203039ec0f9fd744bacf1e4fbc09024
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using System;
namespace ExternPropertyAttributes
{
public class ShowIfAttributeBase : MetaAttribute
{
public string[] Conditions { get; private set; }
public EConditionOperator ConditionOperator { get; private set; }
public bool Inverted { get; protected set; }
public ShowIfAttributeBase(string condition)
{
ConditionOperator = EConditionOperator.And;
Conditions = new string[1] { condition };
}
public ShowIfAttributeBase(EConditionOperator conditionOperator, params string[] conditions)
{
ConditionOperator = conditionOperator;
Conditions = conditions;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 56fb7d9d7e8e6e349a601015f3d293bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: be91ba93f273f60499842de2e0956762
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using UnityEngine;
namespace ExternPropertyAttributes
{
public enum EColor
{
Clear,
White,
Black,
Gray,
Red,
Pink,
Orange,
Yellow,
Green,
Blue,
Indigo,
Violet,
Translucent,
}
public static class EColorExtensions
{
public static Color GetColor(this EColor color)
{
switch (color)
{
case EColor.Clear:
return new Color32(0, 0, 0, 0);
case EColor.White:
return new Color32(255, 255, 255, 255);
case EColor.Black:
return new Color32(0, 0, 0, 255);
case EColor.Gray:
return new Color32(128, 128, 128, 255);
case EColor.Red:
return new Color32(255, 0, 63, 255);
case EColor.Pink:
return new Color32(255, 152, 203, 255);
case EColor.Orange:
return new Color32(255, 128, 0, 255);
case EColor.Yellow:
return new Color32(255, 211, 0, 255);
case EColor.Green:
return new Color32(98, 200, 79, 255);
case EColor.Blue:
return new Color32(0, 135, 189, 255);
case EColor.Indigo:
return new Color32(75, 0, 130, 255);
case EColor.Violet:
return new Color32(128, 0, 255, 255);
case EColor.Translucent:
return new Color32(128, 128, 128, 128);
default:
return new Color32(0, 0, 0, 255);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7345ef147e487094a8946062b8f42ea8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
using System;
namespace ExternPropertyAttributes
{
public enum EConditionOperator
{
And,
Or
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 870b7a0e3a4773246a7d15eadd4499da
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 93d586bdb56283e44b30e784be213a50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class MaxValueAttribute : ValidatorAttribute
{
public float MaxValue { get; private set; }
public MaxValueAttribute(float maxValue)
{
MaxValue = maxValue;
}
public MaxValueAttribute(int maxValue)
{
MaxValue = maxValue;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7f3e565c6abe9094dbb0494d2bc59413
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class MinValueAttribute : ValidatorAttribute
{
public float MinValue { get; private set; }
public MinValueAttribute(float minValue)
{
MinValue = minValue;
}
public MinValueAttribute(int minValue)
{
MinValue = minValue;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3b9bd36c0c4c1c40921243085f16b1a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class RequiredAttribute : ValidatorAttribute
{
public string Message { get; private set; }
public RequiredAttribute(string message = null)
{
Message = message;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 902321a31e442404a9de77a7074fd44b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System;
namespace ExternPropertyAttributes
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class ValidateInputAttribute : ValidatorAttribute
{
public string CallbackName { get; private set; }
public string Message { get; private set; }
public ValidateInputAttribute(string callbackName, string message = null)
{
CallbackName = callbackName;
Message = message;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: eefeb76c242515b4f8225c45235eb654
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
using System;
namespace ExternPropertyAttributes
{
public class ValidatorAttribute : Attribute, ICustomAttribute
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a49608e63dac4c64195b2e4e1ac5fffa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6c57ddf9842db4046ba1509ed74841b0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using FlatKit;
using UnityEditor;
namespace ExternPropertyAttributes.Editor {
[CanEditMultipleObjects]
[CustomEditor(typeof(OutlineSettings))]
public class OutlineSettingsInspector : ExternalCustomInspector { }
[CanEditMultipleObjects]
[CustomEditor(typeof(FogSettings))]
public class FogSettingsInspector : ExternalCustomInspector { }
[CanEditMultipleObjects]
[CustomEditor(typeof(PixelationSettings))]
public class PixelationSettingsInspector : ExternalCustomInspector { }
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aa056e1a4f8d4d518b5bee373fe90fb2
timeCreated: 1701281418

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9b4cd5046c3ad3542a050976caeda97c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEditor;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(HorizontalLineAttribute))]
public class HorizontalLineDecoratorDrawer : DecoratorDrawer
{
public override float GetHeight()
{
HorizontalLineAttribute lineAttr = (HorizontalLineAttribute)attribute;
return EditorGUIUtility.singleLineHeight + lineAttr.Height;
}
public override void OnGUI(Rect position)
{
Rect rect = EditorGUI.IndentedRect(position);
rect.y += EditorGUIUtility.singleLineHeight / 3.0f;
HorizontalLineAttribute lineAttr = (HorizontalLineAttribute)attribute;
ExternalCustomEditorGUI.HorizontalLine(rect, lineAttr.Height, lineAttr.Color.GetColor());
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f20fca4a878d71d4da99cbb70e6cba98
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
using UnityEditor;
using UnityEngine;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(InfoBoxAttribute))]
public class InfoBoxDecoratorDrawer : DecoratorDrawer
{
public override float GetHeight()
{
return GetHelpBoxHeight();
}
public override void OnGUI(Rect rect)
{
InfoBoxAttribute infoBoxAttribute = (InfoBoxAttribute)attribute;
float indentLength = ExternalCustomEditorGUI.GetIndentLength(rect);
Rect infoBoxRect = new Rect(
rect.x + indentLength,
rect.y,
rect.width - indentLength,
GetHelpBoxHeight());
DrawInfoBox(infoBoxRect, infoBoxAttribute.Text, infoBoxAttribute.Type);
}
private float GetHelpBoxHeight()
{
InfoBoxAttribute infoBoxAttribute = (InfoBoxAttribute)attribute;
float minHeight = EditorGUIUtility.singleLineHeight * 2.0f;
float desiredHeight = GUI.skin.box.CalcHeight(new GUIContent(infoBoxAttribute.Text), EditorGUIUtility.currentViewWidth);
float height = Mathf.Max(minHeight, desiredHeight);
return height;
}
private void DrawInfoBox(Rect rect, string infoText, EInfoBoxType infoBoxType)
{
MessageType messageType = MessageType.None;
switch (infoBoxType)
{
case EInfoBoxType.Normal:
messageType = MessageType.Info;
break;
case EInfoBoxType.Warning:
messageType = MessageType.Warning;
break;
case EInfoBoxType.Error:
messageType = MessageType.Error;
break;
}
ExternalCustomEditorGUI.HelpBox(rect, infoText, messageType);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9588cfddbd9556042863ea90a1017ac3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
{
"name": "ExternAttributes.Editor",
"rootNamespace": "",
"references": [
"GUID:15fc0a57446b3144c949da3e2b9737a9"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 625525e52d3f2a642ada60b456fe20d2
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,215 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace ExternPropertyAttributes.Editor
{
// Applied in `CustomInspectorDefinitions.cs`.
public class ExternalCustomInspector : UnityEditor.Editor
{
private List<SerializedProperty> _serializedProperties = new List<SerializedProperty>();
private IEnumerable<FieldInfo> _nonSerializedFields;
private IEnumerable<PropertyInfo> _nativeProperties;
private IEnumerable<MethodInfo> _methods;
private Dictionary<string, SavedBool> _foldouts = new Dictionary<string, SavedBool>();
private void OnEnable()
{
_nonSerializedFields = ReflectionUtility.GetAllFields(
target, f => f.GetCustomAttributes(typeof(ShowNonSerializedFieldAttribute), true).Length > 0);
_nativeProperties = ReflectionUtility.GetAllProperties(
target, p => p.GetCustomAttributes(typeof(ShowNativePropertyAttribute), true).Length > 0);
_methods = ReflectionUtility.GetAllMethods(
target, m => m.GetCustomAttributes(typeof(ButtonAttribute), true).Length > 0);
}
public override void OnInspectorGUI()
{
GetSerializedProperties(ref _serializedProperties);
bool anyExternalCustomAttribute = _serializedProperties.Any(p => PropertyUtility.GetAttribute<ICustomAttribute>(p) != null);
if (!anyExternalCustomAttribute)
{
DrawDefaultInspector();
}
else
{
DrawSerializedProperties();
}
DrawNonSerializedFields();
DrawNativeProperties();
DrawButtons();
}
private void GetSerializedProperties(ref List<SerializedProperty> outSerializedProperties)
{
outSerializedProperties.Clear();
using (var iterator = serializedObject.GetIterator())
{
if (iterator.NextVisible(true))
{
do
{
outSerializedProperties.Add(serializedObject.FindProperty(iterator.name));
}
while (iterator.NextVisible(false));
}
}
}
private void DrawSerializedProperties()
{
serializedObject.Update();
// Draw non-grouped serialized properties
foreach (var property in GetNonGroupedProperties(_serializedProperties))
{
if (property.name.Equals("m_Script", System.StringComparison.Ordinal))
{
using (new EditorGUI.DisabledScope(disabled: true))
{
EditorGUILayout.PropertyField(property);
}
}
else
{
ExternalCustomEditorGUI.PropertyField_Layout(property, includeChildren: true);
}
}
// Draw grouped serialized properties
foreach (var group in GetGroupedProperties(_serializedProperties))
{
IEnumerable<SerializedProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p));
if (!visibleProperties.Any())
{
continue;
}
ExternalCustomEditorGUI.BeginBoxGroup_Layout(group.Key);
foreach (var property in visibleProperties)
{
ExternalCustomEditorGUI.PropertyField_Layout(property, includeChildren: true);
}
ExternalCustomEditorGUI.EndBoxGroup_Layout();
}
// Draw foldout serialized properties
foreach (var group in GetFoldoutProperties(_serializedProperties))
{
IEnumerable<SerializedProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p));
if (!visibleProperties.Any())
{
continue;
}
if (!_foldouts.ContainsKey(group.Key))
{
_foldouts[group.Key] = new SavedBool($"{target.GetInstanceID()}.{group.Key}", false);
}
_foldouts[group.Key].Value = EditorGUILayout.Foldout(_foldouts[group.Key].Value, group.Key, true);
if (_foldouts[group.Key].Value)
{
foreach (var property in visibleProperties)
{
ExternalCustomEditorGUI.PropertyField_Layout(property, true);
}
}
}
serializedObject.ApplyModifiedProperties();
}
private void DrawNonSerializedFields(bool drawHeader = false)
{
if (_nonSerializedFields.Any())
{
if (drawHeader)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Non-Serialized Fields", GetHeaderGUIStyle());
ExternalCustomEditorGUI.HorizontalLine(
EditorGUILayout.GetControlRect(false), HorizontalLineAttribute.DefaultHeight, HorizontalLineAttribute.DefaultColor.GetColor());
}
foreach (var field in _nonSerializedFields)
{
ExternalCustomEditorGUI.NonSerializedField_Layout(serializedObject.targetObject, field);
}
}
}
private void DrawNativeProperties(bool drawHeader = false)
{
if (_nativeProperties.Any())
{
if (drawHeader)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Native Properties", GetHeaderGUIStyle());
ExternalCustomEditorGUI.HorizontalLine(
EditorGUILayout.GetControlRect(false), HorizontalLineAttribute.DefaultHeight, HorizontalLineAttribute.DefaultColor.GetColor());
}
foreach (var property in _nativeProperties)
{
ExternalCustomEditorGUI.NativeProperty_Layout(serializedObject.targetObject, property);
}
}
}
private void DrawButtons(bool drawHeader = false)
{
if (_methods.Any())
{
if (drawHeader)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Buttons", GetHeaderGUIStyle());
ExternalCustomEditorGUI.HorizontalLine(
EditorGUILayout.GetControlRect(false), HorizontalLineAttribute.DefaultHeight, HorizontalLineAttribute.DefaultColor.GetColor());
}
foreach (var method in _methods)
{
ExternalCustomEditorGUI.Button(serializedObject.targetObject, method);
}
}
}
private static IEnumerable<SerializedProperty> GetNonGroupedProperties(IEnumerable<SerializedProperty> properties)
{
return properties.Where(p => PropertyUtility.GetAttribute<IGroupAttribute>(p) == null);
}
private static IEnumerable<IGrouping<string, SerializedProperty>> GetGroupedProperties(IEnumerable<SerializedProperty> properties)
{
return properties
.Where(p => PropertyUtility.GetAttribute<BoxGroupAttribute>(p) != null)
.GroupBy(p => PropertyUtility.GetAttribute<BoxGroupAttribute>(p).Name);
}
private static IEnumerable<IGrouping<string, SerializedProperty>> GetFoldoutProperties(IEnumerable<SerializedProperty> properties)
{
return properties
.Where(p => PropertyUtility.GetAttribute<FoldoutAttribute>(p) != null)
.GroupBy(p => PropertyUtility.GetAttribute<FoldoutAttribute>(p).Name);
}
private static GUIStyle GetHeaderGUIStyle()
{
GUIStyle style = new GUIStyle(EditorStyles.centeredGreyMiniLabel);
style.fontStyle = FontStyle.Bold;
style.alignment = TextAnchor.UpperCenter;
return style;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9dd8aae67f2416c428f8e81fed6f4f32
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 35f155b915f0f4c4295d78f6451df390
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using UnityEngine;
using UnityEditor;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(AllowNestingAttribute))]
public class AllowNestingPropertyDrawer : PropertyDrawerBase
{
protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(rect, label, property);
EditorGUI.PropertyField(rect, property, label, true);
EditorGUI.EndProperty();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f731bdca659b2154db7e2dc33effc220
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,192 @@
using UnityEngine;
using UnityEditor;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(ExpandableAttribute))]
public class ExpandablePropertyDrawer : PropertyDrawerBase
{
protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
System.Type propertyType = PropertyUtility.GetPropertyType(property);
if (typeof(ScriptableObject).IsAssignableFrom(propertyType))
{
ScriptableObject scriptableObject = property.objectReferenceValue as ScriptableObject;
if (scriptableObject == null)
{
return GetPropertyHeight(property);
}
if (property.isExpanded)
{
using (SerializedObject serializedObject = new SerializedObject(scriptableObject))
{
float totalHeight = EditorGUIUtility.singleLineHeight;
using (var iterator = serializedObject.GetIterator())
{
if (iterator.NextVisible(true))
{
do
{
SerializedProperty childProperty = serializedObject.FindProperty(iterator.name);
if (childProperty.name.Equals("m_Script", System.StringComparison.Ordinal))
{
continue;
}
bool visible = PropertyUtility.IsVisible(childProperty);
if (!visible)
{
continue;
}
float height = GetPropertyHeight(childProperty);
totalHeight += height;
}
while (iterator.NextVisible(false));
}
}
totalHeight += EditorGUIUtility.standardVerticalSpacing;
return totalHeight;
}
}
else
{
return GetPropertyHeight(property);
}
}
else
{
return GetPropertyHeight(property) + GetHelpBoxHeight();
}
}
protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(rect, label, property);
System.Type propertyType = PropertyUtility.GetPropertyType(property);
if (typeof(ScriptableObject).IsAssignableFrom(propertyType))
{
ScriptableObject scriptableObject = property.objectReferenceValue as ScriptableObject;
if (scriptableObject == null)
{
EditorGUI.PropertyField(rect, property, label, false);
}
else
{
// Draw a foldout
Rect foldoutRect = new Rect()
{
x = rect.x,
y = rect.y,
width = EditorGUIUtility.labelWidth,
height = EditorGUIUtility.singleLineHeight
};
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label, toggleOnLabelClick: true);
// Draw the scriptable object field
float indentLength = ExternalCustomEditorGUI.GetIndentLength(rect);
float labelWidth = EditorGUIUtility.labelWidth - indentLength + ExternalCustomEditorGUI.HorizontalSpacing;
Rect propertyRect = new Rect()
{
x = rect.x + labelWidth,
y = rect.y,
width = rect.width - labelWidth,
height = EditorGUIUtility.singleLineHeight
};
EditorGUI.BeginChangeCheck();
property.objectReferenceValue = EditorGUI.ObjectField(propertyRect, GUIContent.none, property.objectReferenceValue, propertyType, false);
if (EditorGUI.EndChangeCheck())
{
property.serializedObject.ApplyModifiedProperties();
}
// Draw the child properties
if (property.isExpanded)
{
DrawChildProperties(rect, property);
}
}
}
else
{
string message = $"{typeof(ExpandableAttribute).Name} can only be used on scriptable objects";
DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning);
}
EditorGUI.EndProperty();
}
private void DrawChildProperties(Rect rect, SerializedProperty property)
{
ScriptableObject scriptableObject = property.objectReferenceValue as ScriptableObject;
if (scriptableObject == null)
{
return;
}
Rect boxRect = new Rect()
{
x = 0.0f,
y = rect.y + EditorGUIUtility.singleLineHeight,
width = rect.width * 2.0f,
height = rect.height - EditorGUIUtility.singleLineHeight
};
GUI.Box(boxRect, GUIContent.none);
using (new EditorGUI.IndentLevelScope())
{
EditorGUI.BeginChangeCheck();
SerializedObject serializedObject = new SerializedObject(scriptableObject);
using (var iterator = serializedObject.GetIterator())
{
float yOffset = EditorGUIUtility.singleLineHeight;
if (iterator.NextVisible(true))
{
do
{
SerializedProperty childProperty = serializedObject.FindProperty(iterator.name);
if (childProperty.name.Equals("m_Script", System.StringComparison.Ordinal))
{
continue;
}
bool visible = PropertyUtility.IsVisible(childProperty);
if (!visible)
{
continue;
}
float childHeight = GetPropertyHeight(childProperty);
Rect childRect = new Rect()
{
x = rect.x,
y = rect.y + yOffset,
width = rect.width,
height = childHeight
};
ExternalCustomEditorGUI.PropertyField(childRect, childProperty, true);
yOffset += childHeight;
}
while (iterator.NextVisible(false));
}
}
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c1918a04454ee14a91bce2534050896
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
using UnityEditor;
using UnityEngine;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(MinMaxSliderAttribute))]
public class MinMaxSliderPropertyDrawer : PropertyDrawerBase
{
protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
return (property.propertyType == SerializedPropertyType.Vector2)
? GetPropertyHeight(property)
: GetPropertyHeight(property) + GetHelpBoxHeight();
}
protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(rect, label, property);
MinMaxSliderAttribute minMaxSliderAttribute = (MinMaxSliderAttribute)attribute;
if (property.propertyType == SerializedPropertyType.Vector2)
{
EditorGUI.BeginProperty(rect, label, property);
float indentLength = ExternalCustomEditorGUI.GetIndentLength(rect);
float labelWidth = EditorGUIUtility.labelWidth + ExternalCustomEditorGUI.HorizontalSpacing;
float floatFieldWidth = EditorGUIUtility.fieldWidth;
float sliderWidth = rect.width - labelWidth - 2.0f * floatFieldWidth;
float sliderPadding = 5.0f;
Rect labelRect = new Rect(
rect.x,
rect.y,
labelWidth,
rect.height);
Rect sliderRect = new Rect(
rect.x + labelWidth + floatFieldWidth + sliderPadding - indentLength,
rect.y,
sliderWidth - 2.0f * sliderPadding + indentLength,
rect.height);
Rect minFloatFieldRect = new Rect(
rect.x + labelWidth - indentLength,
rect.y,
floatFieldWidth + indentLength,
rect.height);
Rect maxFloatFieldRect = new Rect(
rect.x + labelWidth + floatFieldWidth + sliderWidth - indentLength,
rect.y,
floatFieldWidth + indentLength,
rect.height);
// Draw the label
EditorGUI.LabelField(labelRect, label.text);
// Draw the slider
EditorGUI.BeginChangeCheck();
Vector2 sliderValue = property.vector2Value;
EditorGUI.MinMaxSlider(sliderRect, ref sliderValue.x, ref sliderValue.y, minMaxSliderAttribute.MinValue, minMaxSliderAttribute.MaxValue);
sliderValue.x = EditorGUI.FloatField(minFloatFieldRect, sliderValue.x);
sliderValue.x = Mathf.Clamp(sliderValue.x, minMaxSliderAttribute.MinValue, Mathf.Min(minMaxSliderAttribute.MaxValue, sliderValue.y));
sliderValue.y = EditorGUI.FloatField(maxFloatFieldRect, sliderValue.y);
sliderValue.y = Mathf.Clamp(sliderValue.y, Mathf.Max(minMaxSliderAttribute.MinValue, sliderValue.x), minMaxSliderAttribute.MaxValue);
if (EditorGUI.EndChangeCheck())
{
property.vector2Value = sliderValue;
}
EditorGUI.EndProperty();
}
else
{
string message = minMaxSliderAttribute.GetType().Name + " can be used only on Vector2 fields";
DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning);
}
EditorGUI.EndProperty();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6706a615c0046cf4aa4f6f4ffae4f823
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
using UnityEditor;
using UnityEngine;
namespace ExternPropertyAttributes.Editor
{
public abstract class PropertyDrawerBase : PropertyDrawer
{
public sealed override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
{
// Check if visible
bool visible = PropertyUtility.IsVisible(property);
if (!visible)
{
return;
}
// Validate
ValidatorAttribute[] validatorAttributes = PropertyUtility.GetAttributes<ValidatorAttribute>(property);
foreach (var validatorAttribute in validatorAttributes)
{
validatorAttribute.GetValidator().ValidateProperty(property);
}
// Check if enabled and draw
EditorGUI.BeginChangeCheck();
bool enabled = PropertyUtility.IsEnabled(property);
using (new EditorGUI.DisabledScope(disabled: !enabled))
{
OnGUI_Internal(rect, property, PropertyUtility.GetLabel(property));
}
// Call OnValueChanged callbacks
if (EditorGUI.EndChangeCheck())
{
PropertyUtility.CallOnValueChangedCallbacks(property);
}
}
protected abstract void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label);
sealed override public float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
bool visible = PropertyUtility.IsVisible(property);
if (!visible)
{
return 0.0f;
}
return GetPropertyHeight_Internal(property, label);
}
protected virtual float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, includeChildren: true);
}
protected float GetPropertyHeight(SerializedProperty property)
{
SpecialCaseDrawerAttribute specialCaseAttribute = PropertyUtility.GetAttribute<SpecialCaseDrawerAttribute>(property);
if (specialCaseAttribute != null)
{
return specialCaseAttribute.GetDrawer().GetPropertyHeight(property);
}
return EditorGUI.GetPropertyHeight(property, includeChildren: true);
}
public virtual float GetHelpBoxHeight()
{
return EditorGUIUtility.singleLineHeight * 2.0f;
}
public void DrawDefaultPropertyAndHelpBox(Rect rect, SerializedProperty property, string message, MessageType messageType)
{
float indentLength = ExternalCustomEditorGUI.GetIndentLength(rect);
Rect helpBoxRect = new Rect(
rect.x + indentLength,
rect.y,
rect.width - indentLength,
GetHelpBoxHeight());
ExternalCustomEditorGUI.HelpBox(helpBoxRect, message, MessageType.Warning, context: property.serializedObject.targetObject);
Rect propertyRect = new Rect(
rect.x,
rect.y + GetHelpBoxHeight(),
rect.width,
GetPropertyHeight(property));
EditorGUI.PropertyField(propertyRect, property, true);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15bad6a367324ff438e9de75919e4b60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEditor;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyPropertyDrawer : PropertyDrawerBase
{
protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
return GetPropertyHeight(property);
}
protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(rect, label, property);
using (new EditorGUI.DisabledScope(disabled: true))
{
EditorGUI.PropertyField(rect, property, label, true);
}
EditorGUI.EndProperty();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 158ee71d6827f134595af325a6ec857a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,110 @@
using UnityEngine;
using UnityEditor;
namespace ExternPropertyAttributes.Editor
{
[CustomPropertyDrawer(typeof(ShowAssetPreviewAttribute))]
public class ShowAssetPreviewPropertyDrawer : PropertyDrawerBase
{
protected override float GetPropertyHeight_Internal(SerializedProperty property, GUIContent label)
{
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
Texture2D previewTexture = GetAssetPreview(property);
if (previewTexture != null)
{
return GetPropertyHeight(property) + GetAssetPreviewSize(property).y;
}
else
{
return GetPropertyHeight(property);
}
}
else
{
return GetPropertyHeight(property) + GetHelpBoxHeight();
}
}
protected override void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(rect, label, property);
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
Rect propertyRect = new Rect()
{
x = rect.x,
y = rect.y,
width = rect.width,
height = EditorGUIUtility.singleLineHeight
};
EditorGUI.PropertyField(propertyRect, property, label);
Texture2D previewTexture = GetAssetPreview(property);
if (previewTexture != null)
{
Rect previewRect = new Rect()
{
x = rect.x + ExternalCustomEditorGUI.GetIndentLength(rect),
y = rect.y + EditorGUIUtility.singleLineHeight,
width = rect.width,
height = GetAssetPreviewSize(property).y
};
GUI.Label(previewRect, previewTexture);
}
}
else
{
string message = property.name + " doesn't have an asset preview";
DrawDefaultPropertyAndHelpBox(rect, property, message, MessageType.Warning);
}
EditorGUI.EndProperty();
}
private Texture2D GetAssetPreview(SerializedProperty property)
{
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
if (property.objectReferenceValue != null)
{
Texture2D previewTexture = AssetPreview.GetAssetPreview(property.objectReferenceValue);
return previewTexture;
}
return null;
}
return null;
}
private Vector2 GetAssetPreviewSize(SerializedProperty property)
{
Texture2D previewTexture = GetAssetPreview(property);
if (previewTexture == null)
{
return Vector2.zero;
}
else
{
int targetWidth = ShowAssetPreviewAttribute.DefaultWidth;
int targetHeight = ShowAssetPreviewAttribute.DefaultHeight;
ShowAssetPreviewAttribute showAssetPreviewAttribute = PropertyUtility.GetAttribute<ShowAssetPreviewAttribute>(property);
if (showAssetPreviewAttribute != null)
{
targetWidth = showAssetPreviewAttribute.Width;
targetHeight = showAssetPreviewAttribute.Height;
}
int width = Mathf.Clamp(targetWidth, 0, previewTexture.width);
int height = Mathf.Clamp(targetHeight, 0, previewTexture.height);
return new Vector2(width, height);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 91ee7a4a8e531d841b7d36be94da45d0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b64bba7951f431b498ee0aafcfcf0434
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace ExternPropertyAttributes.Editor
{
public abstract class SpecialCasePropertyDrawerBase
{
public void OnGUI(Rect rect, SerializedProperty property)
{
// Check if visible
bool visible = PropertyUtility.IsVisible(property);
if (!visible)
{
return;
}
// Validate
ValidatorAttribute[] validatorAttributes = PropertyUtility.GetAttributes<ValidatorAttribute>(property);
foreach (var validatorAttribute in validatorAttributes)
{
validatorAttribute.GetValidator().ValidateProperty(property);
}
// Check if enabled and draw
EditorGUI.BeginChangeCheck();
bool enabled = PropertyUtility.IsEnabled(property);
using (new EditorGUI.DisabledScope(disabled: !enabled))
{
OnGUI_Internal(rect, property, PropertyUtility.GetLabel(property));
}
// Call OnValueChanged callbacks
if (EditorGUI.EndChangeCheck())
{
PropertyUtility.CallOnValueChangedCallbacks(property);
}
}
public float GetPropertyHeight(SerializedProperty property)
{
return GetPropertyHeight_Internal(property);
}
protected abstract void OnGUI_Internal(Rect rect, SerializedProperty property, GUIContent label);
protected abstract float GetPropertyHeight_Internal(SerializedProperty property);
}
public static class SpecialCaseDrawerAttributeExtensions
{
private static Dictionary<Type, SpecialCasePropertyDrawerBase> _drawersByAttributeType;
static SpecialCaseDrawerAttributeExtensions()
{
_drawersByAttributeType = new Dictionary<Type, SpecialCasePropertyDrawerBase>();
}
public static SpecialCasePropertyDrawerBase GetDrawer(this SpecialCaseDrawerAttribute attr)
{
SpecialCasePropertyDrawerBase drawer;
if (_drawersByAttributeType.TryGetValue(attr.GetType(), out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 85c8b6ac240d4464186d8e511aef80b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More