Created
May 24, 2016 10:07
-
-
Save tm8r/f5e547d6659e403c0292356c80bf6893 to your computer and use it in GitHub Desktop.
Revisions
-
tm8r created this gist
May 24, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ using UnityEngine; using UniRx; using UdpReceiverUniRx; using System.IO; namespace Viewer { public class UDPManager : SingletonMonoBehaviour<UDPManager> { public UdpReceiverRx _udpReceiverRx; private IObservable<UdpState> myUdpSequence; void Start () { myUdpSequence = _udpReceiverRx._udpSequence; myUdpSequence .ObserveOnMainThread () .Subscribe (x => ReceiveAction (x.UdpMsg)) .AddTo (this); } void ReceiveAction (string message) { UdpMessage data = null; try { data = JsonUtility.FromJson<UdpMessage> (message); } catch { Debug.LogFormat ("[invalid format] message:{0}", message); return; } switch (data.action) { case "Load": LoadModel (data); break; default: Debug.LogFormat ("[not implemented action] message:{0}", message); break; } } void LoadModel (UdpMessage message) { var path = Directory.GetParent (message.path).Name + "/" + Path.GetFileNameWithoutExtension (message.path); StartCoroutine (MenuPresenter.Instance.LoadModel (path)); } } }