Beispiel #1
0
        /// <summary>
        /// Opens the context menu at the specified position.
        /// </summary>
        /// <param name="position">Position relative to the <paramref name="parent"/>.</param>
        /// <param name="parent">GUI layout over which to open the context menu. Context menu can be opened outside of the
        ///                      area of the layout, as long as the area belongs to the same window.</param>
        public void Open(Vector2I position, GUILayout parent)
        {
            if (parent == null)
            {
                return;
            }

            IntPtr parentPtr = parent.GetCachedPtr();

            Internal_Open(mCachedPtr, ref position, parentPtr);
        }
Beispiel #2
0
        /// <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);
        }