1.8.0: Added AssetsOnly, SceneObjectsOnly, AssignAssetIfNull, AssignComponentIfNull
- Attributes: Added AssetsOnly, SceneObjectsOnly, AssignAssetIfNull, AssignComponentIfNull - Attributes: Replaced AssignIfNull with AssignComponentIfNull
This commit is contained in:
parent
070b82767f
commit
eb19150d98
23 changed files with 302 additions and 73 deletions
25
Editor/ValueModifiers/SceneObjectsOnlyAttributeDrawer.cs
Normal file
25
Editor/ValueModifiers/SceneObjectsOnlyAttributeDrawer.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Module.Inspector.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(SceneObjectsOnlyAttribute))]
|
||||
internal sealed class SceneObjectsOnlyAttributeDrawer : ValueModifierPropertyDrawer
|
||||
{
|
||||
public override void Modify(ValueModifierPropertyAttribute attribute, SerializedProperty property)
|
||||
{
|
||||
if (property.propertyType != SerializedPropertyType.ObjectReference)
|
||||
return;
|
||||
|
||||
Object obj = property.objectReferenceValue;
|
||||
|
||||
if (obj != null && !IsValid(obj))
|
||||
property.objectReferenceValue = null;
|
||||
}
|
||||
|
||||
private static bool IsValid(Object obj)
|
||||
{
|
||||
return !AssetDatabase.Contains(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue