/// <summary>
 /// Start is called on the frame when a script is enabled just before
 /// any of the Update methods is called the first time.
 /// </summary>
 void Start()
 {
     if (PlayerPrefs.HasKey(dataLocKey))
     {
         string loc = PlayerPrefs.GetString(dataLocKey);
         if (Directory.Exists(loc))
         {
             inputField.SetContents(loc);
         }
     }
 }
예제 #2
0
        public void Populate(bool retry = true)
        {
            if (!Directory.Exists(Application.streamingAssetsPath))
            {
                Debug.LogWarning("StreamingAssets folder was moved or deleted! Creating a new one.");
                Directory.CreateDirectory(Application.streamingAssetsPath);
            }

            var profileNames = Directory.GetFiles(Application.streamingAssetsPath, uiController.settingsSearchPattern)
                               .Select(f => Path.GetFileName(f))
                               .ToList();

            if (profileNames.Count > 0)
            {
                if (PlayerPrefs.HasKey(profileKey))
                {
                    string profile = PlayerPrefs.GetString(profileKey);
                    if (profileNames.Contains(profile))
                    {
                        int profileIdx = profileNames.IndexOf(profile);
                        Tuple <int, IEnumerable <string> > data = new Tuple <int, IEnumerable <string> >(
                            profileIdx, profileNames
                            );

                        dropdown.SetContents(data); // pass tuple
                    }
                    else
                    {
                        dropdown.SetContents(profileNames);
                    }
                }
                else
                {
                    dropdown.SetContents(profileNames);
                }
            }
            else
            {
                string newName = uiController.settingsSearchPattern.Replace("*", "my_experiment");
                string newPath = Path.Combine(Application.streamingAssetsPath, newName);
                if (!File.Exists(newPath))
                {
                    File.WriteAllText(newPath, "{\n}");
                    Debug.LogErrorFormat("No profiles found in {0} that match search pattern {1}. A blank one called {2} has been made for you.", Application.streamingAssetsPath, uiController.settingsSearchPattern, newName);
                    if (retry)
                    {
                        Populate(retry: false);
                    }
                }
            }
        }
예제 #3
0
        public void GenerateSidebar()
        {
            Transform[] children = sidebarContentTransform
                                   .Cast <Transform>()
                                   .Select(c => c.transform)
                                   .ToArray();

            foreach (Transform child in children)
            {
                if (ReferenceEquals(settingsElement.transform, child))
                {
                    continue;
                }
                else if (ReferenceEquals(ppidElement.transform, child))
                {
                    continue;
                }
                else if (ReferenceEquals(localFilePathElement.transform, child))
                {
                    continue;
                }
                else if (ReferenceEquals(sessionNumElement.transform, child))
                {
                    continue;
                }
                else
                {
                    DestroyImmediate(child.gameObject);
                }
            }

            foreach (FormElementEntry entry in participantDataPoints)
            {
                FormElement newElement = null;
                switch (entry.dataType)
                {
                case FormDataType.String:
                case FormDataType.Int:
                case FormDataType.Float:
                    newElement            = Instantiate(textPrefab, sidebarContentTransform);
                    newElement.title.text = entry.displayName;
                    newElement.SetDataType(entry.dataType);
                    break;

                case FormDataType.Bool:
                    newElement            = Instantiate(checkBoxPrefab, sidebarContentTransform);
                    newElement.title.text = entry.displayName;
                    break;

                case FormDataType.DropDown:
                    newElement            = Instantiate(dropDownPrefab, sidebarContentTransform);
                    newElement.title.text = entry.displayName;
                    newElement.SetContents(entry.dropDownOptions);
                    break;
                }
                entry.element = newElement;
            }
        }
예제 #4
0
 // https://forum.unity.com/threads/sendmessage-cannot-be-called-during-awake-checkconsistency-or-onvalidate-can-we-suppress.537265/
 public void LateValidate()
 {
     if (tsAndCsToggle != null)
     {
         tsAndCsToggle.title.text = termsAndConditions;
         tsAndCsToggle.SetContents(tsAndCsInitialState);
     }
     UpdateExperimentProfileElementState();
     UpdatePPIDSessionNumElementState();
     UpdateUIState();
     UpdateLocalFileElementState();
 }