private void RecButtonGUI() { bool isDisable = (EditorConnection.instance.ConnectedPlayers.Count == 0) || m_isWait || m_isPlay; EditorGUI.BeginDisabledGroup(isDisable); var contentSize = EditorStyles.label.CalcSize(Styles.RecordContents); EditorGUI.BeginChangeCheck(); m_isRec = GUILayout.Toggle(m_isRec, Styles.RecordContents, EditorStyles.miniButtonRight, GUILayout.MaxWidth(25)); if (EditorGUI.EndChangeCheck()) { if (m_isRec) { var message = new RemoteMessageRecord(); SendMessage(message.ToBytes()); m_isWait = true; } else { var message = new RemoteMessageStopRecord(); SendMessage(message.ToBytes()); m_isWait = true; } } EditorGUI.EndDisabledGroup(); }
/// <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; } }