コード例 #1
0
    public override void OnDeselect(BaseEventData eventData)
    {
        Transform suggestions      = transform.Find("Suggestions");
        Transform closeSuggestions = transform.Find("CloseSuggestions");

        /*if (suggestions.childCount > 0) {
         *              foreach (Transform t in suggestions.GetComponentsInChildren<Transform>()) {
         *                      if (!t.name.Equals (suggestions.name))
         *                              continue;//t.gameObject.SetActive (false);
         *              }
         *      }*/
        //image.sprite = spriteState.disabledSprite;

        NextFrame.Function(delegate {
            if (EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.transform.IsChildOf(gameObject.transform))
            {
                m_CaretVisible = false;
                suggestions.gameObject.SetActive(false);
                closeSuggestions?.gameObject.SetActive(false);
                GetComponentInParent <AutofillTMP>().ResetSelected();
                DeactivateInputField();
            }
            else
            {
                EventSystem.current.SetSelectedGameObject(gameObject);
            }
        });

        base.OnDeselect(eventData);
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        var input = gameObject.GetComponent <TMP_InputField>();

        NextFrame.Function(
            delegate { input.onValueChanged.Invoke(input.text); });
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        ds               = GameObject.Find("GaudyBG").GetComponent <DataScript> ();
        BPValue1         = transform.Find("TMPInputField/BPValue1").GetComponent <TMP_InputField> ();
        BPValue2         = transform.Find("TMPInputField/BPValue2").GetComponent <TMP_InputField> ();
        pulseValue       = transform.Find("TMPInputField/PulseValue").GetComponent <TMP_InputField> ();
        temperatureValue = transform.Find("TMPInputField/TempValue").GetComponent <TMP_InputField> ();
        respirationValue = transform.Find("TMPInputField/RespValue").GetComponent <TMP_InputField> ();

        //Finds the tab this script belongs to
        Transform tempObj = this.transform;

        while (parentTab == null && tempObj != null)
        {
            if (tempObj.name.EndsWith("Tab"))
            {
                parentTab = tempObj;
                break;
            }
            else
            {
                if (tempObj.parent != null)
                {
                    tempObj = tempObj.parent;
                }
                else
                {
                    Debug.Log("Cannot access parent tab!");
                    return;
                }
            }
        }

        NextFrame.Function(CreateValues);
    }
コード例 #4
0
 void Start()
 {
     if (GetComponent <TMP_InputField>().characterValidation.Equals(TMP_InputField.CharacterValidation.None))
     {
         GetComponent <TMP_InputField>().onValidateInput += delegate(string input, int charIndex, char addedChar) { return(MyValidate(input, charIndex, addedChar)); };
     }
     NextFrame.Function(ResizeField);
 }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        firstName = GlobalData.firstName;
        lastName  = GlobalData.lastName;
        NextFrame.Function(AssignName);

        /*charEditor = GameObject.Find ("Canvas").transform.Find ("CharacterEditorPanel").gameObject;
         * if (charEditor == null) {
         *      print ("HI");
         *      charEditor = GameObject.Find ("Canvas").transform.GetChild (0).gameObject;
         * }*/
    }
コード例 #6
0
    void Start()
    {
        gData          = GameObject.Find("Canvas").GetComponent <GlobalDataScript> ();
        mySkin         = Resources.Load(gData.resourcesPath + "/CEStyle") as GUISkin;
        mainInputField = GetComponent <InputField> ();
        mainInputField.onValidateInput += delegate(string input, int charIndex, char addedChar) { return(MyValidate(input, charIndex, addedChar)); };

        if (!mainInputField.text.Equals(""))
        {
            NextFrame.Function(RelocateText);
        }
    }
コード例 #7
0
        protected virtual void InitializeSwipeParamaters()
        {
            SwipeParamater = new SwipeParameter();
            var corners = new Vector3[4];

            swipeBounds.GetWorldCorners(corners);
            SwipeParamater.StartPositionRange = new Rect(corners[0], corners[2] - corners[0]);
            NextFrame.Function(UpdateSwipeParameters);
            SwipeParamater.AngleRanges.Add(new AngleRange(-30, 30));
            SwipeParamater.AngleRanges.Add(new AngleRange(150, 210));
            SwipeParamater.OnSwipeStart  += SwipeStart;
            SwipeParamater.OnSwipeUpdate += SwipeUpdate;
            SwipeParamater.OnSwipeEnd    += SwipeEnd;
        }
