Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions .github/workflows/development-buildandtestupmrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
unity-version:
- 2019
- 2020
- 2021
- 2022
- 6000.0.x
- 6000
include:
- os: ubuntu-latest
build-targets: StandaloneLinux64, Android
# - os: ubuntu-latest
# build-targets: StandaloneLinux64, Android
- os: windows-latest
build-targets: StandaloneWindows64
build-targets: StandaloneWindows64, Android
- os: macos-latest
build-targets: StandaloneOSX, iOS
steps:
Expand Down
4 changes: 0 additions & 4 deletions Editor/CUIImageEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,7 @@ protected override void OnSceneGUI()

Handles.color = Color.gray;
EditorGUI.BeginChangeCheck();
#if UNITY_2022_1_OR_NEWER
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
#else
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), script.transform.rotation, HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
#endif

Handles.Label(newCornerPos, string.Format("Corner Mover"));

Expand Down
6 changes: 1 addition & 5 deletions Editor/CanvasGroupActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ void OnFocus()

void ObtainCanvasGroups()
{
#if UNITY_2023_1_OR_NEWER
canvasGroups = GameObject.FindObjectsByType<CanvasGroup>(FindObjectsSortMode.None);
#else
canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>();
#endif
canvasGroups = GameObject.FindObjectsByType<CanvasGroup>(FindObjectsSortMode.None);
}

void OnGUI()
Expand Down
184 changes: 86 additions & 98 deletions Editor/UIExtensionsMenuOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if UNITY_2019_1_OR_NEWER && !ENABLE_LEGACY_INPUT_MANAGER
#if !ENABLE_LEGACY_INPUT_MANAGER
#define NEW_INPUT_SYSTEM
#endif

Expand Down Expand Up @@ -159,11 +159,7 @@ private static void CreateEventSystem(bool select)

private static void CreateEventSystem(bool select, GameObject parent)
{
#if UNITY_2023_1_OR_NEWER
var esys = Object.FindFirstObjectByType<EventSystem>();
#else
var esys = Object.FindObjectOfType<EventSystem>();
#endif
if (esys == null)
{
var eventSystem = new GameObject("EventSystem");
Expand Down Expand Up @@ -195,11 +191,7 @@ static public GameObject GetOrCreateCanvasGameObject()
return canvas.gameObject;

// No canvas in selection or its parents? Then use just any canvas..
#if UNITY_2023_1_OR_NEWER
canvas = Object.FindFirstObjectByType<Canvas>();
#else
canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas;
#endif
if (canvas != null && canvas.gameObject.activeInHierarchy)
return canvas.gameObject;

Expand Down Expand Up @@ -677,91 +669,91 @@ static public void AddUIVerticallScroller(MenuCommand menuCommand)

Selection.activeGameObject = uiVerticalScrollerRoot;
}
#endregion

#region UIHorizontal Scroller
[MenuItem("GameObject/UI/Extensions/Layout/UI Horizontal Scroller", false)]
static public void AddUIHorizontalScroller(MenuCommand menuCommand)
{
GameObject uiHorizontalScrollerRoot = CreateUIElementRoot("UI Horizontal Scroller", menuCommand, s_ThickGUIElementSize);

GameObject uiScrollerCenter = CreateUIObject("Center", uiHorizontalScrollerRoot);

GameObject childContent = CreateUIObject("Content", uiHorizontalScrollerRoot);

// Set RectTransform to stretch
RectTransform rectTransformScrollSnapRoot = uiHorizontalScrollerRoot.GetComponent<RectTransform>();
rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f);
rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f);
rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero;
rectTransformScrollSnapRoot.sizeDelta = new Vector2(500f, 150f);

// Add required ScrollRect
ScrollRect sr = uiHorizontalScrollerRoot.AddComponent<ScrollRect>();
sr.vertical = false;
sr.horizontal = true;
sr.movementType = ScrollRect.MovementType.Unrestricted;
var uiscr = uiHorizontalScrollerRoot.AddComponent<UIHorizontalScroller>();

//Setup container center point
RectTransform rectTransformCenter = uiScrollerCenter.GetComponent<RectTransform>();
rectTransformCenter.anchorMin = new Vector2(0.3f,0f);
rectTransformCenter.anchorMax = new Vector2(0.6f,1f);
rectTransformCenter.sizeDelta = Vector2.zero;

uiscr.Center = uiScrollerCenter.GetComponent<RectTransform>();

//Setup Content container
RectTransform rectTransformContent = childContent.GetComponent<RectTransform>();
rectTransformContent.anchorMin = Vector2.zero;
rectTransformContent.anchorMax = new Vector2(1f, 1f);
rectTransformContent.sizeDelta = Vector2.zero;

sr.content = rectTransformContent;

// Add sample children
for (int i = 0; i < 10; i++)
{
GameObject childPage = CreateUIObject("Page_" + i, childContent);

GameObject childText = CreateUIObject("Text", childPage);

//Setup 1st Child
Image pageImage = childPage.AddComponent<Image>();
pageImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath);
pageImage.type = Image.Type.Sliced;
pageImage.color = s_DefaultSelectableColor;

