Merge pull request #458 from Unity-UI-Extensions/feature/2023testing

Feature/2023testing
pull/459/head
Simon (Darkside) Jackson 2023-11-23 22:28:02 +00:00 committed by GitHub
commit 0b8f1a0555
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 9 deletions

View File

@ -52,16 +52,28 @@ jobs:
unityVersion: 2021.3 unityVersion: 2021.3
build-target: WSAPlayer build-target: WSAPlayer
- os: windows - os: windows
unityVersion: 2022.2 unityVersion: 2022.3
build-target: Android build-target: Android
- os: macOS - os: macOS
unityVersion: 2022.2 unityVersion: 2022.3
build-target: iOS build-target: iOS
- os: windows - os: windows
unityVersion: 2022.2 unityVersion: 2022.3
build-target: StandaloneWindows64 build-target: StandaloneWindows64
- os: windows - os: windows
unityVersion: 2022.2 unityVersion: 2022.3
build-target: WSAPlayer
- os: windows
unityVersion: 2023.1
build-target: Android
- os: macOS
unityVersion: 2023.1
build-target: iOS
- os: windows
unityVersion: 2023.1
build-target: StandaloneWindows64
- os: windows
unityVersion: 2023.1
build-target: WSAPlayer build-target: WSAPlayer
steps: steps:
- name: Script Version - name: Script Version

View File

@ -29,7 +29,11 @@ namespace UnityEngine.UI.Extensions
void ObtainCanvasGroups() void ObtainCanvasGroups()
{ {
#if UNITY_2023_1_OR_NEWER
canvasGroups = GameObject.FindObjectsByType<CanvasGroup>(FindObjectsSortMode.None);
#else
canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>(); canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>();
#endif
} }
void OnGUI() void OnGUI()

View File

@ -159,7 +159,11 @@ namespace UnityEditor.UI
private static void CreateEventSystem(bool select, GameObject parent) 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>(); var esys = Object.FindObjectOfType<EventSystem>();
#endif
if (esys == null) if (esys == null)
{ {
var eventSystem = new GameObject("EventSystem"); var eventSystem = new GameObject("EventSystem");
@ -191,7 +195,11 @@ namespace UnityEditor.UI
return canvas.gameObject; return canvas.gameObject;
// No canvas in selection or its parents? Then use just any canvas.. // 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; canvas = Object.FindObjectOfType(typeof(Canvas)) as Canvas;
#endif
if (canvas != null && canvas.gameObject.activeInHierarchy) if (canvas != null && canvas.gameObject.activeInHierarchy)
return canvas.gameObject; return canvas.gameObject;
@ -1121,7 +1129,7 @@ namespace UnityEditor.UI
mainButtonRT.anchorMin = Vector2.zero; mainButtonRT.anchorMin = Vector2.zero;
mainButtonRT.anchorMax = Vector2.one; mainButtonRT.anchorMax = Vector2.one;
mainButtonRT.sizeDelta = Vector2.zero; mainButtonRT.sizeDelta = Vector2.zero;
Events.UnityEventTools.AddBoolPersistentListener(mainButton.GetComponent<Button>().onClick, new UnityEngine.Events.UnityAction<bool>(dropDownList.ToggleDropdownPanel), true); Events.UnityEventTools.AddPersistentListener(mainButton.GetComponent<Button>().onClick, dropDownList.ToggleDropdownPanel);
var mainButtonText = mainButton.GetComponentInChildren<Text>(); var mainButtonText = mainButton.GetComponentInChildren<Text>();
mainButtonText.alignment = TextAnchor.MiddleLeft; mainButtonText.alignment = TextAnchor.MiddleLeft;
mainButtonText.text = "Select Item..."; mainButtonText.text = "Select Item...";
@ -1149,7 +1157,7 @@ namespace UnityEditor.UI
overlayRT.sizeDelta = new Vector2(0f, 1f); overlayRT.sizeDelta = new Vector2(0f, 1f);
overlayRT.pivot = new Vector2(0f, 1f); overlayRT.pivot = new Vector2(0f, 1f);
overlay.AddComponent<Image>().color = new Color(0.243f, 0.871f, 0f, 0f); overlay.AddComponent<Image>().color = new Color(0.243f, 0.871f, 0f, 0f);
Events.UnityEventTools.AddBoolPersistentListener(overlay.AddComponent<Button>().onClick, new UnityEngine.Events.UnityAction<bool>(dropDownList.ToggleDropdownPanel), true); Events.UnityEventTools.AddPersistentListener(overlay.AddComponent<Button>().onClick, dropDownList.ToggleDropdownPanel);
//Overlay Scroll Panel //Overlay Scroll Panel
var overlayScrollPanelRT = overlayScrollPanel.GetComponent<RectTransform>(); var overlayScrollPanelRT = overlayScrollPanel.GetComponent<RectTransform>();
overlayScrollPanelRT.position += new Vector3(0, -cbbRT.sizeDelta.y, 0); overlayScrollPanelRT.position += new Vector3(0, -cbbRT.sizeDelta.y, 0);
@ -1257,7 +1265,11 @@ namespace UnityEditor.UI
private static void CreateToolTipItem(bool select, GameObject parent) 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>(); var btti = Object.FindObjectOfType<BoundTooltipItem>();
#endif
if (btti == null) if (btti == null)
{ {
var boundTooltipItem = CreateUIObject("ToolTipItem", parent.GetComponentInParent<Canvas>().gameObject); var boundTooltipItem = CreateUIObject("ToolTipItem", parent.GetComponentInParent<Canvas>().gameObject);

View File

@ -166,7 +166,7 @@ namespace UnityEngine.UI.Extensions
/// <param name="index"></param> /// <param name="index"></param>
public void SelectItemIndex(int index) public void SelectItemIndex(int index)
{ {
ToggleDropdownPanel(false); ToggleDropdownPanel();
OnItemClicked(index); OnItemClicked(index);
} }
@ -351,7 +351,7 @@ namespace UnityEngine.UI.Extensions
if (indx != _selectedIndex && OnSelectionChanged != null) OnSelectionChanged.Invoke(indx); if (indx != _selectedIndex && OnSelectionChanged != null) OnSelectionChanged.Invoke(indx);
_selectedIndex = indx; _selectedIndex = indx;
ToggleDropdownPanel(true); ToggleDropdownPanel();
UpdateSelected(); UpdateSelected();
} }
@ -471,7 +471,7 @@ namespace UnityEngine.UI.Extensions
return; return;
} }
ToggleDropdownPanel(false); ToggleDropdownPanel();
} }
/// <summary> /// <summary>

