private void OnDisable() { Debug.Log("im disabled"); TemplateImage.setBackColor(); TemplateImage.setAllNormalAlpha(); foreach (UPAImage image in animation) { image.setAllNormalAlpha(); } CurrentImg.layers[CurrentImg.selectedLayer].setMappedColorsBack(); }
public static List <UPAImage> OpenAnimationsFromFolder(bool isTemplate, string path = "") { if (path.Length == 0) { path = EditorUtility.OpenFolderPanel( "Choose Animation Folder", "Assets/Sprites", ""); } if (path.Length != 0) { List <UPAImage> animation = new List <UPAImage>(); DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] info = dir.GetFiles("*.asset"); Debug.Log("length = " + info.Length); if (info.Length > 0) { Debug.Log("info length greator than 0"); Debug.Log(path); //We have some asset files, so lets load those in, instead of creating new ones //TODO: i dont know if these frames are loaded in order, may need to sort for (int i = 0; i < info.Length; i++) { string newPath; newPath = path + "/" + (i + 1) + ".asset"; newPath = FileUtil.GetProjectRelativePath(newPath); Debug.Log("expected path = Assets / Sprites / Front RunTest / 1.asset"); Debug.Log("new path = "); //newPath = "Assets/Sprites/Front RunTest/1"; Debug.Log(newPath); UPAImage frameImage = OpenFrameAtPath(newPath); frameImage.LoadAllTexsFromMaps(); frameImage.setAllNormalAlpha(); //frameImage.initilizeAlphas(); animation.Add(frameImage); } } else { info = dir.GetFiles("*.png"); List <FileInfo[]> frames = sortFrames(info); int frameNumber = 1; foreach (FileInfo[] frame in frames) { string newPath = path + "\\" + frameNumber + ".asset"; UPAImage i = loadImageFromFileInfo(frame, isTemplate, newPath); i.initilizeAlphas(); animation.Add(i); frameNumber += 1; } } UPAImage img = animation[0]; Debug.Log(img.GetType()); EditorPrefs.SetString("currentAnimationPath", path); UPAEditorWindow.CurrentImg = img; if (UPAEditorWindow.window != null) { UPAEditorWindow.window.Repaint(); } else { UPAEditorWindow.Init(); } return(animation); } return(null); }