RectTransform rectTransformPage = childPage.GetComponent<RectTransform>();
rectTransformPage.anchorMin = new Vector2(0.5f, 0);
rectTransformPage.anchorMax = new Vector2(0.5f, 1f);
rectTransformPage.sizeDelta = new Vector2(80f, 0f);
rectTransformPage.pivot = new Vector2(0.5f, 0.5f);
rectTransformPage.localPosition = new Vector3(80 * i, 0, 0);
childPage.AddComponent<Button>();

var childCG = childPage.AddComponent<CanvasGroup>();
childCG.interactable = false;

//Setup Text on Item
Text text = childText.AddComponent<Text>();
text.text = "Item_" + i;
text.alignment = TextAnchor.MiddleCenter;
text.color = new Color(0.196f, 0.196f, 0.196f);

//Setup Text on Item
RectTransform rectTransformPageText = childText.GetComponent<RectTransform>();
rectTransformPageText.anchorMin = new Vector2(0.5f, 0.5f);
rectTransformPageText.anchorMax = new Vector2(0.5f, 0.5f);
rectTransformPageText.pivot = new Vector2(0.5f, 0.5f);
}

Selection.activeGameObject = uiHorizontalScrollerRoot;
}
#endregion

#region UI Button
[MenuItem("GameObject/UI/Extensions/Controls/UI Button", false)]
#endregion

#region UIHorizontal Scroller
[MenuItem("GameObject/UI/Extensions/Layout/UI Horizontal Scroller", false)]
static public void AddUIHorizontalScroller(MenuCommand menuCommand)
{
GameObject uiHorizontalScrollerRoot = CreateUIElementRoot("UI Horizontal Scroller", menuCommand, s_ThickGUIElementSize);

GameObject uiScrollerCenter = CreateUIObject("Center", uiHorizontalScrollerRoot);

GameObject childContent = CreateUIObject("Content", uiHorizontalScrollerRoot);

// Set RectTransform to stretch
RectTransform rectTransformScrollSnapRoot = uiHorizontalScrollerRoot.GetComponent<RectTransform>();
rectTransformScrollSnapRoot.anchorMin = new Vector2(0.5f, 0.5f);
rectTransformScrollSnapRoot.anchorMax = new Vector2(0.5f, 0.5f);
rectTransformScrollSnapRoot.anchoredPosition = Vector2.zero;
rectTransformScrollSnapRoot.sizeDelta = new Vector2(500f, 150f);

// Add required ScrollRect
ScrollRect sr = uiHorizontalScrollerRoot.AddComponent<ScrollRect>();
sr.vertical = false;
sr.horizontal = true;
sr.movementType = ScrollRect.MovementType.Unrestricted;
var uiscr = uiHorizontalScrollerRoot.AddComponent<UIHorizontalScroller>();

//Setup container center point
RectTransform rectTransformCenter = uiScrollerCenter.GetComponent<RectTransform>();
rectTransformCenter.anchorMin = new Vector2(0.3f, 0f);
rectTransformCenter.anchorMax = new Vector2(0.6f, 1f);
rectTransformCenter.sizeDelta = Vector2.zero;

uiscr.Center = uiScrollerCenter.GetComponent<RectTransform>();

//Setup Content container
RectTransform rectTransformContent = childContent.GetComponent<RectTransform>();
rectTransformContent.anchorMin = Vector2.zero;
rectTransformContent.anchorMax = new Vector2(1f, 1f);
rectTransformContent.sizeDelta = Vector2.zero;

sr.content = rectTransformContent;

// Add sample children
for (int i = 0; i < 10; i++)
{
GameObject childPage = CreateUIObject("Page_" + i, childContent);

GameObject childText = CreateUIObject("Text", childPage);

//Setup 1st Child
Image pageImage = childPage.AddComponent<Image>();
pageImage.sprite = AssetDatabase.GetBuiltinExtraResource<Sprite>(kStandardSpritePath);
pageImage.type = Image.Type.Sliced;
pageImage.color = s_DefaultSelectableColor;

RectTransform rectTransformPage = childPage.GetComponent<RectTransform>();
rectTransformPage.anchorMin = new Vector2(0.5f, 0);
rectTransformPage.anchorMax = new Vector2(0.5f, 1f);
rectTransformPage.sizeDelta = new Vector2(80f, 0f);
rectTransformPage.pivot = new Vector2(0.5f, 0.5f);
rectTransformPage.localPosition = new Vector3(80 * i, 0, 0);
childPage.AddComponent<Button>();

var childCG = childPage.AddComponent<CanvasGroup>();
childCG.interactable = false;

//Setup Text on Item
Text text = childText.AddComponent<Text>();
text.text = "Item_" + i;
text.alignment = TextAnchor.MiddleCenter;
text.color = new Color(0.196f, 0.196f, 0.196f);

//Setup Text on Item
RectTransform rectTransformPageText = childText.GetComponent<RectTransform>();
rectTransformPageText.anchorMin = new Vector2(0.5f, 0.5f);
rectTransformPageText.anchorMax = new Vector2(0.5f, 0.5f);
rectTransformPageText.pivot = new Vector2(0.5f, 0.5f);
}

Selection.activeGameObject = uiHorizontalScrollerRoot;
}
#endregion

