Esempio n. 1
0
 private void UpdateAssetCollection()
 {
     if (_assetCollection == null || !AssetDatabase.Contains(_assetCollection))
     {
         _assetCollection = AssetCollection.Create(this).SetName("Asset Collection");
         var assetCollectionPath = GetAssetPath(_assetCollection.name, null, "asset");
         AssetUtility.CreatePathFolders(assetCollectionPath);
         AssetDatabase.CreateAsset(_assetCollection, assetCollectionPath);
     }
     else
     {
         // Check the asset collection's current path, to see if it's already in the right place.
         var currentPath         = AssetUtility.GetProjectRelativeAssetPath(_assetCollection);
         var assetCollectionPath = GetAssetPath(_assetCollection.name, null, "asset");
         if (currentPath != assetCollectionPath)
         {
             // Move the old asset to the new location.
             AssetUtility.CreatePathFolders(assetCollectionPath);
             var errorMessage = AssetDatabase.MoveAsset(currentPath, assetCollectionPath);
             if (!string.IsNullOrEmpty(errorMessage))
             {
                 throw new System.InvalidOperationException(errorMessage);
             }
         }
     }
 }
Esempio n. 2
0
        protected void OnEnable()
        {
            if (_assetCollection != null && !ReferenceEquals(_assetCollection.executive, this))
            {
                // Generator executive asset was copied; all generated assets should be detached.
                foreach (var generator in _generators)
                {
                    foreach (var output in generator.activeOutputs)
                    {
                        output.ForgetAsset();
                    }
                }

                _assetCollection = null;
            }
        }