コード例 #1
0
        /// <summary>
        /// Awake function called as soon as the GameObject is set active and before the start function
        /// </summary>
        private void Awake()
        {
            if (_instance != null && _instance != this)
            {
                Destroy(gameObject);
                return;
            }
            else
            {
                _instance = this;
            }
            instance = _instance;

            endDialogue = null;

            dialogueCanvas = transform.Find("DialogueCanvas").gameObject;
            Transform dialogueBox = dialogueCanvas.transform.Find("DialogueBox");

            speakerNameText       = dialogueBox.Find("SpeakerNameText").GetComponent <Text>();
            dialogueText          = dialogueBox.Find("DialogueText").GetComponent <Text>();
            dialogueInputField    = dialogueBox.Find("DialogueInputField").GetComponent <InputField>();
            advanceDialogueButton = dialogueBox.Find("AdvanceDialogueButton").GetComponent <Button>();

            dialogueCanvas.SetActive(false);
        }
コード例 #2
0
        /// <summary>
        /// Changes the current conversation.
        /// </summary>
        /// <param name="newConversation">New conversation to be active</param>
        /// <param name="_endDialogue">Function to be called once dialogue ends. Function must be type void with no parameters.</param>
        void ChangeCurConversation(List <DialogueObject> newConversation, EndDialogue _endDialogue)
        {
            endDialogue = _endDialogue;
            currentConversation.RemoveRange(0, currentConversation.Count);
            currentConversation.AddRange(newConversation);

            dialogueIndex     = 0;
            curDialogueObject = currentConversation[dialogueIndex];
        }
コード例 #3
0
 /// <summary>
 /// Displays a single line of dialogue spoken by the player.
 /// </summary>
 /// <param name="line">Line of dialogue for the player.</param>
 public void MainCharOneLiner(string line)
 {
     endDialogue       = null;
     curDialogueObject = new DialogueObject(playerName, line);
     ShowDialogue(curDialogueObject);
 }
コード例 #4
0
 /// <summary>
 /// Displays a single line of dialogue with the input field. The player is the speaker.
 /// </summary>
 /// <param name="line">Dialogue line player speaks.</param>
 /// <param name="placeholderText">Text displayed in input field before input is entered</param>
 /// <param name="enterFunction">Function to be called when input is entered. Function must be of type void and take in a single string.</param>
 public void MainCharInputOneLiner(string line, string placeholderText, EnterInput enterFunction)
 {
     endDialogue       = null;
     curDialogueObject = new DialogueObject(playerName, line, InputField.ContentType.Alphanumeric, placeholderText, 16, enterFunction);
     ShowDialogue(curDialogueObject);
 }
コード例 #5
0
 public void OneLiner(string speakerName, string line, EndDialogue _endDialogue)
 {
     endDialogue       = _endDialogue;
     curDialogueObject = new DialogueObject(speakerName, line);
     ShowDialogue(curDialogueObject);
 }