using UnityEditor;
using UnityEngine;
namespace Unity.Tutorials.Core.Editor
{
///
/// Criterion for checking that a specific Editor Tool is selected.
///
public class ActiveToolCriterion : Criterion
{
///
/// The Tool we wish to test for.
///
public Tool TargetTool { get { return m_TargetTool; } set { m_TargetTool = value; } }
[SerializeField]
Tool m_TargetTool;
///
/// Starts testing of the criterion.
///
public override void StartTesting()
{
UpdateCompletion();
EditorApplication.update += UpdateCompletion;
}
///
/// Stops testing of the criterion.
///
public override void StopTesting()
{
EditorApplication.update -= UpdateCompletion;
}
///
/// Evaluates if the criterion is completed.
///
///
protected override bool EvaluateCompletion()
{
return Tools.current == m_TargetTool;
}
///
/// Auto-completes the criterion.
///
/// True if the auto-completion succeeded.
public override bool AutoComplete()
{
Tools.current = m_TargetTool;
return true;
}
}
}