Exemple #1
0
        public UISlider CreateSlider(float posX, float posY, Transform parent, string name = "")
        {
            //Search for slider to spawn
            GameObject objectToCopy;

            if (sliderOriginal == null)
            {
                sliderOriginal = SearchGO("ListLevel", "List");
                if (sliderOriginal == null)
                {
                    return(null);
                }
            }
            objectToCopy = sliderOriginal;

            //Create parent GO and set it up
            GameObject uiParent = new GameObject("ModSlider");

            uiParent.transform.SetParent(parent, false);
            uiParent.transform.localScale    = Vector3.one;
            uiParent.transform.localPosition = new Vector3(posX, posY, 0f);

            //Instantiate GO
            GameObject elementCreated = Instantiate(objectToCopy, uiParent.transform);

            elementCreated.name = "ModUIElement";
            elementCreated.transform.localPosition = ZFixVector;

            //Set TextFrame
            UITextFrame display = UIFactory.Instance.CreateTextFrame(0f, 0f, elementCreated.transform);

            display.transform.localPosition = new Vector3(-2.35f, 0f, -0.2f);
            display.ScaleBackground(new Vector2(0.3f, 0.8f));

            //Remove slider icon, hider icon/component and arrows. Reposition title name
            Destroy(elementCreated.GetComponent <GuiFloatHiderApplier>());
            Destroy(elementCreated.transform.Find("Sound").gameObject);
            elementCreated.transform.Find("Arrows").localScale  = Vector3.zero;
            elementCreated.transform.Find("Name").localPosition = new Vector3(0f, 0.32f, -0.2f);
            Destroy(elementCreated.transform.Find("OffIcon").gameObject);

            //Assign component
            UISlider output = uiParent.AddComponent <UISlider>();

            output.Initialize();
            output.UIName = name;

            return(output);
        }
Exemple #2
0
        //======================
        //ListExplorer
        //======================
        public UIListExplorer CreateListExplorer(float posX, float posY, Transform parent, string name = "")
        {
            //Create parent GO and set it up
            GameObject uiParent = new GameObject("ModListExplorer");

            uiParent.transform.SetParent(parent, false);
            uiParent.transform.localScale    = Vector3.one;
            uiParent.transform.localPosition = new Vector3(posX, posY, 0f);

            //Create display
            UITextFrame display = CreateTextFrame(0, 0, uiParent.transform);

            display.name = "Display";
            display.transform.localPosition = ZFixVector;

            //Left  arrow
            //--------------
            //Create arrow button, position and name it
            UIButton leftArrow = CreateButton(UIButton.ButtonType.Default, 0, 0, uiParent.transform, "");

            leftArrow.name = "LeftArrow";
            leftArrow.transform.localScale    = new Vector3(0.4f, 0.8f, 1f);
            leftArrow.transform.localPosition = new Vector3(-1.8f, 0f, -0.2f);
            //Replace gfx and position it
            SearchArrows(); //Search for arrows gfx
            Destroy(leftArrow.transform.Find("ModUIElement").Find("Root").Find("Background").gameObject);
            GameObject lArrow = Instantiate(leftArrowOriginal, leftArrow.transform.Find("ModUIElement").Find("Root"));

            lArrow.transform.localScale    = new Vector3(2f, 1f, 1f);
            lArrow.transform.localPosition = new Vector3(-0.5f, 0f, 0f);
            //Remove logic components from the gfx
            Destroy(lArrow.GetComponent <GuiClickable>());
            Destroy(lArrow.GetComponent <GuiClickRect>());
            Destroy(lArrow.GetComponent <GuiChangeEffect_ClickUpdSlider>());

            //Right arrow
            //--------------
            //Create arrow button, position and name it
            UIButton rightArrow = CreateButton(UIButton.ButtonType.Default, 0, 0, uiParent.transform, "");

            rightArrow.name = "RightArrow";
            rightArrow.transform.localScale    = new Vector3(0.4f, 0.8f, 1f);
            rightArrow.transform.localPosition = new Vector3(1.8f, 0f, -0.2f);
            //Replace gfx and position it
            Destroy(rightArrow.transform.Find("ModUIElement").Find("Root").Find("Background").gameObject);
            GameObject rArrow = Instantiate(rightArrowOriginal, rightArrow.transform.Find("ModUIElement").Find("Root"));

            rArrow.transform.localScale       = new Vector3(-2f, 1f, 1f); //The -2 flips the gfx horizontally
            rArrow.transform.localPosition    = new Vector3(0.5f, 0f, 0f);
            rArrow.transform.localEulerAngles = Vector3.zero;
            //Remove logic components from the gfx
            Destroy(rArrow.GetComponent <GuiClickable>());
            Destroy(rArrow.GetComponent <GuiClickRect>());
            Destroy(rArrow.GetComponent <GuiChangeEffect_ClickUpdSlider>());

            //Create title
            UITextFrame title = CreateTextFrame(0f, 0f, uiParent.transform);

            title.name = "UIName";
            title.transform.localPosition = new Vector3(0f, 0.65f, 0.6f);
            title.transform.localScale   *= 0.8f;
            title.ScaleText(1.25f);
            title.ScaleBackground(new Vector2(0.625f, 1f));

            //Assign component
            UIListExplorer output = uiParent.AddComponent <UIListExplorer>();

            output.Initialize();
            output.UIName = name;

            return(output);
        }