コード例 #1
0
 internal AddressableAssetEntry(string guid, string address, AddressableAssetGroup parent, bool readOnly)
 {
     m_GUID        = guid;
     m_Address     = address;
     m_ReadOnly    = readOnly;
     parentGroup   = parent;
     IsInResources = false;
     IsInSceneList = false;
 }
コード例 #2
0
 internal AddressableAssetEntry(string guid, string address, AddressableAssetGroup parent, bool readOnly)
 {
     if (guid.Length > 0 && address.Contains("[") && address.Contains("]"))
     {
         Debug.LogErrorFormat("Address '{0}' cannot contain '[ ]'.", address);
     }
     m_GUID        = guid;
     m_Address     = address;
     m_ReadOnly    = readOnly;
     parentGroup   = parent;
     IsInResources = false;
     IsInSceneList = false;
 }
コード例 #3
0
 /// <summary>
 /// Applies schema values for the group to the schema values found in the template
 /// </summary>
 /// <param name="group">The AddressableAssetGroup to apply the schema settings to</param>
 public void ApplyToAddressableAssetGroup(AddressableAssetGroup group)
 {
     foreach (AddressableAssetGroupSchema schema in group.Schemas)
     {
         List <Preset> presets = SchemaPresetObjects;
         foreach (Preset p in presets)
         {
             Assert.IsNotNull(p);
             if (p.CanBeAppliedTo(schema))
             {
                 p.ApplyTo(schema);
                 schema.Group = group;
             }
         }
     }
 }
コード例 #4
0
        public override void Prepare(BuildTarget target,
                                     Model.NodeData node,
                                     IEnumerable <PerformGraph.AssetGroups> incoming,
                                     IEnumerable <Model.ConnectionData> connectionsToOutput,
                                     PerformGraph.Output Output)
        {
            if (!AddressableAssetSettingsDefaultObject.SettingsExists)
            {
                throw new NodeException("Addressable Asset Settings not found.", "Create Addressable Asset Settings object from Addressables window.");
            }

            if (string.IsNullOrEmpty(m_groupGuid))
            {
                throw new NodeException($"No valid Asset Group is selected.", "Configure valid Asset Group from inspector.");
            }

            var settings = AddressableAssetSettingsDefaultObject.GetSettings(false);

            m_group = settings.FindGroup(g => g.Guid == m_groupGuid);
            if (m_group == null)
            {
                throw new NodeException($"Asset Group '{m_groupGuid}' not found.", "Reselect valid Asset Group from inspector.");
            }

            if (Output != null)
            {
                var dst = (connectionsToOutput == null || !connectionsToOutput.Any())?
                          null : connectionsToOutput.First();

                if (incoming != null)
                {
                    foreach (var ag in incoming)
                    {
                        Output(dst, ag.assetGroups);
                    }
                }
                else
                {
                    Output(dst, new Dictionary <string, List <AssetReference> >());
                }
            }
        }
