Skip to content

Commit d2329b6

Browse files
authored
Merge pull request #9940 from keveleigh/assorted-unity-improvements
Assorted Unity improvements
2 parents 379e961 + a90f7c5 commit d2329b6

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

Assets/MRTK/Core/Inspectors/Profiles/MixedRealityToolkitConfigurationProfileInspector.cs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,32 @@ protected override void OnEnable()
153153
using (var c = new EditorGUI.ChangeCheckScope())
154154
{
155155
// Reconciling old Experience Scale property with the Experience Settings Profile
156-
var oldExperienceSettigsScale = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;
156+
ExperienceScale? oldExperienceSettingsScale = null;
157+
if (experienceSettingsProfile.objectReferenceValue is MixedRealityExperienceSettingsProfile oldExperienceSettingsProfile
158+
&& oldExperienceSettingsProfile != null)
159+
{
160+
oldExperienceSettingsScale = oldExperienceSettingsProfile.TargetExperienceScale;
161+
}
157162

158163
changed |= RenderProfile(experienceSettingsProfile, typeof(MixedRealityExperienceSettingsProfile), true, false, null, true);
159164

160165
// Experience configuration
161-
if(!mrtkConfigProfile.ExperienceSettingsProfile.IsNull())
162-
{
166+
if (mrtkConfigProfile.ExperienceSettingsProfile != null)
167+
{
163168
// If the Experience Scale property changed, make sure we also alter the configuration profile's target experience scale property for compatibility
164-
var newExperienceSettigs = (experienceSettingsProfile.objectReferenceValue as MixedRealityExperienceSettingsProfile)?.TargetExperienceScale;
165-
if(oldExperienceSettigsScale.HasValue && newExperienceSettigs.HasValue && oldExperienceSettigsScale != newExperienceSettigs)
169+
ExperienceScale? newExperienceSettingsScale = null;
170+
if (experienceSettingsProfile.objectReferenceValue is MixedRealityExperienceSettingsProfile newExperienceSettingsProfile
171+
&& newExperienceSettingsProfile != null)
172+
{
173+
newExperienceSettingsScale = newExperienceSettingsProfile.TargetExperienceScale;
174+
}
175+
176+
if (oldExperienceSettingsScale.HasValue && newExperienceSettingsScale.HasValue && oldExperienceSettingsScale != newExperienceSettingsScale)
166177
{
167-
experienceScaleMigration.intValue = (int)newExperienceSettigs;
178+
experienceScaleMigration.intValue = (int)newExperienceSettingsScale;
168179
experienceScaleMigration.serializedObject.ApplyModifiedProperties();
169180
}
170-
// If we have not changed the Experience Settings profile and it's value is out of sync with the top level configuration profile, display a migration prompt
181+
// If we have not changed the Experience Settings profile and its value is out of sync with the top level configuration profile, display a migration prompt
171182
else if ((ExperienceScale)experienceScaleMigration.intValue != mrtkConfigProfile.ExperienceSettingsProfile.TargetExperienceScale)
172183
{
173184
Color errorColor = Color.Lerp(Color.white, Color.red, 0.5f);

Assets/MRTK/SDK/Features/UX/Scripts/Collections/GridObjectCollection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ protected virtual void OnDrawGizmosSelected()
517517
}
518518
}
519519

520+
#if UNITY_EDITOR
520521
private void Awake()
521522
{
522-
#if UNITY_EDITOR
523523
if (!EditorApplication.isPlaying)
524524
{
525525
if (assetVersion != CurrentAssetVersion)
@@ -528,8 +528,8 @@ private void Awake()
528528
PerformVersionPatching();
529529
}
530530
}
531-
#endif
532531
}
532+
#endif
533533

534534
#region asset version migration
535535
private const int CurrentAssetVersion = 1;

Assets/MRTK/Tests/EditModeTests/Tools/MigrationToolTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void ButtonMigrationTest()
7979
quadRenderer.sharedMaterial = testMat;
8080

8181
ButtonConfigHelper buttonConfig = buttonGameObject.GetComponent<ButtonConfigHelper>();
82-
ButtonIconSet testIconSet = new ButtonIconSet();
82+
ButtonIconSet testIconSet = ScriptableObject.CreateInstance<ButtonIconSet>();
8383
buttonConfig.IconStyle = ButtonIconStyle.Quad;
8484
buttonConfig.IconSet = testIconSet;
8585
buttonConfig.EditorSetDefaultIconSet(testIconSet);

0 commit comments

Comments
 (0)