- Home /
Components for 2D Animation System
Hello there. I'm currently tasked with writing a custom 2D animation system to use in Unity. We're going to use it for things like HUD animations so it'll always be in screen coordinates. The animations will be built out of png frames with each anim having it's own folder. I know how to do most of the work but I had a couple of question with regard to making it a Unity interface editable tool.
1) I want to have the user be able to drag a folder (located somewhere in /Resources) from the Project panel to an Inpsector component in the prefab. I know how to set up public vars in my scripts for things like textures but I'm not sure if there's a way to make the folder location for the frames dragable. This is how the frames for the anim would be defined. Is there a certain type of class I can use to achieve this? I plan on using Resources.LoadAll() to get the array of frames once I know the path.
2) To place an animation on the screen I've got a prefab built starting with an empty GameObject (pos, rot, scale all (0,0,0)) then I added a GUITexture component (pos,rot, scale all at (0,0,0)). The icon for placement is 32x32 so I set the X,Y Pixel Insert both to -16 so that the center of the icon is the center of the animation. When the root GameObject is moved around you get around the screen with X and Y going between 0 - 1.0. This is good for a start but I'm wondering: a) Is there a better way to get an icon on the screen to represent where the animation will be? I can make the texture for the location smaller, but I wanted something that will automatically switch off when the user selects another object in the Hierarchy. Kind of like when the Mesh outline on a 3D object disappears when selecting something else. We're going to have tons of animations for different states but I don't want the screen to get cluttered with their icons on screen all the time. b) Is there a way to let the user define the location in screen coordinates (top->bottom, left->right) in the Inspector? I know that kind of defeats the purpose for multiple screen sizes but I was thinking of having screen size be another variable in the Inspector. Not ideal but we've found it's easier to let the designers think in terms of screen coords rather than screen percentages.
Thank you. Let me know if any of this doesn't make sense. -Mo