예제 #1
0
    public void CheckForUpdate()
    {
        if (DialogHandler.NpcResponse == null)
        {
            return;
        }
        DialogModel.NpcName.text = DialogHandler.DialogNpc != null?DialogHandler.DialogNpc.GetName() : DialogHandler.CustomDialogName;

        DialogModel.NpcText.text = DialogHandler.NpcResponse.DialogText;

        DialogModel.NpcImage.sprite = DialogHandler.DialogNpc != null?GeneralMethods.CreateSprite(DialogHandler.DialogNpc.GetImage()) : DialogHandler.CustomDialogSprite;

        DialogModel.PlayerResponseHolder.transform.DestroyChildren();

        DialogHandler.CheckResponses();
        var        responses   = DialogHandler.GetResponses();
        GameObject firstButton = null;

        foreach (var response in responses)
        {
            var go = Instantiate(PlayerResponsePrefab, Vector3.zero, Quaternion.identity) as GameObject;
            go.transform.SetParent(DialogModel.PlayerResponseHolder.transform, false);
            var playerResponseModel = go.GetComponent <PlayerResponseModel>();
            playerResponseModel.Init(response, response.DialogText);
            firstButton = firstButton ?? go;
        }

        EventSystem.SetSelectedGameObject(firstButton);
    }