-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Expand file tree
/
Copy pathUtil.cs
More file actions
107 lines (91 loc) · 3.38 KB
/
Copy pathUtil.cs
File metadata and controls
107 lines (91 loc) · 3.38 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine;
using UnityEngine.UIElements;
namespace UnityEditor.Build.Profile
{
/// <summary>
/// Class containing build profile window utility functions.
/// </summary>
internal static class Util
{
internal const string k_StyleSheet = "BuildProfile/StyleSheets/BuildProfile.uss";
internal const string k_PY_MediumUssClass = "py-medium";
/// <summary>
/// Helper function for setting the platform settings helpbox based on
/// license and module installation status.
/// </summary>
internal static bool UpdatePlatformRequirementsWarningHelpBox(HelpBox helpbox, GUID platformId)
{
if (helpbox == null)
return false;
ClearHelpBox(helpbox);
if (!BuildProfileModuleUtil.IsBuildProfileLicensed(platformId))
{
BuildProfileModuleUtil.UpdateHelpBoxForLicenseNotFound(helpbox, platformId);
helpbox.Show();
return true;
}
if (!BuildProfileModuleUtil.IsModuleInstalled(platformId))
{
BuildProfileModuleUtil.UpdateHelpBoxForModuleNotInstalled(helpbox, platformId);
helpbox.Show();
return true;
}
if (!BuildProfileModuleUtil.IsBuildProfileSupported(platformId))
{
helpbox.text = TrText.notSupportedWarning;
helpbox.Show();
return true;
}
helpbox.Hide();
return false;
}
internal static bool UpdateSupportedPlatformStatusHelpBox(HelpBox helpbox, GUID platformGuid)
{
if (helpbox == null)
return false;
ClearHelpBox(helpbox);
if (BuildProfileModuleUtil.UpdateHelpBoxForSupportedPlatformStatus(platformGuid, helpbox))
{
helpbox.Show();
return true;
}
helpbox.Hide();
return false;
}
static void ClearHelpBox(HelpBox helpbox)
{
if (helpbox == null)
return;
helpbox.text = string.Empty;
helpbox.buttonText = string.Empty;
helpbox.linkText = string.Empty;
helpbox.linkHref = string.Empty;
}
internal static void ApplyActionState(this VisualElement elem, ActionState state)
{
switch (state)
{
case ActionState.Hidden:
elem.Hide();
elem.SetEnabled(false);
break;
case ActionState.Disabled:
elem.Show();
elem.SetEnabled(false);
break;
case ActionState.Enabled:
elem.Show();
elem.SetEnabled(true);
break;
default:
throw new ArgumentOutOfRangeException(nameof(state), state, nameof(elem));
}
}
internal static void Hide(this VisualElement elem) => elem.style.display = DisplayStyle.None;
internal static void Show(this VisualElement elem) => elem.style.display = DisplayStyle.Flex;
}
}