コード例 #8
0
 /**
  * Used temporarily as a delay for the save confirmation message
  */
 private void Fade()
 {
     if (notification.GetComponent <CanvasGroup>().alpha > 0)
     {
         if (!fade)
         {
             return;
         }
         //t.color = new Color (t.color.r, t.color.g, t.color.b, t.color.a - Time.deltaTime / 6f);
         notification.GetComponent <CanvasGroup>().alpha = (notification.GetComponent <CanvasGroup>().alpha - Time.deltaTime / 3f);
         NextFrame.Function(Fade);
         return;
     }
     Destroy(notification);
 }
コード例 #9
0
    /**
     * Loads the data into xmlDoc to use
     */
    public void LoadXML()
    {
        string text = ds.GetData(tm.getCurrentSection(), transform.name.Substring(0, transform.name.Length - 3));

        if (text == null)
        {
            Debug.Log("No Data to load");
            ds.newTabs.Add(this.transform);
            return;
        }
        Debug.Log("Loaded data: " + text);
        xmlDoc = new XmlDocument();
        xmlDoc.LoadXml(text);
        //LoadXMLData();
        NextFrame.Function(LoadXMLData);
    }
コード例 #10
0
    public void UpdateText()
    {
        if (!pastingLock)
        {
            NextFrame.Function(UpdateTextOnNextFrame);
            pastingLock = true;

            inputText.rectTransform.offsetMax = Vector2.zero;
            inputText.rectTransform.offsetMin = Vector2.zero;
            if (!inputCaret)
            {
                inputCaret = (RectTransform)inputText.rectTransform.parent.Find("CustomContentValue Input Caret").transform;
            }
            inputCaret.offsetMax = Vector2.zero;
            inputCaret.offsetMin = Vector2.zero;
        }

        return;
    }
コード例 #11
0
    public void ResizeField()
    {
        if (resizeLock)
        {
            return;
        }
        resizeLock = true;

        var inputField = GetComponent <TMP_InputField>();

        if (inputField)
        {
            var rectTrans = inputField.textComponent.GetComponent <RectTransform>();
            if (rectTrans)
            {
                rectTrans.offsetMax = new Vector2(0, 0);
                rectTrans.offsetMin = new Vector2(0, 0);
            }
        }

        NextFrame.Function(ActivateResizeTMP);
        NextFrame.Function(delegate { NextFrame.Function(ActivateResizeTMP); });
    }
コード例 #12
0
    /**
     * Use this to show a confirmation that the case was saved successfully
     */
    public void ShowMessage(string message, bool error)
    {
        if (transform.Find("ContentPanel") != null && transform.Find("ContentPanel").GetComponent <FilePickerScript>().levelName.Equals("CassReader"))
        {
            return;
        }
        Transform parentTransform = GameObject.Find("TopCanvas")?.transform;

        if (parentTransform == null)
        {
            parentTransform = GameObject.Find("GaudyBG").transform;
        }
        if (!error)
        {
            if (parentTransform.Find("NotificationPanel") == null)
            {
                Destroy(notification);
                notification      = Instantiate(Resources.Load("Writer/Prefabs/NotificationMessage") as GameObject, parentTransform);
                notification.name = "NotificationPanel";
            }
        }
        else if (parentTransform.Find("ErrorPanel") == null)
        {
            Destroy(notification);
            notification      = Instantiate(Resources.Load("Writer/Prefabs/ErrorMessage") as GameObject, parentTransform);
            notification.name = "ErrorPanel";
        }
        CancelInvoke("Fade");
        fade = false;
        notification.GetComponent <CanvasGroup>().alpha = 1;
        notification.SetActive(true);
        TextMeshProUGUI messageText = notification.transform.Find("BG/Message").GetComponent <TextMeshProUGUI>();

        messageText.text = message;
        Invoke("Fade", 5f);
        NextFrame.Function(delegate { fade = true; });
    }
