Exemplo n.º 1
0
 internal void UpdateGroup(ABGroup group)
 {
     if (group != null)
     {
         _currentGroup = group;
         Refresh();
     }
 }
Exemplo n.º 2
0
 internal void UpdateGroup(ABGroup group)
 {
     if (group != null)
     {
         _currentGroup = group;
         _assetTreeView.SetFocusAndEnsureSelectedItem();
         _assetTreeView.UpdateGroup(group);
         _currentAsset = null;
     }
 }
Exemplo n.º 3
0
 internal ABAsset CreateAndAddToCollection(UnityEngine.Object assetObject, ABGroup group)
 {
     if (IsCreateAndAddToCollectionValid(assetObject, group))
     {
         ABAsset asset = new ABAsset(assetObject);
         group.Items.Add(asset);
         SaveGroup(group);
         return(asset);
     }
     throw new Exception("Ассет не создался из-за ошибок");
 }
Exemplo n.º 4
0
        protected internal ABGroup InitialSetup(ABGroup createdObj)
        {
            if (createdObj == null)
            {
                throw new NullReferenceException("GroupAssetBundles is null");
            }
            createdObj.Name      = $"newGroup{Settings.Items.Count}";
            createdObj.Version   = "1";
            createdObj.BuildPath = createdObj.LocalLoadPath = createdObj.RemoteLoadPath = createdObj.Name;

            return(createdObj);
        }
 internal void SaveGroup(ABGroup group, bool isSaveAssets = false)
 {
     if (group == null)
     {
         Debug.LogWarning($"Сохранение группы {group.Name} не произошло, т.к он является null");
         return;
     }
     EditorUtility.SetDirty(group);
     if (isSaveAssets)
     {
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
     }
 }
Exemplo n.º 6
0
        internal ABGroup Create()
        {
            if (Settings == null)
            {
                throw new FileNotFoundException("Settings is not found", ABNames.FileSettings);
            }
            if (!Directory.Exists(ABPaths.GroupsDirectoryPath))
            {
                AssetDatabase.CreateFolder(ABPaths.MainDirecctoryPath, ABNames.Groups);
            }
            ABGroup newGroup = ScriptableObject.CreateInstance <ABGroup>();

            AssetDatabase.CreateAsset(newGroup, Path.Combine(ABPaths.GroupsDirectoryPath, $"newGroup{Settings.Items.Count}.asset"));
            Settings.Items.Add(newGroup);
            return(InitialSetup(newGroup));
        }
Exemplo n.º 7
0
 internal void Delete(ABAsset asset, ABGroup group)
 {
     if (Settings == null)
     {
         throw new FileNotFoundException("Settings is not found", ABNames.FileSettings);
     }
     if (asset == null)
     {
         throw new ArgumentNullException("SimpleAsset", "SimpleAsset is null");
     }
     if (group == null)
     {
         throw new ArgumentNullException("GroupAssetBundlesParent", "GroupAssetBundlesParent is null");
     }
     group.Items.Remove(asset);
     SaveGroup(group);
 }
Exemplo n.º 8
0
        internal void Delete(ABGroup group)
        {
            if (Settings == null)
            {
                throw new FileNotFoundException("Settings is not found", ABNames.FileSettings);
            }
            string assetPath = AssetDatabase.GetAssetPath(group);

            if (string.IsNullOrEmpty(assetPath))
            {
                throw new FileNotFoundException("Group is not found", group.name);
            }
            if (Settings.Items.Contains(group))
            {
                Settings.Items.Remove(group);
            }
            AssetDatabase.DeleteAsset(assetPath);
        }
Exemplo n.º 9
0
 private bool IsCreateAndAddToCollectionValid(UnityEngine.Object assetObject, ABGroup group)
 {
     if (Settings == null)
     {
         throw new FileNotFoundException("Settings is not found", ABNames.FileSettings);
     }
     if (assetObject == null)
     {
         throw new ArgumentNullException("AssetObject", "AssetObject is null");
     }
     if (group == null)
     {
         throw new ArgumentNullException("GroupAssetBundlesParent", "GroupAssetBundlesParent is null");
     }
     if (group.Items.Select(_asset => _asset.AssetObject).FirstOrDefault(obj => obj == assetObject) != null)
     {
         EditorGUIUtility.PingObject(assetObject);
         throw new ArgumentException("В этой группе уже есть этот ассет");
     }
     return(true);
     //throw new ArgumentException("Ассет не соответствует нужному типу");
 }
 public ABGroupTreeViewItem(ABGroup group, int depth) : base(group.Name.GetHashCode(), depth, group.Name)
 {
     Group = group;
 }
