Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        void OnMessageEvent(MessageEventArgs args)
        {
            var messageBase = new RemoteMessageBase();

            messageBase = RemoteMessageBase.Desirialize <RemoteMessageBase>(args.data);
            Debug.Log("messageId:" + messageBase.m_messageId);
            switch (messageBase.m_messageId)
            {
            case RemoteMessageBase.MessageId.Reflesh:
            {
                var message = RemoteMessageBase.Desirialize <RemoteMessageReflesh>(args.data);
                message.m_scriptNames    = new string[EventScriptSystem.instance.scripts.Count];
                message.m_scriptNoValues = new int[EventScriptSystem.instance.scripts.Count];
                for (var i = 0; i < message.m_scriptNames.Length; i++)
                {
                    message.m_scriptNames[i]    = EventScriptSystem.instance.scripts[i].name;
                    message.m_scriptNoValues[i] = i;
                }
                message.m_isRecord = InputRecorder.instance.isRecording;
                message.m_isPlay   = EventScriptSystem.instance.isPlay;


                SendRemoteMessage(message.ToBytes());
            }
            break;

            case RemoteMessageBase.MessageId.Play:
            {
                var message = RemoteMessageBase.Desirialize <RemoteMessagePlay>(args.data);
                EventScriptSystem.instance.Play(message.m_scriptIdx);
                message.m_isSuccess = true;
                SendRemoteMessage(message.ToBytes());
                m_updateTask += PlayScriptFinishCB;
            }
            break;

            case RemoteMessageBase.MessageId.Stop:
            {
                EventScriptSystem.instance.Stop();
                messageBase.m_isSuccess = true;
                SendRemoteMessage(messageBase.ToBytes());
            }
            break;

            case RemoteMessageBase.MessageId.AddEventScript:
            {
                var message   = RemoteMessageBase.Desirialize <RemoteMessageAddEventScript>(args.data);
                var textAsset = new TextAsset(message.m_text);
                textAsset.name           = message.m_name;
                message.m_setIndex       = EventScriptSystem.instance.SetScript(textAsset);
                message.m_scriptNames    = new string[EventScriptSystem.instance.scripts.Count];
                message.m_scriptNoValues = new int[EventScriptSystem.instance.scripts.Count];
                for (var i = 0; i < message.m_scriptNames.Length; i++)
                {
                    message.m_scriptNames[i]    = EventScriptSystem.instance.scripts[i].name;
                    message.m_scriptNoValues[i] = i;
                }

                message.m_isSuccess = true;
                SendRemoteMessage(message.ToBytes());
            }
            break;

            case RemoteMessageBase.MessageId.Record:
            {
                InputRecorder.instance.Record();
                messageBase.m_isSuccess = true;
                SendRemoteMessage(messageBase.ToBytes());
            }
            break;

            case RemoteMessageBase.MessageId.StopRecord:
            {
                var message = RemoteMessageBase.Desirialize <RemoteMessageStopRecord>(args.data);
                InputRecorder.instance.Stop();
                message.m_text      = InputRecorder.instance.textAsset.ToString();
                message.m_isSuccess = true;
                SendRemoteMessage(message.ToBytes());
            }
            break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Playerから受信したメッセージのCB
        /// </summary>
        /// <param name="args"></param>
        private void OnMessageEvent(UnityEngine.Networking.PlayerConnection.MessageEventArgs args)
        {
            var messageBase = RemoteMessageBase.Desirialize <RemoteMessageBase>(args.data);

            switch (messageBase.m_messageId)
            {
            case RemoteMessageBase.MessageId.Reflesh:
            {
                var message = RemoteMessageBase.Desirialize <RemoteMessageReflesh>(args.data);
                m_scriptNames    = new List <GUIContent>();
                m_scriptNoValues = new List <int>(message.m_scriptNoValues);
                for (var i = 0; i < message.m_scriptNames.Length; i++)
                {
                    m_scriptNames.Add(new GUIContent(message.m_scriptNames[i]));
                }
                m_isPlay = message.m_isPlay;
                m_isRec  = message.m_isRecord;
                m_isWait = false;
            }
            break;

            case RemoteMessageBase.MessageId.Play:
            {
                m_isWait = false;
                m_isPlay = messageBase.m_isSuccess;
            }
            break;

            case RemoteMessageBase.MessageId.Stop:
            {
                m_isWait = false;
            }
            break;

            case RemoteMessageBase.MessageId.AddEventScript:
            {
                var message = RemoteMessageAddEventScript.Desirialize <RemoteMessageAddEventScript>(args.data);

                m_scriptNames    = new List <GUIContent>();
                m_scriptNoValues = new List <int>(message.m_scriptNoValues);
                for (var i = 0; i < message.m_scriptNames.Length; i++)
                {
                    m_scriptNames.Add(new GUIContent(message.m_scriptNames[i]));
                }
                m_scriptIdx = message.m_setIndex;

                m_isWait = false;
            }
            break;

            case RemoteMessageBase.MessageId.PlayFinish:
            {
                m_isPlay = false;
            }
            break;

            case RemoteMessageBase.MessageId.Record:
            {
                m_isRec  = messageBase.m_isSuccess;
                m_isWait = false;
            }
            break;

            case RemoteMessageBase.MessageId.StopRecord:
            {
                var message = RemoteMessageStopRecord.Desirialize <RemoteMessageStopRecord>(args.data);
                var path    = EditorUtility.SaveFilePanel(
                    "Save Event Script Data as TXT",
                    "",
                    "",
                    "txt");
                if (path.Length != 0)
                {
                    using (StreamWriter sw = new StreamWriter(path))
                    {
                        sw.Write(message.m_text);
                        sw.Close();
                    }
                }
                m_isWait = false;
            }
            break;
            }
        }