UnityEditor.LayerVisibilityWindow.Init C# (CSharp) Method

Init() private method

private Init ( Rect buttonRect ) : void
buttonRect UnityEngine.Rect
return void
        private void Init(Rect buttonRect)
        {
            buttonRect = GUIUtility.GUIToScreenRect(buttonRect);
            this.CalcValidLayers();
            int num = ((this.s_LayerNames.Count + 2) + 1) + 1;
            float a = (num * 16f) + 6f;
            int sortingLayerCount = InternalEditorUtility.GetSortingLayerCount();
            if (sortingLayerCount > 1)
            {
                a += 22f;
                a += sortingLayerCount * 16f;
            }
            this.m_ContentHeight = a;
            a += 2f;
            a = Mathf.Min(a, 600f);
            Vector2 windowSize = new Vector2(180f, a);
            base.ShowAsDropDown(buttonRect, windowSize);
        }

Usage Example

示例#1
0
        internal static bool ShowAtPosition(Rect buttonRect)
        {
            // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (!justClosed)
            {
                Event.current.Use();
                if (s_LayerVisibilityWindow == null)
                {
                    s_LayerVisibilityWindow = CreateInstance <LayerVisibilityWindow>();
                }
                s_LayerVisibilityWindow.Init(buttonRect);
                return(true);
            }
            return(false);
        }