Version 3.3.0.1

ActionResolver class

Namespace: Sirenix.OdinInspector.Editor.ActionResolvers
Assembly: Sirenix.OdinInspector.Editor
public sealed class ActionResolver

An ActionResolver resolves a string to an action, given an InspectorProperty instance to use as context. Call Get(InspectorProperty, String) to get an instance of an ActionResolver.

Action resolvers are a globally extendable system that can be hooked into and modified or changed by creating and registering an ActionResolverCreator.

See Odin's tutorials for details and examples of how to use ActionResolvers.

Inheritance
  • System.Object
  • ActionResolver

Constructors

ActionResolver()
public ActionResolver()

Fields

Action
The delegate that executes the actual action. You should not call this manually, but instead call DoAction(Int32).
public ResolvedAction Action
Context
The context of this ActionResolver, containing all of its configurations and values it needs to function. For performance and simplicity reasons, this is a single very large struct that is passed around by ref to anything that needs it.
public ActionResolverContext Context

Properties

ErrorMessage
The current error message that the resolver has, or null if there is no error message. This is a shortcut for writing "resolver.Context.ErrorMessage".
public string ErrorMessage { get; }
HasError
Whether there is an error message at the moment. This is a shortcut for writing "resolver.Context.ErrorMessage != null".
public bool HasError { get; }

Methods

DoAction(Int32)
Executes the resolved action for a given selection index.
public void DoAction(int selectionIndex = 0)
Parameters
System.Int32 selectionIndex

The selection index to execute the action on. Defaults to 0.

DoActionForAllSelectionIndices()
Executes the action for all selection indices.
public void DoActionForAllSelectionIndices()
DrawError()
Draws an error message box if there is an error, and does nothing if there is no error.
public void DrawError()
DrawErrors(ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver)
Draws error boxes for all errors in the given action resolvers, or does nothing if there are no errors. This is equivalent to calling DrawError() on all resolvers passed to this method.
public static void DrawErrors(ActionResolver r1 = null, ActionResolver r2 = null, ActionResolver r3 = null, ActionResolver r4 = null, ActionResolver r5 = null, ActionResolver r6 = null, ActionResolver r7 = null, ActionResolver r8 = null)
DrawErrors(ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver[])
Draws error boxes for all errors in the given action resolvers, or does nothing if there are no errors. This is equivalent to calling DrawError() on all resolvers passed to this method.
public static void DrawErrors(ActionResolver r1 = null, ActionResolver r2 = null, ActionResolver r3 = null, ActionResolver r4 = null, ActionResolver r5 = null, ActionResolver r6 = null, ActionResolver r7 = null, ActionResolver r8 = null, params ActionResolver[] remainder)
Get(InspectorProperty, String)
Creates a new action resolver instance for a given string.
public static ActionResolver Get(InspectorProperty property, string resolvedString)
Parameters
InspectorProperty property

The property that is the context for the resolution to happen in.

System.String resolvedString

The string that should be resolved to an action.

Returns
ActionResolver

Get(InspectorProperty, String, NamedValue[])
Creates a new action resolver instance for a given string.
public static ActionResolver Get(InspectorProperty property, string resolvedString, params NamedValue[] namedArgs)
Parameters
InspectorProperty property

The property that is the context for the resolution to happen in.

System.String resolvedString

The string that should be resolved to an action.

NamedValue[] namedArgs

The extra named args that this resolver has access to. Passing in a named arg that already exists will silently override the pre-existing named arg.

Returns
ActionResolver

GetCombinedErrors(ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver)
Gets a nicely formatted string that lists all the errors in the given set of action resolvers. The returned value is null if there are no errors.
public static string GetCombinedErrors(ActionResolver r1 = null, ActionResolver r2 = null, ActionResolver r3 = null, ActionResolver r4 = null, ActionResolver r5 = null, ActionResolver r6 = null, ActionResolver r7 = null, ActionResolver r8 = null)
Returns
System.String

GetCombinedErrors(ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver, ActionResolver[])
Gets a nicely formatted string that lists all the errors in the given set of action resolvers. The returned value is null if there are no errors.
public static string GetCombinedErrors(ActionResolver r1, ActionResolver r2, ActionResolver r3, ActionResolver r4, ActionResolver r5, ActionResolver r6, ActionResolver r7, ActionResolver r8, params ActionResolver[] remainder)
Returns
System.String

GetFromContext(ref ActionResolverContext)
Creates a new action resolver instance from a pre-built context struct. This is a more advanced use that requires you to know how the context needs to be set up before action resolution happens. However, this allows you to do more advanced things like adjust various context values before string resolution happens.
public static ActionResolver GetFromContext(ref ActionResolverContext context)
Parameters
ActionResolverContext context

The pre-built context that should be used to get a resolver.

Returns
ActionResolver