//HotSpot _mousedDownHotspot = null;
		//HotSpot _mousedUpHotspot = null;

		void Update() {

			if (Camera.main == null) {return;}

			bool hoveringHotSpot = false;


				ray = Camera.main.ScreenPointToRay (Input.mousePosition);
				if (Physics.Raycast (ray, out hit, Mathf.Infinity, layermask)) {
			
						if (hit.collider != null) {

							
				
								HotSpot hotSpot = hit.collider.GetComponent<HotSpot> ();
								
								// Did we enter a hotspot && and is it a valid hotspot
								if (hotSpot != null) {
					
									// If so, then we are definitely hovering over a hotspot
									hoveringHotSpot = true;	

									// Are we still hovering over the same hotspot?
									
									if(_lastHotspotEntered != hotSpot) {

										//Debug.Log ("Enter Hot Spot: " + hit.collider.name);

										// If not then change the last hot spot entered and let the new hot spot know that we entered it
										_lastHotspotEntered = hotSpot;
										hotSpot.MouseEnter();
									}
					
								}
				
						}
						else {
							// If the collider is null then we are not hovering over a hotspot
							hoveringHotSpot = false;
						}
				}
				

			// Handle hotspot hover and click
			if (hoveringHotSpot) {

				// On Mouse Down
				if (Input.GetMouseButtonDown (0)) {
					_lastHotspotEntered.MouseDown();
				}

				// On Mosue Up
				if (Input.GetMouseButtonUp(0)) {			
					_lastHotspotEntered.MouseUp();
				}
			}

			//Debug.Log ("Hovering Over Hotspot? " + hoveringHotSpot);

			// Did we exit a hotspot
			if(!hoveringHotSpot && _lastHotspotEntered != null) {
		
				_lastHotspotEntered.MouseExit();
				_lastHotspotEntered = null;

			}
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Initializes a new instance of the <see cref="WhatPumpkin.Sgrid.Triggers.HotSpotEventArgs"/> class.
		/// </summary>
		/// <param name="hsEventType">Hs event type.</param>
		/// <param name="name">Name.</param>
	
		public HotSpotEventArgs(MouseEventType hsEventType, HotSpot hotspot, string name, bool conditionsMet) {
		
			_mouseEventType = hsEventType;

			_hotSpot = hotspot;

			_name = name;

			_conditionsMet = conditionsMet;

		}