Weapos Rejiggered
Modified weapon scripts to eliminate specialized projectile behavior - allows charged weapons to have projectiles and modify weapon stats when charged Added machine gun weapon & VFX Moved third party code to Plugins folder to improve compile times
This commit is contained in:
parent
2a0fe34611
commit
dbc522a224
2105 changed files with 7033 additions and 1141 deletions
10
Assets/Plugins/NaughtyAttributes/Scripts/Core.meta
Normal file
10
Assets/Plugins/NaughtyAttributes/Scripts/Core.meta
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f67e408a6d0adf4ab29d095ccd8b116
|
||||
folderAsset: yes
|
||||
timeCreated: 1507998942
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0d8ad70d0e1e04248b1f5c5d5fb358f4
|
||||
folderAsset: yes
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
public class DrawConditionAttribute : NaughtyAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8fd9817e8bf3e054ab8e73b47bdce8c7
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class HideIfAttribute : DrawConditionAttribute
|
||||
{
|
||||
private string conditionName;
|
||||
|
||||
public HideIfAttribute(string conditionName)
|
||||
{
|
||||
this.conditionName = conditionName;
|
||||
}
|
||||
|
||||
public string ConditionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.conditionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aafc3a255165311419b7070198e7ffaf
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ShowIfAttribute : DrawConditionAttribute
|
||||
{
|
||||
private string conditionName;
|
||||
|
||||
public ShowIfAttribute(string conditionName)
|
||||
{
|
||||
this.conditionName = conditionName;
|
||||
}
|
||||
|
||||
public string ConditionName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.conditionName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6a9e9448e6e70094297d49ec9c82c6e1
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c76425e719cd4424d868674bcfb233f2
|
||||
folderAsset: yes
|
||||
timeCreated: 1508151410
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public class ButtonAttribute : DrawerAttribute
|
||||
{
|
||||
private string text;
|
||||
|
||||
public ButtonAttribute(string text = null)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d61d9be90aa48764096a2bea37c9bd60
|
||||
timeCreated: 1508591778
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
public abstract class DrawerAttribute : NaughtyAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57360d74732bf2749b2f8d5e0a0ea6f5
|
||||
timeCreated: 1508151410
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class DropdownAttribute : DrawerAttribute
|
||||
{
|
||||
private string valuesFieldName;
|
||||
|
||||
public DropdownAttribute(string valuesFieldName)
|
||||
{
|
||||
this.valuesFieldName = valuesFieldName;
|
||||
}
|
||||
|
||||
public string ValuesFieldName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.valuesFieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IDropdownList : IEnumerable<KeyValuePair<string, object>>
|
||||
{
|
||||
}
|
||||
|
||||
public class DropdownList<T> : IDropdownList
|
||||
{
|
||||
private List<KeyValuePair<string, object>> values;
|
||||
|
||||
public DropdownList()
|
||||
{
|
||||
this.values = new List<KeyValuePair<string, object>>();
|
||||
}
|
||||
|
||||
public void Add(string displayName, T value)
|
||||
{
|
||||
this.values.Add(new KeyValuePair<string, object>(displayName, value));
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
|
||||
{
|
||||
return this.values.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return this.GetEnumerator();
|
||||
}
|
||||
|
||||
public static explicit operator DropdownList<object>(DropdownList<T> target)
|
||||
{
|
||||
DropdownList<object> result = new DropdownList<object>();
|
||||
foreach (var kvp in target)
|
||||
{
|
||||
result.Add(kvp.Key, kvp.Value);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cd3b8c98b0803554e9152991fe806c62
|
||||
timeCreated: 1508752474
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class MinMaxSliderAttribute : DrawerAttribute
|
||||
{
|
||||
private float minValue;
|
||||
private float maxValue;
|
||||
|
||||
public MinMaxSliderAttribute(float minValue, float maxValue)
|
||||
{
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public float MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minValue;
|
||||
}
|
||||
}
|
||||
|
||||
public float MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 61d133a2d203a77419f35652a7f3fae0
|
||||
timeCreated: 1508427131
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ReadOnlyAttribute : DrawerAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4fa676ebc6d589c44817272871db148b
|
||||
timeCreated: 1508862052
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ReorderableListAttribute : DrawerAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ff85489452472c241987e5ba4c5e512a
|
||||
timeCreated: 1508402303
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ResizableTextAreaAttribute : DrawerAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1793ea6e464ee6448930ecf133ed6a1d
|
||||
timeCreated: 1508583166
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ShowAssetPreviewAttribute : DrawerAttribute
|
||||
{
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public ShowAssetPreviewAttribute(int width = 64, int height = 64)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.width;
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 313b856a920a987418d6437a8e20a59f
|
||||
timeCreated: 1509089502
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
|
||||
public class ShowNativePropertyAttribute : DrawerAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: acc7d7e8ec9e47a4aaf4167698ae076f
|
||||
timeCreated: 1510926376
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ShowNonSerializedFieldAttribute : DrawerAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a176aad85de73b34ba3ecd4f7baa367b
|
||||
timeCreated: 1508835721
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class SliderAttribute : DrawerAttribute
|
||||
{
|
||||
private float minValue;
|
||||
private float maxValue;
|
||||
|
||||
public SliderAttribute(float minValue, float maxValue)
|
||||
{
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public SliderAttribute(int minValue, int maxValue)
|
||||
{
|
||||
this.minValue = minValue;
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public float MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minValue;
|
||||
}
|
||||
}
|
||||
|
||||
public float MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f75eef8142877c345ba9b95046dd3bf6
|
||||
timeCreated: 1508422518
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 86ca4f90dd05bc448959ecd8f44097a7
|
||||
folderAsset: yes
|
||||
timeCreated: 1508330803
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class BoxGroupAttribute : GroupAttribute
|
||||
{
|
||||
public BoxGroupAttribute(string name = "")
|
||||
: base(name)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 88c5a8d79f9e72a43a4cfa67fd08fdd6
|
||||
timeCreated: 1508326108
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
public abstract class GroupAttribute : NaughtyAttribute
|
||||
{
|
||||
private string name;
|
||||
|
||||
public GroupAttribute(string name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: beb48511ef6091e4ba054ad1b618933c
|
||||
timeCreated: 1508326108
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 51ee806b39c5fb343ae7d268404d8c67
|
||||
folderAsset: yes
|
||||
timeCreated: 1508497398
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class BlankSpaceAttribute : MetaAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dabcf1c7fa8fc8542b57cca99110e3b1
|
||||
timeCreated: 1508500060
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class InfoBoxAttribute : MetaAttribute
|
||||
{
|
||||
private string text;
|
||||
private InfoBoxType type;
|
||||
private string visibleIf;
|
||||
|
||||
public InfoBoxAttribute(string text, InfoBoxType type = InfoBoxType.Normal, string visibleIf = null)
|
||||
{
|
||||
this.text = text;
|
||||
this.type = type;
|
||||
this.visibleIf = visibleIf;
|
||||
}
|
||||
|
||||
public InfoBoxAttribute(string text, string visibleIf)
|
||||
: this(text, InfoBoxType.Normal, visibleIf)
|
||||
{
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.text;
|
||||
}
|
||||
}
|
||||
|
||||
public InfoBoxType Type
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
|
||||
public string VisibleIf
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.visibleIf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum InfoBoxType
|
||||
{
|
||||
Normal,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 42c6184c84ab19d4382b06f9017f136d
|
||||
timeCreated: 1508607449
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
public abstract class MetaAttribute : NaughtyAttribute
|
||||
{
|
||||
private int order = 0;
|
||||
|
||||
public int Order
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.order;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.order = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcd6d339bcd667044a48d41a78a7830c
|
||||
timeCreated: 1508497398
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class OnValueChangedAttribute : MetaAttribute
|
||||
{
|
||||
private string callbackName;
|
||||
|
||||
public OnValueChangedAttribute(string callbackName)
|
||||
{
|
||||
this.callbackName = callbackName;
|
||||
}
|
||||
|
||||
public string CallbackName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.callbackName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a144cdc17b6e4cf4f86692ae1dc7e4d7
|
||||
timeCreated: 1508610277
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class SectionAttribute : MetaAttribute
|
||||
{
|
||||
private string sectionLabel;
|
||||
|
||||
public SectionAttribute(string sectionLabel)
|
||||
{
|
||||
this.sectionLabel = sectionLabel;
|
||||
}
|
||||
|
||||
public string SectionLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.sectionLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d4c1e33f7907b4647adaed489176ce0f
|
||||
timeCreated: 1508497398
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
// The base class for all naughty attributes
|
||||
public class NaughtyAttribute : Attribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1accb89cb44c4a342a1857e5e3d13abb
|
||||
timeCreated: 1508052914
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a655727c2e629a438ad94f60080b9ea
|
||||
folderAsset: yes
|
||||
timeCreated: 1508151410
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class MaxValueAttribute : ValidatorAttribute
|
||||
{
|
||||
private float maxValue;
|
||||
|
||||
public MaxValueAttribute(float maxValue)
|
||||
{
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public MaxValueAttribute(int maxValue)
|
||||
{
|
||||
this.maxValue = maxValue;
|
||||
}
|
||||
|
||||
public float MaxValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.maxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e018059e7fe12fd42a3a1bba0dbbf9c5
|
||||
timeCreated: 1508047804
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class MinValueAttribute : ValidatorAttribute
|
||||
{
|
||||
private float minValue;
|
||||
|
||||
public MinValueAttribute(float minValue)
|
||||
{
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
public MinValueAttribute(int minValue)
|
||||
{
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
public float MinValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.minValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 337be62eb8c929f4ab8b3d495a712a56
|
||||
timeCreated: 1508048805
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class RequiredAttribute : ValidatorAttribute
|
||||
{
|
||||
private string message;
|
||||
|
||||
public RequiredAttribute(string message = null)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b70ebd0fbd89c648981f08469806779
|
||||
timeCreated: 1508655546
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public class ValidateInputAttribute : ValidatorAttribute
|
||||
{
|
||||
private string callbackName;
|
||||
private string message;
|
||||
|
||||
public ValidateInputAttribute(string callbackName, string message = null)
|
||||
{
|
||||
this.callbackName = callbackName;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public string CallbackName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.callbackName;
|
||||
}
|
||||
}
|
||||
|
||||
public string Message
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f13ea28cf56e89f4cb335e28c9ab5d9a
|
||||
timeCreated: 1508657795
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes
|
||||
{
|
||||
public abstract class ValidatorAttribute : NaughtyAttribute
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5fac74a9575c45342be1e6dda45610ad
|
||||
timeCreated: 1508151410
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Plugins/NaughtyAttributes/Scripts/Editor.meta
Normal file
10
Assets/Plugins/NaughtyAttributes/Scripts/Editor.meta
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b76068e69df25a94ab378b0b6829c4f0
|
||||
folderAsset: yes
|
||||
timeCreated: 1507995613
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bfd420e5bf6a25049b8fcea8b2f48c94
|
||||
folderAsset: yes
|
||||
timeCreated: 1508153828
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
|
||||
public abstract class BaseAttribute : Attribute, IAttribute
|
||||
{
|
||||
private Type targetAttributeType;
|
||||
|
||||
public BaseAttribute(Type targetAttributeType)
|
||||
{
|
||||
this.targetAttributeType = targetAttributeType;
|
||||
}
|
||||
|
||||
public Type TargetAttributeType
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.targetAttributeType;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd861c512b7cd804fa5f01b4d0e9f5bc
|
||||
timeCreated: 1508424822
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class FieldDrawerAttribute : BaseAttribute
|
||||
{
|
||||
public FieldDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad0dbf00ca9ec1e4290145dc40bda96f
|
||||
timeCreated: 1508835980
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public interface IAttribute
|
||||
{
|
||||
Type TargetAttributeType { get; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: eec883c51d802eb49be41f384e227dad
|
||||
timeCreated: 1508424822
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class MethodDrawerAttribute : BaseAttribute
|
||||
{
|
||||
public MethodDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b89ac4d9b78686548baa09fb0b103850
|
||||
timeCreated: 1508592495
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class NativePropertyDrawerAttribute : BaseAttribute
|
||||
{
|
||||
public NativePropertyDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7c30e23a060c0614b876d7f14e0ee649
|
||||
timeCreated: 1510924166
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class PropertyDrawConditionAttribute : BaseAttribute
|
||||
{
|
||||
public PropertyDrawConditionAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7962631135870e4fa748e6f81cd64d4
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class PropertyDrawerAttribute : BaseAttribute
|
||||
{
|
||||
public PropertyDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 77bb6824c4e9e054db05347dd8465f24
|
||||
timeCreated: 1508153828
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class PropertyGrouperAttribute : BaseAttribute
|
||||
{
|
||||
public PropertyGrouperAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9d1b7efb592ab4a4796c70edaad2be75
|
||||
timeCreated: 1508332897
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class PropertyMetaAttribute : BaseAttribute
|
||||
{
|
||||
public PropertyMetaAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b46e1700b41c60141b19b0a7ed25a383
|
||||
timeCreated: 1508497398
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
using System;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class PropertyValidatorAttribute : BaseAttribute
|
||||
{
|
||||
public PropertyValidatorAttribute(Type targetAttributeType) : base(targetAttributeType)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38c34a83bfd0a07468f20ae50c36737f
|
||||
timeCreated: 1508153828
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3876cb6aacfb99f46803d5e50eacdf2c
|
||||
folderAsset: yes
|
||||
timeCreated: 1508230862
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public class CodeGenerator : UnityEditor.Editor
|
||||
{
|
||||
private static readonly string GENERATED_CODE_TARGET_FOLDER =
|
||||
(Application.dataPath.Replace("Assets", string.Empty) + AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("CodeGenerator")[0]))
|
||||
.Replace("CodeGenerator.cs", string.Empty)
|
||||
.Replace("/", "\\");
|
||||
|
||||
private static readonly string CLASS_NAME_PLACEHOLDER = "__classname__";
|
||||
private static readonly string ENTRIES_PLACEHOLDER = "__entries__";
|
||||
private static readonly string META_ENTRY_FORMAT = "metasByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
|
||||
private static readonly string DRAWER_ENTRY_FORMAT = "drawersByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
|
||||
private static readonly string GROUPER_ENTRY_FORMAT = "groupersByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
|
||||
private static readonly string VALIDATOR_ENTRY_FORMAT = "validatorsByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
|
||||
private static readonly string DRAW_CONDITION_ENTRY_FORMAT = "drawConditionsByAttributeType[typeof({0})] = new {1}();" + Environment.NewLine;
|
||||
|
||||
//[UnityEditor.Callbacks.DidReloadScripts]
|
||||
[MenuItem("NaughtyAttributes/Update Attributes Database")]
|
||||
private static void GenerateCode()
|
||||
{
|
||||
GenerateScript<PropertyMeta, PropertyMetaAttribute>("PropertyMetaDatabase", "PropertyMetaDatabaseTemplate", META_ENTRY_FORMAT);
|
||||
GenerateScript<PropertyDrawer, PropertyDrawerAttribute>("PropertyDrawerDatabase", "PropertyDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
|
||||
GenerateScript<PropertyGrouper, PropertyGrouperAttribute>("PropertyGrouperDatabase", "PropertyGrouperDatabaseTemplate", GROUPER_ENTRY_FORMAT);
|
||||
GenerateScript<PropertyValidator, PropertyValidatorAttribute>("PropertyValidatorDatabase", "PropertyValidatorDatabaseTemplate", VALIDATOR_ENTRY_FORMAT);
|
||||
GenerateScript<PropertyDrawCondition, PropertyDrawConditionAttribute>("PropertyDrawConditionDatabase", "PropertyDrawConditionDatabaseTemplate", DRAW_CONDITION_ENTRY_FORMAT);
|
||||
|
||||
GenerateScript<FieldDrawer, FieldDrawerAttribute>("FieldDrawerDatabase", "FieldDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
|
||||
GenerateScript<MethodDrawer, MethodDrawerAttribute>("MethodDrawerDatabase", "MethodDrawerDatabaseTemplate", DRAWER_ENTRY_FORMAT);
|
||||
GenerateScript<NativePropertyDrawer, NativePropertyDrawerAttribute>("NativePropertyDrawerDatabase", "NativePropertyDrawerDbTemplate", DRAWER_ENTRY_FORMAT);
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
private static void GenerateScript<TClass, TAttribute>(string scriptName, string templateName, string entryFormat)
|
||||
where TAttribute : IAttribute
|
||||
{
|
||||
string[] templateAssets = AssetDatabase.FindAssets(templateName);
|
||||
if (templateAssets.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string templateGUID = templateAssets[0];
|
||||
string templateRelativePath = AssetDatabase.GUIDToAssetPath(templateGUID);
|
||||
string templateFormat = (AssetDatabase.LoadAssetAtPath(templateRelativePath, typeof(TextAsset)) as TextAsset).ToString();
|
||||
//string templateFullPath = (Application.dataPath.Replace("Assets", string.Empty) + templateRelativePath).Replace("/", "\\");
|
||||
//string templateFormat = IOUtility.ReadFromFile(templateFullPath);
|
||||
|
||||
StringBuilder entriesBuilder = new StringBuilder();
|
||||
List<Type> subTypes = GetAllSubTypes(typeof(TClass));
|
||||
|
||||
foreach (var subType in subTypes)
|
||||
{
|
||||
IAttribute[] attributes = (IAttribute[])subType.GetCustomAttributes(typeof(TAttribute), true);
|
||||
if (attributes.Length > 0)
|
||||
{
|
||||
entriesBuilder.AppendFormat(entryFormat, attributes[0].TargetAttributeType.Name, subType.Name);
|
||||
}
|
||||
}
|
||||
|
||||
string scriptContent = templateFormat
|
||||
.Replace(CLASS_NAME_PLACEHOLDER, scriptName)
|
||||
.Replace(ENTRIES_PLACEHOLDER, entriesBuilder.ToString());
|
||||
|
||||
scriptContent = Regex.Replace(scriptContent, @"\r\n|\n\r|\r|\n", Environment.NewLine); // Normalize line endings
|
||||
|
||||
string scriptPath = GENERATED_CODE_TARGET_FOLDER + scriptName + ".cs";
|
||||
|
||||
IOUtility.WriteToFile(scriptPath, scriptContent);
|
||||
}
|
||||
|
||||
private static List<Type> GetAllSubTypes(Type baseClass)
|
||||
{
|
||||
var result = new List<Type>();
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
foreach (var assemly in assemblies)
|
||||
{
|
||||
Type[] types = assemly.GetTypes();
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsSubclassOf(baseClass))
|
||||
{
|
||||
result.Add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 990da0e1629b14049842bf2ac82cbff0
|
||||
timeCreated: 1508230160
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class FieldDrawerDatabase
|
||||
{
|
||||
private static Dictionary<Type, FieldDrawer> drawersByAttributeType;
|
||||
|
||||
static FieldDrawerDatabase()
|
||||
{
|
||||
drawersByAttributeType = new Dictionary<Type, FieldDrawer>();
|
||||
drawersByAttributeType[typeof(ShowNonSerializedFieldAttribute)] = new ShowNonSerializedFieldFieldDrawer();
|
||||
|
||||
}
|
||||
|
||||
public static FieldDrawer GetDrawerForAttribute(Type attributeType)
|
||||
{
|
||||
FieldDrawer drawer;
|
||||
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
|
||||
{
|
||||
return drawer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b2406e32d0ab1214ab4959f1cdc8a609
|
||||
timeCreated: 1508836346
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class MethodDrawerDatabase
|
||||
{
|
||||
private static Dictionary<Type, MethodDrawer> drawersByAttributeType;
|
||||
|
||||
static MethodDrawerDatabase()
|
||||
{
|
||||
drawersByAttributeType = new Dictionary<Type, MethodDrawer>();
|
||||
drawersByAttributeType[typeof(ButtonAttribute)] = new ButtonMethodDrawer();
|
||||
|
||||
}
|
||||
|
||||
public static MethodDrawer GetDrawerForAttribute(Type attributeType)
|
||||
{
|
||||
MethodDrawer drawer;
|
||||
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
|
||||
{
|
||||
return drawer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 40b81aa63ff76d34ea67277db99a6a25
|
||||
timeCreated: 1508592498
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class NativePropertyDrawerDatabase
|
||||
{
|
||||
private static Dictionary<Type, NativePropertyDrawer> drawersByAttributeType;
|
||||
|
||||
static NativePropertyDrawerDatabase()
|
||||
{
|
||||
drawersByAttributeType = new Dictionary<Type, NativePropertyDrawer>();
|
||||
drawersByAttributeType[typeof(ShowNativePropertyAttribute)] = new ShowNativePropertyNativePropertyDrawer();
|
||||
|
||||
}
|
||||
|
||||
public static NativePropertyDrawer GetDrawerForAttribute(Type attributeType)
|
||||
{
|
||||
NativePropertyDrawer drawer;
|
||||
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
|
||||
{
|
||||
return drawer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9fd2f82e21266a94ea967208610dda1e
|
||||
timeCreated: 1510925645
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class PropertyDrawConditionDatabase
|
||||
{
|
||||
private static Dictionary<Type, PropertyDrawCondition> drawConditionsByAttributeType;
|
||||
|
||||
static PropertyDrawConditionDatabase()
|
||||
{
|
||||
drawConditionsByAttributeType = new Dictionary<Type, PropertyDrawCondition>();
|
||||
drawConditionsByAttributeType[typeof(HideIfAttribute)] = new HideIfPropertyDrawCondition();
|
||||
drawConditionsByAttributeType[typeof(ShowIfAttribute)] = new ShowIfPropertyDrawCondition();
|
||||
|
||||
}
|
||||
|
||||
public static PropertyDrawCondition GetDrawConditionForAttribute(Type attributeType)
|
||||
{
|
||||
PropertyDrawCondition drawCondition;
|
||||
if (drawConditionsByAttributeType.TryGetValue(attributeType, out drawCondition))
|
||||
{
|
||||
return drawCondition;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0b96dc9fe878bfc49865d28d601a7468
|
||||
timeCreated: 1508414568
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class PropertyDrawerDatabase
|
||||
{
|
||||
private static Dictionary<Type, PropertyDrawer> drawersByAttributeType;
|
||||
|
||||
static PropertyDrawerDatabase()
|
||||
{
|
||||
drawersByAttributeType = new Dictionary<Type, PropertyDrawer>();
|
||||
drawersByAttributeType[typeof(DropdownAttribute)] = new DropdownPropertyDrawer();
|
||||
drawersByAttributeType[typeof(MinMaxSliderAttribute)] = new MinMaxSliderPropertyDrawer();
|
||||
drawersByAttributeType[typeof(ReadOnlyAttribute)] = new ReadOnlyPropertyDrawer();
|
||||
drawersByAttributeType[typeof(ReorderableListAttribute)] = new ReorderableListPropertyDrawer();
|
||||
drawersByAttributeType[typeof(ResizableTextAreaAttribute)] = new ResizableTextAreaPropertyDrawer();
|
||||
drawersByAttributeType[typeof(ShowAssetPreviewAttribute)] = new ShowAssetPreviewPropertyDrawer();
|
||||
drawersByAttributeType[typeof(SliderAttribute)] = new SliderPropertyDrawer();
|
||||
|
||||
}
|
||||
|
||||
public static PropertyDrawer GetDrawerForAttribute(Type attributeType)
|
||||
{
|
||||
PropertyDrawer drawer;
|
||||
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
|
||||
{
|
||||
return drawer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ClearCache()
|
||||
{
|
||||
foreach (var kvp in drawersByAttributeType)
|
||||
{
|
||||
kvp.Value.ClearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57bb89ab38f8da84db719a3fad7934d2
|
||||
timeCreated: 1508241644
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class PropertyGrouperDatabase
|
||||
{
|
||||
private static Dictionary<Type, PropertyGrouper> groupersByAttributeType;
|
||||
|
||||
static PropertyGrouperDatabase()
|
||||
{
|
||||
groupersByAttributeType = new Dictionary<Type, PropertyGrouper>();
|
||||
groupersByAttributeType[typeof(BoxGroupAttribute)] = new BoxGroupPropertyGrouper();
|
||||
|
||||
}
|
||||
|
||||
public static PropertyGrouper GetGrouperForAttribute(Type attributeType)
|
||||
{
|
||||
PropertyGrouper grouper;
|
||||
if (groupersByAttributeType.TryGetValue(attributeType, out grouper))
|
||||
{
|
||||
return grouper;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0e5fed99fdc5f794291677a80073b4ba
|
||||
timeCreated: 1508333008
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class PropertyMetaDatabase
|
||||
{
|
||||
private static Dictionary<Type, PropertyMeta> metasByAttributeType;
|
||||
|
||||
static PropertyMetaDatabase()
|
||||
{
|
||||
metasByAttributeType = new Dictionary<Type, PropertyMeta>();
|
||||
metasByAttributeType[typeof(BlankSpaceAttribute)] = new BlankSpacePropertyMeta();
|
||||
metasByAttributeType[typeof(InfoBoxAttribute)] = new InfoBoxPropertyMeta();
|
||||
metasByAttributeType[typeof(OnValueChangedAttribute)] = new OnValueChangedPropertyMeta();
|
||||
metasByAttributeType[typeof(SectionAttribute)] = new SectionPropertyMeta();
|
||||
|
||||
}
|
||||
|
||||
public static PropertyMeta GetMetaForAttribute(Type attributeType)
|
||||
{
|
||||
PropertyMeta meta;
|
||||
if (metasByAttributeType.TryGetValue(attributeType, out meta))
|
||||
{
|
||||
return meta;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57233c5ec1975024aa0723241b2f8210
|
||||
timeCreated: 1508497398
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// This class is auto generated
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NaughtyAttributes.Editor
|
||||
{
|
||||
public static class PropertyValidatorDatabase
|
||||
{
|
||||
private static Dictionary<Type, PropertyValidator> validatorsByAttributeType;
|
||||
|
||||
static PropertyValidatorDatabase()
|
||||
{
|
||||
validatorsByAttributeType = new Dictionary<Type, PropertyValidator>();
|
||||
validatorsByAttributeType[typeof(MaxValueAttribute)] = new MaxValuePropertyValidator();
|
||||
validatorsByAttributeType[typeof(MinValueAttribute)] = new MinValuePropertyValidator();
|
||||
validatorsByAttributeType[typeof(RequiredAttribute)] = new RequiredPropertyValidator();
|
||||
validatorsByAttributeType[typeof(ValidateInputAttribute)] = new ValidateInputPropertyValidator();
|
||||
|
||||
}
|
||||
|
||||
public static PropertyValidator GetValidatorForAttribute(Type attributeType)
|
||||
{
|
||||
PropertyValidator validator;
|
||||
if (validatorsByAttributeType.TryGetValue(attributeType, out validator))
|
||||
{
|
||||
return validator;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue