forked from microsoft/MixedRealityToolkit-Unity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToolTipBackground.cs
More file actions
42 lines (34 loc) · 1.16 KB
/
ToolTipBackground.cs
File metadata and controls
42 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using UnityEngine;
using HoloToolkit.Unity;
namespace HoloToolkit.UX.ToolTips
{
[RequireComponent(typeof(MeshFilter))]
/// <summary>
/// Base class for a tool tip background
/// Automatically finds a ToolTip and subscribes to ContentChange action
/// Resizes its content to match ToolTip's content in ScaleToFitContent()
/// </summary>
public abstract class ToolTipBackground : MonoBehaviour
{
[SerializeField]
protected ToolTip toolTip;
protected virtual void OnEnable()
{
toolTip = gameObject.EnsureComponent<ToolTip>();
if (toolTip == null)
{
Debug.LogError("No tooltip found in ToolTipMeshBackground");
enabled = false;
return;
}
toolTip.ContentChange += ContentChange;
}
protected virtual void ContentChange()
{
ScaleToFitContent();
}
protected abstract void ScaleToFitContent();
}
}