namespace UIWidgets
{
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// Utilities.
///
[Obsolete("Replaced with Utilities class.")]
public static class Utilites
{
///
/// Get path to gameobject.
///
/// GameObject.
/// Path.
[Obsolete("Replaced with Utilities.GameObjectPath().")]
public static string GameObjectPath(GameObject go)
{
return Utilities.GameObjectPath(go);
}
///
/// Get or add component.
///
/// Component.
/// Object.
/// Component type.
[Obsolete("Replaced with Utilities.GetOrAddComponent().")]
public static T GetOrAddComponent(Component obj)
where T : Component
{
return Utilities.GetOrAddComponent(obj);
}
///
/// Get or add component.
///
/// Component.
/// Object.
/// Component type.
[Obsolete("Replaced with Utilities.GetOrAddComponent().")]
public static T GetOrAddComponent(GameObject obj)
where T : Component
{
return Utilities.GetOrAddComponent(obj);
}
///
/// Get or add component.
///
/// Source component.
/// Target component.
/// Component type.
[Obsolete("Replaced with Utilities.GetOrAddComponent().")]
public static void GetOrAddComponent(Component source, ref T target)
where T : Component
{
Utilities.GetOrAddComponent(source, ref target);
}
///
/// Fix the instantiated object (in some cases object have wrong position, rotation and scale).
///
/// Source.
/// Instance.
[Obsolete("Replaced with Utilities.FixInstantiated().")]
public static void FixInstantiated(Component source, Component instance)
{
Utilities.FixInstantiated(source.gameObject, instance.gameObject);
}
///
/// Fix the instantiated object (in some cases object have wrong position, rotation and scale).
///
/// Source.
/// Instance.
[Obsolete("Replaced with Utilities.FixInstantiated().")]
public static void FixInstantiated(GameObject source, GameObject instance)
{
Utilities.FixInstantiated(source, instance);
}
///
/// Finds the canvas.
///
/// The canvas.
/// Current object.
[Obsolete("Replaced with UtilitiesUI.FindCanvas().")]
public static Transform FindCanvas(Transform currentObject)
{
return UtilitiesUI.FindCanvas(currentObject);
}
///
/// Finds the topmost canvas.
///
/// The canvas.
/// Current object.
[Obsolete("Replaced with UtilitiesUI.FindTopmostCanvas().")]
public static Transform FindTopmostCanvas(Transform currentObject)
{
return UtilitiesUI.FindTopmostCanvas(currentObject);
}
///
/// Calculates the drag position.
///
/// The drag position.
/// Screen position.
/// Canvas.
/// Canvas RectTransform.
[Obsolete("Replaced with UtilitiesUI.CalculateDragPosition().")]
public static Vector3 CalculateDragPosition(Vector3 screenPosition, Canvas canvas, RectTransform canvasRect)
{
return UtilitiesUI.CalculateDragPosition(screenPosition, canvas, canvasRect);
}
///
/// Updates the layout.
///
/// Layout.
[Obsolete("Use LayoutUtilities.UpdateLayout() instead.")]
public static void UpdateLayout(LayoutGroup layout)
{
LayoutUtilities.UpdateLayout(layout);
}
///
/// Get top left corner position of specified RectTransform.
///
/// RectTransform.
/// Top left corner position.
[Obsolete("Replaced with UtilitiesRectTransform.GetTopLeftCorner().")]
public static Vector2 GetTopLeftCorner(RectTransform rect)
{
return UtilitiesRectTransform.GetTopLeftCorner(rect);
}
///
/// Set top left corner position of specified RectTransform.
///
/// RectTransform.
/// Top left corner position.
[Obsolete("Replaced with UtilitiesRectTransform.SetTopLeftCorner().")]
public static void SetTopLeftCorner(RectTransform rect, Vector2 position)
{
UtilitiesRectTransform.SetTopLeftCorner(rect, position);
}
///
/// Determines if slider is horizontal.
///
/// true if slider is horizontal; otherwise, false.
/// Slider.
[Obsolete("Replaced with UtilitiesUI.IsHorizontal().")]
public static bool IsHorizontal(Slider slider)
{
return UtilitiesUI.IsHorizontal(slider);
}
///
/// Determines if scrollbar is horizontal.
///
/// true if scrollbar is horizontal; otherwise, false.
/// Scrollbar.
[Obsolete("Replaced with UtilitiesUI.IsHorizontal().")]
public static bool IsHorizontal(Scrollbar scrollbar)
{
return UtilitiesUI.IsHorizontal(scrollbar);
}
///
/// Is two float values is nearly equal?
///
/// First value.
/// Second value.
/// Epsilon.
/// true if two float values is nearly equal; otherwise false.
[Obsolete("Replaced with Mathf.Approximately(a, b)")]
public static bool NearlyEqual(float a, float b, float epsilon)
{
return Mathf.Approximately(a, b);
}
///
/// Get graphic component from TextAdapter.
///
/// Adapter.
/// Graphic component.
[Obsolete("Replaced with UtilitiesUI.GetGraphic().")]
public static Graphic GetGraphic(TextAdapter adapter)
{
return UtilitiesUI.GetGraphic(adapter);
}
///
/// Default handle for the property changed event.
///
/// Sender.
/// Event arguments.
[Obsolete("Replaced with Utilities.DefaultPropertyHandler().")]
public static void DefaultPropertyHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
// do nothing
}
///
/// Default handle for the changed event.
///
[Obsolete("Replaced with Utilities.DefaultHandler().")]
public static void DefaultHandler()
{
// do nothing
}
///
/// Copy RectTransform values.
///
/// Source.
/// Target.
[Obsolete("Replaced with Utilities.CopyRectTransformValues().")]
public static void CopyRectTransformValues(RectTransform source, RectTransform target)
{
Utilities.CopyRectTransformValues(source, target);
}
#region Obsolete Input
///
/// Is pointer over screen?
///
/// true if pointer over screen; otherwise false.
[Obsolete("Replaced with CompatibilityInput.IsPointerOverScreen.")]
public static bool IsPointerOverScreen()
{
return CompatibilityInput.IsPointerOverScreen;
}
#endregion
#region Obsolete Time
///
/// Function to get time to use with animations.
/// Can be replaced with custom function.
///
[Obsolete("Replaced with UtilitiesTime.GetTime().")]
public static readonly Func GetTime = UtilitiesTime.DefaultGetTime;
///
/// Function to get unscaled time to use by widgets.
/// Can be replaced with custom function.
///
[Obsolete("Replaced with UtilitiesTime.GetTime(true)")]
public static readonly Func GetUnscaledTime = UtilitiesTime.DefaultGetUnscaledTime;
///
/// Function to get delta time to use with animations.
/// Can be replaced with custom function.
///
[Obsolete("Replaced with UtilitiesTime.GetDeltaTime().")]
public static readonly Func GetDeltaTime = UtilitiesTime.DefaultGetDeltaTime;
///
/// Default GetTime function from the default Time class.
///
/// Return unscaled time.
/// Time.
[Obsolete("Replaced with UtilitiesTime.DefaultGetTime().")]
public static float DefaultGetTime(bool unscaledTime)
{
return UtilitiesTime.DefaultGetTime(unscaledTime);
}
///
/// Default GetUnscaledTime function.
///
/// Default Time.unscaledTime.
[Obsolete("Replaced with UtilitiesTime.DefaultGetUnscaledTime().")]
public static float DefaultGetUnscaledTime()
{
return UtilitiesTime.DefaultGetUnscaledTime();
}
///
/// Default GetDeltaTime function from the default Time class.
///
/// Return unscaled delta time.
/// Delta Time.
[Obsolete("Replaced with UtilitiesTime.DefaultGetDeltaTime().")]
public static float DefaultGetDeltaTime(bool unscaledTime)
{
return UtilitiesTime.DefaultGetDeltaTime(unscaledTime);
}
///
/// Suspends the coroutine execution for the given amount of seconds using unscaled time.
///
/// Delay in seconds.
/// Yield instruction to wait.
[Obsolete("Replaced with UtilitiesTime.Wait(seconds, true).")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "HAA0401:Possible allocation of reference type enumerator", Justification = "Enumerator is reusable.")]
public static IEnumerator WaitForSecondsUnscaled(float seconds)
{
return UtilitiesTime.Wait(seconds, true);
}
///
/// Check how much time takes to run specified action.
///
/// Action.
/// Text to add to log.
[Obsolete("Replaced with UtilitiesTime.CheckRunTime().")]
public static void CheckRunTime(Action action, string log = "")
{
UtilitiesTime.CheckRunTime(action, log);
}
#endregion
#region Obsolete color
///
/// Convert specified color to RGB hex.
///
/// RGB hex.
/// Color.
[Obsolete("Replaced with UtilitiesColor.RGB2Hex().")]
public static string RGB2Hex(Color32 c)
{
return UtilitiesColor.RGB2Hex(c);
}
///
/// Convert specified color to RGBA hex.
///
/// RGBA hex.
/// Color.
[Obsolete("Replaced with UtilitiesColor.RGBA2Hex().")]
public static string RGBA2Hex(Color32 c)
{
return UtilitiesColor.RGBA2Hex(c);
}
///
/// Converts the string representation of a number to its Byte equivalent. A return value indicates whether the conversion succeeded or failed.
///
/// true if hex was converted successfully; otherwise, false.
/// A string containing a number to convert.
/// When this method returns, contains the 8-bit unsigned integer value equivalent to the number contained in s if the conversion succeeded, or zero if the conversion failed. The conversion fails if the s parameter is null or String.Empty, is not of the correct format, or represents a number less than MinValue or greater than MaxValue. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
[Obsolete("Replaced with UtilitiesColor.TryParseHex().")]
public static bool TryParseHex(string hex, out byte result)
{
return UtilitiesColor.TryParseHex(hex, out result);
}
///
/// Converts the string representation of a color to its Color equivalent. A return value indicates whether the conversion succeeded or failed.
///
/// true if hex was converted successfully; otherwise, false.
/// A string containing a color to convert.
/// When this method returns, contains the color value equivalent to the color contained in hex if the conversion succeeded, or Color.black if the conversion failed. The conversion fails if the hex parameter is null or String.Empty, is not of the correct format. This parameter is passed uninitialized; any value originally supplied in result will be overwritten.
[Obsolete("Use ColorUtility.TryParseHtmlString().")]
public static bool TryHexToRGBA(string hex, out Color32 result)
{
return UtilitiesColor.TryHexToRGBA(hex, out result);
}
#endregion
#region Obsolete Editor
#if UNITY_EDITOR
///
/// Get friendly name of the specified type.
///
/// Type.
/// Friendly name.
[Obsolete("Replaced with UtilitiesEditor.GetFriendlyTypeName().")]
public static string GetFriendlyTypeName(Type type)
{
return UtilitiesEditor.GetFriendlyTypeName(type);
}
///
/// Get type by full name.
///
/// Type name.
/// Type.
[Obsolete("Replaced with UtilitiesEditor.GetType().")]
public static Type GetType(string typename)
{
return UtilitiesEditor.GetType(typename);
}
///
/// Create gameobject.
///
/// Prefab.
/// Support editor undo.
/// Created gameobject.
[Obsolete("Replaced with UtilitiesEditor.CreateGameObject().")]
public static GameObject CreateGameObject(GameObject prefab, bool undo = true)
{
return UtilitiesEditor.CreateGameObject(prefab, undo);
}
///
/// Returns the asset object of type T with the specified GUID.
///
/// GUID.
/// Asset with the specified GUID.
/// Asset type.
[Obsolete("Replaced with UtilitiesEditor.LoadAssetWithGUID().")]
public static T LoadAssetWithGUID(string guid)
where T : UnityEngine.Object
{
return UtilitiesEditor.LoadAssetWithGUID(guid);
}
///
/// Find assets by specified search.
///
/// Assets type.
/// Search string.
/// Assets list.
[Obsolete("Replaced with UtilitiesEditor.GetAssets().")]
public static List GetAssets(string search)
where T : UnityEngine.Object
{
return UtilitiesEditor.GetAssets(search);
}
///
/// Get asset by label.
///
/// Asset type.
/// Asset label.
/// Asset.
[Obsolete("Replaced with UtilitiesEditor.GetAsset().")]
public static T GetAsset(string label)
where T : UnityEngine.Object
{
return UtilitiesEditor.GetAsset(label);
}
///
/// Get asset path by label.
///
/// Asset label.
/// Asset path.
[Obsolete("Replaced with UtilitiesEditor.GetAssetPath().")]
public static string GetAssetPath(string label)
{
return UtilitiesEditor.GetAssetPath(label);
}
///
/// Get prefab by label.
///
/// Prefab label.
/// Prefab.
[Obsolete("Replaced with UtilitiesEditor.GetPrefab().")]
public static GameObject GetPrefab(string label)
{
return UtilitiesEditor.GetPrefab(label);
}
///
/// Get generated prefab by label.
///
/// Prefab label.
/// Prefab.
[Obsolete("Replaced with UtilitiesEditor.GetGeneratedPrefab().")]
public static GameObject GetGeneratedPrefab(string label)
{
return UtilitiesEditor.GetGeneratedPrefab(label);
}
///
/// Set prefabs label.
///
/// Prefab.
[Obsolete("Replaced with UtilitiesEditor.SetPrefabLabel().")]
public static void SetPrefabLabel(UnityEngine.Object prefab)
{
UtilitiesEditor.SetPrefabLabel(prefab);
}
///
/// Create widget template from asset specified by label.
///
/// Template label.
/// Widget template.
[Obsolete("Replaced with UtilitiesEditor.CreateWidgetTemplateFromAsset().")]
public static GameObject CreateWidgetTemplateFromAsset(string templateLabel)
{
return UtilitiesEditor.CreateWidgetTemplateFromAsset(templateLabel);
}
///
/// Creates the widget from prefab by name.
///
/// Widget name.
/// Apply style to created widget.
/// Converter for the created widget (mostly used to replace Unity Text with TMPro Text).
/// Created GameObject.
[Obsolete("Replaced with UtilitiesEditor.CreateWidgetFromAsset().")]
public static GameObject CreateWidgetFromAsset(string widget, bool applyStyle = true, Action converter = null)
{
return UtilitiesEditor.CreateWidgetFromAsset(widget, applyStyle, converter);
}
///
/// Creates the widget from prefab by name.
///
/// Widget name.
/// Apply style to created widget.
/// Converter for the created widget (mostly used to replace Unity Text with TMPro Text).
/// Created GameObject.
[Obsolete("Replaced with UtilitiesEditor.CreateWidgetFromPrefab().")]
public static GameObject CreateWidgetFromPrefab(GameObject prefab, bool applyStyle = true, Action converter = null)
{
return UtilitiesEditor.CreateWidgetFromPrefab(prefab, applyStyle, converter);
}
///
/// Replace Close button callback on Cancel instead of the Hide for the Dialog components in the specified GameObject.
///
/// GameObject.
[Obsolete("Replaced with UtilitiesEditor.FixDialogCloseButton().")]
public static void FixDialogCloseButton(GameObject go)
{
UtilitiesEditor.FixDialogCloseButton(go);
}
///
/// Gets the canvas transform.
///
/// The canvas transform.
[Obsolete("Replaced with UtilitiesEditor.GetCanvasTransform().")]
public static Transform GetCanvasTransform()
{
return UtilitiesEditor.GetCanvasTransform();
}
///
/// Serialize object with BinaryFormatter to base64 string.
///
/// Object to serialize.
/// Serialized string.
[Obsolete("Replaced with UtilitiesEditor.Serialize().")]
public static string Serialize(object obj)
{
return UtilitiesEditor.Serialize(obj);
}
///
/// De-serialize object with BinaryFormatter from base64 string.
///
/// Object type.
/// Serialized string.
/// De-serialized object.
[Obsolete("Replaced with UtilitiesEditor.Deserialize().")]
public static T Deserialize(string encoded)
{
return UtilitiesEditor.Deserialize(encoded);
}
#endif
#endregion
#region Obsolete Collections
///
/// Create list.
///
/// Type of the item.
/// Items count.
/// Function to create item.
/// List.
[Obsolete("Replaced with UtilitiesCollections.CreateList().")]
public static ObservableList CreateList(int count, Func create)
{
return UtilitiesCollections.CreateList(count, create);
}
///
/// Retrieves all the elements that match the conditions defined by the specified predicate.
///
/// Item type.
/// Items.
/// The Predicate{T} delegate that defines the conditions of the elements to search for.
/// A List{T} containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty List{T}.
[Obsolete("Replaced with UtilitiesCollections.FindAll().")]
public static ObservableList FindAll(List source, Func match)
{
return UtilitiesCollections.FindAll(source, match);
}
///
/// Get sum of the list.
///
/// List to sum.
/// Sum.
[Obsolete("Replaced with UtilitiesCollections.Sum().")]
public static float Sum(List source)
{
return UtilitiesCollections.Sum(source);
}
///
/// Check is input array not empty and all values are null.
///
/// Type of value.
/// Input array.
/// true if input array not empty and all values are null; otherwise false.
[Obsolete("Replaced with UtilitiesCollections.AllNull().")]
public static bool AllNull(T[] arr)
where T : class
{
return UtilitiesCollections.AllNull(arr);
}
///
/// Prints the specified list to log.
///
/// Type.
/// List.
[Obsolete("Replaced with UtilitiesCollections.Log().")]
public static void Log(List list)
{
UtilitiesCollections.Log(list);
}
#endregion
}
}