Commented research tech button script
This commit is contained in:
@@ -1,64 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* @author Aaron Moser
|
||||
*
|
||||
* @package Assets.Scripts.Research
|
||||
*/
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
/**
|
||||
* @section DESCRIPTION
|
||||
*
|
||||
* Class contains functionality for tech button, including custom events.
|
||||
*/
|
||||
public class TechButton : Button, IPointerEnterHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Has to be set with SetResearchEvent before onMouseEnter event gets invoked.
|
||||
/// </summary>
|
||||
private NResearch.EResearchEvent eResearchEvent;
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public values
|
||||
|
||||
/// <summary>
|
||||
/// Delegate of pointer/mouse enter event.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/**
|
||||
* Delegate of pointer/mouse enter event.
|
||||
*/
|
||||
public delegate void TechButtonMouseEnterHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Public event for the pointer/mouse enter event. Gets invoked whenever a TechButton is hovered.
|
||||
/// </summary>
|
||||
/**
|
||||
* Public event for the pointer/mouse enter event. Gets invoked whenever a TechButton is hovered.
|
||||
*/
|
||||
public event TechButtonMouseEnterHandler onMouseEnter;
|
||||
|
||||
/// <summary>
|
||||
/// Delegate of pointer/mouse exit event.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
/**
|
||||
* Delegate of pointer/mouse exit event.
|
||||
*/
|
||||
public delegate void TechButtonMouseExitHandler(object sender, NResearch.ResearchEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Public event for the pointer/mouse exit event. Gets invoked whenever a TechButton is unhovered.
|
||||
/// </summary>
|
||||
/**
|
||||
* Public event for the pointer/mouse exit event. Gets invoked whenever a TechButton is unhovered.
|
||||
*/
|
||||
public event TechButtonMouseExitHandler onMouseExit;
|
||||
|
||||
/// <summary>
|
||||
/// Gets called from unity if mouse pointer/mouse enters TechButton gameobject.
|
||||
/// </summary>
|
||||
/// <param name="eventData"></param>
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private values
|
||||
|
||||
/**
|
||||
* Intern value of research event.
|
||||
* Has to be set with SetResearchEvent before onMouseEnter event gets invoked.
|
||||
*/
|
||||
private NResearch.EResearchEvent eResearchEvent;
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Public functions
|
||||
|
||||
/**
|
||||
* Gets called from unity if mouse pointer/mouse enters TechButton gameobject.
|
||||
*
|
||||
* @param eventData, data of event.
|
||||
*/
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
onMouseEnter?.Invoke(this, new NResearch.ResearchEventArgs(eResearchEvent));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets called from unity if mouse pointer/mouse exits TechButton gameobject.
|
||||
/// </summary>
|
||||
/// <param name="eventData"></param>
|
||||
/**
|
||||
* Gets called from unity if mouse pointer/mouse exits TechButton gameobject.
|
||||
*
|
||||
* @param eventData, data of event.
|
||||
*/
|
||||
public override void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
onMouseExit?.Invoke(this, new NResearch.ResearchEventArgs(NResearch.EResearchEvent.ExitTechButton));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets called from ResearchTechViewScript if pointer/mouse left a tech button.
|
||||
/// </summary>
|
||||
/// <param name="eResearchEvent"></param>
|
||||
/**
|
||||
* Gets called from ResearchTechViewScript if pointer/mouse left a tech button.
|
||||
*
|
||||
* @param eResearchEvent, research event, intern value to set to.
|
||||
*/
|
||||
public void SetResearchEvent(NResearch.EResearchEvent eResearchEvent)
|
||||
{
|
||||
this.eResearchEvent = eResearchEvent;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
// Private functions
|
||||
}
|
||||
Reference in New Issue
Block a user