ddionisio / MateAnimator

Adding more features to the open sourced Animator from Unity.
113 stars 29 forks source link

Patch for using 'Editor Default Resources' folder #1

Closed mulova closed 10 years ago

mulova commented 10 years ago

In advance, thank you for this good plugin. As you know, Animator Timeline editor resources are actually included in runtime. So please move 'Skins', 'TexturesEditor' folders in 'Editor Default Resources'. And change the AMEditorResources.GetDir(), LoadSkin(), LoadEditorTexture() method

public static GUISkin LoadSkin(string name) {
    if(skinsDir == null) skinsDir = GetDir(name + ".guiskin");
    return EditorGUIUtility.Load(string.Format("{0}{1}.guiskin", skinsDir, name)) as GUISkin;
}

public static Texture LoadEditorTexture(string name) {
    if(textureEditorDir == null) textureEditorDir = GetDir(name + ".png");
    return EditorGUIUtility.Load(string.Format("{0}{1}.png", textureEditorDir, name)) as Texture;
}

private static string GetDir(string filename) {
    string ret = "";
    string path = FindPath(filename, "Assets", true);
    if(path != null) {
        int lastInd = path.LastIndexOf('/');
        if(lastInd != -1) {
            ret = path.Substring(0, lastInd+1);
        }
    }
    int index = ret.IndexOf("Editor Default Resources/");
    if (index >= 0) {
            ret = ret.Substring(index+"Editor Default Resources/".Length);
    }   
    return ret;
}
ddionisio commented 10 years ago

I don't think those files will be loaded at runtime, nor will they be packaged to the build. So long as you don't reference any of those images in a scene via a script. I'll have to remember if I did verify that case. I'm pretty sure that's how Unity works with assets.

Originally they reside in a Resource folder, which will get packaged to the game build (not what we want). Which is why I changed it. I thought about putting them into "Editor Default Resources", but the problem is they will have to be outside the Animator's folder. Unless it's fine to have a separate "Editor Default Resources"? I'll have to check again. It would be fine if I decide to make a package build of this tool.

ddionisio commented 10 years ago

Ok, I just verified it real quick by building a project. It does not include any of the images used by the Animator when packaging the files for the build.

I would love to put them in Editor Default Resources, but unfortunately Unity only looks for that in the Assets folder. Would be nice if it also included other instances of Editor Default Resources.

I'm sticking with the current method. The only real issue with it is the slight load time when you first open the window.