@@ -9,26 +9,27 @@ namespace Microsoft.MixedReality.Toolkit.Core.Inspectors.Profiles
99{
1010 public class MixedRealityProfileCloneWindow : EditorWindow
1111 {
12- private struct SubProfileAction
12+ public enum ProfileCloneBehavior
1313 {
14- public enum TypeEnum
15- {
16- UseExisting ,
17- CloneExisting ,
18- UseSubstitution ,
19- }
14+ UseExisting ,
15+ CloneExisting ,
16+ UseSubstitution ,
17+ LeaveEmpty ,
18+ }
2019
21- public SubProfileAction ( TypeEnum action , SerializedProperty property , Object substitutionReference , System . Type profileType )
20+ private struct SubProfileAction
21+ {
22+ public SubProfileAction ( ProfileCloneBehavior behavior , SerializedProperty property , Object substitutionReference , System . Type profileType )
2223 {
23- ActionType = action ;
24+ Behavior = behavior ;
2425 Property = property ;
2526 SubstitutionReference = substitutionReference ;
2627 ProfileType = profileType ;
2728
28- CloneName = ( SubstitutionReference != null ) ? SubstitutionReference . name : string . Empty ;
29+ CloneName = ( SubstitutionReference != null ) ? "New " + SubstitutionReference . name : "New " + profileType . Name ;
2930 }
3031
31- public TypeEnum ActionType ;
32+ public ProfileCloneBehavior Behavior ;
3233 public SerializedProperty Property ;
3334 public string CloneName ;
3435 public Object SubstitutionReference ;
@@ -94,7 +95,7 @@ private void Initialize(BaseMixedRealityProfile parentProfile, BaseMixedRealityP
9495 continue ;
9596
9697 subProfileActions . Add ( new SubProfileAction (
97- SubProfileAction . TypeEnum . UseExisting ,
98+ ProfileCloneBehavior . UseExisting ,
9899 subProfileProperty ,
99100 subProfileProperty . objectReferenceValue ,
100101 subProfileType ) ) ;
@@ -117,14 +118,17 @@ private void OnGUI()
117118 return ;
118119 }
119120
120- EditorGUILayout . HelpBox ( "Cloning " + childProperty . displayName + " from " + parentProfile . name , MessageType . Info ) ;
121+ EditorGUILayout . BeginVertical ( EditorStyles . helpBox ) ;
122+ EditorGUILayout . ObjectField ( "Cloning profile" , childProfile , typeof ( BaseMixedRealityProfile ) , false ) ;
123+ EditorGUILayout . ObjectField ( "from parent profile" , parentProfile , typeof ( BaseMixedRealityProfile ) , false ) ;
124+ EditorGUILayout . EndVertical ( ) ;
121125 EditorGUILayout . Space ( ) ;
122126
123127 if ( subProfileActions . Count > 0 )
124128 {
125129 EditorGUILayout . HelpBox ( "This profile has sub-profiles. By defult your clone will reference the existing profiles. If you want to specify a different profile, or if you want to clone the sub-profile, use the options below." , MessageType . Info ) ;
126130
127- EditorGUILayout . BeginVertical ( EditorStyles . helpBox ) ;
131+ EditorGUILayout . BeginVertical ( ) ;
128132
129133 for ( int i = 0 ; i < subProfileActions . Count ; i ++ )
130134 {
@@ -133,20 +137,20 @@ private void OnGUI()
133137
134138 SubProfileAction action = subProfileActions [ i ] ;
135139
136- action . ActionType = ( SubProfileAction . TypeEnum ) EditorGUILayout . EnumPopup ( action . Property . displayName , action . ActionType ) ;
140+ action . Behavior = ( ProfileCloneBehavior ) EditorGUILayout . EnumPopup ( action . Property . displayName , action . Behavior ) ;
137141
138- switch ( action . ActionType )
142+ switch ( action . Behavior )
139143 {
140- case SubProfileAction . TypeEnum . UseExisting :
144+ case ProfileCloneBehavior . UseExisting :
141145 GUI . color = Color . Lerp ( Color . white , Color . clear , 0.5f ) ;
142146 EditorGUILayout . ObjectField ( "Existing" , action . Property . objectReferenceValue , action . ProfileType , false ) ;
143147 break ;
144148
145- case SubProfileAction . TypeEnum . UseSubstitution :
149+ case ProfileCloneBehavior . UseSubstitution :
146150 action . SubstitutionReference = EditorGUILayout . ObjectField ( "Substitution" , action . SubstitutionReference , action . ProfileType , false ) ;
147151 break ;
148152
149- case SubProfileAction . TypeEnum . CloneExisting :
153+ case ProfileCloneBehavior . CloneExisting :
150154 if ( action . Property . objectReferenceValue == null )
151155 {
152156 EditorGUILayout . LabelField ( "Can't clone profile - none is set." ) ;
@@ -156,6 +160,11 @@ private void OnGUI()
156160 action . CloneName = EditorGUILayout . TextField ( "Clone name" , action . CloneName ) ;
157161 }
158162 break ;
163+
164+ case ProfileCloneBehavior . LeaveEmpty :
165+ // Add one line for formatting reasons
166+ EditorGUILayout . LabelField ( " " ) ;
167+ break ;
159168 }
160169 subProfileActions [ i ] = action ;
161170 }
@@ -200,18 +209,18 @@ private void CloneMainProfile()
200209 {
201210 SerializedProperty actionProperty = newChildSerializedObject . FindProperty ( action . Property . name ) ;
202211
203- switch ( action . ActionType )
212+ switch ( action . Behavior )
204213 {
205- case SubProfileAction . TypeEnum . UseExisting :
214+ case ProfileCloneBehavior . UseExisting :
206215 // Do nothing
207216 break ;
208217
209- case SubProfileAction . TypeEnum . UseSubstitution :
218+ case ProfileCloneBehavior . UseSubstitution :
210219 // Apply the chosen reference to the new property
211220 actionProperty . objectReferenceValue = action . SubstitutionReference ;
212221 break ;
213222
214- case SubProfileAction . TypeEnum . CloneExisting :
223+ case ProfileCloneBehavior . CloneExisting :
215224 // Clone the profile, then apply the new reference
216225
217226 // If the property reference is null, skip this step, the user was warned
@@ -230,6 +239,10 @@ private void CloneMainProfile()
230239 PasteProfileValues ( newChildProfile , newSubProfile , newSubProfileSerializedObject ) ;
231240 newSubProfileSerializedObject . ApplyModifiedProperties ( ) ;
232241 break ;
242+
243+ case ProfileCloneBehavior . LeaveEmpty :
244+ actionProperty . objectReferenceValue = null ;
245+ break ;
233246 }
234247 }
235248
0 commit comments