/// <summary> /// Load all of the Basic mode profiles (located in the Default Profile Folder) /// </summary> /// <param name="rSetActive"></param> private void LoadBasicModeProfiles(bool rSetActive) { mBasicModeProfiles.Clear(); var lProfiles = AssetHelper.LoadAssets <CharacterWizardProfile>(DefaultProfileFolder) .OrderBy(x => x.Priority); foreach (var lProfile in lProfiles) { // Check required Motion Packs before adding to list if (lProfile.CheckRequiredMotionPacks()) { mBasicModeProfiles.Add(lProfile); } } if (rSetActive) { ActiveProfile = mBasicModeProfiles.FirstOrDefault(); } }
private void DrawBasicProfileOption(CharacterWizardProfile lProfile) { if (lProfile == null) { return; } try { EditorGUILayout.BeginVertical(ProfileOptionBoxStyle); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button(new GUIContent(lProfile.Image, lProfile.Description), ProfileButtonStyle)) { ActiveProfile = lProfile; if (CanBuild) { this.StartCoroutine(CreateCharacter()); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUILayout.LabelField(lProfile.DisplayText.Trim(), ProfileLabelStyle); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); } finally { EditorGUILayout.EndVertical(); } }
/// <summary> /// Create a copy of this profile at the specified path /// </summary> /// <param name="rNewPath"></param> /// <returns></returns> public CharacterWizardProfile Copy(string rNewPath = "") { CharacterWizardProfile lCopiedProfile = null; try { string lNewPath = string.IsNullOrEmpty(rNewPath) ? AssetHelper.GetNewAssetPath(AssetPath) : AssetHelper.GetNewAssetPath(rNewPath); if (!lNewPath.EndsWith(".asset")) { lNewPath += ".asset"; } if (!File.Exists(lNewPath)) { AssetDatabase.CopyAsset(AssetPath, lNewPath); } lCopiedProfile = AssetDatabase.LoadAssetAtPath <CharacterWizardProfile>(lNewPath); if (lCopiedProfile != null) { // Ensure that the copied profile is set up for user editing lCopiedProfile.ReadOnly = false; lCopiedProfile.Priority = PriorityStatus.User; lCopiedProfile._Renamed = false; } return(lCopiedProfile); } catch (IOException ex) { Debug.LogException(ex); } return(lCopiedProfile); }
/// <summary> /// Draw the Profile selection controls within the Profile section UI /// </summary> private void DrawProfileSelect() { if (ActiveProfile != null && ActiveProfile.ReadOnly) { EditorHelper.DrawInspectorDescription("The selected profile does not allow editing. Press the 'Copy' button" + " to make a duplicate for editing"); } if (ActiveProfile != null && !ActiveProfile.HasRequiredPacks) { EditorHelper.DrawInspectorDescription("One or more of the Motion Packs used by this profile are missing. " + "Select the profile's asset directly in the Project View to edit these requirements.\n\n" + "You may still proceed with setting up a character without the missing Motion Packs.", MessageType.Warning); } try { EditorGUILayout.BeginHorizontal(); if (EditorHelper.ScriptableObjectField("Profile", "The Character Wizard Profile to use for creating this character.", ActiveProfile, typeof(CharacterWizardProfile), this)) { ActiveProfile = (CharacterWizardProfile)EditorHelper.FieldObjectValue; OnActiveProfileChanged(true); } GUILayout.Space(10); EditorGUI.BeginDisabledGroup(ActiveProfile == null); if (GUILayout.Button("Copy", SmallButtonStyle, GUILayout.Width(60))) { // Create a copy of the current profile if (ActiveProfile != null) { ActiveProfile = (ActiveProfile.Priority == CharacterWizardProfile.PriorityStatus.User) ? ActiveProfile.Copy() : ActiveProfile.Copy(DefaultCustomProfileFolder + ActiveProfile.FileName); OnActiveProfileChanged(true); } } EditorGUI.EndDisabledGroup(); GUILayout.Space(10); if (GUILayout.Button("New", SmallButtonStyle, GUILayout.Width(60))) { // Create a new profile ActiveProfile = CharacterWizardProfile.Create(DefaultCustomProfileFolder + NewProfileName); OnActiveProfileChanged(true); } GUILayout.Space(10); } finally { EditorGUILayout.EndHorizontal(); } if (ActiveProfile != null && !ActiveProfile.ReadOnly) { EditorGUILayout.HelpBox( "Changing the profile name will also rename the asset file in your project. " + "The change will not take effect until you press Enter or focus on another input field.", MessageType.Info); GUILayout.Space(5); if (EditorHelper.DelayedTextField("Profile Name", "Enter a new name for the profile. This will rename the profile's .asset file.", ActiveProfile.name, this)) { if (!string.IsNullOrEmpty(EditorHelper.FieldStringValue)) { ActiveProfile.Rename(EditorHelper.FieldStringValue, true); OnActiveProfileChanged(true); } } } }
/// <summary> /// Load a stored profile and set it to the Active Profile /// </summary> private void UseStoredProfile() { ActiveProfile = CharacterWizardProfile.LoadFromStoredPath(PrefsKey.ActiveProfile); OnActiveProfileChanged(true); }
/// <summary> /// Load a profile at the specified path /// </summary> /// <param name="rPath"></param> /// <returns></returns> public static CharacterWizardProfile Load(string rPath) { CharacterWizardProfile lProfile = AssetDatabase.LoadAssetAtPath <CharacterWizardProfile>(rPath); return(lProfile); }