fix conversation dialog
This commit is contained in:
@@ -15,15 +15,15 @@ public class ChoiceController : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, KeyValuePair<string, BaseAction> option, int index)
|
||||
{
|
||||
int buttonSpacing = -44;
|
||||
int buttonSpacing = -50;
|
||||
|
||||
Button button = Instantiate(choiceButtonTemplate);
|
||||
|
||||
button.transform.SetParent(choiceButtonTemplate.transform.parent);
|
||||
button.transform.localScale = Vector3.one;
|
||||
button.transform.localPosition = new Vector3(0, index * buttonSpacing, 0);
|
||||
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
|
||||
button.name = option.Key;
|
||||
button.gameObject.SetActive(true);
|
||||
|
||||
ChoiceController choiceController = button.GetComponent<ChoiceController>();
|
||||
choiceController._option = option;
|
||||
return choiceController;
|
||||
|
||||
@@ -12,6 +12,9 @@ public class ConversationController : MonoBehaviour
|
||||
[SerializeField]
|
||||
public Button _choiceButton;
|
||||
|
||||
[SerializeField]
|
||||
private Button _closeBtn;
|
||||
|
||||
private List<ChoiceController> choiceControllers = new();
|
||||
public static ConversationController Instance { get; private set; }
|
||||
|
||||
@@ -32,10 +35,17 @@ public class ConversationController : MonoBehaviour
|
||||
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
|
||||
choiceControllers.Add(c);
|
||||
}
|
||||
_closeBtn.onClick.AddListener(() =>
|
||||
{
|
||||
Hide();
|
||||
});
|
||||
|
||||
Time.timeScale = 0;
|
||||
_choiceButton.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void RemoveChoices()
|
||||
{
|
||||
foreach (ChoiceController c in choiceControllers)
|
||||
@@ -47,5 +57,6 @@ public class ConversationController : MonoBehaviour
|
||||
{
|
||||
RemoveChoices();
|
||||
gameObject.SetActive(false);
|
||||
Time.timeScale = 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user