I am having no problems triggering an animation with a collision, but can't quite work out how to trigger an animation from a GUI button click. Thanks!
Script used:
var mainmenuSkin : GUISkin;
function OnGUI ()
{
GUI.skin = mainmenuSkin;
var ScreenX : int = 10;
var ScreenY : int = 10;
var areaWidth : int = 100;
var areaHeight : int = 100;
GUILayout.BeginArea (Rect (ScreenX, ScreenY, areaWidth, areaHeight));
if(GUILayout.Button ("MoveCube")){
animation.Play("GuiCubeMove.anim");
}
GUILayout.EndArea();
}
The script creates the button fine, but I get an error message that reads: "There is no 'Animation' attached to the "GUI" game object, but a script is trying to access it." after adding:
animation.Play("GuiCubeMove.anim");
So, i am evidently only calling the animation, not the object with the animation attached to it, but not sure how to make that link happen. Thanks!