Skip to content

Instantly share code, notes, and snippets.

@seldomU
Last active May 16, 2016 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seldomU/2a5b12c8f9418586145e to your computer and use it in GitHub Desktop.
Save seldomU/2a5b12c8f9418586145e to your computer and use it in GitHub Desktop.
Accessing the RelationsInspector API through reflection

Accessing the RelationsInspector API through reflection

By including the code file below, any Unity project can access RelationsInspector's API without depending on it to be present. This is useful when a tool should offer optional controls when the user has RelationsInspector installed, and hide them if he does not. For example, an optional button could create a graph window like this:

string backendTypeName = "TheBackendTypeNameYouWantToAccess";

// check if the backend as well as RelationsInspector are installed
if ( RelationsInspectorLink.HasBackend( backendTypeName ) )
{
	if ( GUILayout.Button( "Show graph" ) )
	{
		RelationsInspectorLink.ResetTargets( yourTargetObjectArray, backendTypeName );
	}
}

This way the tool can adapt to RelationsInspector's presence without requiring any changes to its own code.

Make sure to include RelationsInspectorLink in your tool's namespace, to avoid collisions with other tools using the same approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment