using UnityEngine;
namespace Tobii.Research.CodeExamples
{
class IEyeTracker_TryApplyLicenses
{
public static IEnumerator Execute(IEyeTracker eyeTracker, string licensePath)
{
ApplyLicense(eyeTracker, licensePath);
ClearLicense(eyeTracker);
yield break;
}
private static void ApplyLicense(IEyeTracker eyeTracker, string licensePath)
{
var licenseCollection = new LicenseCollection(
new System.Collections.Generic.List<LicenseKey>
{
new LicenseKey(System.IO.File.ReadAllBytes(licensePath))
});
FailedLicenseCollection failedLicenses;
if (eyeTracker.TryApplyLicenses(licenseCollection, out failedLicenses))
{
"Successfully applied license from {0} on eye tracker with serial number {1}.",
licensePath, eyeTracker.SerialNumber));
}
else
{
"Failed to apply license from {0} on eye tracker with serial number {1}.\n" +
"The validation result is {2}.",
licensePath, eyeTracker.SerialNumber, failedLicenses[0].ValidationResult));
}
}
private static void ClearLicense(IEyeTracker eyeTracker)
{
eyeTracker.ClearAppliedLicenses();
}
}
}