Blockchain code Metaverse VR

Unity×VR×Blockchain(279)

スポンサーリンク

//tips

//vivox理解

送信確認チェックができるように実装追加も行なった。

下記のメソッドを追加。

public void Send_Event_Message(string message,string stanzaNameSpace,string stanzaBody)
{
vivox.channelSession.BeginSendText(null,message,stanzaNameSpace,stanzaBody, ar =>
{
try
{
vivox.channelSession.EndSendText(ar);
}

catch (Exception e)
{
Debug.Log(e.Message);
}
});

}

public void Check_Message_Args(IChannelTextMessage message)
{
if (message.ApplicationStanzaNamespace == "Test")
{
Debug.Log("This is a test");
if (message.ApplicationStanzaBody == "blue")
{
Debug.Log("This player is blue");
}
}

if(message.ApplicationStanzaBody=="Hello Body")
{
Debug.Log("This is a hidden message");
}

またUIボタン用にこちらも追加した。

public void Send_Event_Message()
{
credentials.Send_Event_Message(tmp_Input_SendMessages.text,"Test",null);
}

さらに、joinした場合とleftした場合にメッセージを表示させるコードを追加。

public void On_Participant_Added(object sender, KeyEventArg<string> participantArgs)
{
var source = (VivoxUnity.IReadOnlyDictionary<string, IParticipant>)sender;

IParticipant user = source[participantArgs.Key];
Debug.Log($"{user.Account.Name} has joined the channel");

Text temp = Instantiate(lobbyUI.txt_Message_Prefab, lobbyUI.container.transform);
temp.text = $"{user.Account.Name} has joined the channel";

}

public void On_Participant_Removed(object sender, KeyEventArg<string> participantArgs)
{
var source = (VivoxUnity.IReadOnlyDictionary<string, IParticipant>)sender;

IParticipant user = source[participantArgs.Key];
Debug.Log($"{user.Account.Name} has left the channel");

Text temp = Instantiate(lobbyUI.txt_Message_Prefab, lobbyUI.container.transform);
temp.text = $"{user.Account.Name} has left the channel";

}

ここからはDirect Messageのメソッドについて確認していく。

public void Send_Direct_Message(string userToSend,string message)
{
var accountID = new AccountId(vivox.issuer,userToSend,vivox.domain);

vivox.loginSession.BeginSendDirectedMessage(accountID, message, ar =>
{
try
{
vivox.loginSession.EndSendDirectedMessage(ar);

}
catch(Exception e)
{
Debug.Log(e.Message);
}

});
}

public void On_Direct_Message_Received(object sender,QueueItemAddedEventArgs<IDirectedTextMessage> txtMsgArgs)
{
var msgSender=(IReadOnlyQueue<IDirectedTextMessage>)sender;

while (msgSender.Count>0)
{
Debug.Log(msgSender.Dequeue().Message);
var msg = msgSender.Dequeue().Message;
var temp = Instantiate(lobbyUI.txt_Message_Prefab,lobbyUI.container.transform);
temp.text = msg;
//Debug.Log(txtMsgArgs.Value.Message);

}
}

public void On_Direct_Message_Failed(object sender, QueueItemAddedEventArgs<IFailedDirectedTextMessage> txtMsgArgs)
{
var msgSender = (IReadOnlyQueue<IFailedDirectedTextMessage>)sender;

Debug.Log(txtMsgArgs.Value.Sender);

vivox.failedMessages.Add(txtMsgArgs.Value);
}

を追加し、新たなextentionも設けた。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Linq;

namespace VivoxUnity
{
public static class ExtentionMethods
{

public static string Get_Selected(this TMP_Dropdown dropdown)
{
int index = dropdown.value;
string result;
if(index >=0 && index < dropdown.options.Count)
{
result = dropdown.options[index].text;
return result;
}
return null;
}

public static void Add_Value(this TMP_Dropdown dropdown,string valueToAdd)
{
dropdown.options.Add(new TMP_Dropdown.OptionData() { text = valueToAdd });
dropdown.RefreshShownValue();
}

public static void Remove_Value(this TMP_Dropdown dropdown,string valueToRemove)
{
TMP_Dropdown.OptionData remove=dropdown.options.Find((x) => x.text == valueToRemove);

if (dropdown.options.Remove(remove))
{
dropdown.options.Remove(remove);
dropdown.RefreshShownValue();
}
}
}

}

実行すると下記エラーが発生するようになった。

DllNotFoundException: VivoxNative
VivoxCoreInstancePINVOKE+SWIGExceptionHelper..cctor () (at Assets/Vivox/Runtime/VivoxUnity/generated_files/VivoxCoreInstancePINVOKE.cs:128)
Rethrow as TypeInitializationException: The type initializer for 'SWIGExceptionHelper' threw an exception.
VivoxCoreInstancePINVOKE..cctor () (at Assets/Vivox/Runtime/VivoxUnity/generated_files/VivoxCoreInstancePINVOKE.cs:148)
Rethrow as TypeInitializationException: The type initializer for 'VivoxCoreInstancePINVOKE' threw an exception.
VivoxUnity.Client.get_Initialized () (at Assets/Vivox/Runtime/VivoxUnity/Client.cs:188)
VivoxUnity.Client.Uninitialize () (at Assets/Vivox/Runtime/VivoxUnity/Client.cs:134)
LoginCredentials.Awake () (at Assets/VIVOXTEST/LoginCredentials.cs:21)

Extentionがうまく機能していないよう。webGLにプラットフォームを変換したのが問題だったよう。

元のMacのプラットフォームに戻したら正常に機能した。

再生することはできるがビルドができない問題は変わらない。

Trying to add file /Users/akihironakamura/Desktop/Unity2018/BlockchainTest/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll to the list of ouptut files in the build report, but a file at that path has already been added.
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

ArgumentException: An item with the same key has already been added. Key: /Users/akihironakamura/Desktop/Unity2018/BlockchainTest/vtest.app/Contents/Resources/Data/Managed/Assembly-CSharp.dll
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <e1319b7195c343e79b385cd3aa43f5dc>:0)
UnityEditor.PackageManager.Packages.GetForAssemblyFilePaths (System.Collections.Generic.List`1[T] assemblyPaths) (at /Users/builduser/buildslave/unity/build/Modules/PackageManager/Editor/Managed/PackageManager.cs:86)
UnityEditor.BuildEventsHandlerPostProcess.ReportBuildPackageIds (UnityEditor.Build.Reporting.BuildFile[] buildFiles) (at /Users/builduser/buildslave/unity/build/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs:72)
UnityEditor.BuildEventsHandlerPostProcess.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at /Users/builduser/buildslave/unity/build/Modules/UnityEditorAnalyticsEditor/BuildEventsHandler.cs:49)
UnityEditor.Build.BuildPipelineInterfaces+<OnBuildPostProcess>c__AnonStorey2.<>m__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:398)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:356)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun() (at /Users/builduser/buildslave/unity/build/Editor/Mono/BuildPlayerWindow.cs:167)

Error building Player: ArgumentException: An item with the same key has already been added. Key: /Users/akihironakamura/Desktop/Unity2018/BlockchainTest/vtest.app/Contents/Resources/Data/Managed/Assembly-CSharp.dll

いくつか探ってみたがファイルのパス以外にはunityのバージョンの問題のよう。バージョンを安易にあげたくないので様子を見る。

https://masakami.com/archives/2019/11/19/490/

https://social.msdn.microsoft.com/Forums/ja-JP/5b798a7d-3092-4342-9ce4-cf0145e69047/systemargumentexception-an-item-with-the-same-key-has-already-been-added?forum=winformsdesigner

https://forum.unity.com/threads/argumentexception-an-item-with-the-same-key-has-already-been-added.837457/

人気の記事

1

皆さん、ついに、エアラインでも、サブスクリプションが始まったのはご存じですか? まだ実験段階ですが、ANAが、定額全国住み放題サービスを提供する「ADDress」と組んで、国内線を4回まで定額利用可能 ...

2

無料でネットショップを開けるアプリとして多くの人に驚きを与えたBASE株式会社が、2019年10月25日東証マザーズに上場しました。2020年2月時点で90万店を超えるショップを抱えるまでに成長してい ...

3

2011年にサービスを開始してから圧倒的な成長率を誇るインテリア通販サイト 【FLYMEe/フライミー】を皆さんご存じでしょうか。 「自分のイメージするインテリア、本当に欲しいインテリアがどこにあるの ...

4

ついに、noteの月間アクティブユーザー数が4400万人(2020年3月時点)に到達しました。 そもそも、「note」とは、クリエイターが、文章やマンガ、写真、音声を投稿することができ、ユーザーはその ...

5

ボードゲームカフェが1日2回転で儲かるという記事をみつけたので興味を持ち、調べてみました。 まずは、需要がどれくらいあるのか、市場のようすからみていきましょう。 世界最大のボードゲーム市場はドイツで、 ...

-Blockchain, code, Metaverse, VR
-, ,

Copyright© BUSINESS HUNTER , 2023 All Rights Reserved Powered by AFFINGER5.