private void OnGUI()
        {
            if (cloneWindow == null || parentProfile == null || childProfile == null)
            {
                Close();
                return;
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.ObjectField("Cloning profile", childProfile, typeof(BaseMixedRealityProfile), false);
            EditorGUILayout.ObjectField("from parent profile", parentProfile, typeof(BaseMixedRealityProfile), false);
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (subProfileActions.Count > 0)
            {
                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);

                EditorGUILayout.BeginVertical();

                for (int i = 0; i < subProfileActions.Count; i++)
                {
                    GUI.color = Color.white;
                    EditorGUILayout.Space();

                    SubProfileAction action = subProfileActions[i];

                    action.Behavior = (ProfileCloneBehavior)EditorGUILayout.EnumPopup(action.Property.displayName, action.Behavior);

                    switch (action.Behavior)
                    {
                    case ProfileCloneBehavior.UseExisting:
                        GUI.color = Color.Lerp(Color.white, Color.clear, 0.5f);
                        EditorGUILayout.ObjectField("Existing", action.Property.objectReferenceValue, action.ProfileType, false);
                        break;

                    case ProfileCloneBehavior.UseSubstitution:
                        action.SubstitutionReference = EditorGUILayout.ObjectField("Substitution", action.SubstitutionReference, action.ProfileType, false);
                        break;

                    case ProfileCloneBehavior.CloneExisting:
                        if (action.Property.objectReferenceValue == null)
                        {
                            EditorGUILayout.LabelField("Can't clone profile - none is set.");
                        }
                        else
                        {
                            action.CloneName = EditorGUILayout.TextField("Clone name", action.CloneName);
                        }
                        break;

                    case ProfileCloneBehavior.LeaveEmpty:
                        // Add one line for formatting reasons
                        EditorGUILayout.LabelField(" ");
                        break;
                    }
                    subProfileActions[i] = action;
                }

                EditorGUILayout.EndVertical();
            }

            GUI.color = Color.white;
            // Space between props and buttons at botton
            GUILayout.FlexibleSpace();

            // Get the selected folder in the project window
            targetFolder = EditorGUILayout.ObjectField("Target Folder", targetFolder, typeof(DefaultAsset), false);
            EditorGUILayout.HelpBox("If no folder is provided, the profile will be cloned to the Assets/MixedRealityToolkit.Generated/CustomProfiles folder.", MessageType.Info);
            childProfileAssetName = EditorGUILayout.TextField("Profile Name", childProfileAssetName);

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("Clone"))
            {
                targetFolder = EnsureTargetFolder(targetFolder);
                CloneMainProfile();
            }
            if (GUILayout.Button("Cancel"))
            {
                cloneWindow.Close();
            }

            EditorGUILayout.EndHorizontal();

            Repaint();
        }
        private void OnGUI()
        {
            if (cloneWindow == null || childProfile == null)
            {
                Close();
                return;
            }

            EditorGUILayout.BeginVertical(EditorStyles.helpBox);
            EditorGUILayout.ObjectField("Cloning profile", childProfile, typeof(BaseMixedRealityProfile), false);
            if (parentProfile != null)
            {   // Only show this if we're initiating this from a parent profile
                EditorGUILayout.ObjectField("from parent profile", parentProfile, typeof(BaseMixedRealityProfile), false);
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();

            if (subProfileActions.Count > 0)
            {
                AdvancedMode = EditorGUILayout.Foldout(SessionState.GetBool(AdvancedModeKey, false), "Advanced Options", true, MixedRealityStylesUtility.BoldFoldoutStyle);
                SessionState.SetBool(AdvancedModeKey, AdvancedMode);

                if (AdvancedMode)
                {
                    EditorGUILayout.HelpBox("This profile has sub-profiles. By default 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);

                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                    for (int i = 0; i < subProfileActions.Count; i++)
                    {
                        GUI.color = Color.white;
                        EditorGUILayout.Space();

                        SubProfileAction action = subProfileActions[i];

                        action.Behavior = (ProfileCloneBehavior)EditorGUILayout.EnumPopup(action.Property.displayName, action.Behavior);

                        switch (action.Behavior)
                        {
                        case ProfileCloneBehavior.UseExisting:
                            GUI.color = Color.Lerp(Color.white, Color.clear, 0.5f);
                            EditorGUILayout.ObjectField("Existing", action.Property.objectReferenceValue, action.ProfileType, false);
                            break;

                        case ProfileCloneBehavior.UseSubstitution:
                            action.SubstitutionReference = EditorGUILayout.ObjectField("Substitution", action.SubstitutionReference, action.ProfileType, false);
                            break;

                        case ProfileCloneBehavior.CloneExisting:
                            if (action.Property.objectReferenceValue == null)
                            {
                                EditorGUILayout.LabelField("Can't clone profile - none is set.");
                            }
                            else
                            {
                                action.CloneName = EditorGUILayout.TextField("Clone name", action.CloneName);
                            }
                            using (new EditorGUILayout.HorizontalScope())
                            {
                                if (action.TargetFolder == null)
                                {
                                    action.TargetFolder = targetFolder;
                                }
                                action.TargetFolder = EditorGUILayout.ObjectField("Target Folder", action.TargetFolder, typeof(DefaultAsset), false);
                                if (GUILayout.Button("Put in original folder", EditorStyles.miniButton, GUILayout.MaxWidth(120)))
                                {
                                    string profilePath = AssetDatabase.GetAssetPath(action.Property.objectReferenceValue);
                                    action.TargetFolder = AssetDatabase.LoadAssetAtPath <Object>(Path.GetDirectoryName(profilePath));
                                }
                            }
                            break;

                        case ProfileCloneBehavior.LeaveEmpty:
                            // Add one line for formatting reasons
                            EditorGUILayout.LabelField(" ");
                            break;
                        }
                        subProfileActions[i] = action;
                    }

                    EditorGUILayout.EndVertical();
                }
            }

            GUI.color = Color.white;
            // Space between props and buttons at bottom
            GUILayout.FlexibleSpace();

            // Get the selected folder in the project window
            using (new EditorGUILayout.HorizontalScope())
            {
                targetFolder = EditorGUILayout.ObjectField("Target Folder", targetFolder, typeof(DefaultAsset), false);
                if (GUILayout.Button("Put in original folder", EditorStyles.miniButton, GUILayout.MaxWidth(125)))
                {
                    string profilePath = AssetDatabase.GetAssetPath(childProfile);
                    targetFolder = AssetDatabase.LoadAssetAtPath <Object>(Path.GetDirectoryName(profilePath));
                }
            }

            EditorGUILayout.HelpBox("If no folder is provided, the profile will be cloned to the Assets/MixedRealityToolkit.Generated/CustomProfiles folder.", MessageType.Info);
            childProfileAssetName = EditorGUILayout.TextField("Profile Name", childProfileAssetName);

            using (new EditorGUILayout.HorizontalScope())
            {
                if (GUILayout.Button("Clone"))
                {
                    targetFolder = EnsureTargetFolder(targetFolder);
                    CloneMainProfile();
                }

                if (GUILayout.Button("Cancel"))
                {
                    cloneWindow.Close();
                }
            }

            // If there are no sub profiles, limit the max so the window isn't spawned too large
            if (subProfileActions.Count <= 0 || !AdvancedMode)
            {
                cloneWindow.minSize = MinWindowSizeBasic;
                cloneWindow.maxSize = MinWindowSizeBasic;
            }
            else
            {
                Vector2 minWindowSize = MinWindowSizeBasic;
                minWindowSize.y     = Mathf.Max(minWindowSize.y, subProfileActions.Count * SubProfileSizeMultiplier);
                cloneWindow.minSize = minWindowSize;
                cloneWindow.maxSize = minWindowSize;
            }

            Repaint();
        }