#region UI Button
[MenuItem("GameObject/UI/Extensions/Controls/UI Button", false)]
static public void AddUIButton(MenuCommand menuCommand)
{
GameObject uiButtonRoot = CreateUIElementRoot("UI Button", menuCommand, s_ThickGUIElementSize);
Expand Down Expand Up @@ -1265,11 +1257,7 @@ private static void CreateToolTipItem(bool select)

private static void CreateToolTipItem(bool select, GameObject parent)
{
#if UNITY_2023_1_OR_NEWER
var btti = Object.FindFirstObjectByType<BoundTooltipItem>();
#else
var btti = Object.FindObjectOfType<BoundTooltipItem>();
#endif
if (btti == null)
{
var boundTooltipItem = CreateUIObject("ToolTipItem", parent.GetComponentInParent<Canvas>().gameObject);
Expand Down
2 changes: 1 addition & 1 deletion Examples~
Submodule Examples~ updated 132 files
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ To get started with the project, here's a little guide:

## [Updates:](https://unity-ui-extensions.github.io/ReleaseNotes/RELEASENOTES)

## Release 2.4.0 - Unity supports Unity UI - 2025/11/20

Stay tuned as we begin work on a Unity 6 update, to verify Unity 6 support and possibly get some new controls in the mix.

## Release 2.3.2 - Rejuvenation - 2023/11/26

2023 is certainly an interesting year to keep you on your toes, and finding time to keep managing all the requests and updates that come in are taking their toll, especially for a FREE project, but nonetheless, I still do it.
Expand Down
34 changes: 17 additions & 17 deletions Runtime/Scripts/Controls/ColorPicker/ColorImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@
namespace UnityEngine.UI.Extensions.ColorPicker
{
[RequireComponent(typeof(Image))]
public class ColorImage : MonoBehaviour
{
public ColorPickerControl picker;
public class ColorImage : MonoBehaviour
{
public ColorPickerControl picker;

private Image image;
private Image image;

private void Awake()
{
image = GetComponent<Image>();
picker.onValueChanged.AddListener(ColorChanged);
}
private void Awake()
{
image = GetComponent<Image>();
picker.onValueChanged.AddListener(ColorChanged);
}

private void OnDestroy()
{
picker.onValueChanged.RemoveListener(ColorChanged);
}
private void OnDestroy()
{
picker.onValueChanged.RemoveListener(ColorChanged);
}

private void ColorChanged(Color newColor)
{
image.color = newColor;
private void ColorChanged(Color newColor)
{
image.color = newColor;
}
}
}
}
15 changes: 1 addition & 14 deletions Runtime/Scripts/Controls/ColorPicker/ColorLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

namespace UnityEngine.UI.Extensions.ColorPicker
{

#if UNITY_2022_1_OR_NEWER
[RequireComponent(typeof(TMPro.TMP_Text))]
#else
[RequireComponent(typeof(Text))]
#endif
public class ColorLabel : MonoBehaviour
{
public ColorPickerControl picker;
Expand All @@ -22,18 +17,10 @@ public class ColorLabel : MonoBehaviour

public int precision = 0;

#if UNITY_2022_1_OR_NEWER
private TMPro.TMP_Text label;
#else
private Text label;
#endif
private void Awake()
{
#if UNITY_2022_1_OR_NEWER
label = GetComponent<TMPro.TMP_Text>();
#else
label = GetComponent<Text>();
#endif
if (!label)
{
Debug.LogError($"{gameObject.name} does not have a Text component assigned for the {nameof(ColorLabel)}");
Expand Down Expand Up @@ -63,7 +50,7 @@ private void ColorChanged(Color color)
UpdateValue();
}

private void HSVChanged(float hue, float sateration, float value)
private void HSVChanged(float hue, float saturation, float value)
{
UpdateValue();
}
Expand Down
6 changes: 3 additions & 3 deletions Runtime/Scripts/Controls/ColorPicker/ColorSampler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ColorSampler : MonoBehaviour, IPointerDownHandler, IPointerUpHandle

protected Texture2D screenCapture;

public ColorChangedEvent oncolorSelected = new ColorChangedEvent();
public ColorChangedEvent onColorSelected = new ColorChangedEvent();

protected Color color;

Expand Down Expand Up @@ -71,8 +71,8 @@ protected virtual void HandleSamplerColoring()

protected virtual void SelectColor()
{
if (oncolorSelected != null)
oncolorSelected.Invoke(color);
if (onColorSelected != null)
onColorSelected.Invoke(color);

enabled = false;
}
Expand Down
Loading
Loading