static private PrefabBuildInfo GetPrefabBuildInfo(PrefabBuilder builder, Model.NodeData node, BuildTarget target, string groupKey) { var prefabCacheDir = FileUtility.EnsureCacheDirExists(target, node, PrefabBuilder.kCacheDirName); var buildInfoPath = FileUtility.PathCombine(prefabCacheDir, groupKey + ".asset"); return(AssetDatabase.LoadAssetAtPath <PrefabBuildInfo>(buildInfoPath)); }
public override Node Clone(Model.NodeData newData) { var newNode = new PrefabBuilder(); newNode.m_instance = new SerializableMultiTargetInstance(m_instance); newNode.m_replacePrefabOptions = m_replacePrefabOptions; newNode.m_outputDir = new SerializableMultiTargetString(m_outputDir); newNode.m_outputOption = new SerializableMultiTargetInt(m_outputOption); newData.AddDefaultInputPoint(); newData.AddDefaultOutputPoint(); return(newNode); }
static public void SavePrefabBuildInfo(string buildPath, PrefabBuilder builder, Model.NodeData node, BuildTarget target, string groupKey, List <AssetReference> assets) { var prefabCacheDir = FileUtility.EnsureCacheDirExists(target, node, PrefabBuilder.kCacheDirName); var buildInfoPath = FileUtility.PathCombine(prefabCacheDir, groupKey + ".asset"); var version = PrefabBuilderUtility.GetPrefabBuilderVersion(builder.Builder.ClassName); var buildInfo = ScriptableObject.CreateInstance <PrefabBuildInfo>(); buildInfo.Initialize(buildPath, groupKey, builder.Builder.ClassName, builder.Builder[target], version, builder.Options, assets); AssetDatabase.CreateAsset(buildInfo, buildInfoPath); }
static public bool DoesPrefabNeedRebuilding(string buildPath, PrefabBuilder builder, Model.NodeData node, BuildTarget target, string groupKey, List <AssetReference> assets) { var buildInfo = GetPrefabBuildInfo(builder, node, target, groupKey); // need rebuilding if no buildInfo found if (buildInfo == null) { return(true); } // need rebuilding if build path is changed if (buildInfo.m_buildDir != buildPath) { return(true); } // need rebuilding if given builder is changed if (buildInfo.m_builderClass != builder.Builder.ClassName) { return(true); } // need rebuilding if given builder is changed if (buildInfo.m_instanceData != builder.Builder[target]) { return(true); } // need rebuilding if replace prefab option is changed if (buildInfo.m_replacePrefabOptions != (int)builder.Options) { return(true); } var builderVersion = PrefabBuilderUtility.GetPrefabBuilderVersion(builder.Builder.ClassName); // need rebuilding if given builder version is changed if (buildInfo.m_prefabBuilderVersion != builderVersion) { return(true); } // need rebuilding if given groupKey changed if (buildInfo.m_groupKey != groupKey) { return(true); } if (!Enumerable.SequenceEqual( buildInfo.m_usedAssets.Select(v => v.importFrom).OrderBy(s => s), assets.Select(v => v.importFrom).OrderBy(s => s))) { return(true); } // If any asset is modified from last time, then need rebuilding foreach (var usedAsset in buildInfo.m_usedAssets) { if (usedAsset.IsAssetModifiedFromLastTime) { return(true); } } return(false); }
public static bool DoesPrefabNeedRebuilding(string buildPath, PrefabBuilder builder, Model.NodeData node, BuildTarget target, string groupKey, List <AssetReference> assets, PrefabCreateDescription createDescription) { var buildInfo = GetPrefabBuildInfo(builder, node, target, groupKey); // need rebuilding if no buildInfo found if (buildInfo == null) { return(true); } // need rebuilding if build path is changed if (buildInfo.m_buildDir != buildPath) { return(true); } // need rebuilding if given builder is changed if (buildInfo.m_builderClass != builder.Builder.ClassName) { return(true); } // need rebuilding if given builder is changed if (buildInfo.m_instanceData != builder.Builder[target]) { return(true); } var builderVersion = PrefabBuilderUtility.GetPrefabBuilderVersion(builder.Builder.ClassName); // need rebuilding if given builder version is changed if (buildInfo.m_prefabBuilderVersion != builderVersion) { return(true); } // need rebuilding if given groupKey changed if (buildInfo.m_groupKey != groupKey) { return(true); } var hash1 = MD5.Create(); assets.ForEach(a => hash1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(a.importFrom))); createDescription.additionalAssetPaths.ForEach(path => hash1.ComputeHash(System.Text.Encoding.UTF8.GetBytes(path))); if (buildInfo.m_usedAssetsHash != hash1.ToString()) { return(true); } // If any asset is modified from last time, then need rebuilding foreach (var usedAsset in buildInfo.m_usedAssets) { if (usedAsset.IsAssetModifiedFromLastTime) { return(true); } } return(false); }