View File

@ -13,7 +13,11 @@ namespace UnityEngine.UI.Extensions
void Awake() void Awake()
{ {
#if UNITY_2023_1_OR_NEWER
foreach (var list in FindObjectsByType<ReorderableList>(FindObjectsSortMode.None))
#else
foreach (var list in FindObjectsOfType<ReorderableList>()) foreach (var list in FindObjectsOfType<ReorderableList>())
#endif
{ {
list.OnElementDropped.AddListener(ElementDropped); list.OnElementDropped.AddListener(ElementDropped);
} }

View File

@ -169,7 +169,11 @@ namespace UnityEngine.UI.Extensions
// If we do not have a group of selectables already set, we'll just loop through every object that's a monobehaviour, and look for selectable interfaces in them // If we do not have a group of selectables already set, we'll just loop through every object that's a monobehaviour, and look for selectable interfaces in them
if (selectableGroup == null) { if (selectableGroup == null) {
#if UNITY_2023_1_OR_NEWER
behavioursToGetSelectionsFrom = GameObject.FindObjectsByType<MonoBehaviour>(FindObjectsSortMode.None);
#else
behavioursToGetSelectionsFrom = GameObject.FindObjectsOfType<MonoBehaviour>(); behavioursToGetSelectionsFrom = GameObject.FindObjectsOfType<MonoBehaviour>();
#endif
} else { } else {
behavioursToGetSelectionsFrom = selectableGroup; behavioursToGetSelectionsFrom = selectableGroup;
} }

View File

@ -46,7 +46,13 @@ namespace UnityEngine.UI.Extensions
get get
{ {
if (instance == null) if (instance == null)
{
#if UNITY_2023_1_OR_NEWER
instance = GameObject.FindFirstObjectByType<BoundTooltipItem>();
#else
instance = GameObject.FindObjectOfType<BoundTooltipItem>(); instance = GameObject.FindObjectOfType<BoundTooltipItem>();
#endif
}
return instance; return instance;
} }
} }

View File

@ -92,7 +92,13 @@ namespace UnityEngine.UI.Extensions
get get
{ {
if (instance == null) if (instance == null)
{
#if UNITY_2023_1_OR_NEWER
instance = FindFirstObjectByType<ToolTip>();
#else
instance = FindObjectOfType<ToolTip>(); instance = FindObjectOfType<ToolTip>();
#endif
}
return instance; return instance;
} }
} }