Skip to content

Commit 7ab9697

Browse files
committed
fix #77, settings
1 parent 9eadcc0 commit 7ab9697

File tree

7 files changed

+38
-11
lines changed

7 files changed

+38
-11
lines changed

Assets/Testing/AWS1HourTest.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ PrefabInstance:
12031203
- target: {fileID: 2834388984357925155, guid: 0a3b6392f04558844bd340e68ced1ff9,
12041204
type: 3}
12051205
propertyPath: m_AnchoredPosition.y
1206-
value: 1365
1206+
value: 1625
12071207
objectReference: {fileID: 0}
12081208
- target: {fileID: 2896031059644693069, guid: 0a3b6392f04558844bd340e68ced1ff9,
12091209
type: 3}
@@ -1253,7 +1253,7 @@ PrefabInstance:
12531253
- target: {fileID: 4267567203292169432, guid: 0a3b6392f04558844bd340e68ced1ff9,
12541254
type: 3}
12551255
propertyPath: m_AnchoredPosition.y
1256-
value: 2520
1256+
value: 3000
12571257
objectReference: {fileID: 0}
12581258
- target: {fileID: 4612929069887686480, guid: 0a3b6392f04558844bd340e68ced1ff9,
12591259
type: 3}

Assets/UXF/Scripts/Etc/Editor/UXFWizard.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ static void OnProjectChanged()
7272

7373
public void OnGUI()
7474
{
75-
GUIStyle labelStyle = new GUIStyle();
75+
GUIStyle labelStyle = new GUIStyle(EditorStyles.label);
7676
labelStyle.wordWrap = true;
77-
labelStyle.margin = new RectOffset(6, 0, 0, 0);
7877

7978
var rect = GUILayoutUtility.GetRect(Screen.width, 128, GUI.skin.box);
8079
if (uxfIcon)

Assets/UXF/Scripts/Etc/Settings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ public List<object> GetObjectList(string key)
371371
/// <param name="valueIfNotFound">The value returned if the setting does not exist (i.e., a default value).</param>
372372
public List<object> GetObjectList(string key, List<object> valueIfNotFound) { return ContainsKey(key) ? GetObjectList(key) : valueIfNotFound; }
373373

374-
374+
375375
public bool ContainsKey(string key)
376376
{
377-
try
377+
if (baseDict.ContainsKey(key))
378378
{
379-
return baseDict.ContainsKey(key);
379+
return true;
380380
}
381-
catch (KeyNotFoundException)
381+
else
382382
{
383383
if (parentSettingsContainer != null && parentSettingsContainer.settings != null)
384384
{

Assets/UXF/Scripts/Session.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ namespace UXF
1414
/// The Session represents a single "run" of an experiment, and contains all information about that run.
1515
/// </summary>
1616
[ExecuteInEditMode]
17-
[RequireComponent(typeof(FileSaver))]
1817
public class Session : MonoBehaviour, ISettingsContainer, IDataAssociatable
1918
{
2019
/// <summary>

Assets/UXF/Scripts/UI/UIController.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,16 @@ IEnumerator GetJsonUrl()
626626
www.timeout = 5;
627627
yield return www.SendWebRequest();
628628

629-
if (www.isNetworkError || www.isHttpError)
629+
bool error;
630+
#if UNITY_2020_OR_NEWER
631+
error = www.result != UnityWebRequest.Result.Success;
632+
#else
633+
#pragma warning disable
634+
error = www.isHttpError || www.isNetworkError;
635+
#pragma warning restore
636+
#endif
637+
638+
if (error)
630639
{
631640
Utilities.UXFDebugLogError(www.error);
632641
yield break;

Assets/UXF/Tests/Editor/TestSettings.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,26 @@ public void CascadeSettings()
143143
Assert.IsNull(s.settings);
144144
}
145145

146+
[Test]
147+
public void CascadeSettingsWithDefault()
148+
{
149+
GameObject go = new GameObject();
150+
Session s = go.AddComponent<Session>();
151+
Block b = s.CreateBlock();
152+
Trial t = b.CreateTrial();
153+
154+
Dictionary<string, object> dict = MiniJSON.Json.Deserialize(jsonString) as Dictionary<string, object>;
155+
b.settings.UpdateWithDict(dict);
156+
157+
t.settings.SetValue("key1", "test");
158+
t.settings.SetValue("key2", 100);
159+
160+
Assert.AreEqual(t.settings.GetString("string"), "The quick brown fox \"jumps\" over the lazy dog ");
161+
Assert.AreEqual(t.settings.GetString("string", string.Empty), "The quick brown fox \"jumps\" over the lazy dog ");
162+
Assert.AreEqual(t.settings.GetObject("string", string.Empty), "The quick brown fox \"jumps\" over the lazy dog ");
163+
Assert.AreEqual(t.settings.GetObject("something_not_set", string.Empty), string.Empty);
164+
}
165+
146166
}
147167

148168
}

Assets/UXF/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.4
1+
2.1.5

0 commit comments

Comments
 (0)