65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Microsoft.MixedReality.Toolkit.UI
|
|
{
|
|
/// <summary>
|
|
/// Theme engine that allows control to enable/disable a GameObject based on the current state
|
|
/// </summary>
|
|
public class InteractableActivateTheme : InteractableThemeBase
|
|
{
|
|
/// <inheritdoc />
|
|
public override bool IsEasingSupported => false;
|
|
|
|
public InteractableActivateTheme()
|
|
{
|
|
Types = new Type[] { typeof(Transform) };
|
|
Name = "Activate Theme";
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override ThemeDefinition GetDefaultThemeDefinition()
|
|
{
|
|
return new ThemeDefinition()
|
|
{
|
|
ThemeType = GetType(),
|
|
StateProperties = new List<ThemeStateProperty>()
|
|
{
|
|
new ThemeStateProperty()
|
|
{
|
|
Name = "Activate",
|
|
Type = ThemePropertyTypes.Bool,
|
|
Values = new List<ThemePropertyValue>(),
|
|
Default = new ThemePropertyValue() { Bool = true }
|
|
},
|
|
},
|
|
CustomProperties = new List<ThemeProperty>(),
|
|
};
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override ThemePropertyValue GetProperty(ThemeStateProperty property)
|
|
{
|
|
ThemePropertyValue start = new ThemePropertyValue();
|
|
start.Bool = Host.activeSelf;
|
|
return start;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void SetValue(ThemeStateProperty property, int index, float percentage)
|
|
{
|
|
SetValue(property, property.Values[index]);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void SetValue(ThemeStateProperty property, ThemePropertyValue value)
|
|
{
|
|
Host.SetActive(value.Bool);
|
|
}
|
|
}
|
|
}
|