Esempio n. 1
0
    static public InstantGuiElement  CreateLabel()
    {
        InstantGuiElement element = InstantGuiElement.Create("Label", typeof(InstantGuiElement), GetSelectedElement());

        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 2
0
    public override void  Align()
    {
        base.Align();

        //re-creating elements if labels exist
        if (autoFill && labels.Length != elements.Length)
        {
            for (int i = elements.Length - 1; i >= 0; i--)
            {
                DestroyImmediate(elements[i].gameObject);
            }
            elements = new InstantGuiElement[labels.Length];
            for (int i = 0; i < elements.Length; i++)
            {
                elements[i] = InstantGuiElement.Create("List_Element",
                                                       typeof(InstantGuiElement), (InstantGuiElement)this);                                                 //should be toggle
            }
        }

        //calculating number of lines
        int numElements;

        if (elementSize <= 0)
        {
            numElements = elements.Length;
        }
        else
        {
            numElements = Mathf.CeilToInt((absolute.bottom - absolute.top) * 1.0f / elementSize);
            numElements = Mathf.Max(numElements, 0);
        }

        //enabling or disabling invisible elements
        int lastShown = Mathf.Min(elements.Length - 1, firstShown + numElements - 1);

        for (int i = 0; i < firstShown; i++)   //disabling
        {
            elements[i].gameObject.SetActive(false);
        }

        for (int i = firstShown; i <= lastShown; i++)   //enabling
        {
            elements[i].gameObject.SetActive(true);
            if (autoFill)
            {
                elements[i].text = labels[i];
            }

            //setting position


            elements[i].Align();
        }

        for (int i = lastShown; i < elements.Length; i++)   //disabling
        {
            elements[i].gameObject.SetActive(false);
        }
    }
Esempio n. 3
0
    static public InstantGuiInputText CreateInputText()
    {
        InstantGuiInputText element = (InstantGuiInputText)InstantGuiElement.Create("InputText", typeof(InstantGuiInputText), GetSelectedElement());

        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 4
0
    static public InstantGuiToggle CreateToggle()
    {
        InstantGuiToggle element = (InstantGuiToggle)InstantGuiElement.Create("Toggle", typeof(InstantGuiToggle), GetSelectedElement());

        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 5
0
    static public InstantGuiButton CreateButton()
    {
        InstantGuiButton element = (InstantGuiButton)InstantGuiElement.Create("Button", typeof(InstantGuiButton), GetSelectedElement());

        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 6
0
    static public InstantGuiWindow CreateWindow()
    {
        InstantGuiWindow element = (InstantGuiWindow)InstantGuiElement.Create("Window", typeof(InstantGuiWindow), GetSelectedElement());

        element.closeButton = InstantGuiElement.Create("Window_CloseButton", typeof(InstantGuiElement), element);
        element.closeButton.useStylePlacement = true;
        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 7
0
    public InstantGuiElement CreateField()
    {
        InstantGuiElement field = InstantGuiElement.Create("", typeof(InstantGuiElement), this);

        field.relative.Set(0, 100, 0, 100);
        field.offset.Set(0, 0, 0, 0);
        field.lockPosition = true;
        field.dynamic      = false;
        return(field);
    }
Esempio n. 8
0
    static public InstantGuiSlider CreateHorizontalSlider()
    {
        InstantGuiSlider element = (InstantGuiSlider)InstantGuiElement.Create("HorizontalSlider", typeof(InstantGuiSlider), GetSelectedElement());

        element.diamond         = InstantGuiElement.Create("HorizontalSlider_Diamond", typeof(InstantGuiElement), element);
        element.incrementButton = InstantGuiElement.Create("HorizontalSlider_IncrementButton", typeof(InstantGuiElement), element);
        element.decrementButton = InstantGuiElement.Create("HorizontalSlider_DecrementButton", typeof(InstantGuiElement), element);
        element.horizontal      = true;
        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 9
0
    static public InstantGuiTextArea CreateTextArea()
    {
        InstantGuiTextArea element = (InstantGuiTextArea)InstantGuiElement.Create("TextArea", typeof(InstantGuiTextArea), GetSelectedElement());

        element.slider = CreateVerticalSlider();
        element.slider.useStylePlacement = true;
        element.slider.transform.parent  = element.transform;

        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 10
0
    static public InstantGuiSlider CreateVerticalSlider()
    {
        InstantGuiSlider element = (InstantGuiSlider)InstantGuiElement.Create("VerticalSlider", typeof(InstantGuiSlider), GetSelectedElement());

        element.diamond          = InstantGuiElement.Create("VerticalSlider_Diamond", typeof(InstantGuiElement), element);
        element.incrementButton  = InstantGuiElement.Create("VerticalSlider_IncrementButton", typeof(InstantGuiElement), element);
        element.decrementButton  = InstantGuiElement.Create("VerticalSlider_DecrementButton", typeof(InstantGuiElement), element);
        element.diamond.editable = false;
        //element.diamond.useStylePlacement = true;
        element.incrementButton.useStylePlacement = true;
        element.decrementButton.useStylePlacement = true;
        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 11
0
    static public InstantGuiTabs CreateTabGroup()
    {
        InstantGuiTabs element = (InstantGuiTabs)InstantGuiElement.Create("TabGroup", typeof(InstantGuiTabs), GetSelectedElement());

        element.tabs   = new InstantGuiElement[1]; element.tabs[0] = InstantGuiElement.Create("Tab", typeof(InstantGuiElement), element);
        element.fields = new InstantGuiElement[1];  element.fields[0] = InstantGuiElement.Create("Tab_Field", "", typeof(InstantGuiElement), element);

        element.fields[0].relative.Set(0, 100, 0, 100);
        element.fields[0].offset.Set(0, 0, 0, 0);
        element.fields[0].lockPosition = true;
        element.fields[0].dynamic      = false;

        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 12
0
    static public InstantGuiPopup CreatePopup()
    {
        InstantGuiPopup element = (InstantGuiPopup)InstantGuiElement.Create("Popup", typeof(InstantGuiPopup), GetSelectedElement());

        element.list = CreateList();
        //element.list.useStylePlacement = true;
        element.list.transform.parent = element.transform;
        element.list.relative.Set(0, 100, 100, 100);
        element.list.offset.Set(0, 0, 0, 200);

        //element.diamond = InstantGuiElement.Create("Slider_Diamond", InstantGuiElement, element);
        //element.incrementButton = InstantGuiElement.Create("Slider_IncrementButton", InstantGuiElement, element);
        //element.decrementButton = InstantGuiElement.Create("Slider_DecrementButton", InstantGuiElement, element);
        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 13
0
    static public InstantGuiList CreateList()
    {
        InstantGuiList element = (InstantGuiList)InstantGuiElement.Create("List", typeof(InstantGuiList), GetSelectedElement());

        element.slider = CreateVerticalSlider();
        element.slider.useStylePlacement = true;
        element.slider.transform.parent  = element.transform;

        element.elementStyleName = "List_Element";

        //element.diamond = InstantGuiElement.Create("Slider_Diamond", InstantGuiElement, element);
        //element.incrementButton = InstantGuiElement.Create("Slider_IncrementButton", InstantGuiElement, element);
        //element.decrementButton = InstantGuiElement.Create("Slider_DecrementButton", InstantGuiElement, element);
        InstantGui.ForceUpdate();
        Selection.activeGameObject = element.gameObject;
        return(element);
    }
Esempio n. 14
0
    public override void  Align()
    {
        base.Align();

        //setting first shown value
        if (slider != null)
        {
            slider.min        = 0;
            slider.max        = Mathf.Max(0, labels.Length - elements.Length);
            slider.shownValue = elements.Length;

            //scrolling slider
            slider.value -= Input.GetAxisRaw("Mouse ScrollWheel") * 10;
            slider.value  = Mathf.Clamp(slider.value, slider.min, slider.max);

            firstShown = (int)slider.value;
        }

        //calculating number of lines
        int linesNum;

        if (lineHeight <= 0)
        {
            linesNum = elements.Length;
        }
        else
        {
            linesNum = Mathf.FloorToInt((absolute.bottom - absolute.top) * 1.0f / lineHeight);
            linesNum = Mathf.Max(linesNum, 0);
        }

        //re-creating elements if line num changed
        if (elements.Length != linesNum)
        {
            //destroying overcount
            for (int i = elements.Length - 1; i >= linesNum; i--)
            {
                if (elements[i] != null)
                {
                    StartCoroutine(elements[i].YieldAndDestroy());                                    //DestroyImmediate(elements[i].gameObject);
                }
            }
            //resizing array
            InstantGuiElement[] newElements = new InstantGuiElement[linesNum];
            int count = Mathf.Min(linesNum, elements.Length);
            for (int i = 0; i < count; i++)
            {
                newElements[i] = elements[i];
            }
            elements = newElements;

            //creating undefened elements
            for (int i = 0; i < elements.Length; i++)
            {
                if (!elements[i])
                {
                    elements[i] = InstantGuiElement.Create("ListElement", typeof(InstantGuiElement), this);
                }
            }
        }

        //setting text and position
        for (int i = 0; i < elements.Length; i++)
        {
            if (i + firstShown < labels.Length && firstShown >= 0)
            {
                elements[i].text = labels[i + firstShown];
            }
            else
            {
                elements[i].text = "";
            }

            elements[i].offset   = new InstantGuiElementPos(0, -sliderMargin, 0, 0);
            elements[i].relative = new InstantGuiElementPos(0, 100, (int)((100.0f / linesNum) * i), (int)((100.0f / linesNum) * (i + 1)));
            elements[i].editable = false;
            //elements[i].style = elementStyle;
        }
    }