Exemple #1
0
 public override void Initialize(Model.NodeData data)
 {
     m_path  = new SerializableMultiTargetString();
     m_style = AssertionStyle.AllowOnlyAssetsUnderAssertionPath;
     data.AddDefaultInputPoint();
     data.AddDefaultOutputPoint();
 }
Exemple #2
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new Imported();

            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #3
0
        //public override void Prepare (BuildTarget target,
        //	Model.NodeData node,
        //	IEnumerable<PerformGraph.AssetGroups> incoming,
        //	IEnumerable<Model.ConnectionData> connectionsToOutput,
        //	PerformGraph.Output Output)
        //{
        //	ValidateLoadPath(
        //		m_loadPath[target],
        //		GetLoaderFullLoadPath(target),
        //		() => {
        //			//can be empty
        //			//throw new NodeException(node.Name + ": Load Path is empty.", node.Id);
        //		},
        //		() => {
        //			throw new NodeException(node.Name + ": Directory not found: " + GetLoaderFullLoadPath(target), node.Id);
        //		}
        //	);

        //	Load(target, node, connectionsToOutput, Output);
        //}

        void Load(BuildTarget target,
                  Model.NodeData node,
                  IEnumerable <Model.ConnectionData> connectionsToOutput,
                  PerformGraph.Output Output)
        {
            if (connectionsToOutput == null || Output == null)
            {
                return;
            }

            // SOMEWHERE_FULLPATH/PROJECT_FOLDER/Assets/
            var assetsFolderPath = Application.dataPath + Model.Settings.UNITY_FOLDER_SEPARATOR;

            var outputSource    = new List <AssetReference>();
            var targetFilePaths = FileUtility.GetAllFilePathsInFolder(GetLoaderFullLoadPath(target));

            foreach (var targetFilePath in targetFilePaths)
            {
                // already contained into Assets/ folder.
                // imported path is Assets/SOMEWHERE_FILE_EXISTS.
                if (targetFilePath.StartsWith(assetsFolderPath))
                {
                    var relativePath = targetFilePath.Replace(assetsFolderPath, Model.Settings.Path.ASSETS_PATH);

                    if (TypeUtility.IsGraphToolSystemAsset(relativePath))
                    {
                        continue;
                    }

                    var r = AssetReferenceDatabase.GetReference(relativePath);

                    if (r == null)
                    {
                        continue;
                    }

                    if (!TypeUtility.IsLoadingAsset(r))
                    {
                        continue;
                    }

                    if (r != null)
                    {
                        outputSource.Add(r);
                    }
                    continue;
                }

                throw new NodeException(node.Name + ": Invalid Load Path. Path must start with Assets/", node.Name);
            }

            var output = new Dictionary <string, List <AssetReference> > {
                { "0", outputSource }
            };

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

            Output(dst, output);
        }
Exemple #4
0
        private AssetImporter GetReferenceAssetImporter(Model.NodeData node, bool allowCustom)
        {
            if (allowCustom)
            {
                if (m_useCustomSettingAsset)
                {
                    if (CustomSettingAsset != null)
                    {
                        var path = AssetDatabase.GUIDToAssetPath(CustomSettingAssetGuid);
                        return(AssetImporter.GetAtPath(path));
                    }
                    return(null);
                }
            }

            var sampleFileDir = FileUtility.PathCombine(Model.Settings.Path.ImporterSettingsPath, node.Id);

            UnityEngine.Assertions.Assert.IsTrue(Directory.Exists(sampleFileDir));

            var sampleFiles = FileUtility.GetFilePathsInFolder(sampleFileDir)
                              .Where(path => !path.EndsWith(Model.Settings.UNITY_METAFILE_EXTENSION))
                              .ToList();

            UnityEngine.Assertions.Assert.IsTrue(sampleFiles.Count == 1);

            return(AssetImporter.GetAtPath(sampleFiles[0]));
        }
        private void UpdateVariant(Model.NodeData n, Variant variant)
        {
            Model.ConnectionPointData p = n.InputPoints.Find(v => v.Id == variant.ConnectionPointId);
            UnityEngine.Assertions.Assert.IsNotNull(p);

            p.Label = variant.Name;
        }
        private void AddVariant(Model.NodeData n, string name)
        {
            var p        = n.AddInputPoint(name);
            var newEntry = new Variant(name, p);

            m_variants.Add(newEntry);
            UpdateVariant(n, newEntry);
        }
