Example #1
0
    void Start()
    {
        GUIUtility.Init();
        RoutingModal.Init();

        foreach (var module in m_modules)
        {
            module.Init();
        }

        m_macroModule.Init();
    }
Example #2
0
    void Update()
    {
        if (GUIUtility.ControlModal != null)
        {
            RoutingModal.Update();
            RoutingModal.UIUpdate();
        }

        foreach (var module in m_modules)
        {
            module.ManagerUpdate();

            if (GUIUtility.ControlModal == null)
            {
                module.UIUpdate();
            }
        }

        m_macroModule.UIUpdate();

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            m_opacity = 0f;
        }


        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            m_opacity = 0.4f;
        }


        if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            m_opacity = 0.8f;
        }


        if (Input.GetKeyDown(KeyCode.Tab))
        {
            m_collapseAll = !m_collapseAll;
            foreach (var module in m_modules)
            {
                module.m_hidden = m_collapseAll;
            }
        }
    }
Example #3
0
    private void OnGUI()
    {
        GUIUtility.Opacity = m_opacity;

        GUIUtility.BaseHeight  = ItemHeight;
        GUIUtility.ItemPadding = ItemPadding;

        // Text color
        GUI.contentColor    = Color.black;
        GUI.backgroundColor = Color.clear;

        if (!m_displayGUI)
        {
            return;
        }

        GUI.skin = m_guiSkin;
        Rect activeRect = new Rect(0, 0, MODULEWIDTH, Screen.height - 2 * PADDING);

        foreach (var module in m_modules)
        {
            if (module.gameObject.activeInHierarchy)
            {
                if (activeRect.y + module.GetHeight() > Screen.height)
                {
                    activeRect.x += MODULEWIDTH;
                    activeRect.y  = PADDING;
                }

                module.DrawGUI(activeRect);
                activeRect.y += module.GetHeight();
            }
        }

        m_macroModule.DrawGUI(new Rect(
                                  Screen.width - MODULEWIDTH,
                                  0,
                                  MODULEWIDTH, Screen.height));

        GUI.color = Color.white * 0.8f;

        if (GUIUtility.ControlModal != null)
        {
            RoutingModal.DrawGUI();
        }
    }
Example #4
0
    public override void UIUpdate()
    {
        ///Handle inputs
        Vector2 mouse = Input.mousePosition;

        mouse.y = Screen.height - mouse.y;

        if (currentRect.Contains(mouse))
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (routingType != RoutingType.None)
                {
                    if (mouse.x < RangeGrabPosition(uiMin) + 10)
                    {
                        isSlidingUIMin = true;
                    }
                    else if (mouse.x > RangeGrabPosition(uiMax) - 10)
                    {
                        isSlidingUIMax = true;
                    }
                    else
                    {
                        isSliding = true;
                    }
                }
                else
                {
                    isSliding = true;
                }

                GUIUtility.ActiveControl = this;
            }
            if (Input.GetMouseButtonDown(1))
            {
                RoutingModal.SetTarget(this);
            }
        }


        if (isSliding)
        {
            float percent = (mouse.x - currentRect.min.x) / (currentRect.max.x - currentRect.min.x);
            value = min + (max - min) * Mathf.Clamp01(percent);

            if (Input.GetMouseButtonUp(0))
            {
                isSliding = false;
                GUIUtility.ActiveControl = null;
            }
        }
        else if (routingType != RoutingType.None)
        {
            if (isSlidingUIMin)
            {
                float percent = (mouse.x - currentRect.min.x) / (currentRect.max.x - currentRect.min.x);
                uiMin = Mathf.Clamp01(percent);

                if (Input.GetMouseButtonUp(0))
                {
                    isSlidingUIMin           = false;
                    GUIUtility.ActiveControl = null;
                }
            }
            else if (isSlidingUIMax)
            {
                float percent = (mouse.x - currentRect.min.x) / (currentRect.max.x - currentRect.min.x);
                uiMax = Mathf.Clamp01(percent);

                if (Input.GetMouseButtonUp(0))
                {
                    isSlidingUIMax           = false;
                    GUIUtility.ActiveControl = null;
                }
            }
        }
    }