Skip to content

SVHandleDisplay

Death edited this page Apr 6, 2018 · 4 revisions

SVHandleDisplay

Abstract class which can be inherited in order to add [SVHandle] functionality to any Type.

public abstract class SVHandleDisplay

Properties

Type Name Summary
int Priority Int used when no specific type is defined.
Type ExecutingType The type in which this display is responsible for drawing.

Methods

Type Name Summary Arguments
void Draw The actual method that will be called to draw the object. SVArgs args, ref object value

Example

The following example showcases how one would define a custom, secondary, Handle class for drawing a Vector3[] array.

public class Vector3ArrayHandleDisplay_Line : SVHandleDisplay
{
	// Since this method is thought of as a secondary to even the defaults, we will give it a priority of -2.
	public override int Priority
	{
		get { return -2; }
	}

	public override Type ExecutingType
	{
		get { return typeof(Vector3[]); }
	}

	public override void Draw(SVArgs args, ref object value)
	{
		Vector3[] inPoints = value as Vector3[];

		for (int i = 0; i < inPoints.Length; i++)
		{
			if (i > 0)
				Handles.DrawLine(inPoints[i], inPoints[i - 1]);
			inPoints[i] = Handles.DoPositionHandle(inPoints[i], Quaternion.identity);
		}

		value = inPoints;
	}
}

// Example Usage:
[SVHandle(typeof(Vector3ArrayHandleDisplay_Line))]
public Vector3[] MyVectorArray;

Main

Docs

Clone this wiki locally