Exemplo n.º 1
0
        private void Awake()
        {
            WidgetInputHandler.RegisterInput(this.m_KeyCode, this);
            m_RectTransform = GetComponent <RectTransform> ();
            m_CanvasGroup   = GetComponent <CanvasGroup> ();
            if (!IsVisible)
            {
                m_RectTransform.localScale = Vector3.zero;
            }
            if (this.m_AlphaTweenRunner == null)
            {
                this.m_AlphaTweenRunner = new TweenRunner <FloatTween> ();
            }
            this.m_AlphaTweenRunner.Init(this);

            if (this.m_ScaleTweenRunner == null)
            {
                this.m_ScaleTweenRunner = new TweenRunner <Vector3Tween> ();
            }
            this.m_ScaleTweenRunner.Init(this);

            onShow.AddListener(delegate {
                Execute("OnShow", new CallbackEventData());
            });
            onClose.AddListener(delegate {
                Execute("OnClose", new CallbackEventData());
            });
            m_IsShowing = IsVisible;
            OnAwake();
        }
Exemplo n.º 2
0
        public static void RegisterInput(KeyCode key, UIWidget widget)
        {
            if (m_WidgetKeyBindings == null)
            {
                WidgetInputHandler handler = GameObject.FindObjectOfType <WidgetInputHandler>();
                if (handler == null)
                {
                    GameObject handlerObject = new GameObject("WidgetInputHandler");
                    handlerObject.AddComponent <WidgetInputHandler>();
                    handlerObject.AddComponent <SingleInstance>();
                }
                m_WidgetKeyBindings = new Dictionary <KeyCode, List <UIWidget> >();
            }
            if (key == KeyCode.None)
            {
                return;
            }

            List <UIWidget> widgets;

            if (!m_WidgetKeyBindings.TryGetValue(key, out widgets))
            {
                m_WidgetKeyBindings.Add(key, new List <UIWidget>()
                {
                    widget
                });
            }
            else
            {
                widgets.RemoveAll(x => x == null);
                widgets.Add(widget);
                m_WidgetKeyBindings[key] = widgets;
            }
        }
Exemplo n.º 3
0
        private void Awake()
        {
            //Register the KeyCode to show or close the widget.
            WidgetInputHandler.RegisterInput(this.m_KeyCode, this);
            m_RectTransform         = GetComponent <RectTransform> ();
            m_CanvasGroup           = GetComponent <CanvasGroup> ();
            this.m_Scrollbars       = GetComponentsInChildren <Scrollbar>();
            this.m_CameraTransform  = Camera.main.transform;
            this.m_CameraController = this.m_CameraTransform.GetComponent("ThirdPersonCamera") as MonoBehaviour;

            if (!IsVisible)
            {
                //Set local scale to zero, when widget is not visible. Used to correctly animate the widget.
                m_RectTransform.localScale = Vector3.zero;
            }
            if (this.m_AlphaTweenRunner == null)
            {
                this.m_AlphaTweenRunner = new TweenRunner <FloatTween> ();
            }
            this.m_AlphaTweenRunner.Init(this);

            if (this.m_ScaleTweenRunner == null)
            {
                this.m_ScaleTweenRunner = new TweenRunner <Vector3Tween> ();
            }
            this.m_ScaleTweenRunner.Init(this);
            m_IsShowing = IsVisible;

            OnAwake();
        }
Exemplo n.º 4
0
 protected virtual void OnDestroy()
 {
     WidgetInputHandler.UnregisterInput(m_KeyCode, this);
 }
Exemplo n.º 5
0
 protected virtual void OnDestroy()
 {
     //Unregister input key
     WidgetInputHandler.UnregisterInput(this.m_KeyCode, this);
 }