summaryrefslogtreecommitdiff
path: root/Assets/Plugins/AdvancedInspector/Attributes/Background.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-15 19:05:22 +0800
committerchai <chaifix@163.com>2020-10-15 19:05:22 +0800
commitf049177e20a276049c61edbad631c1b2bbdd5706 (patch)
tree7d1a1cd9b690a5d9a8b9a65554a191d6ec769601 /Assets/Plugins/AdvancedInspector/Attributes/Background.cs
parent6990a0d1fbdcbbf404f40713363ac1a148c8840a (diff)
-advanced inspector
+odin
Diffstat (limited to 'Assets/Plugins/AdvancedInspector/Attributes/Background.cs')
-rw-r--r--Assets/Plugins/AdvancedInspector/Attributes/Background.cs100
1 files changed, 0 insertions, 100 deletions
diff --git a/Assets/Plugins/AdvancedInspector/Attributes/Background.cs b/Assets/Plugins/AdvancedInspector/Attributes/Background.cs
deleted file mode 100644
index e5ade555..00000000
--- a/Assets/Plugins/AdvancedInspector/Attributes/Background.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using UnityEngine;
-using System.Reflection;
-using System.Collections.Generic;
-
-namespace AdvancedInspector
-{
- /// <summary>
- /// Changes the color of the background of an expandable item.
- /// </summary>
- [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Struct)]
- public class BackgroundAttribute : Attribute, IRuntimeAttribute<Color>
- {
- public delegate Color BackgroundDelegate();
- public delegate Color BackgroundStaticDelegate(BackgroundAttribute background, object instance, object value);
-
- private Color color = Color.clear;
-
- /// <summary>
- /// Give this item's background a color.
- /// </summary>
- public Color Color
- {
- get { return color; }
- set { color = value; }
- }
-
- #region IRuntime Implementation
- private string methodName = "";
-
- public string MethodName
- {
- get { return methodName; }
- set { methodName = value; }
- }
-
- public Type Template
- {
- get { return typeof(BackgroundDelegate); }
- }
-
- public Type TemplateStatic
- {
- get { return typeof(BackgroundStaticDelegate); }
- }
-
- private List<Delegate> delegates = new List<Delegate>();
-
- public List<Delegate> Delegates
- {
- get { return delegates; }
- set { delegates = value; }
- }
-
- public Color Invoke(int index, object instance, object value)
- {
- if (delegates.Count == 0 || index >= delegates.Count)
- return color;
-
- try
- {
- if (delegates[index].Target == null)
- {
- return (Color)delegates[index].DynamicInvoke(this, instance, value);
- }
- else
- {
- return (Color)delegates[index].DynamicInvoke();
- }
- }
- catch (Exception e)
- {
- if (e is TargetInvocationException)
- e = ((TargetInvocationException)e).InnerException;
-
- Debug.LogError(string.Format("Invoking a method to retrieve a Background attribute failed. The exception was \"{0}\".", e.Message));
- return color;
- }
- }
- #endregion
-
- public BackgroundAttribute(string methodName)
- {
- this.methodName = methodName;
- }
-
- public BackgroundAttribute(Delegate method)
- {
- this.delegates.Add(method);
- }
-
- public BackgroundAttribute(float r, float g, float b)
- : this(r, g, b, 1) { }
-
- public BackgroundAttribute(float r, float g, float b, float a)
- {
- this.color = new Color(r, g, b, a);
- }
- }
-} \ No newline at end of file