/// <summary> /// Calculates optimal size of a GUI element. /// </summary> /// <param name="element">GUI element to calculate the optimal size for.</param> /// <returns>Size that allows the GUI element to properly display all of its content.</returns> public static Vector2I CalculateOptimalSize(GUIElement element) { Vector2I output; Internal_CalculateOptimalSize(element.GetCachedPtr(), out output); return(output); }
/// <summary> /// Adds a new element to the layout after all existing elements. /// </summary> /// <param name="element">GUI element to add.</param> public void AddElement(GUIElement element) { if (element != null) { Internal_AddElement(mCachedPtr, element.mCachedPtr); } }
/// <summary> /// Inserts a GUI element before the element at the specified index. /// </summary> /// <param name="index">Index to insert the GUI element at. This must be in range [0, GetNumChildren()).</param> /// <param name="element">GUI element to insert.</param> public void InsertElement(int index, GUIElement element) { if (index < 0 || index > ChildCount) { throw new ArgumentOutOfRangeException("index", index, "Index out of range."); } if (element != null) { Internal_InsertElement(mCachedPtr, index, element.mCachedPtr); } }
/// <summary> /// Calculates the bounds of a GUI element. This is similar to <see cref="GUIElement.Bounds"/> but allows you to /// returns bounds relative to a specific parent GUI panel. /// </summary> /// <param name="element">Elements to calculate the bounds for.</param> /// <param name="relativeTo">GUI layout the bounds will be relative to. If this is null or the provided layout is /// not a parent of the provided GUI element, the returned bounds will be relative to the /// first GUI panel parent instead.</param> /// <returns>Bounds of a GUI element relative to the provided GUI layout.</returns> public static Rect2I CalculateBounds(GUIElement element, GUILayout relativeTo = null) { IntPtr relativeToNative = IntPtr.Zero; if (relativeTo != null) { relativeToNative = relativeTo.GetCachedPtr(); } Rect2I output; Internal_CalculateBounds(element.GetCachedPtr(), relativeToNative, out output); return(output); }