public void DoGen(Texture2D texture, Rect rect) { this.rect = rect; texturePath = AssetDatabase.GetAssetPath(texture); TextureImporter textureImporter = AssetImporter.GetAtPath(texturePath) as TextureImporter; textureImporter.isReadable = true; textureImporter.npotScale = TextureImporterNPOTScale.None; AssetDatabase.ImportAsset(texturePath); this.tex = AssetDatabase.LoadAssetAtPath <Texture2D>(texturePath); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); //binary texture binaryImage = BinaryImageFromTexture(tex); if (generateTexture) { string binaryImageAssetPath = EditorUtils.AppendFilePathSuffix(texturePath, binarySuffix); TextureFromBinaryImage(binaryImage, binaryImageAssetPath); } FixOnePointLink(binaryImage); //outline var outlineImage = OutlineFromBinaryImage(binaryImage); if (generateTexture) { string outlineImageAssetPath = EditorUtils.AppendFilePathSuffix(texturePath, outlineSuffix); TextureFromBinaryImage(outlineImage, outlineImageAssetPath); } CutMoreConnectLinked(binaryImage, outlineImage); CutTwoLoopLinked(binaryImage, outlineImage); if (generateTexture) { string binaryImageAssetPath = EditorUtils.AppendFilePathSuffix(texturePath, binarySuffix + "1"); TextureFromBinaryImage(binaryImage, binaryImageAssetPath); } if (generateTexture) { string outlineImageAssetPath = EditorUtils.AppendFilePathSuffix(texturePath, outlineSuffix + "1"); TextureFromBinaryImage(outlineImage, outlineImageAssetPath); } //GetPath Paths paths = GetPaths(outlineImage); Debug.LogError("Path Count:" + paths.Count); //Merge Loop MergeMultiLoop(paths); AssetDatabase.Refresh(); //cut simplify }