/// <summary> /// Processes custom versions created by code in assembly. /// </summary> /// <param name="moduleDef">The module definition.</param> /// <param name="versions">The versions.</param> /// <param name="buildTime">The build time.</param> /// <returns></returns> private bool ProcessCustomVersion(ModuleDefMD moduleDef, IList <VS_VERSIONINFO> versions, DateTime buildTime) { const string assemblyTypeName = "Assembly"; var assemblyTypeDef = moduleDef.Types.SingleOrDefault(t => t.FullName == assemblyTypeName); if (assemblyTypeDef == null) { return(false); } bool updated = false; using (var customModule = ModuleUtility.CreateModule()) { assemblyTypeDef.Copy(customModule); // disabled for now... I need to figure out the problem with PDB moduleDef.Types.Remove(assemblyTypeDef); var customAssembly = customModule.Load(); var assemblyType = customAssembly.GetType(assemblyTypeName); // first of all, try to get at least a version var version = GetVersion(assemblyType, "GetVersion", buildTime); if (version == null) { return(false); } var literalVersion = version.ToString(); // now we can try to get file and product versions // ...files... var literalFileVersion = GetLiteralVersion(assemblyType, "GetFileVersion", buildTime) ?? literalVersion; Version fileVersion; Version.TryParse(literalFileVersion, out fileVersion); // ...product... var literalProductVersion = GetLiteralVersion(assemblyType, "GetProductVersion", buildTime) ?? literalFileVersion; Version productVersion; Version.TryParse(literalProductVersion, out productVersion); // Assembly version if (moduleDef.Assembly.Version != version) { moduleDef.Assembly.Version = version; updated = true; } updated = SetVersionString(versions, "Assembly Version", literalVersion) || updated; // File version updated = SetAssemblyAttribute(moduleDef, typeof(AssemblyFileVersionAttribute), literalFileVersion) || updated; updated = SetVersionString(versions, "FileVersion", literalFileVersion) || updated; updated = versions.Select(v => SetFileVersionDWORD(v, fileVersion)).AnyOfAll() || updated; // Product version updated = SetAssemblyAttribute(moduleDef, typeof(AssemblyInformationalVersionAttribute), literalProductVersion) || updated; updated = SetVersionString(versions, "ProductVersion", literalProductVersion) || updated; updated = versions.Select(v => SetProductVersionDWORD(v, productVersion)).AnyOfAll() || updated; } return(updated); }
/// <summary> /// 利用Prefs获取当前输出目录 /// 如果获取输出目录拿到的模块id为空直接返回 /// 不为空则更改全局命名空间 /// </summary> private void UpdateOutputDirectory() { outputDirectory = EditorPrefs.GetString(OutputDirectoryPrefsKey); var moduleId = ModuleUtility.GetModuleId(outputDirectory); if (moduleId == null) { return; } globalNameSpace = moduleId; OnGlobalNameSpaceChanged(); }
void AutoGenerateSpriteSkinData(SpriteMetaData metaData) { //If bone data exist but skinning data doesn't exist, auto generate them if (metaData.spriteBone != null && metaData.spriteBone.Count > 0 && (metaData.vertices == null || metaData.vertices.Count == 0)) { var spriteMeshDataController = new SpriteMeshDataController(); var smd = new SpriteMeshData(); smd.spriteID = metaData.spriteID; smd.frame = metaData.rect; smd.pivot = metaData.pivot; smd.bones = ModuleUtility.CreateSpriteBoneData(metaData.spriteBone.ToArray(), Matrix4x4.TRS(metaData.rect.position, Quaternion.identity, Vector3.one)); spriteMeshDataController.spriteMeshData = smd; spriteMeshDataController.OutlineFromAlpha(new OutlineGenerator(), GetDataProvider <ITextureDataProvider>(), 0.05f, 200); spriteMeshDataController.Triangulate(new Triangulator()); spriteMeshDataController.Subdivide(new Triangulator(), 0.25f); spriteMeshDataController.CalculateWeights(new BoundedBiharmonicWeightsGenerator(), null, 0.01f); spriteMeshDataController.SortTrianglesByDepth(); List <Vertex2DMetaData> vmd = new List <Vertex2DMetaData>(smd.vertices.Count); foreach (var v in smd.vertices) { vmd.Add(new Vertex2DMetaData() { position = v.position - smd.frame.position, boneWeight = v.editableBoneWeight.ToBoneWeight(true) }); } List <Vector2Int> emd = new List <Vector2Int>(smd.edges.Count); foreach (var e in smd.edges) { emd.Add(new Vector2Int(e.index1, e.index2)); } metaData.vertices = vmd; metaData.indices = smd.indices.ToArray(); metaData.edges = emd.ToArray(); } }
private List <SpriteBoneData> CreateBones() { SpriteBone[] spriteBones = new SpriteBone[] { new SpriteBone() { name = "root", length = 1f, parentId = -1, position = Vector2.zero, rotation = Quaternion.identity }, new SpriteBone() { name = "bone 0", length = 1f, parentId = 0, position = Vector2.right, rotation = Quaternion.identity } }; return(ModuleUtility.CreateSpriteBoneData(spriteBones, Matrix4x4.identity)); }
public void ConvertBoneMetadataToTextureSpace_RegardlessOfOrder(SpriteBone[] original, List <Vector2> expectedPositions, List <Vector2> expectedEndPosition) { List <SpriteBoneData> spriteBoneData = ModuleUtility.CreateSpriteBoneData(original, Matrix4x4.identity); VerifyApproximatedSpriteBones(spriteBoneData, expectedPositions, expectedEndPosition); }
/// <summary> /// 获取当前命名空间是否在核心目录下 /// </summary> private void TryCloseAutoAddIfPrecompile() { requireAddIfPrecompile = !ModuleUtility.IsCoreModule(globalNameSpace); }