예제 #1
0
파일: ContextMenu.cs 프로젝트: nanze81/bsf
        /// <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);
        }
예제 #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);
        }