Пример #1
0
    /// <summary>
    /// Send text of input field to my party members.
    /// </summary>
    public void SendChatInputForPlayer()
    {
        // 名前入力テキストが空だった場合
        if (string.IsNullOrEmpty(nameInput.text))
        {
            // 名前を入力してくださいとチャット欄に出力する
            playerToPlayerChatText.text += CreateChatText(StaticMethods.CreateRichTextFromCaptionAndColorName("名前を入力してください。", "yellow"), playerToPlayerChatText.text);
            return;
        }

        // 名前から送り先の検索
        GameObject[] sendObject = StaticMethods.FindGameObjectsWithNameAndTag(nameInput.text, "Player");

        // その名前のプレイヤーが存在しなければ
        if (sendObject == null)
        {
            // 名前が見つからなかった旨を記述する
            playerToPlayerChatText.text += CreateChatText(StaticMethods.CreateRichTextFromCaptionAndColorName(nameInput.text + "さんが見つかりませんでした。", "yellow"), playerToPlayerChatText.text);
            return;
        }

        // 送る
        for (int i = 0; i < sendObject.Length; i++)
        {
            photonView.RPC("PtoPChat", sendObject[i].GetPhotonView().owner, input.text);
        }

        // 自分の個別チャット欄に送り先と送った内容を記述する
        playerToPlayerChatText.text += CreateChatText(StaticMethods.CreateRichTextFromCaptionAndColor("<size=15>To</size> " + nameInput.text, nameColor) + " " + input.text, playerToPlayerChatText.text);

        input.text = "";
        GUI.FocusControl("");
    }