Exemple #7
0
        public override void Initialize(Model.NodeData data)
        {
            m_groupSizeByte = new SerializableMultiTargetInt();
            m_groupingType  = new SerializableMultiTargetInt();

            data.AddDefaultInputPoint();
            data.AddDefaultOutputPoint();
        }
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new GroupingByFile();

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #9
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new Loader();

            newNode.m_loadPath = new SerializableMultiTargetString(m_loadPath);

            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #10
0
        public override void Initialize(Model.NodeData data)
        {
            m_groupingKeyword = new SerializableMultiTargetString(Model.Settings.GROUPING_KEYWORD_DEFAULT);
            m_patternType     = new SerializableMultiTargetInt((int)GroupingPatternType.WildCard);
            m_allowSlash      = false;

            data.AddDefaultInputPoint();
            data.AddDefaultOutputPoint();
        }
Exemple #11
0
        public override void Initialize(Model.NodeData data)
        {
            //Take care of this with Initialize(NodeData)
            m_exportPath   = new SerializableMultiTargetString();
            m_exportOption = new SerializableMultiTargetInt();
            m_flattenDir   = new SerializableMultiTargetInt();

            data.AddDefaultInputPoint();
        }
Exemple #12
0
        public override void Initialize(Model.NodeData data)
        {
            if (m_loadPath == null)
            {
                m_loadPath = new SerializableMultiTargetString();
            }

            data.AddDefaultOutputPoint();
        }
        public override void Initialize(Model.NodeData data)
        {
            m_bundleNameTemplate = new SerializableMultiTargetString(Model.Settings.BUNDLECONFIG_BUNDLENAME_TEMPLATE_DEFAULT);
            m_useGroupAsVariants = false;
            m_variants           = new List <Variant>();

            data.AddDefaultInputPoint();
            data.AddDefaultOutputPoint();
        }
Exemple #14
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new AssertUnwantedAssetsInBundle();

            newNode.m_path  = new SerializableMultiTargetString(m_path);
            newNode.m_style = m_style;
            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #15
0
        public override void Initialize(Model.NodeData data)
        {
            m_spritePackingTagNameTemplate = new SerializableMultiTargetString("*");
            m_overwritePackingTag          = false;
            m_useCustomSettingAsset        = false;
            m_customSettingAssetGuid       = string.Empty;

            data.AddDefaultInputPoint();
            data.AddDefaultOutputPoint();
        }
        public void Import(V1.NodeData v1, Model.NodeData v2)
        {
            m_bundleNameTemplate = new SerializableMultiTargetString(v1.BundleNameTemplate);
            m_useGroupAsVariants = v1.BundleConfigUseGroupAsVariants;

            foreach (var v in v1.Variants)
            {
                m_variants.Add(new Variant(v.Name, v2.FindInputPoint(v.ConnectionPointId)));
            }
        }
Exemple #17
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new Label();

            newNode.m_label = m_label;

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #18
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new GroupingBySize();

            newNode.m_groupSizeByte = new SerializableMultiTargetInt(m_groupSizeByte);
            newNode.m_groupingType  = new SerializableMultiTargetInt(m_groupingType);

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #19
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new Grouping();

            newNode.m_groupingKeyword = new SerializableMultiTargetString(m_groupingKeyword);
            newNode.m_patternType     = new SerializableMultiTargetInt(m_patternType);
            newNode.m_allowSlash      = m_allowSlash;

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #20
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new Exporter();

            newNode.m_exportPath   = new SerializableMultiTargetString(m_exportPath);
            newNode.m_exportOption = new SerializableMultiTargetInt(m_exportOption);
            newNode.m_flattenDir   = new SerializableMultiTargetInt(m_flattenDir);

            newData.AddDefaultInputPoint();

            return(newNode);
        }
Exemple #21
0
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new ImportSetting();

            newNode.m_overwritePackingTag          = m_overwritePackingTag;
            newNode.m_spritePackingTagNameTemplate = new SerializableMultiTargetString(m_spritePackingTagNameTemplate);
            newNode.m_useCustomSettingAsset        = m_useCustomSettingAsset;
            newNode.m_customSettingAssetGuid       = m_customSettingAssetGuid;

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();
            return(newNode);
        }
Exemple #22
0
        public void ResetConfig(Model.NodeData node)
        {
            if (m_importerEditor != null)
            {
                UnityEngine.Object.DestroyImmediate(m_importerEditor);
                m_importerEditor = null;
            }
            m_useCustomSettingAsset = false;
            CustomSettingAssetGuid  = string.Empty;
            var sampleFileDir = FileUtility.PathCombine(Model.Settings.Path.ImporterSettingsPath, node.Id);

            FileUtility.RemakeDirectory(sampleFileDir);
        }
        public string GetBundleName(BuildTarget target, Model.NodeData node, string groupKey)
        {
            var bundleName = m_bundleNameTemplate[target];

            if (m_useGroupAsVariants)
            {
                return(bundleName.ToLower());
            }
            else
            {
                return(bundleName.Replace(Model.Settings.KEYWORD_WILDCARD.ToString(), groupKey).ToLower());
            }
        }
