Added new control template (editor menu only) - progress bar
--HG-- branch : developpull/413/head
parent
6902d8dc64
commit
e648e09beb
|
@ -24,7 +24,7 @@ namespace UnityEditor.UI
|
||||||
private const string kCheckmarkPath = "UI/Skin/Checkmark.psd";
|
private const string kCheckmarkPath = "UI/Skin/Checkmark.psd";
|
||||||
|
|
||||||
private static Vector2 s_ThickGUIElementSize = new Vector2(kWidth, kThickHeight);
|
private static Vector2 s_ThickGUIElementSize = new Vector2(kWidth, kThickHeight);
|
||||||
//private static Vector2 s_ThinGUIElementSize = new Vector2(kWidth, kThinHeight);
|
private static Vector2 s_ThinGUIElementSize = new Vector2(kWidth, kThinHeight);
|
||||||
private static Vector2 s_ImageGUIElementSize = new Vector2(100f, 100f);
|
private static Vector2 s_ImageGUIElementSize = new Vector2(100f, 100f);
|
||||||
private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f);
|
private static Color s_DefaultSelectableColor = new Color(1f, 1f, 1f, 1f);
|
||||||
private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f);
|
private static Color s_TextColor = new Color(50f / 255f, 50f / 255f, 50f / 255f, 1f);
|
||||||
|
@ -747,6 +747,52 @@ namespace UnityEditor.UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[MenuItem("GameObject/UI/Extensions/Progress Bar", false)]
|
||||||
|
static public void AddSlider(MenuCommand menuCommand)
|
||||||
|
{
|
||||||
|
// Create GOs Hierarchy
|
||||||
|
GameObject root = CreateUIElementRoot("Progress Bar", menuCommand, s_ThinGUIElementSize);
|
||||||
|
|
||||||
|
GameObject background = CreateUIObject("Background", root);
|
||||||
|
GameObject fillArea = CreateUIObject("Fill Area", root);
|
||||||
|
GameObject fill = CreateUIObject("Fill", fillArea);
|
||||||
|
|
||||||
|
// Background
|
||||||
|
Image backgroundImage = background.AddComponent<Image>();
|
||||||
|
backgroundImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kBackgroundSpriteResourcePath);
|
||||||
|
backgroundImage.type = Image.Type.Sliced;
|
||||||
|
backgroundImage.color = s_DefaultSelectableColor;
|
||||||
|
RectTransform backgroundRect = background.GetComponent<RectTransform>();
|
||||||
|
backgroundRect.anchorMin = new Vector2(0, 0.25f);
|
||||||
|
backgroundRect.anchorMax = new Vector2(1, 0.75f);
|
||||||
|
backgroundRect.sizeDelta = new Vector2(0, 0);
|
||||||
|
|
||||||
|
// Fill Area
|
||||||
|
RectTransform fillAreaRect = fillArea.GetComponent<RectTransform>();
|
||||||
|
fillAreaRect.anchorMin = new Vector2(0, 0.25f);
|
||||||
|
fillAreaRect.anchorMax = new Vector2(1, 0.75f);
|
||||||
|
fillAreaRect.anchoredPosition = Vector2.zero;
|
||||||
|
fillAreaRect.sizeDelta = Vector2.zero;
|
||||||
|
|
||||||
|
// Fill
|
||||||
|
Image fillImage = fill.AddComponent<Image>();
|
||||||
|
fillImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath);
|
||||||
|
fillImage.type = Image.Type.Sliced;
|
||||||
|
fillImage.color = s_DefaultSelectableColor;
|
||||||
|
|
||||||
|
RectTransform fillRect = fill.GetComponent<RectTransform>();
|
||||||
|
fillRect.sizeDelta = Vector2.zero;
|
||||||
|
|
||||||
|
// Setup slider component
|
||||||
|
Slider slider = root.AddComponent<Slider>();
|
||||||
|
slider.value = 0;
|
||||||
|
slider.fillRect = fill.GetComponent<RectTransform>();
|
||||||
|
slider.targetGraphic = fillImage;
|
||||||
|
slider.direction = Slider.Direction.LeftToRight;
|
||||||
|
SetDefaultColorTransitionValues(slider);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Helper Functions
|
#region Helper Functions
|
||||||
|
|
Loading…
Reference in New Issue