InjectionAttribute Class

Summary

Base class for attributes which define behaviours for automatically injecting values into static properties.
Assembly
Weaver.dll
Namespace
Weaver
Interfaces
  • IInjector
  • IHasCustomMenu
  • WeaverWindow.IItem
Base Types
  • Attribute
Derived Types
graph BT Type-->Base0["Attribute"] Type-.->Interface0["IInjector"] Type-.->Interface1["IHasCustomMenu"] Type-.->Interface2["WeaverWindow.IItem"] Type["InjectionAttribute"] class Type type-node Derived0["AssetInjectionAttribute"]-->Type click Derived0 "/weaver/api/Weaver/AssetInjectionAttribute" Derived1["PrefAttribute"]-->Type click Derived1 "/weaver/api/Weaver/PrefAttribute"

Syntax

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public abstract class InjectionAttribute : Attribute, IInjector, IHasCustomMenu, WeaverWindow.IItem

Attributes

Type Description
AttributeUsageAttribute

Fields

Name Constant Value Summary
_InspectorTooltip
[Editor-Only] The cached tooltip of this attribute. Should only be read by Weaver.InjectionAttribute.GetInspectorTooltip.
_ToString
[Editor-Only] Cached return value of Weaver.InjectionAttribute.ToString.

Properties

Name Value Summary
EditorOnly bool
If set to true, this attribute won't be used in builds. Must be set for attributes inside #if UNITY_EDITOR regions since that fact can't be detected automatically.
InEditMode bool
[Editor-Only] Indicates whether the attributed member's value should be assigned in Edit Mode, otherwise it will only be assigned in Play Mode and on startup in a build.
Optional bool
If set to true, this attribute will not give any errors when it is unable to initialize with an appropriate value.
ShouldShow bool
[Editor-Only] Indicates whether this attribute should currently be visible in the Weaver.Editor.Window.WeaverWindow.
Tooltip string
A description of the purpose of the attributed property to be shown in the Unity Editor.

Methods

Name Value Summary
AddItemsToMenu(GenericMenu) void
[Editor-Only] Adds various functions for this attribute to the `menu`.
AppendDetail(StringBuilder, bool, string) void
[Editor-Only] Appends an opening bracket or comma depending on `isFirst` followed by the specified `detail` and sets `isFirst` to false. Intended for use within Weaver.InjectionAttribute.AppendDetails(System.Text.StringBuilder,System.Boolean@).
AppendDetails(StringBuilder, bool) void
[Editor-Only] Appends any optional properties that have been set on this attribute.
CheckContextMenu() void
[Editor-Only] Calls Weaver.InjectionAttribute.CheckContextMenu(UnityEngine.Rect) with the last UnityEngine.GUILayout rect.
CheckContextMenu(Rect) void
[Editor-Only] If the current event is a UnityEngine.EventType.ContextClick inside the `area`, this method builds a menu using Weaver.InjectionAttribute.AddItemsToMenu(UnityEditor.GenericMenu) and shows it.
DoInspectorGUI() void
[Editor-Only] Draws the inspector GUI for this attribute.
Equals(Object) bool
[Editor-Only] Uses System.Object.ReferenceEquals(System.Object,System.Object) instead of the default System.Attribute.Equals(System.Object).
GetHashCode() int
[Editor-Only] Returns the hash code for this instance.
GetInspectorTooltip() string
[Editor-Only] Builds, caches, and returns a tooltip message for this attribute.
GetMissingValueMessage() string
[Editor-Only] Returns a message indicating that no value has been assigned for this attribute.
GetTempLabelContent() GUIContent
[Editor-Only] Returns a reusable UnityEngine.GUIContent containing the name, tooltip, and icon of this attribute.
GetValue() Object
[Editor-Only] Tries to get the value of the attributed member. Catches and logs any exceptions.
GetValueToInject() Object
[Editor-Only] Returns a value to be assigned to the attributed property.
LogThisInvalidAttribute(string) bool
[Editor-Only] Logs a message indicating that this attribute is invalid, followed by a `message` explaining why. Returns false.
SetValue(Object) void
[Editor-Only] Tries to set the value of the attributed member. Catches and logs any exceptions.
ToString() string
[Editor-Only] Returns a description of this attribute.
TryInitialize() bool
[Editor-Only] Attempts to initialize this attribute and returns true if successful.

Operators

Name Value Summary
operator !=(InjectionAttribute, Object) bool
operator ==(InjectionAttribute, Object) bool