added tooltips
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
using Assets.Scripts.Actions;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Actions.Interfaces;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
[System.Serializable]
|
||||
public class ConversationChangeEvent : UnityEvent<BaseAction> { }
|
||||
public class ConversationChangeEvent : UnityEvent<IPlayerAction> { }
|
||||
|
||||
public class ChoiceController : MonoBehaviour
|
||||
{
|
||||
public KeyValuePair<string, BaseAction> _option;
|
||||
public IPlayerAction _option;
|
||||
public ConversationChangeEvent conversationChangeEvent;
|
||||
// Update is called once per frame
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, KeyValuePair<string, BaseAction> option, int index)
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, IPlayerAction option, int index)
|
||||
{
|
||||
int buttonSpacing = -50;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class ChoiceController : MonoBehaviour
|
||||
button.transform.SetParent(choiceButtonTemplate.transform.parent);
|
||||
button.transform.localScale = Vector3.one;
|
||||
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
|
||||
button.name = option.Key;
|
||||
button.name = option.Description;
|
||||
button.gameObject.SetActive(true);
|
||||
ChoiceController choiceController = button.GetComponent<ChoiceController>();
|
||||
choiceController._option = option;
|
||||
@@ -36,11 +35,11 @@ public class ChoiceController : MonoBehaviour
|
||||
var btn = GetComponent<Button>();
|
||||
|
||||
var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
|
||||
txt.text = _option.Key;
|
||||
txt.text = _option.Description;
|
||||
}
|
||||
|
||||
public void MakeChoice()
|
||||
{
|
||||
conversationChangeEvent.Invoke(_option.Value);
|
||||
conversationChangeEvent.Invoke(_option);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user