コード例 #13
0
    public override void OnDeselect(BaseEventData eventData)
    {
        Transform suggestions = transform.Find("Suggestions");

        /*if (suggestions.childCount > 0) {
         *      foreach (Transform t in suggestions.GetComponentsInChildren<Transform>()) {
         *              if (!t.name.Equals (suggestions.name))
         *                      continue;//t.gameObject.SetActive (false);
         *      }
         * }*/
        NextFrame.Function(delegate
        {
            if (EventSystem.current.currentSelectedGameObject == null || !EventSystem.current.currentSelectedGameObject.transform.IsChildOf(gameObject.transform))
            {
                m_CaretVisible = false;
                suggestions.gameObject.SetActive(false);
                this.DeactivateInputField();
            }
            else
            {
                EventSystem.current.SetSelectedGameObject(gameObject);
            }
        });
    }
コード例 #14
0
 // Use this for initialization
 void Start()
 {
     NextFrame.Function(ResetScroll);
 }
コード例 #15
0
    //-------------------------------------------------------------------------------------------------------------------
    //---------------------------------------------------------------------------------------

    void ChooseScenePopup()
    {
        GameObject confirm;

        //If there's a way to tell a user exited from a case, this code *should* work, but case object is null. Will return to
        if (GlobalData.caseObj != null)
        {
            print("You are from the " + GlobalData.resourcePath);
            GlobalData.caseObj = null;
            if (GlobalData.demo)
            {
                confirm = GameObject.Find("GaudyBG").transform.Find("ReaderWriterSelector").gameObject;
            }
            else
            {
                confirm = GameObject.Find("GaudyBG").transform.Find("LocalOrServerConfirmation").gameObject;
            }

            if (GlobalData.resourcePath.Equals("Writer"))
            {
                levelName = "Writer";
                GlobalData.resourcePath = "Writer";
                Application.backgroundLoadingPriority = ThreadPriority.Low;
                StartLoading();
                confirm.SetActive(false);
                return;
            }
            else if (GlobalData.resourcePath.Equals("Reader"))
            {
                levelName = "CassReader";
                GameObject.Find("GaudyBG").GetComponent <ServerControls>().DisableNewCase();
                //GameObject.Find("GaudyBG").GetComponent<ServerControls>().ChangeEditButtons();
                GlobalData.resourcePath = "Reader";
                Application.backgroundLoadingPriority = ThreadPriority.Low;
                StartLoading();
                return;
            }
        }


        Button serverButton;
        Button localButton;

        if (GlobalData.demo)
        {
            confirm      = GameObject.Find("GaudyBG").transform.Find("ReaderWriterSelector").gameObject;
            serverButton = confirm.transform.Find("CaseWriter").GetComponent <Button>();
            localButton  = confirm.transform.Find("CaseReader").GetComponent <Button>();
        }
        else
        {
            confirm = GameObject.Find("GaudyBG").transform.Find("LocalOrServerConfirmation").gameObject;
            confirm.transform.Find("ConfirmActionPanel/Content/Row0/ActionValue").GetComponent <Text>().text = "Use Reader or Writer?";
            serverButton = confirm.transform.Find("ConfirmActionPanel/Content/Row1/ServerButton").GetComponent <Button>();
            localButton  = confirm.transform.Find("ConfirmActionPanel/Content/Row1/LocalButton").GetComponent <Button>();
            Button bothButton = confirm.transform.Find("ConfirmActionPanel/Content/Row1/BothButton").GetComponent <Button>();
            bothButton.gameObject.SetActive(false);

            serverButton.onClick.RemoveAllListeners();
            localButton.onClick.RemoveAllListeners();
            bothButton.onClick.RemoveAllListeners();

            serverButton.GetComponentInChildren <Text>().text = "Writer";
            localButton.GetComponentInChildren <Text>().text  = "Reader";
        }

        serverButton.onClick.AddListener(delegate {
            print("writer");
            confirm.SetActive(false);
            levelName = "Writer";
            if (!GlobalData.demo)
            {
                serverButton.GetComponentInChildren <Text>().text = "Server";
                localButton.GetComponentInChildren <Text>().text  = "Local";
            }
            GlobalData.resourcePath = "Writer";
            Application.backgroundLoadingPriority = ThreadPriority.Low;
            NextFrame.Function(StartLoading);
        });

        localButton.onClick.AddListener(delegate {
            print("reader");
            confirm.SetActive(false);
            levelName = "CassReader";
            if (!GlobalData.demo)
            {
                serverButton.GetComponentInChildren <Text>().text = "Server";
                localButton.GetComponentInChildren <Text>().text  = "Local";
            }
            GameObject.Find("GaudyBG").GetComponent <ServerControls>().DisableNewCase();
            //GameObject.Find("GaudyBG").GetComponent<ServerControls>().ChangeEditButtons();
            GlobalData.resourcePath = "Reader";
            Application.backgroundLoadingPriority = ThreadPriority.Low;
            NextFrame.Function(StartLoading);
        });

        confirm.SetActive(true);
    }