Exemple #24
0
        //public override void Prepare (BuildTarget target,
        //	Model.NodeData node,
        //	IEnumerable<PerformGraph.AssetGroups> incoming,
        //	IEnumerable<Model.ConnectionData> connectionsToOutput,
        //	PerformGraph.Output Output)
        //{
        //	Action<Type, Type, AssetReference> multipleAssetTypeFound = (Type expectedType, Type foundType, AssetReference foundAsset) => {
        //		throw new NodeException(string.Format("{3} :ImportSetting expect {0}, but different type of incoming asset is found({1} {2})",
        //			expectedType.FullName, foundType.FullName, foundAsset.fileNameAndExtension, node.Name), node.Id);
        //	};

        //	Action<Type> unsupportedType = (Type unsupported) => {
        //		throw new NodeException(string.Format("{0} :Incoming asset type is not supported by ImportSetting (Incoming type:{1}). Perhaps you want to use Modifier instead?",
        //			node.Name, (unsupported != null)?unsupported.FullName:"null"), node.Id);
        //	};

        //	Action<Type, Type> incomingTypeMismatch = (Type expectedType, Type incomingType) => {
        //		throw new NodeException(string.Format("{0} :Incoming asset type is does not match with this ImportSetting (Expected type:{1}, Incoming type:{2}).",
        //			node.Name, (expectedType != null)?expectedType.FullName:"null", (incomingType != null)?incomingType.FullName:"null"), node.Id);
        //	};
        //          Action customConfigIsNull = () => {
        //              throw new NodeException(string.Format("{0} :You must select custom setting asset.", node.Name), node.Id);
        //          };

        //	Action<ConfigStatus> errorInConfig = (ConfigStatus _) => {

        //		var firstAsset = TypeUtility.GetFirstIncomingAsset(incoming);

        //		if(firstAsset != null) {
        //			// give a try first in sampling file
        //			var configFilePath = FileUtility.GetImportSettingTemplateFilePath(firstAsset);
        //			SaveSampleFile(node, configFilePath);

        //			ValidateInputSetting(node, target, incoming, multipleAssetTypeFound, unsupportedType, incomingTypeMismatch, (ConfigStatus eType) => {
        //				if(eType == ConfigStatus.NoSampleFound) {
        //					throw new NodeException(node.Name + " :ImportSetting has no sampling file. Please configure it from Inspector.", node.Id);
        //				}
        //				if(eType == ConfigStatus.TooManySamplesFound) {
        //					throw new NodeException(node.Name + " :ImportSetting has too many sampling file. Please fix it from Inspector.", node.Id);
        //                      }
        //                  }, customConfigIsNull);
        //		}
        //	};

        //          ValidateInputSetting(node, target, incoming, multipleAssetTypeFound, unsupportedType, incomingTypeMismatch, errorInConfig, customConfigIsNull);

        //	// ImportSettings does not add, filter or change structure of group, so just pass given group of assets
        //	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>>());
        //		}
        //	}
        //}

        //public override void Build (BuildTarget target,
        //	Model.NodeData node,
        //	IEnumerable<PerformGraph.AssetGroups> incoming,
        //	IEnumerable<Model.ConnectionData> connectionsToOutput,
        //	PerformGraph.Output Output,
        //	Action<Model.NodeData, string, float> progressFunc)
        //{
        //	if(incoming != null){
        //		ApplyImportSetting(target, node, incoming);
        //	}
        //}

        private void SaveSampleFile(Model.NodeData node, string configFilePath)
        {
            var samplingDirectoryPath = FileUtility.PathCombine(Model.Settings.Path.ImporterSettingsPath, node.Id);

            if (!Directory.Exists(samplingDirectoryPath))
            {
                Directory.CreateDirectory(samplingDirectoryPath);
            }

            UnityEngine.Assertions.Assert.IsNotNull(configFilePath);
            var targetFilePath = FileUtility.PathCombine(samplingDirectoryPath, Path.GetFileName(configFilePath));

            FileUtility.CopyFile(configFilePath, targetFilePath);

            AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive);
        }
        public override Node Clone(Model.NodeData newData)
        {
            var newNode = new BundleConfigurator();

            newNode.m_bundleNameTemplate = new SerializableMultiTargetString(m_bundleNameTemplate);
            newNode.m_variants           = new List <Variant>(m_variants.Count);
            newNode.m_useGroupAsVariants = m_useGroupAsVariants;

            newData.AddDefaultInputPoint();
            newData.AddDefaultOutputPoint();

            foreach (var v in m_variants)
            {
                newNode.AddVariant(newData, v.Name);
            }

            return(newNode);
        }
