Hi there,
This is my first post here so I dont know if this is the correct area or the correct way to right my question. I am trying to create a talent tree… Actually I have it ready and what I want is when the user hit the right click to decrease the talents that he spent in one talent point
(For example if he has 1 talent point that spent 5 point when he hit the right click to decrease the talent point and add it in the total_skill_points)
This is the part of my code that increase or decrease the talents
public void OnClick (int value){
if ( skills[value].SkillPointsAdded < skills[value].SkillPointReq && skillPoints > 0 ){
skills[value].SkillPointsAdded ++ ;
skillPoints --;
TalentAdd(value);
Total ++;
Debug.Log("Your total points are " + Total);
}
}
public void OnRightClick (int value){
if (skills[value].SkillPointsAdded > 0){
this.skills[value].SkillPointsAdded--;
Debug.Log ( this.skills[value].SkillName + "" +this.skills[value].SkillPointsAdded);
this.skillPoints ++;
this.Total -- ;
}
}
The problem is that when I add the script on multiple UI buttons and right click somewhere everything is decreased. I need only to decrease the one that I am clicking…
Also I use a custom RightEventHandler so I am copying that cs also here :
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using System.Collections;
[ExecuteInEditMode]
[AddComponentMenu("Event/RightButtonEvent")]
public class RightButtonEvent : MonoBehaviour , IPointerEnterHandler, IPointerExitHandler{
[System.Serializable] public class RightButton: UnityEvent{}
public RightButton onRightDown;
public RightButton onRightUp;
private bool isOver = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetMouseButtonDown (1)){
onRightDown.Invoke();
}
if (Input.GetMouseButton(1)){
onRightUp.Invoke ();
}
}
public void OnPointerEnter(PointerEventData eventData){
isOver = true;
}
public void OnPointerExit(PointerEventData eventData){
isOver = false;
}
}
Thank you in advance.