/// <summary> /// Set default values taken from the assigned group. /// </summary> /// <param name="group">The group this schema has been added to.</param> protected override void OnSetGroup(AddressableAssetGroup group) { //this can happen during the load of the addressables asset if (group.Settings != null) { if (BuildPath == null || string.IsNullOrEmpty(BuildPath.GetValue(group.Settings))) { m_BuildPath = new ProfileValueReference(); BuildPath.SetVariableByName(group.Settings, AddressableAssetSettings.kLocalBuildPath); } if (LoadPath == null || string.IsNullOrEmpty(LoadPath.GetValue(group.Settings))) { m_LoadPath = new ProfileValueReference(); LoadPath.SetVariableByName(group.Settings, AddressableAssetSettings.kLocalLoadPath); } } if (m_AssetBundleProviderType.Value == null) { m_AssetBundleProviderType.Value = typeof(AssetBundleProvider); } if (m_BundledAssetProviderType.Value == null) { m_BundledAssetProviderType.Value = typeof(BundledAssetProvider); } }
public void BundledAssetGroupSchema_SetPathVariable_ProperlySetsReferenceOnPath() { AddressableAssetGroup group = null; ProfileValueReference pathValue = null; BundledAssetGroupSchema schema = null; try { Type[] types = new Type[] {}; group = m_Settings.CreateGroup("Group1", false, false, false, null, types); List <string> variableNames = new List <string>(); variableNames.Add("LocalBuildPath"); variableNames.Add(AddressableAssetSettings.kLocalBuildPath); schema = ScriptableObject.CreateInstance <BundledAssetGroupSchema>(); schema.SetPathVariable(group.Settings, ref pathValue, AddressableAssetSettings.kLocalBuildPath, "LocalBuildPath", variableNames); } finally { if (group != null) { m_Settings.RemoveGroupInternal(group, true, false); } if (schema != null) { ScriptableObject.DestroyImmediate(schema); } } }
internal void SetBundledAssetGroupSchemaPaths(AddressableAssetSettings settings, ProfileValueReference pvr, string newVariableName, string oldVariableName, List <string> variableNames) { if (variableNames.Contains(newVariableName)) { pvr.SetVariableByName(settings, newVariableName); } else if (variableNames.Contains(oldVariableName)) { pvr.SetVariableByName(settings, oldVariableName); } else { Debug.LogWarning("Default path variable " + newVariableName + " not found when initializing BundledAssetGroupSchema. Please manually set the path via the groups window."); } }
void DrawRemoteCatalogPaths() { ProfileValueReference BuildPath = m_AasTarget.RemoteCatalogBuildPath; ProfileValueReference LoadPath = m_AasTarget.RemoteCatalogLoadPath; AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings; if (settings == null) { return; } List <ProfileGroupType> groupTypes = ProfileGroupType.CreateGroupTypes(settings.profileSettings.GetProfile(settings.activeProfileId)); List <string> options = groupTypes.Select(group => group.GroupTypePrefix).ToList(); //set selected to custom options.Add(AddressableAssetProfileSettings.customEntryString); int?selected = options.Count - 1; HashSet <string> vars = settings.profileSettings.GetAllVariableIds(); if (vars.Contains(BuildPath.Id) && vars.Contains(LoadPath.Id) && !m_UseCustomPaths) { for (int i = 0; i < groupTypes.Count; i++) { ProfileGroupType.GroupTypeVariable buildPathVar = groupTypes[i].GetVariableBySuffix("BuildPath"); ProfileGroupType.GroupTypeVariable loadPathVar = groupTypes[i].GetVariableBySuffix("LoadPath"); if (BuildPath.GetName(settings) == groupTypes[i].GetName(buildPathVar) && LoadPath.GetName(settings) == groupTypes[i].GetName(loadPathVar)) { selected = i; break; } } } if (selected.HasValue && selected != options.Count - 1) { m_UseCustomPaths = false; } else { m_UseCustomPaths = true; } EditorGUI.BeginChangeCheck(); var newIndex = EditorGUILayout.Popup("Build & Load Paths", selected.HasValue ? selected.Value : options.Count - 1, options.ToArray()); if (EditorGUI.EndChangeCheck() && newIndex != selected) { if (options[newIndex] != AddressableAssetProfileSettings.customEntryString) { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); BuildPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "BuildPath"); LoadPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "LoadPath"); m_UseCustomPaths = false; } else { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); m_UseCustomPaths = true; } EditorUtility.SetDirty(this); } if (m_UseCustomPaths) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogBuildPath"), m_RemoteCatBuildPath); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogLoadPath"), m_RemoteCatLoadPath); } EditorGUI.indentLevel++; m_ShowPaths = EditorGUILayout.Foldout(m_ShowPaths, "Path Preview", true); if (m_ShowPaths) { EditorStyles.helpBox.fontSize = 12; var baseBuildPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, BuildPath.Id); var baseLoadPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, LoadPath.Id); EditorGUILayout.HelpBox(String.Format("Build Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseBuildPathValue)), MessageType.None); EditorGUILayout.HelpBox(String.Format("Load Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseLoadPathValue)), MessageType.None); } EditorGUI.indentLevel--; }