Exemple #1
0
        private void UploadtTextAssetGUI()
        {
            bool isDisable = (EditorConnection.instance.ConnectedPlayers.Count == 0) || m_isWait || m_isPlay || m_isRec || (m_uploadTextAsset == null);

            EditorGUILayout.BeginHorizontal();
            m_uploadTextAsset = (TextAsset)EditorGUILayout.ObjectField(Styles.EventScriptContens, m_uploadTextAsset, typeof(TextAsset), true);
            EditorGUI.BeginDisabledGroup(isDisable);
            if (GUILayout.Button(Styles.UploadContens, EditorStyles.miniButton, GUILayout.MaxWidth(25)))
            {
                var message = new RemoteMessageAddEventScript();
                message.m_name = m_uploadTextAsset.name;
                message.m_text = m_uploadTextAsset.text;
                SendMessage(message.ToBytes());
                m_isWait = true;
            }
            EditorGUI.EndDisabledGroup();

            EditorGUILayout.EndHorizontal();
        }
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;
            }
        }