Exemple #26
0
        private void ApplyImportSetting(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming)
        {
            var referenceImporter = GetReferenceAssetImporter(node, true);
            var configurator      = new ImportSettingsConfigurator(referenceImporter);

            foreach (var ag in incoming)
            {
                foreach (var groupKey in ag.assetGroups.Keys)
                {
                    var assets = ag.assetGroups[groupKey];
                    foreach (var asset in assets)
                    {
                        var  importer         = AssetImporter.GetAtPath(asset.importFrom);
                        bool importerModified = false;
                        if (!configurator.IsEqual(importer, m_overwritePackingTag))
                        {
                            configurator.OverwriteImportSettings(importer);
                            importerModified = true;
                        }
                        if (m_overwritePackingTag)
                        {
                            if (asset.filterType == typeof(UnityEditor.TextureImporter))
                            {
                                var textureImporter = AssetImporter.GetAtPath(asset.importFrom) as TextureImporter;
                                var newTagName      = GetTagName(target, groupKey);
                                if (textureImporter.spritePackingTag != newTagName)
                                {
                                    textureImporter.spritePackingTag = newTagName;
                                    importerModified = true;
                                }
                            }
                        }

                        if (importerModified)
                        {
                            importer.SaveAndReimport();
                            asset.TouchImportAsset();
                        }
                    }
                }
            }
        }
        private void ValidateVariantsProperlyConfiguired(
            Model.NodeData node,
            Dictionary <string, List <AssetReference> > output, Dictionary <string, List <string> > variantsInfo)
        {
            foreach (var bundleName in output.Keys)
            {
                if (!variantsInfo.ContainsKey(bundleName))
                {
                    continue;
                }
                List <string> variants = variantsInfo [bundleName];

                if (variants.Count < 2)
                {
                    throw new NodeException(node.Name + ":" + bundleName + " is not configured to create more than 2 variants.", node.Id);
                }

                List <AssetReference> assets = output [bundleName];

                List <AssetReference> variant0Assets = assets.Where(a => a.variantName == variants [0]).ToList();

                for (int i = 1; i < variants.Count; ++i)
                {
                    List <AssetReference> variantAssets = assets.Where(a => a.variantName == variants [i]).ToList();
                    if (variant0Assets.Count != variantAssets.Count)
                    {
                        throw new NodeException(node.Name + ":Variant mismatch found." + bundleName + " variant " + variants [0] + " and " + variants [i] + " do not match containing assets.", node.Id);
                    }

                    foreach (var a0 in variant0Assets)
                    {
                        if (!variantAssets.Any(a => a.fileName == a0.fileName))
                        {
                            throw new NodeException(node.Name + ":Variant mismatch found." + bundleName + " does not contain " + a0.fileNameAndExtension + " in variant " + variants [i], node.Id);
                        }
                    }
                }
            }
        }
Exemple #28
0
        public static ConfigStatus GetConfigStatus(Model.NodeData node)
        {
            var sampleFileDir = FileUtility.PathCombine(Model.Settings.Path.ImporterSettingsPath, node.Id);

            if (!Directory.Exists(sampleFileDir))
            {
                return(ConfigStatus.NoSampleFound);
            }

            var sampleFiles = FileUtility.GetFilePathsInFolder(sampleFileDir)
                              .Where(path => !path.EndsWith(Model.Settings.UNITY_METAFILE_EXTENSION))
                              .ToList();

            if (sampleFiles.Count == 0)
            {
                return(ConfigStatus.NoSampleFound);
            }
            if (sampleFiles.Count == 1)
            {
                return(ConfigStatus.GoodSampleFound);
            }

            return(ConfigStatus.TooManySamplesFound);
        }
Exemple #29
0
 public void Import(V1.NodeData v1, Model.NodeData v2)
 {
     m_loadPath = new SerializableMultiTargetString(v1.LoaderLoadPath);
 }
Exemple #30
0
 public void Import(V1.NodeData v1, Model.NodeData v2)
 {
     m_exportPath   = new SerializableMultiTargetString(v1.ExporterExportPath);
     m_exportOption = new SerializableMultiTargetInt(v1.ExporterExportOption);
     m_flattenDir   = new SerializableMultiTargetInt();
 }