Following script:
using UnityEngine;
using System.Collections;
public class DoorToggle : MonoBehaviour {
private bool doorOpen = false;
// Use this for initialization
void Start () {
}
void OnMouseUpAsButton () {
if (doorOpen) {
gameObject.animation.Play("Close");
}
else {
gameObject.animation.Play("Open");
}
doorOpen = !doorOpen;
}
void OnGUI() {
GUI.Box(new Rect(32,32,100,24),doorOpen.ToString());
}
// Update is called once per frame
void Update () {
}
}
doesn’t work. Code gets executed as doorOpen is changing values, but it doesn’t work.
Door were animated in Blender, closing/opening animations are like 60 frames (1sec). I’ve tried to use Play, PlayQueued and even crossfade, none of these are working.