コード例 #16
0
 public void OpenDemoScene(string fileName)
 {
     GlobalData.fileName = fileName;
     GlobalData.filePath = Application.streamingAssetsPath + "/DemoCases/Cases/";
     NextFrame.Function(ActivateScene);
 }
コード例 #17
0
 // Use this for initialization
 void Start()
 {
     NextFrame.Function(Fix);
 }
コード例 #18
0
 public void RecieveText(InputField newText)
 {
     mainInputField.text = newText.text;
     NextFrame.Function(RelocateText);
 }
コード例 #19
0
 protected virtual void SetAccordionToTweenNextFrame() => NextFrame.Function(SetAccordionToTweenTransition);
コード例 #20
0
    /**
     * Run every frame. Determins the world position of the entry being held as well as the placeholder's location
     */
    void Update()
    {
        if (drag)
        {
            //container.GetComponent<LayoutElement> ().ignoreLayout = true;
            //Check how far down the list of sibling entrys that this entry physically is
            rt.position = new Vector3(rt.position.x, Input.mousePosition.y - dMPos, 0f);
            int pos = 0;
            foreach (Transform entry in entries)
            {
                if (entry.transform.localPosition.y > container.localPosition.y)
                {
                    pos++;
                }
            }
            placeholder.transform.SetSiblingIndex(pos); //Set the placeholder index to match

            //This is used for scrolling when held at the top/bottom of the scroll area.
            //Adjust the .01f to change the speed of the scrolling (.01 means 1% per frame as far as I can tell)
            Vector3[] corners = new Vector3[4];
            scrollRectTransform.GetWorldCorners(corners);
            if (transform.position.y > corners[1].y - 40 && scrollScrollRect.verticalNormalizedPosition < 1.0f)
            {
                scrollScrollRect.verticalNormalizedPosition += .01f;
            }
            else if (transform.position.y < corners[0].y + 40 && scrollScrollRect.verticalNormalizedPosition > 0.0f)
            {
                scrollScrollRect.verticalNormalizedPosition -= .01f;
            }

            //If the user let go
            if (!Input.GetMouseButton(0))
            {
                drag = false;
                GetComponentInParent <DragOverrideScript>().enabled = true;
                foreach (Transform t in entries)
                {
                    t.GetComponent <ReaderMoveableObjectCursorScript>().enabled = true;
                }
                container.GetComponent <CanvasGroup>().alpha          = 1.0f;
                container.GetComponent <LayoutElement>().ignoreLayout = false;
                //Destroy (placeholder);
                //placeholder = null;

                //Double check the position
                pos = 0;
                foreach (Transform entry in entries)
                {
                    if (entry.parent == container.parent)
                    {
                        //Debug.Log ("dropped: " + container.localPosition.y + ", entry: " + entry.transform.localPosition.y);
                        if (container.localPosition.y < entry.transform.localPosition.y)
                        {
                            pos++;
                        }
                    }
                }

                //Destroy the placeholder and set the entry to the correct new location
                Destroy(placeholder);
                placeholder = null;
                hm.MoveTo(container.gameObject, pos, transformIndex);
                if (!EventSystem.current.IsPointerOverGameObject())
                {
                    OnPointerExit(null);
                }

                if (GetComponentInParent <DiagnosisCountScript>() != null)
                {
                    GetComponentInParent <DiagnosisCountScript>().ReorderEntries();
                }

                //Adjust the mouse icon accordingly
                if (!hover && cursor)
                {
                    cursor.sprite = null;
                    cursor.sprite = cursorPicture;
                }

                //Set the color if color feedback is enabled
                if (applyFeedbackColor)
                {
                    NextFrame.Function(ApplyFeedbackToEntries);
                }
            }
        }
    }