Exemplo n.º 11
0
 private void OnSelectGroup(ABGroup selectedGroup)
 {
     _currentGroup = selectedGroup;
     OnSelectABGroup?.Invoke(selectedGroup);
 }
Exemplo n.º 12
0
 private void SaveGroup(ABGroup group)
 {
     EditorUtility.SetDirty(group);
     AssetDatabase.SaveAssets();
 }
Exemplo n.º 13
0
        internal void BuildGroup(ABGroup group)
        {
            if (Settings == null)
            {
                throw new FileNotFoundException("Setttings not found", "ABSettings.asset");
            }
            if (group == null)
            {
                throw new NullReferenceException("SimpleGroupAssetBundles is null");
            }
            string           buildPath        = string.Empty;
            string           localLoadPath    = string.Empty;
            string           remoteLoadPath   = string.Empty;
            BuildTarget      buildTarget      = BuildTarget.StandaloneWindows;
            BuildTargetGroup buildTargetGroup = BuildTargetGroup.Standalone;

            if (group.IsCustomSettings)
            {
                buildPath        = group.BuildPath;
                localLoadPath    = group.LocalLoadPath;
                remoteLoadPath   = group.RemoteLoadPath;
                buildTarget      = group.BuildTarget;
                buildTargetGroup = group.BuildTargetGroup;
            }
            else
            {
                buildPath        = $"{Settings.BuildPath}/{group.BuildPath}";
                localLoadPath    = $"{Settings.LocalLoadPath}/{group.LocalLoadPath}";
                remoteLoadPath   = $"{Settings.RemoteLoadPath}/{group.RemoteLoadPath}";
                buildTarget      = Settings.BuildTarget;
                buildTargetGroup = Settings.BuildTargetGroup;
            }
            if (buildPath.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                throw new DirectoryNotFoundException("BuildPath invalid chars");
            }
            if (localLoadPath.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                throw new DirectoryNotFoundException("LocalLoadPath invalid chars");
            }
            if (remoteLoadPath.IndexOfAny(Path.GetInvalidPathChars()) != -1)
            {
                throw new DirectoryNotFoundException("LocalLoadPath invalid chars");
            }
            if (group.BundleBuilds == null || group.BundleBuilds.Count() <= 0)
            {
                Debug.LogWarning($"Бандлы для билда группы {group.Name} являются null или их нет. Билд этой группы не будет производиться");
                return;
            }
            if (!Directory.Exists(buildPath))
            {
                try
                {
                    Directory.CreateDirectory(buildPath);
                }
                catch (IOException ex)
                {
                    throw ex;
                    throw new IOException("Путь билда указывает на файл");
                }
                catch (NotSupportedException ex)
                {
                    throw ex;
                    throw new NotSupportedException("Путь билда содержит двоеточие (:), которое не является частью метки");
                }
            }
            _currentManifest                = new ABManifest();
            _currentManifest.Name           = group.Name;
            _currentManifest.Version        = group.Version;
            _currentManifest.LocalLoadPath  = localLoadPath;
            _currentManifest.RemoteLoadPath = remoteLoadPath;
            foreach (var item in group.BundleBuilds)
            {
                _currentManifest.Bundles.Add(new BundleInfo {
                    Name = item.assetBundleName
                });
            }
            var parameters = new BundleBuildParameters(buildTarget, buildTargetGroup, buildPath);

            parameters.BundleCompression = group.Compression;
            var buildContent = new BundleBuildContent(group.BundleBuilds);

            foreach (var item in buildContent.Assets)
            {
                _currentManifest.Assets.Add(new AssetInfo()
                {
                    Name = buildContent.Addresses[item],
                    Path = AssetDatabase.GUIDToAssetPath(item.ToString())
                });
            }
            foreach (var item in buildContent.Scenes)
            {
                _currentManifest.Scenes.Add(new AssetInfo()
                {
                    Name = buildContent.Addresses[item],
                    Path = AssetDatabase.GUIDToAssetPath(item.ToString())
                });
            }
            IBundleBuildResults results;
            var returnCode = ContentPipeline.BuildAssetBundles(parameters, buildContent, out results, new[] { new ArchiveAndCompressBundles() });

            if (returnCode == ReturnCode.Success)
            {
                string jsonContent = JsonUtility.ToJson(_currentManifest);
                using (var sw = File.CreateText(Path.Combine(buildPath, $"manifest-{group.Name}.json")))
                {
                    sw.Write(jsonContent);
                }
            }
        }
Exemplo n.º 14
0
 private void OnSelectGroup(ABGroup group)
 {
     _assetsBlock.UpdateGroup(group);
 }