1
Misc Archive / OnHover function: saving "isOver" as a local boolean variable
« on: August 21, 2014, 03:33:35 PM »
First, I just want to say this is a really neat package. I am definitely considering upgrading from the free version after I learn the ins and outs of the code more thoroughly. Right now I am trying to implement two "left" and "right" buttons that scroll a panel when they are moused over. I seem to have the scrolling part right, but I read that since NGUI does not continuously fire events (from this thread), I will have to assign isOver to a local variable which I named "pressed".
However this started giving me the error: "The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(Monobehaviour) pressed". I guess it doesn't like what I am doing in void OnHover(), but why?
- public class MouseOverScroll : UIButton {
- public enum Direction{Left, Right};
- public Direction dir = Direction.Left;
- public GameObject dragpanel;
- UIDraggablePanel dps;
- public bool pressed = false;
- void Start () {
- dps = dragpanel.GetComponent<UIDraggablePanel> ();
- }
- void Update() {
- if(pressed) {
- if (dir == Direction.Left) {
- dps.SendMessage("Scroll", 0.5f);
- }
- else if (dir == Direction.Right) {
- dps.SendMessage("Scroll", -0.5f);
- }
- }
- }
- public override void OnHover (bool isOver)
- {
- base.OnHover (isOver);
- pressed = isOver;
- }
- }
However this started giving me the error: "The same field name is serialized multiple times in the class or its parent class. This is not supported: Base(Monobehaviour) pressed". I guess it doesn't like what I am doing in void OnHover(), but why?