コード例 #21
0
    /// <summary>
    /// Switches the tab
    /// </summary>
    /// <param name="tabName">Formatted tab name</param>
    public void SwitchTab(string tabName)
    {
        //Transform[] tabButtonsList = TabButtonContentPar.GetComponentsInChildren<Transform>();
        List <Transform> tabButtonsList = new List <Transform>();

        for (int i = 0; i < TabButtonContentPar.transform.childCount; i++)
        {
            var trans = TabButtonContentPar.transform.GetChild(i);
            if (trans.gameObject.activeSelf)
            {
                tabButtonsList.Add(TabButtonContentPar.transform.GetChild(i));
            }
        }

        /* For debugging
         *      string str = "";
         *      foreach (Transform t in tabButtonsList) {
         *              str += t.name + ", ";
         *      }
         *      Debug.Log (str);*/

        string tName   = null;
        string section = currentSection;
        string tabType;

        float tempScrollPos = 0;

        //Check if the tab is specified. If not, let the user choose their tab
        TabInfoScript tabScript = null;

        //int n = -1;
        if (tabName == null || tabName.Equals(""))           //If no provided tab name
        {
            tabScript = ds.GetData(section).GetCurrentTab(); //Check to see if there were any active tabs for the current section
            if (tabScript == null || tabScript.type == "")   //If no active tab
                                                             //n = 0;
            {
                SectionDataScript sds = ds.GetData(section);
                if (sds.GetTabList().Count > 0)   //If the section has any tabs at all
                {
                    string tempTabName = sds.GetTabList()[0];
                    tempTabName = tempTabName.Replace('_', ' ').Substring(0, tempTabName.Length - "Tab".Length);
                    sds.SetCurrentTab(tempTabName);
                    tabType = tempTabName;
                    sds.GetTabInfo(tabType).Visit();
                    if (sds.AllTabsVisited())
                    {
                        //Track that this section has had all tabs visited
                        Tracker.RecordData(
                            Tracker.DataType.progress,
                            GlobalData.caseObj.recordNumber,
                            new Tracker.ProgressData(sds.GetPosition(), -1));// ds.GetSectionsList().FindIndex((string sec) => sec.Equals(section))));
                    }
                    else
                    {
                        //Track the tab visit
                        Tracker.RecordData(
                            Tracker.DataType.progress,
                            GlobalData.caseObj.recordNumber,
                            new Tracker.ProgressData(sds.GetPosition(), sds.GetTabInfo(tabType).n));
                    }
                    Tracker.PrintAllData();
                }
                else     //Section has no tabs. New Section. Let user pick tab
                         //transform.Find("TabSelectorBG").gameObject.SetActive(true);
                {
                    return;
                    //This will set the tab as the default specified in the Default data script
                    //sds.SetCurrentTab (new TabInfoScript(0, ID.defaultTab));
                    //tab = ID.defaultTab;
                }
            }
            else     //Set tab to the section's last active tab
            {
                tabType = tabScript.type;
            }
            Destroy(currentTab);
            currentTab = null;
        }
        else
        {
            //Switching away from a tab
            if (currentTab != null)
            {
                if ((tabName + "Tab").Equals(currentTab.name) && section.Equals(currentSection))
                {
                    return;
                }
                else
                {
                    //This line throws errors with a "/" in the name
                    //TabButtonContentPar.transform.Find(currentTab.name + "Button").GetComponent<Button>().interactable = true;

                    tName = currentTab.name /*.Replace (" ", "_")*/ + "Button";
                    foreach (Transform t in tabButtonsList)
                    {
                        if (t.name.Equals(tName))
                        {
                            t.GetComponent <Button>().interactable = true;
                            //Enable visited mark
                            if (ds.forceInOrder)
                            {
                                //Enabling something (like the visited notice) resets the scrollbar back to 0 (to the left)
                                //NextFrame.Function(delegate { TabButtonContentPar.transform.parent.parent.GetComponent<ScrollRect>().horizontalNormalizedPosition = tempScrollPos; });
                                tempScrollPos = TabButtonContentPar.transform.parent.parent.GetComponent <ScrollRect>().horizontalNormalizedPosition;
                                t.Find("Visited").gameObject.SetActive(true);
                            }
                            break;
                        }
                    }

                    Destroy(currentTab);
                    currentTab = null;
                }
            }
            //Debug.Log(string.Join(",", ds.GetData (currentSection).GetTabList().ToArray()));
            tabType = ds.GetData(currentSection).GetTabInfo(tabName).type;
            ds.GetData(currentSection).GetTabInfo(tabName).Visit();
            if (ds.GetData(currentSection).AllTabsVisited())
            {
                //Track that this section has had all tabs visited
                int sectionIdx = ds.GetSectionsList().FindIndex((string sec) => sec.Equals(section));

                //If the last section has been completed, mark the case as visited
                if (sectionIdx == ds.GetSectionsList().Count - 1)
                {
                    Tracker.RecordData(
                        Tracker.DataType.finishedCase,
                        GlobalData.caseObj.recordNumber,
                        true);
                }
                else
                {
                    //Record the completed section
                    Tracker.RecordData(
                        Tracker.DataType.progress,
                        GlobalData.caseObj.recordNumber,
                        new Tracker.ProgressData(ds.GetData(currentSection).GetPosition(), ds.GetData(currentSection).GetTabInfo(tabName).n));
                }

                //Remove the lock on the next step
                if (ds.forceInOrder)
                {
                    int nextPos = ds.GetData(currentSection).GetPosition() + 1;
                    if (nextPos < ds.GetSectionsList().Count)
                    {
                        Transform button = ds.SectionButtonPar.transform.GetChild(nextPos);
                        button.GetComponent <Button>().interactable = true;
                        if (button.Find("Overlay"))
                        {
                            button.Find("Overlay").GetComponent <Image>().color = new Color(0, 0, 0, (float)50 / 255);
                            button.Find("Overlay").GetComponent <HideOnMouseHoverScript>().enabled = true;
                        }
                        button.Find("Lock").gameObject.SetActive(false);
                        ds.SectionButtonPar.transform.GetChild(ds.GetData(currentSection).GetPosition() + 1).GetComponent <Button>().interactable = true;
                    }
                }

                //Apply the checkmark when the last tab is visited
                Transform currentButton = ds.SectionButtonPar.transform.GetChild(ds.GetData(currentSection).GetPosition());
                currentButton.Find("AllTabsVisitedCheck").gameObject.SetActive(true);
            }
            else
            {
                //Track the tab visit
                Tracker.RecordData(
                    Tracker.DataType.progress,
                    GlobalData.caseObj.recordNumber,
                    new Tracker.ProgressData(ds.GetData(currentSection).GetPosition(), ds.GetData(currentSection).GetTabInfo(tabName).n));
            }
            Tracker.PrintAllData();



            if (tabType.ToLower().EndsWith("tab"))   //Remove the "Tab" from the end of the type
            {
                tabType = tabType.Substring(0, tabType.Length - 3);
            }
        }
        //Debug.Log ("Section: " + currentSection + ", Name: " + tabName + ", Type: " + tabType); //Type is _ + Tab, but should be prefab folder - " Tab"



        //Load in the specified tab
        //string name = tabName;
        //string folder = tabType + " Tab";
        //tabType = tabType.Replace (" ", string.Empty) + "Tab";
        //Folder should be the same as the prefab folder. Tab should equal the prefab name. Name should be the link to text

        //Debug.Log ("Prefabs/Tabs/" + folder + "/" + tabType);
        //GameObject newPrefab = Resources.Load(GlobalData.resourcePath + "/Prefabs/Tabs/" + folder + "/" + tabType) as GameObject;
        //GameObject newTab = Instantiate (newPrefab, TabContentPar.transform);

        //GameObject newPrefab = Resources.Load(GlobalData.resourcePath + "/Prefabs/Tabs/" + tabType + " Tab/" + tabType.Replace(" ", string.Empty) + "Tab") as GameObject;
        GameObject newTab = Instantiate(Resources.Load(GlobalData.resourcePath + "/Prefabs/Tabs/" + tabType + " Tab/" + tabType.Replace(" ", string.Empty) + "Tab") as GameObject, TabContentPar.transform);

        newTab.name = tabName + "Tab";

        if (GlobalData.GDS.isMobile)
        {
            newTab.transform.GetComponentInChildren <Scrollbar>().targetGraphic.enabled          = true;
            newTab.transform.GetComponentInChildren <Scrollbar>().GetComponent <Image>().enabled = true;
        }

        //newTab.AddComponent<Text> ().text = "" + n;
        currentTab = newTab;
        ds.GetData(section).SetCurrentTab(tabName);

        //Adjust the buttons
        int tNameHash = (currentTab.name /*.Replace (" ", "_")*/ + "Button").GetHashCode();
        int j         = 0;

        foreach (Transform t in tabButtonsList)
        {
            //if (t.name.Equals (tName)) {
            if (t.name.GetHashCode() == tNameHash)
            {
                //Writer code to disable trash button for persistant tabs was here. Changing to visited code now
                //Enable the visited check
                t.GetChild(t.childCount - 1).gameObject.SetActive(true);
                t.GetComponent <Button>().interactable = false;
                t.GetComponent <ScriptButtonFixScript>().FixTab();

                //Find the value that we need to auto-scroll to
                float viewportWidth           = TabButtonContentPar.transform.parent.GetComponent <RectTransform>().rect.width;
                float tabWidth                = t.GetComponent <RectTransform>().rect.width;
                float contentParOffset        = TabButtonContentPar.GetComponent <RectTransform>().anchoredPosition.x;
                float tabButtonOffset         = t.transform.localPosition.x;
                float leftSideTabButtonLocal  = tabButtonOffset - tabWidth / 2 + contentParOffset;
                float rightSideTabButtonLocal = tabButtonOffset + tabWidth / 2 + contentParOffset;
                if (leftSideTabButtonLocal < 0)
                {
                    //Past left side
                    print("Past left");
                    float tabHorizontalPos = Mathf.Clamp01((tabButtonOffset - tabWidth / 2) / (TabButtonContentPar.GetComponent <RectTransform>().rect.width - viewportWidth));
                    TabButtonContentPar.transform.parent.parent.GetComponent <ScrollRect>().horizontalNormalizedPosition = tabHorizontalPos;
                }
                else if (rightSideTabButtonLocal > viewportWidth)
                {
                    //past right side
                    print("Past right");
                    float tabHorizontalPos = Mathf.Clamp01((tabButtonOffset + tabWidth / 2 - viewportWidth) / (TabButtonContentPar.GetComponent <RectTransform>().rect.width - viewportWidth));
                    TabButtonContentPar.transform.parent.parent.GetComponent <ScrollRect>().horizontalNormalizedPosition = tabHorizontalPos;
                }

                /*
                 *              //If the tab's left side is to the left of the tab viewport
                 *              if (t.position.x - tabWidth / 2 < viewportX - viewportWidth / 2) {
                 *                      float tabHorizontalPos = (t.localPosition.x - t.GetComponent<RectTransform>().rect.width / 2 - viewportWidth) / (TabButtonContentPar.GetComponent<RectTransform>().rect.width - viewportWidth);
                 *                      TabButtonContentPar.transform.parent.parent.GetComponent<ScrollRect>().horizontalNormalizedPosition = tabHorizontalPos;
                 *              //Else if the right side of the tab is past the right side of the tab viewport
                 *              } else if (t.position.x + tabWidth / 2 > viewportX + viewportWidth / 2) {
                 *                      float tabHorizontalPos = (t.localPosition.x + t.GetComponent<RectTransform>().rect.width / 2 - viewportWidth) / (TabButtonContentPar.GetComponent<RectTransform>().rect.width - viewportWidth);
                 *                      TabButtonContentPar.transform.parent.parent.GetComponent<ScrollRect>().horizontalNormalizedPosition = tabHorizontalPos;
                 *              }
                 */
                break;
            }
            j++;
        }
        if (ds.forceInOrder && tabButtonsList.Count > j + 1)
        {
            //tabButtonsList[j + 1].Find("Locked").gameObject.SetActive(false);
            //tabButtonsList[j + 1].GetComponent<Button>().enabled = true;
        }
        print(tempScrollPos);
        if (tempScrollPos > 0)
        {
            TabButtonContentPar.transform.parent.parent.GetComponent <ScrollRect>().horizontalNormalizedPosition = tempScrollPos;
            NextFrame.Function(delegate {
                //Can't do next frame, because that messes up the code that alligns to a tab off the screen
                //TabButtonContentPar.transform.parent.parent.GetComponent<ScrollRect>().horizontalNormalizedPosition = tempScrollPos;
            });
        }

        /*
         *      foreach(TabScrollButtonScript scrollButton in TabButtonContentPar.transform.parent.parent.parent.GetComponentsInChildren<TabScrollButtonScript>()) {
         *              if (scrollButton.name.EndsWith("Right")) {
         *                      //scrollButton.gameObject.SetActive(true);
         *              }
         *      }*/

        //Debug.Log(ds.GetData(getCurrentSection()).GetAllData());
        //Resources.UnloadUnusedAssets();
    }