示例#1
0
/******************************************************************************
*                    Implementation Details
******************************************************************************/


            /// <summary>
            /// Perform any needful setup here, mainly locating textures if necessary and creating
            /// the UIButton to backstop any clicks
            /// </summary>
            protected void Awake()
            {
                #region static style

                if (buttonStyle == null)
                {
                    buttonStyle = new GUIStyle(GUIStyle.none);

                    if (hoverBackground != null)
                    {
                        buttonStyle.hover.background = hoverBackground;
                    }
                }

                #endregion

                Log.Debug("DraggableWindow.Awake");
                backstop = GuiUtil.CreateBlocker(windowRect, float.NaN /*GuiUtil.GetGuiCamera().nearClipPlane + 1f*/, "DraggableWindow.Backstop");

                Draggable     = true;
                Visible       = true;
                ClampToScreen = true;
                Title         = "Draggable Window";


                windowRect = Setup();
                lastRect   = new Rect(windowRect);


                backstop.Move(windowRect);
                backstop.transform.parent = transform; // links blocker visibility with window visibility

                // check for programmer error
                if (windowRect.width < 1f || windowRect.height < 1f)
                {
                    Log.Warning("DraggableWindow.Base: Derived class did not set up initial window Rect");
                }

                GameEvents.onHideUI.Add(OnHideUI);
                GameEvents.onShowUI.Add(OnShowUI);

                Log.Debug("DraggableWindow {0} Awake", Title);
#if DEBUG
                // if debugging, register for our own events so we can see when they're being fired
                //OnVisibilityChange += OnVisibilityChangedEvent;
                //OnClosed += OnCloseEvent;
                //OnDraggabilityChange += OnDraggabilityChangedEvent;
#endif
            }