1.8.0: Added AssetsOnly, SceneObjectsOnly, AssignAssetIfNull, AssignComponentIfNull

- Attributes: Added AssetsOnly, SceneObjectsOnly, AssignAssetIfNull, AssignComponentIfNull
- Attributes: Replaced AssignIfNull with AssignComponentIfNull
This commit is contained in:
Anders Ejlersen 2022-08-27 14:04:17 +02:00
parent 070b82767f
commit eb19150d98
23 changed files with 302 additions and 73 deletions

View file

@ -6,5 +6,11 @@ namespace Module.Inspector
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class ShowHiddenFieldAttribute : PropertyAttribute
{
public readonly bool editable;
public ShowHiddenFieldAttribute(bool editable = false)
{
this.editable = editable;
}
}
}

View file

@ -0,0 +1,14 @@
using System;
using UnityEngine.Scripting;
namespace Module.Inspector
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class AssetsOnlyAttribute : ValueModifierPropertyAttribute
{
[Preserve]
public AssetsOnlyAttribute()
{
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dd2c5463415149c39cafdfb013ffd252
timeCreated: 1660247975

View file

@ -0,0 +1,39 @@
using System;
namespace Module.Inspector
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class AssignAssetIfNullAttribute : ValueModifierPropertyAttribute
{
public readonly bool useType;
public readonly Type type;
public readonly string filter;
public readonly string[] searchFolders;
public AssignAssetIfNullAttribute(string[] searchFolders = null)
{
this.searchFolders = searchFolders;
}
public AssignAssetIfNullAttribute(string filter, string[] searchFolders = null)
{
this.filter = filter;
this.searchFolders = searchFolders;
}
public AssignAssetIfNullAttribute(Type type, string[] searchFolders = null)
{
this.type = type;
this.searchFolders = searchFolders;
useType = true;
}
public AssignAssetIfNullAttribute(Type type, string filter, string[] searchFolders = null)
{
this.type = type;
this.filter = filter;
this.searchFolders = searchFolders;
useType = true;
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 82c31267a89846069809fd3085f7026e
timeCreated: 1661366494

View file

@ -3,30 +3,19 @@ using System;
namespace Module.Inspector
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class AssignIfNullAttribute : ValueModifierPropertyAttribute
public sealed class AssignComponentIfNullAttribute : ValueModifierPropertyAttribute
{
public readonly bool includeChildren;
public readonly bool useType;
public readonly Type type;
public readonly bool includeChildren;
public AssignIfNullAttribute()
public AssignComponentIfNullAttribute(bool includeChildren = false)
{
useType = false;
}
public AssignIfNullAttribute(bool includeChildren)
{
useType = false;
this.includeChildren = includeChildren;
useType = false;
}
public AssignIfNullAttribute(Type type)
{
this.type = type;
useType = true;
}
public AssignIfNullAttribute(Type type, bool includeChildren)
public AssignComponentIfNullAttribute(Type type, bool includeChildren = false)
{
this.type = type;
this.includeChildren = includeChildren;

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50df169977e042c4bfb5dcf29b06c86c
timeCreated: 1661598908

View file

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

View file

@ -0,0 +1,14 @@
using System;
using UnityEngine.Scripting;
namespace Module.Inspector
{
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public sealed class SceneObjectsOnlyAttribute : ValueModifierPropertyAttribute
{
[Preserve]
public SceneObjectsOnlyAttribute()
{
}
}
}

View file

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a5113fd42950401b823cee1be6f3450b
timeCreated: 1660250588