コード例 #5
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Addressable Asset Group: Configure Asset Group for Addressable System.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            if (!AddressableAssetSettingsDefaultObject.SettingsExists)
            {
                EditorGUILayout.HelpBox("To work with this node, create Addressable Asset Settings object from Addressables window first.", MessageType.Warning);
                return;
            }

            var settings = AddressableAssetSettingsDefaultObject.GetSettings(false);

            if (!string.IsNullOrEmpty(m_groupGuid))
            {
                m_group = settings.FindGroup(g => g.Guid == m_groupGuid);
            }

            var groupNames = settings.groups.Where(g => !g.ReadOnly).Select(g => g.Name).ToArray();

            var selectedIndex = Array.IndexOf(groupNames, m_group == null ? string.Empty : m_group.Name);

            var newIndex = EditorGUILayout.Popup("Group", selectedIndex, groupNames);

            if (newIndex != selectedIndex)
            {
                var newGroup = settings.FindGroup(g => g.Name == groupNames[newIndex]);

                m_group     = newGroup;
                m_groupGuid = newGroup.Guid;

                onValueChanged();
            }
        }
        internal static bool SafeMoveResourcesToGroup(AddressableAssetSettings settings, AddressableAssetGroup targetGroup, List <string> paths, List <string> guids)
        {
            if (guids == null || guids.Count == 0 || paths == null || guids.Count != paths.Count)
            {
                Debug.LogWarning("No valid Resources found to move");
                return(false);
            }

            if (targetGroup == null)
            {
                Debug.LogWarning("No valid group to move Resources to");
                return(false);
            }

            Dictionary <string, string> guidToNewPath = new Dictionary <string, string>();

            var message = "Any assets in Resources that you wish to mark as Addressable must be moved within the project. We will move the files to:\n\n";

            for (int i = 0; i < guids.Count; i++)
            {
                var newName = paths[i].Replace("\\", "/");
                newName = newName.Replace("Resources", "Resources_moved");
                newName = newName.Replace("resources", "resources_moved");
                if (newName == paths[i])
                {
                    continue;
                }

                guidToNewPath.Add(guids[i], newName);
                message += newName + "\n";
            }
            message += "\nAre you sure you want to proceed?";
            if (EditorUtility.DisplayDialog("Move From Resources", message, "Yes", "No"))
            {
                settings.MoveAssetsFromResources(guidToNewPath, targetGroup);
                return(true);
            }
            return(false);
        }
        internal static bool SafeMoveResourcesToGroup(AddressableAssetSettings settings, AddressableAssetGroup targetGroup, List <string> paths)
        {
            var guids = new List <string>();

            foreach (var p in paths)
            {
                guids.Add(AssetDatabase.AssetPathToGUID(p));
            }
            return(SafeMoveResourcesToGroup(settings, targetGroup, paths, guids));
        }
コード例 #8
0
 /// <summary>
 /// Override this method to perform post creation initialization.
 /// </summary>
 /// <param name="group">The group that the schema is added to.</param>
 protected virtual void OnSetGroup(AddressableAssetGroup group)
 {
 }
コード例 #9
0
        internal void OnGUI(AddressableAssetGroup parent)
        {
            List <string> keys = new List <string>(Keys); //copy key list to avoid dictionary errors.

            foreach (var key in keys)
            {
                var itemType = m_EntryMap[key].GetType();
                if (itemType == typeof(string))
                {
                    string currValue = m_EntryMap[key].ToString();
                    var    newValue  = ProfilesEditor.ValueGUILayout(parent.Settings, key, currValue);
                    if (newValue != currValue)
                    {
                        SetDataFromString(key, newValue);
                    }
                }
                else
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(key);
                    //do custom UI for type...
                    if (itemType.IsEnum)
                    {
                        var currValue = m_EntryMap[key] as Enum;
                        var newValue  = EditorGUILayout.EnumPopup(currValue);
                        if (currValue == null || !currValue.Equals(newValue))
                        {
                            SetData(key, newValue);
                        }
                    }
                    else if (itemType.IsPrimitive)
                    {
                        var currValue = m_EntryMap[key];
                        if (itemType == typeof(bool))
                        {
                            var newValue = EditorGUILayout.Toggle((bool)currValue);
                            if (newValue != (bool)currValue)
                            {
                                SetData(key, newValue);
                            }
                        }
                        else if (itemType == typeof(int))
                        {
                            var newValue = EditorGUILayout.IntField((int)currValue);
                            if (newValue != (int)currValue)
                            {
                                SetData(key, newValue);
                            }
                        }
                        else if (itemType == typeof(float))
                        {
                            var newValue = EditorGUILayout.FloatField((float)currValue);
                            if (newValue != (float)currValue)
                            {
                                SetData(key, newValue);
                            }
                        }
                        else
                        {
                            var newValue = EditorGUILayout.DelayedTextField(currValue.ToString());
                            if (newValue != currValue.ToString())
                            {
                                SetDataFromString(key, newValue);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
        }
コード例 #10
0
 public abstract bool BeforeSetEntryOnInspectorGUI(string assetPath, out AddressableAssetGroup assetGroup, out string address);