BuildStatusButton.cs
1.74 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
using System;
using UnityEditor;
using UnityEditor.Collaboration;
using UnityEngine;
#if UNITY_2019_1_OR_NEWER
using UnityEngine.UIElements;
#else
using UnityEngine.Experimental.UIElements;
#endif
namespace UnityEditor.Collaboration
{
internal class BuildStatusButton : Button
{
private readonly string iconPrefix = "Icons/Collab.Build";
private readonly string iconSuffix = ".png";
Label labelElement = new Label();
Image iconElement = new Image() {name = "BuildIcon"};
public BuildStatusButton(Action clickEvent) : base(clickEvent)
{
iconElement.image = EditorGUIUtility.Load(iconPrefix + iconSuffix) as Texture;
labelElement.text = "Build Now";
Add(iconElement);
Add(labelElement);
}
public BuildStatusButton(Action clickEvent, BuildState state, int failures) : base(clickEvent)
{
switch (state)
{
case BuildState.InProgress:
iconElement.image = EditorGUIUtility.Load(iconPrefix + iconSuffix) as Texture;
labelElement.text = "In progress";
break;
case BuildState.Failed:
iconElement.image = EditorGUIUtility.Load(iconPrefix + "Failed" + iconSuffix) as Texture;
labelElement.text = failures + ((failures == 1) ? " failure" : " failures");
break;
case BuildState.Success:
iconElement.image = EditorGUIUtility.Load(iconPrefix + "Succeeded" + iconSuffix) as Texture;
labelElement.text = "success";
break;
}
Add(iconElement);
Add(labelElement);
}
}
}