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:
Reinier Vens 2021-01-31 03:52:32 +00:00
commit dbc522a224
2105 changed files with 7033 additions and 1141 deletions

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bfd420e5bf6a25049b8fcea8b2f48c94
folderAsset: yes
timeCreated: 1508153828
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class FieldDrawerAttribute : BaseAttribute
{
public FieldDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,9 @@
using System;
namespace NaughtyAttributes.Editor
{
public interface IAttribute
{
Type TargetAttributeType { get; }
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class MethodDrawerAttribute : BaseAttribute
{
public MethodDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class NativePropertyDrawerAttribute : BaseAttribute
{
public NativePropertyDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class PropertyDrawConditionAttribute : BaseAttribute
{
public PropertyDrawConditionAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class PropertyDrawerAttribute : BaseAttribute
{
public PropertyDrawerAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class PropertyGrouperAttribute : BaseAttribute
{
public PropertyGrouperAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class PropertyMetaAttribute : BaseAttribute
{
public PropertyMetaAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,11 @@
using System;
namespace NaughtyAttributes.Editor
{
public class PropertyValidatorAttribute : BaseAttribute
{
public PropertyValidatorAttribute(Type targetAttributeType) : base(targetAttributeType)
{
}
}
}

View file

@ -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:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3876cb6aacfb99f46803d5e50eacdf2c
folderAsset: yes
timeCreated: 1508230862
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -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;
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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();
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -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:

View file

@ -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;
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 24e9da8a6b324374a9f655d3a867b284
timeCreated: 1508241122
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7b15ea6695a69d74ab656006617d8d21
folderAsset: yes
timeCreated: 1508230862
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, FieldDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, FieldDrawer>();
__entries__
}
public static FieldDrawer GetDrawerForAttribute(Type attributeType)
{
FieldDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 943b4c41373856243996247275be2cd8
timeCreated: 1508836344
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, MethodDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, MethodDrawer>();
__entries__
}
public static MethodDrawer GetDrawerForAttribute(Type attributeType)
{
MethodDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 52d15465eb3439f4a9b95963a21d19b7
timeCreated: 1508592495
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, NativePropertyDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, NativePropertyDrawer>();
__entries__
}
public static NativePropertyDrawer GetDrawerForAttribute(Type attributeType)
{
NativePropertyDrawer drawer;
if (drawersByAttributeType.TryGetValue(attributeType, out drawer))
{
return drawer;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b82f5f6bf1fd4314c93624a8bc8835fd
timeCreated: 1510924467
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyDrawCondition> drawConditionsByAttributeType;
static __classname__()
{
drawConditionsByAttributeType = new Dictionary<Type, PropertyDrawCondition>();
__entries__
}
public static PropertyDrawCondition GetDrawConditionForAttribute(Type attributeType)
{
PropertyDrawCondition drawCondition;
if (drawConditionsByAttributeType.TryGetValue(attributeType, out drawCondition))
{
return drawCondition;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: b36f5858330c2d140a697f19ba6cc36b
timeCreated: 1508414568
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,39 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyDrawer> drawersByAttributeType;
static __classname__()
{
drawersByAttributeType = new Dictionary<Type, PropertyDrawer>();
__entries__
}
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();
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 136a96a904b577244b08be5d5542a77d
timeCreated: 1508241102
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyGrouper> groupersByAttributeType;
static __classname__()
{
groupersByAttributeType = new Dictionary<Type, PropertyGrouper>();
__entries__
}
public static PropertyGrouper GetGrouperForAttribute(Type attributeType)
{
PropertyGrouper grouper;
if (groupersByAttributeType.TryGetValue(attributeType, out grouper))
{
return grouper;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 7fcc5bff99ecd4843b766f23cd585b55
timeCreated: 1508332899
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyMeta> metasByAttributeType;
static __classname__()
{
metasByAttributeType = new Dictionary<Type, PropertyMeta>();
__entries__
}
public static PropertyMeta GetMetaForAttribute(Type attributeType)
{
PropertyMeta meta;
if (metasByAttributeType.TryGetValue(attributeType, out meta))
{
return meta;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: fde25cf95f45b50469fcf4ee1e38993c
timeCreated: 1508497401
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
// This class is auto generated
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
public static class __classname__
{
private static Dictionary<Type, PropertyValidator> validatorsByAttributeType;
static __classname__()
{
validatorsByAttributeType = new Dictionary<Type, PropertyValidator>();
__entries__
}
public static PropertyValidator GetValidatorForAttribute(Type attributeType)
{
PropertyValidator validator;
if (validatorsByAttributeType.TryGetValue(attributeType, out validator))
{
return validator;
}
else
{
return null;
}
}
}
}

View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a21c3d37c1492da4386198388150024c
timeCreated: 1508230862
licenseType: Free
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4db73d2276d0e8144a206c5c2cd350de
folderAsset: yes
timeCreated: 1508055750
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,394 @@
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Reflection;
// using UnityEditor;
// using UnityEngine;
//
// namespace NaughtyAttributes.Editor
// {
// [CanEditMultipleObjects]
// [CustomEditor(typeof(UnityEngine.Object), true)]
// public class InspectorEditor : UnityEditor.Editor
// {
// private SerializedProperty script;
//
// private IEnumerable<FieldInfo> fields;
// private HashSet<FieldInfo> groupedFields;
// private Dictionary<string, List<FieldInfo>> groupedFieldsByGroupName;
// private IEnumerable<FieldInfo> nonSerializedFields;
// private IEnumerable<PropertyInfo> nativeProperties;
// private IEnumerable<MethodInfo> methods;
//
// private Dictionary<string, SerializedProperty> serializedPropertiesByFieldName;
//
// private bool useDefaultInspector;
//
// private void OnEnable()
// {
// this.script = this.serializedObject.FindProperty("m_Script");
//
// // Cache serialized fields
// this.fields = this.GetFields(f => this.serializedObject.FindProperty(f.Name) != null);
//
// // If there are no NaughtyAttributes use default inspector
// if (this.fields.All(f => f.GetCustomAttributes(typeof(NaughtyAttribute), true).Length == 0))
// {
// this.useDefaultInspector = true;
// }
// else
// {
// this.useDefaultInspector = false;
//
// // Cache grouped fields
// this.groupedFields = new HashSet<FieldInfo>(this.fields.Where(f => f.GetCustomAttributes(typeof(GroupAttribute), true).Length > 0));
//
// // Cache grouped fields by group name
// this.groupedFieldsByGroupName = new Dictionary<string, List<FieldInfo>>();
// foreach (var groupedField in this.groupedFields)
// {
// string groupName = (groupedField.GetCustomAttributes(typeof(GroupAttribute), true)[0] as GroupAttribute).Name;
//
// if (this.groupedFieldsByGroupName.ContainsKey(groupName))
// {
// this.groupedFieldsByGroupName[groupName].Add(groupedField);
// }
// else
// {
// this.groupedFieldsByGroupName[groupName] = new List<FieldInfo>()
// {
// groupedField
// };
// }
// }
//
// // Cache serialized properties by field name
// this.serializedPropertiesByFieldName = new Dictionary<string, SerializedProperty>();
// foreach (var field in this.fields)
// {
// this.serializedPropertiesByFieldName[field.Name] = this.serializedObject.FindProperty(field.Name);
// }
// }
//
// // Cache non-serialized fields
// this.nonSerializedFields = this.GetFields(
// f => f.GetCustomAttributes(typeof(DrawerAttribute), true).Length > 0 && this.serializedObject.FindProperty(f.Name) == null);
//
// // Cache the native properties
// this.nativeProperties = this.GetProperties(
// p => p.GetCustomAttributes(typeof(DrawerAttribute), true).Length > 0);
//
// // Cache methods with DrawerAttribute
// this.methods = this.GetMethods(m => m.GetCustomAttributes(typeof(DrawerAttribute), true).Length > 0);
// }
//
// private void OnDisable()
// {
// PropertyDrawerDatabase.ClearCache();
// }
//
// public override void OnInspectorGUI()
// {
// if (this.useDefaultInspector)
// {
// this.DrawDefaultInspector();
// }
// else
// {
// this.serializedObject.Update();
//
// if (this.script != null)
// {
// GUI.enabled = false;
// EditorGUILayout.PropertyField(this.script);
// GUI.enabled = true;
// }
//
// // Draw fields
// HashSet<string> drawnGroups = new HashSet<string>();
// foreach (var field in this.fields)
// {
// if (this.groupedFields.Contains(field))
// {
// // Draw grouped fields
// string groupName = (field.GetCustomAttributes(typeof(GroupAttribute), true)[0] as GroupAttribute).Name;
// if (!drawnGroups.Contains(groupName))
// {
// drawnGroups.Add(groupName);
//
// PropertyGrouper grouper = this.GetPropertyGrouperForField(field);
// if (grouper != null)
// {
// grouper.BeginGroup(groupName);
//
// this.ValidateAndDrawFields(this.groupedFieldsByGroupName[groupName]);
//
// grouper.EndGroup();
// }
// else
// {
// this.ValidateAndDrawFields(this.groupedFieldsByGroupName[groupName]);
// }
// }
// }
// else
// {
// // Draw non-grouped field
// this.ValidateAndDrawField(field);
// }
// }
//
// this.serializedObject.ApplyModifiedProperties();
// }
//
// // Draw non-serialized fields
// foreach (var field in this.nonSerializedFields)
// {
// DrawerAttribute drawerAttribute = (DrawerAttribute)field.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
// FieldDrawer drawer = FieldDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
// if (drawer != null)
// {
// drawer.DrawField(this.target, field);
// }
// }
//
// // Draw native properties
// foreach (var property in this.nativeProperties)
// {
// DrawerAttribute drawerAttribute = (DrawerAttribute)property.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
// NativePropertyDrawer drawer = NativePropertyDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
// if (drawer != null)
// {
// drawer.DrawNativeProperty(this.target, property);
// }
// }
//
// // Draw methods
// foreach (var method in this.methods)
// {
// DrawerAttribute drawerAttribute = (DrawerAttribute)method.GetCustomAttributes(typeof(DrawerAttribute), true)[0];
// MethodDrawer methodDrawer = MethodDrawerDatabase.GetDrawerForAttribute(drawerAttribute.GetType());
// if (methodDrawer != null)
// {
// methodDrawer.DrawMethod(this.target, method);
// }
// }
// }
//
// private void ValidateAndDrawFields(IEnumerable<FieldInfo> fields)
// {
// foreach (var field in fields)
// {
// this.ValidateAndDrawField(field);
// }
// }
//
// private void ValidateAndDrawField(FieldInfo field)
// {
// this.ValidateField(field);
// this.ApplyFieldMeta(field);
// this.DrawField(field);
// }
//
// private void ValidateField(FieldInfo field)
// {
// ValidatorAttribute[] validatorAttributes = (ValidatorAttribute[])field.GetCustomAttributes(typeof(ValidatorAttribute), true);
//
// foreach (var attribute in validatorAttributes)
// {
// PropertyValidator validator = PropertyValidatorDatabase.GetValidatorForAttribute(attribute.GetType());
// if (validator != null)
// {
// validator.ValidateProperty(this.serializedPropertiesByFieldName[field.Name]);
// }
// }
// }
//
// private void DrawField(FieldInfo field)
// {
// // Check if the field has draw conditions
// PropertyDrawCondition drawCondition = this.GetPropertyDrawConditionForField(field);
// if (drawCondition != null)
// {
// bool canDrawProperty = drawCondition.CanDrawProperty(this.serializedPropertiesByFieldName[field.Name]);
// if (!canDrawProperty)
// {
// return;
// }
// }
//
// // Check if the field has HideInInspectorAttribute
// HideInInspector[] hideInInspectorAttributes = (HideInInspector[])field.GetCustomAttributes(typeof(HideInInspector), true);
// if (hideInInspectorAttributes.Length > 0)
// {
// return;
// }
//
// // Draw the field
// EditorGUI.BeginChangeCheck();
// PropertyDrawer drawer = this.GetPropertyDrawerForField(field);
// if (drawer != null)
// {
// drawer.DrawProperty(this.serializedPropertiesByFieldName[field.Name]);
// }
// else
// {
// EditorGUILayout.PropertyField(this.serializedPropertiesByFieldName[field.Name], true);
// }
//
// if (EditorGUI.EndChangeCheck())
// {
// OnValueChangedAttribute[] onValueChangedAttributes = (OnValueChangedAttribute[])field.GetCustomAttributes(typeof(OnValueChangedAttribute), true);
// foreach (var onValueChangedAttribute in onValueChangedAttributes)
// {
// PropertyMeta meta = PropertyMetaDatabase.GetMetaForAttribute(onValueChangedAttribute.GetType());
// if (meta != null)
// {
// meta.ApplyPropertyMeta(this.serializedPropertiesByFieldName[field.Name], onValueChangedAttribute);
// }
// }
// }
// }
//
// private void ApplyFieldMeta(FieldInfo field)
// {
// // Apply custom meta attributes
// MetaAttribute[] metaAttributes = field
// .GetCustomAttributes(typeof(MetaAttribute), true)
// .Where(attr => attr.GetType() != typeof(OnValueChangedAttribute))
// .Select(obj => obj as MetaAttribute)
// .ToArray();
//
// System.Array.Sort(metaAttributes, (x, y) =>
// {
// return x.Order - y.Order;
// });
//
// foreach (var metaAttribute in metaAttributes)
// {
// PropertyMeta meta = PropertyMetaDatabase.GetMetaForAttribute(metaAttribute.GetType());
// if (meta != null)
// {
// meta.ApplyPropertyMeta(this.serializedPropertiesByFieldName[field.Name], metaAttribute);
// }
// }
// }
//
// private PropertyDrawer GetPropertyDrawerForField(FieldInfo field)
// {
// DrawerAttribute[] drawerAttributes = (DrawerAttribute[])field.GetCustomAttributes(typeof(DrawerAttribute), true);
// if (drawerAttributes.Length > 0)
// {
// PropertyDrawer drawer = PropertyDrawerDatabase.GetDrawerForAttribute(drawerAttributes[0].GetType());
// return drawer;
// }
// else
// {
// return null;
// }
// }
//
// private PropertyGrouper GetPropertyGrouperForField(FieldInfo field)
// {
// GroupAttribute[] groupAttributes = (GroupAttribute[])field.GetCustomAttributes(typeof(GroupAttribute), true);
// if (groupAttributes.Length > 0)
// {
// PropertyGrouper grouper = PropertyGrouperDatabase.GetGrouperForAttribute(groupAttributes[0].GetType());
// return grouper;
// }
// else
// {
// return null;
// }
// }
//
// private PropertyDrawCondition GetPropertyDrawConditionForField(FieldInfo field)
// {
// DrawConditionAttribute[] drawConditionAttributes = (DrawConditionAttribute[])field.GetCustomAttributes(typeof(DrawConditionAttribute), true);
// if (drawConditionAttributes.Length > 0)
// {
// PropertyDrawCondition drawCondition = PropertyDrawConditionDatabase.GetDrawConditionForAttribute(drawConditionAttributes[0].GetType());
// return drawCondition;
// }
// else
// {
// return null;
// }
// }
//
// private List<FieldInfo> GetFields(Func<FieldInfo, bool> predicate)
// {
// List<Type> types = new List<Type>()
// {
// this.target.GetType()
// };
//
// while (types.Last().BaseType != null)
// {
// types.Add(types.Last().BaseType);
// }
//
// List<FieldInfo> fields = new List<FieldInfo>();
// for (int i = types.Count - 1; i >= 0; i--)
// {
// IEnumerable<FieldInfo> fieldInfos = types[i]
// .GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly)
// .Where(predicate);
//
// fields.AddRange(fieldInfos);
// }
//
// return fields;
// }
//
// private List<PropertyInfo> GetProperties(Func<PropertyInfo, bool> predicate)
// {
// List<Type> types = new List<Type>()
// {
// this.target.GetType()
// };
//
// while (types.Last().BaseType != null)
// {
// types.Add(types.Last().BaseType);
// }
//
// List<PropertyInfo> properties = new List<PropertyInfo>();
// for (int i = types.Count - 1; i >= 0; i--)
// {
// IEnumerable<PropertyInfo> propertyInfos = types[i]
// .GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly)
// .Where(predicate);
//
// properties.AddRange(propertyInfos);
// }
//
// return properties;
// }
//
// private List<MethodInfo> GetMethods(Func<MethodInfo, bool> predicate)
// {
// List<Type> types = new List<Type>()
// {
// this.target.GetType()
// };
//
// while (types.Last().BaseType != null)
// {
// types.Add(types.Last().BaseType);
// }
//
// List<MethodInfo> methods = new List<MethodInfo>();
// for (int i = types.Count - 1; i >= 0; i--)
// {
// IEnumerable<MethodInfo> methodInfos = types[i]
// .GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly)
// .Where(predicate);
//
// methods.AddRange(methodInfos);
// }
//
// return methods;
// }
// }
// }

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 9e82d6d6926a6c74688e2787b37630d1
timeCreated: 1508055750
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 79b05858e72c1b0498eca7954843c802
folderAsset: yes
timeCreated: 1508835721
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,9 @@
using System.Reflection;
namespace NaughtyAttributes.Editor
{
public abstract class FieldDrawer
{
public abstract void DrawField(UnityEngine.Object target, FieldInfo field);
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8949267118f232a4fbebd777de8ed6fe
timeCreated: 1508835721
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
using UnityEngine;
using System.Reflection;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[FieldDrawer(typeof(ShowNonSerializedFieldAttribute))]
public class ShowNonSerializedFieldFieldDrawer : FieldDrawer
{
public override void DrawField(UnityEngine.Object target, FieldInfo field)
{
object value = field.GetValue(target);
if (value == null)
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNonSerializedFieldFieldDrawer).Name, "Reference");
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
}
else if (!EditorDrawUtility.DrawLayoutField(value, field.Name))
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNonSerializedFieldFieldDrawer).Name, field.FieldType.Name);
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 8449d5c2158e97d479caaec24c61baec
timeCreated: 1508835721
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: f95312994b1f8c746a402669cb1655eb
folderAsset: yes
timeCreated: 1508592494
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,30 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace NaughtyAttributes.Editor
{
[MethodDrawer(typeof(ButtonAttribute))]
public class ButtonMethodDrawer : MethodDrawer
{
public override void DrawMethod(UnityEngine.Object target, MethodInfo methodInfo)
{
if (methodInfo.GetParameters().Length == 0)
{
ButtonAttribute buttonAttribute = (ButtonAttribute)methodInfo.GetCustomAttributes(typeof(ButtonAttribute), true)[0];
string buttonText = string.IsNullOrEmpty(buttonAttribute.Text) ? methodInfo.Name : buttonAttribute.Text;
if (GUILayout.Button(buttonText))
{
methodInfo.Invoke(target, null);
}
}
else
{
string warning = typeof(ButtonAttribute).Name + " works only on methods with no parameters";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ad01ec1a22422c6409f913d60ce39d61
timeCreated: 1508592494
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,9 @@
using System.Reflection;
namespace NaughtyAttributes.Editor
{
public abstract class MethodDrawer
{
public abstract void DrawMethod(UnityEngine.Object target, MethodInfo methodInfo);
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: a65a1addcdd323249b590f7a06110869
timeCreated: 1508592494
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ae67cc6bfa799f147968e9b0371a21fc
folderAsset: yes
timeCreated: 1510924467
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,9 @@
using System.Reflection;
namespace NaughtyAttributes.Editor
{
public abstract class NativePropertyDrawer
{
public abstract void DrawNativeProperty(UnityEngine.Object target, PropertyInfo property);
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 715c5ada29663a245b0b35937c892377
timeCreated: 1510924467
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,28 @@
using UnityEngine;
using System.Reflection;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[NativePropertyDrawer(typeof(ShowNativePropertyAttribute))]
public class ShowNativePropertyNativePropertyDrawer : NativePropertyDrawer
{
public override void DrawNativeProperty(UnityEngine.Object target, PropertyInfo property)
{
object value = property.GetValue(target, null);
if (value == null)
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNativePropertyNativePropertyDrawer).Name, "Reference");
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
}
else if (!EditorDrawUtility.DrawLayoutField(value, property.Name))
{
string warning = string.Format("{0} doesn't support {1} types", typeof(ShowNativePropertyNativePropertyDrawer).Name, property.PropertyType.Name);
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 518b0fde2a9d15d498bc17fd1d7062c7
timeCreated: 1510926376
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0ed2b7d432f0ad644b1f0752cf65aa9c
folderAsset: yes
timeCreated: 1508414568
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace NaughtyAttributes.Editor
{
[PropertyDrawCondition(typeof(HideIfAttribute))]
public class HideIfPropertyDrawCondition : PropertyDrawCondition
{
public override bool CanDrawProperty(SerializedProperty property)
{
HideIfAttribute hideIfAttribute = PropertyUtility.GetAttributes<HideIfAttribute>(property)[0];
UnityEngine.Object target = PropertyUtility.GetTargetObject(property);
FieldInfo conditionField = target.GetType().GetField(hideIfAttribute.ConditionName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (conditionField != null &&
conditionField.FieldType == typeof(bool))
{
return !(bool)conditionField.GetValue(target);
}
MethodInfo conditionMethod = target.GetType().GetMethod(hideIfAttribute.ConditionName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (conditionMethod != null &&
conditionMethod.ReturnType == typeof(bool) &&
conditionMethod.GetParameters().Length == 0)
{
return !(bool)conditionMethod.Invoke(target, null);
}
string warning = hideIfAttribute.GetType().Name + " needs a valid boolean condition field or method name to work";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
return true;
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: f7e60d80f0231654ab13cfb1178e6eb8
timeCreated: 1508414568
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,9 @@
using UnityEditor;
namespace NaughtyAttributes.Editor
{
public abstract class PropertyDrawCondition
{
public abstract bool CanDrawProperty(SerializedProperty property);
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ce2d1d9afa04cae43a18bd01ec9447eb
timeCreated: 1508414568
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,37 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace NaughtyAttributes.Editor
{
[PropertyDrawCondition(typeof(ShowIfAttribute))]
public class ShowIfPropertyDrawCondition : PropertyDrawCondition
{
public override bool CanDrawProperty(SerializedProperty property)
{
ShowIfAttribute showIfAttribute = PropertyUtility.GetAttributes<ShowIfAttribute>(property)[0];
UnityEngine.Object target = PropertyUtility.GetTargetObject(property);
FieldInfo conditionField = target.GetType().GetField(showIfAttribute.ConditionName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (conditionField != null &&
conditionField.FieldType == typeof(bool))
{
return (bool)conditionField.GetValue(target);
}
MethodInfo conditionMethod = target.GetType().GetMethod(showIfAttribute.ConditionName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
if (conditionMethod != null &&
conditionMethod.ReturnType == typeof(bool) &&
conditionMethod.GetParameters().Length == 0)
{
return (bool)conditionMethod.Invoke(target, null);
}
string warning = showIfAttribute.GetType().Name + " needs a valid boolean condition field or method name to work";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, target);
return true;
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: fce0c8241476ad94cbbcdd6faae90700
timeCreated: 1508414568
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 4327d74fca5deaa4c83c483fe468d274
folderAsset: yes
timeCreated: 1508051576
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,118 @@
using UnityEngine;
using UnityEditor;
using System.Reflection;
using System.Collections;
using System;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(DropdownAttribute))]
public class DropdownPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
DropdownAttribute dropdownAttribute = PropertyUtility.GetAttributes<DropdownAttribute>(property)[0];
UnityEngine.Object target = PropertyUtility.GetTargetObject(property);
FieldInfo fieldInfo = target.GetType().GetField(property.name,
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
FieldInfo valuesFieldInfo = target.GetType().GetField(dropdownAttribute.ValuesFieldName,
BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public);
if (valuesFieldInfo == null)
{
this.DrawWarningBox(string.Format("{0} cannot find a values field with name \"{1}\"", dropdownAttribute.GetType().Name, dropdownAttribute.ValuesFieldName));
EditorGUILayout.PropertyField(property, true);
}
else if (fieldInfo.FieldType == valuesFieldInfo.FieldType.GetElementType())
{
// Selected value
object selectedValue = fieldInfo.GetValue(target);
// Values and display options
IList valuesList = (IList)valuesFieldInfo.GetValue(target);
object[] values = new object[valuesList.Count];
string[] displayOptions = new string[valuesList.Count];
for (int i = 0; i < values.Length; i++)
{
object value = valuesList[i];
values[i] = value;
displayOptions[i] = value.ToString();
}
// Selected value index
int selectedValueIndex = Array.IndexOf(values, selectedValue);
if (selectedValueIndex < 0)
{
selectedValueIndex = 0;
}
// Draw the dropdown
this.DrawDropdown(target, fieldInfo, property.displayName, selectedValueIndex, values, displayOptions);
}
else if (valuesFieldInfo.GetValue(target) is IDropdownList)
{
// Current value
object selectedValue = fieldInfo.GetValue(target);
// Current value index, values and display options
IDropdownList dropdown = (IDropdownList)valuesFieldInfo.GetValue(target);
IEnumerator<KeyValuePair<string, object>> dropdownEnumerator = dropdown.GetEnumerator();
int index = -1;
int selectedValueIndex = -1;
List<object> values = new List<object>();
List<string> displayOptions = new List<string>();
while (dropdownEnumerator.MoveNext())
{
index++;
KeyValuePair<string, object> current = dropdownEnumerator.Current;
if (current.Value.Equals(selectedValue))
{
selectedValueIndex = index;
}
values.Add(current.Value);
displayOptions.Add(current.Key);
}
if (selectedValueIndex < 0)
{
selectedValueIndex = 0;
}
// Draw the dropdown
this.DrawDropdown(target, fieldInfo, property.displayName, selectedValueIndex, values.ToArray(), displayOptions.ToArray());
}
else
{
this.DrawWarningBox(typeof(DropdownAttribute).Name + " works only when the type of the field is equal to the element type of the array");
EditorGUILayout.PropertyField(property, true);
}
}
private void DrawDropdown(UnityEngine.Object target, FieldInfo fieldInfo, string label, int selectedValueIndex, object[] values, string[] displayOptions)
{
EditorGUI.BeginChangeCheck();
int newIndex = EditorGUILayout.Popup(label, selectedValueIndex, displayOptions);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(target, "Dropdown");
fieldInfo.SetValue(target, values[newIndex]);
}
}
private void DrawWarningBox(string message)
{
EditorGUILayout.HelpBox(message, MessageType.Warning);
Debug.LogWarning(message);
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 19d935f1205a5804c80c51c3ad95a271
timeCreated: 1508753698
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,75 @@
using UnityEngine;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(MinMaxSliderAttribute))]
public class MinMaxSliderPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
MinMaxSliderAttribute minMaxSliderAttribute = PropertyUtility.GetAttributes<MinMaxSliderAttribute>(property)[0];
if (property.propertyType == SerializedPropertyType.Vector2)
{
Rect controlRect = EditorGUILayout.GetControlRect();
float labelWidth = EditorGUIUtility.labelWidth;
float floatFieldWidth = EditorGUIUtility.fieldWidth;
float sliderWidth = controlRect.width - labelWidth - 2f * floatFieldWidth;
float sliderPadding = 5f;
Rect labelRect = new Rect(
controlRect.x,
controlRect.y,
labelWidth,
controlRect.height);
Rect sliderRect = new Rect(
controlRect.x + labelWidth + floatFieldWidth + sliderPadding,
controlRect.y,
sliderWidth - 2f * sliderPadding,
controlRect.height);
Rect minFloatFieldRect = new Rect(
controlRect.x + labelWidth,
controlRect.y,
floatFieldWidth,
controlRect.height);
Rect maxFloatFieldRect = new Rect(
controlRect.x + labelWidth + floatFieldWidth + sliderWidth,
controlRect.y,
floatFieldWidth,
controlRect.height);
// Draw the label
EditorGUI.LabelField(labelRect, property.displayName);
// 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;
}
}
else
{
string warning = minMaxSliderAttribute.GetType().Name + " can be used only on Vector2 fields";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, PropertyUtility.GetTargetObject(property));
EditorGUILayout.PropertyField(property, true);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 27011af81554b5b4489b155f09275475
timeCreated: 1508427131
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,14 @@
using UnityEditor;
namespace NaughtyAttributes.Editor
{
public abstract class PropertyDrawer
{
public abstract void DrawProperty(SerializedProperty property);
public virtual void ClearCache()
{
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: fd2df67a49fb7bd4d8e3914c5a2cf4a8
timeCreated: 1508051576
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,16 @@
using UnityEditor;
using UnityEngine;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
GUI.enabled = false;
EditorGUILayout.PropertyField(property, true);
GUI.enabled = true;
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: a392efb1d44b30744bb7bf76e479cfab
timeCreated: 1508862451
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,55 @@
using UnityEngine;
using UnityEditor;
using UnityEditorInternal;
using System.Collections.Generic;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(ReorderableListAttribute))]
public class ReorderableListPropertyDrawer : PropertyDrawer
{
private Dictionary<string, ReorderableList> reorderableListsByPropertyName = new Dictionary<string, ReorderableList>();
public override void DrawProperty(SerializedProperty property)
{
if (property.isArray)
{
if (!this.reorderableListsByPropertyName.ContainsKey(property.name))
{
ReorderableList reorderableList = new ReorderableList(property.serializedObject, property, true, true, true, true)
{
drawHeaderCallback = (Rect rect) =>
{
EditorGUI.LabelField(rect, string.Format("{0}: {1}", property.displayName, property.arraySize), EditorStyles.label);
},
drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
{
var element = property.GetArrayElementAtIndex(index);
rect.y += 2f;
EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element);
}
};
this.reorderableListsByPropertyName[property.name] = reorderableList;
}
this.reorderableListsByPropertyName[property.name].DoLayoutList();
}
else
{
string warning = typeof(ReorderableListAttribute).Name + " can be used only on arrays or lists";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, PropertyUtility.GetTargetObject(property));
EditorGUILayout.PropertyField(property, true);
}
}
public override void ClearCache()
{
this.reorderableListsByPropertyName.Clear();
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 6d5a6c66de03d1d4882f0c83b0e5f8f2
timeCreated: 1508402303
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,34 @@
using UnityEngine;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(ResizableTextAreaAttribute))]
public class ResizableTextAreaPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
if (property.propertyType == SerializedPropertyType.String)
{
EditorGUILayout.LabelField(property.displayName);
EditorGUI.BeginChangeCheck();
string textAreaValue = EditorGUILayout.TextArea(property.stringValue, GUILayout.MinHeight(EditorGUIUtility.singleLineHeight * 3f));
if (EditorGUI.EndChangeCheck())
{
property.stringValue = textAreaValue;
}
}
else
{
string warning = PropertyUtility.GetAttributes<ResizableTextAreaAttribute>(property)[0].GetType().Name + " can only be used on string fields";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, PropertyUtility.GetTargetObject(property));
EditorGUILayout.PropertyField(property, true);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 57848d4e847a8d445a53095abdbbb274
timeCreated: 1508583167
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,44 @@
using UnityEngine;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(ShowAssetPreviewAttribute))]
public class ShowAssetPreviewPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
EditorGUILayout.PropertyField(property, true);
if (property.propertyType == SerializedPropertyType.ObjectReference)
{
if (property.objectReferenceValue != null)
{
Texture2D previewTexture = AssetPreview.GetAssetPreview(property.objectReferenceValue);
if (previewTexture != null)
{
ShowAssetPreviewAttribute showAssetPreviewAttribute = PropertyUtility.GetAttributes<ShowAssetPreviewAttribute>(property)[0];
int width = Mathf.Clamp(showAssetPreviewAttribute.Width, 0, previewTexture.width);
int height = Mathf.Clamp(showAssetPreviewAttribute.Height, 0, previewTexture.height);
GUILayout.Label(previewTexture, GUILayout.MaxWidth(width), GUILayout.MaxHeight(height));
}
else
{
this.DrawWarningBox(property.name + " doesn't have an asset preview", property);
}
}
}
else
{
this.DrawWarningBox(property.name + " doesn't have an asset preview", property);
}
}
private void DrawWarningBox(string warningText, SerializedProperty property)
{
EditorGUILayout.HelpBox(warningText, MessageType.Warning);
Debug.LogWarning(warningText, PropertyUtility.GetTargetObject(property));
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 6c461f4d7edd955419e5e6ce2c874599
timeCreated: 1509089502
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,31 @@
using UnityEngine;
using UnityEditor;
namespace NaughtyAttributes.Editor
{
[PropertyDrawer(typeof(SliderAttribute))]
public class SliderPropertyDrawer : PropertyDrawer
{
public override void DrawProperty(SerializedProperty property)
{
SliderAttribute sliderAttribute = PropertyUtility.GetAttributes<SliderAttribute>(property)[0];
if (property.propertyType == SerializedPropertyType.Integer)
{
EditorGUILayout.IntSlider(property, (int)sliderAttribute.MinValue, (int)sliderAttribute.MaxValue);
}
else if (property.propertyType == SerializedPropertyType.Float)
{
EditorGUILayout.Slider(property, sliderAttribute.MinValue, sliderAttribute.MaxValue);
}
else
{
string warning = sliderAttribute.GetType().Name + " can be used only on int or float fields";
EditorGUILayout.HelpBox(warning, MessageType.Warning);
Debug.LogWarning(warning, PropertyUtility.GetTargetObject(property));
EditorGUILayout.PropertyField(property, true);
}
}
}
}

View file

@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: ae129a284d179ae41b8ab20f506e5d99
timeCreated: 1508422518
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 35fed6de66b90ad418e2ca247a303b9b
folderAsset: yes
timeCreated: 1508331735
licenseType: Free
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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