namespace VRTK.Prefabs.Locomotion.Movement.SpatialManipulation
{
using UnityEngine;
using Malimbe.MemberClearanceMethod;
using Malimbe.XmlDocumentationAttribute;
using Malimbe.PropertySerializationAttribute;
using Zinnia.Data.Attribute;
using Malimbe.MemberChangeMethod;
using Zinnia.Action;
///
/// The public interface for the Drag.Rotate.Scale Spatial Manipulator prefab.
///
public class SpatialManipulatorFacade : MonoBehaviour
{
#region Object Settings
///
/// The primary source to track positional and rotational data on to apply to the manipulator.
///
[Serialized, Cleared]
[field: Header("Object Settings"), DocumentedByXml]
public GameObject PrimarySource { get; set; }
///
/// The secondary source to track positional and rotational data on to apply to the manipulator.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public GameObject SecondarySource { get; set; }
///
/// The target to apply the spatial manipulation to.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public GameObject Target { get; set; }
///
/// An optional offset to take into consideration when manipulating the target.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public GameObject Offset { get; set; }
#endregion
#region Activation Settings
///
/// The Action to engage the position manipulation.
///
[Serialized, Cleared]
[field: Header("Activation Settings"), DocumentedByXml]
public BooleanAction ActivatePositionManipulation { get; set; }
///
/// The Action to engage the rotation manipulation.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public BooleanAction ActivateRotationManipulation { get; set; }
///
/// The Action to engage the scale manipulation.
///
[Serialized, Cleared]
[field: DocumentedByXml]
public BooleanAction ActivateScaleManipulation { get; set; }
#endregion
#region Reference Settings
///
/// The manipulator that handles position.
///
[Serialized]
[field: Header("Reference Settings"), DocumentedByXml, Restricted]
public SpatialManipulator PositionManipulator { get; protected set; }
///
/// The manipulator that handles rotation.
///
[Serialized]
[field: DocumentedByXml, Restricted]
public SpatialManipulator RotationManipulator { get; protected set; }
///
/// The manipulator that handles scale.
///
[Serialized]
[field: DocumentedByXml, Restricted]
public SpatialManipulator ScaleManipulator { get; protected set; }
#endregion
protected virtual void OnEnable()
{
SetReferenceSettings();
ScaleManipulator.ActivationAction = ActivateScaleManipulation;
RotationManipulator.ActivationAction = ActivateRotationManipulation;
PositionManipulator.ActivationAction = ActivatePositionManipulation;
}
protected virtual void SetReferenceSettings()
{
SetObjectSettings(ScaleManipulator);
SetObjectSettings(RotationManipulator);
SetObjectSettings(PositionManipulator);
}
protected virtual void SetObjectSettings(SpatialManipulator manipulator)
{
manipulator.PrimarySource = PrimarySource;
manipulator.SecondarySource = SecondarySource;
manipulator.Target = Target;
manipulator.Offset = Offset;
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(PrimarySource))]
protected virtual void OnAfterPrimarySourceChange()
{
SetReferenceSettings();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(SecondarySource))]
protected virtual void OnAfterSecondarySourceChange()
{
SetReferenceSettings();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(Target))]
protected virtual void OnAfterTargetChange()
{
SetReferenceSettings();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(Offset))]
protected virtual void OnAfterOffsetChange()
{
SetReferenceSettings();
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(ActivateScaleManipulation))]
protected virtual void OnAfterActivateScaleManipulationChange()
{
ScaleManipulator.ActivationAction = ActivateScaleManipulation;
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(ActivateRotationManipulation))]
protected virtual void OnAfterActivateRotationManipulationChange()
{
RotationManipulator.ActivationAction = ActivateRotationManipulation;
}
///
/// Called after has been changed.
///
[CalledAfterChangeOf(nameof(ActivatePositionManipulation))]
protected virtual void OnAfterActivatePositionManipulationChange()
{
PositionManipulator.ActivationAction = ActivatePositionManipulation;
}
}
}