forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtil.cs
More file actions
85 lines (76 loc) · 2.94 KB
/
Copy pathUtil.cs
File metadata and controls
85 lines (76 loc) · 2.94 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
// 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";
const int k_HelBoxChildItemCount = 2;
/// <summary>
/// Helper function for setting the platform settings helpbox based on
/// license and module installation status.
/// </summary>
internal static bool UpdatePlatformRequirementsWarningHelpBox(HelpBox target, string platformId)
{
if (target.childCount > k_HelBoxChildItemCount)
{
// Remove extra element added by this method. HelpBox default is
// two elements.
target[2].RemoveFromHierarchy();
}
var licenseNotFoundElement = BuildProfileModuleUtil.CreateLicenseNotFoundElement(platformId);
if (licenseNotFoundElement is not null)
{
target.text = string.Empty;
target.Add(licenseNotFoundElement);
target.Show();
return true;
}
if (!BuildProfileModuleUtil.IsModuleInstalled(platformId))
{
target.text = string.Empty;
target.Add(BuildProfileModuleUtil.CreateModuleNotInstalledElement(platformId));
target.Show();
return true;
}
if (!BuildProfileModuleUtil.IsBuildProfileSupported(platformId))
{
target.text = TrText.notSupportedWarning;
target.Show();
return true;
}
target.Hide();
return false;
}
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;
}
}