/// <summary> /// 接続先選択用GUI /// </summary> private void GUILayoutConnect() { EditorGUILayout.BeginHorizontal(); var contents = new GUIContent("Connect To"); var v2 = EditorStyles.label.CalcSize(contents); EditorGUILayout.LabelField(contents, GUILayout.Width(v2.x)); if (m_attachProfilerState != null) { #if UNITY_2020_1_OR_NEWER ConnectionGUILayout.ConnectionTargetSelectionDropdown(m_attachProfilerState, EditorStyles.toolbarDropDown); #else ConnectionGUILayout.AttachToPlayerDropdown(m_attachProfilerState, EditorStyles.toolbarDropDown); #endif #if false switch (m_attachProfilerState.connectedToTarget) { case ConnectionTarget.None: //This case can never happen within the Editor, since the Editor will always fall back onto a connection to itself. break; case ConnectionTarget.Player: Profiler.enabled = GUILayout.Toggle(Profiler.enabled, string.Format("Profile the attached Player ({0})", m_attachProfilerState.connectionName), EditorStyles.toolbarButton); break; case ConnectionTarget.Editor: // The name of the Editor or the PlayMode Player would be "Editor" so adding the connectionName here would not add anything. Profiler.enabled = GUILayout.Toggle(Profiler.enabled, "Profile the Player in the Editor", EditorStyles.toolbarButton); break; default: break; } #endif } EditorGUILayout.EndHorizontal(); var playerCount = EditorConnection.instance.ConnectedPlayers.Count; StringBuilder builder = new StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); }
/// <summary> /// /// </summary> private void GUILayoutConnect() { EditorGUILayout.BeginHorizontal(); var contents = new GUIContent("Connect To"); var v2 = EditorStyles.label.CalcSize(contents); EditorGUILayout.LabelField(contents, GUILayout.Width(v2.x)); if (m_connectionState != null) { #if UNITY_2020_1_OR_NEWER ConnectionGUILayout.ConnectionTargetSelectionDropdown(m_connectionState, EditorStyles.toolbarDropDown); #else ConnectionGUILayout.AttachToPlayerDropdown(m_connectionState, EditorStyles.toolbarDropDown); #endif } EditorGUILayout.EndHorizontal(); }
/// <summary> /// 接続先選択用GUI /// </summary> private void GUILayoutConnect() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Connect To"); ConnectionGUILayout.AttachToPlayerDropdown(m_attachProfilerState, EditorStyles.toolbarDropDown); EditorGUILayout.EndHorizontal(); var playerCount = EditorConnection.instance.ConnectedPlayers.Count; StringBuilder builder = new StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); }
void OnGUI() { Initialize(); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Connect to "); #if UNITY_2018_1_OR_NEWER if (attachProfilerState != null) { #if UNITY_2020_1_OR_NEWER ConnectionGUILayout.ConnectionTargetSelectionDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #else ConnectionGUILayout.AttachToPlayerDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #endif } #else // AttachProfiler if (m_attachProfilerUIOnGUILayOut != null && m_attachProfilerUI != null) { m_attachProfilerUIOnGUILayOut.Invoke(m_attachProfilerUI, new object[] { this }); } #endif if (GUILayout.Button("Get Snap List")) { MessageDataDir messageDataDir = new MessageDataDir(); messageDataDir.messageID = MessageID.Dir; byte[] bytes; Converter.ObjectToBytes(messageDataDir, out bytes); EditorConnection.instance.Send(UnityMemoryProfilerSupportKunClient.kMsgSendEditorToPlayer, bytes); } EditorGUILayout.EndHorizontal(); // 接続済みPlayerのリスト表示部 { var playerCount = EditorConnection.instance.ConnectedPlayers.Count; StringBuilder builder = new StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); } if (m_snaps != null) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); for (var i = 0; i < m_snaps.Count; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(m_snaps[i]); if (GUILayout.Button("DownLoad", GUILayout.Width(75))) { MessageDataDownload messageDataDownload = new MessageDataDownload(); messageDataDownload.messageID = MessageID.DownLoad; messageDataDownload.fname = m_snaps[i].text; byte[] bytes; Converter.ObjectToBytes(messageDataDownload, out bytes); EditorConnection.instance.Send(UnityMemoryProfilerSupportKunClient.kMsgSendEditorToPlayer, bytes); } if (GUILayout.Button("Delete", GUILayout.Width(75))) { MessageDataDelete messageDataDelete = new MessageDataDelete(); messageDataDelete.messageID = MessageID.Delete; messageDataDelete.fname = m_snaps[i].text; byte[] bytes; Converter.ObjectToBytes(messageDataDelete, out bytes); EditorConnection.instance.Send(UnityMemoryProfilerSupportKunClient.kMsgSendEditorToPlayer, bytes); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); } }
private void GUILayoutConnect() { EditorGUILayout.BeginHorizontal(); var content = new GUIContent("Connect To"); var contentSize = EditorStyles.label.CalcSize(content); EditorGUILayout.LabelField(content, GUILayout.MaxWidth(contentSize.x)); if (attachProfilerState != null) { #if UNITY_2020_1_OR_NEWER ConnectionGUILayout.ConnectionTargetSelectionDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #else ConnectionGUILayout.AttachToPlayerDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #endif } EditorGUI.BeginChangeCheck(); contentSize = EditorStyles.label.CalcSize(Styles.RecOnContent); mIsRecording = GUILayout.Toggle(mIsRecording, mIsRecording ? Styles.RecOnContent : Styles.RecOffContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10)); if (EditorGUI.EndChangeCheck()) { if (mIsRecording) { SendMessage(MessageData.MessageID.RECORDING_ON); } else { SendMessage(MessageData.MessageID.RECORDING_OFF); } } content = new GUIContent(string.Format("Frame:{0,6}/", profileDataList.Count)); contentSize = EditorStyles.label.CalcSize(content); EditorGUILayout.LabelField(content, GUILayout.MaxWidth(contentSize.x + 10)); content = new GUIContent(string.Format("Frame:{0}", frameCountMax)); contentSize = EditorStyles.label.CalcSize(content); var tmp = EditorGUILayout.DelayedIntField(frameCountMax, GUILayout.MaxWidth(contentSize.x - 32)); if (tmp > 0) { frameCountMax = tmp; } // // Clear // contentSize = EditorStyles.label.CalcSize(Styles.clearData); if (GUILayout.Button(Styles.clearData, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10))) { profileDataList.Clear(); mSlider = 0; } // // Load CSV // contentSize = EditorStyles.label.CalcSize(Styles.OpenContent); if (GUILayout.Button(Styles.OpenContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10))) { var path = EditorUtility.OpenFilePanel("Open Profile Data", "", "csv"); if (!string.IsNullOrEmpty(path)) { using (StreamReader sr = new StreamReader(path)) { if (mProfileDataList == null) { mProfileDataList = new List <ProfileData>(); } else { mProfileDataList.Clear(); } // headerを読み捨てる sr.ReadLine(); // Bodyの読み込む while (!sr.EndOfStream) { var line = sr.ReadLine(); var item = new ProfileData(); item.SetCsvBody(line); mProfileDataList.Add(item); } sr.Close(); } } } // // Save File // contentSize = EditorStyles.label.CalcSize(Styles.SaveContent); if (GUILayout.Button(Styles.SaveContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10))) { var path = EditorUtility.SaveFilePanel( "Save Profile Data as CSV", "", "", "csv"); if (path.Length != 0) { using (StreamWriter sw = new StreamWriter(path)) { sw.WriteLine(ProfileData.GetCSVHeader()); foreach (var d in profileDataList) { sw.WriteLine(d.GetCSVBody()); } sw.Close(); } } } EditorGUI.BeginChangeCheck(); contentSize = EditorStyles.label.CalcSize(Styles.statsContent); mEnabledStats = GUILayout.Toggle(mEnabledStats, Styles.statsContent, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10)); if (EditorGUI.EndChangeCheck()) { SendMessage(mEnabledStats ? MessageData.MessageID.STATS_ON : MessageData.MessageID.STATS_OFF); } EditorGUILayout.EndHorizontal(); var playerCount = EditorConnection.instance.ConnectedPlayers.Count; StringBuilder builder = new StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); }
// ---------------------------------------------------------------------------------------- // <summary> 接続先選択GUIの描画 // ---------------------------------------------------------------------------------------- private void GUILayoutConnect() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Connect To", GUILayout.ExpandWidth(false)); #if UNITY_2020_1_OR_NEWER PlayerConnectionGUILayout.ConnectionTargetSelectionDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #else PlayerConnectionGUILayout.AttachToPlayerDropdown(attachProfilerState, EditorStyles.toolbarDropDown); #endif // Play { var contentSize = EditorStyles.label.CalcSize(Style.PlayContents); EditorGUI.BeginChangeCheck(); isPlay = GUILayout.Toggle(isPlay, Style.PlayContents, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10)); if (EditorGUI.EndChangeCheck()) { if (isPlay) { editorSendData.command = PlayerView.Command.Play; } else { editorSendData.command = PlayerView.Command.Stop; } SendMessage(editorSendData); } } // Rec { EditorGUI.BeginDisabledGroup(recordPath == null || recordPath.Length == 0); var contentSize = EditorStyles.label.CalcSize(Style.RecOnContents); EditorGUI.BeginChangeCheck(); isRecord = GUILayout.Toggle(isRecord, isRecord ? Style.RecOnContents: Style.RecOffContents, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10)); if (EditorGUI.EndChangeCheck()) { if (isRecord) { recordCount = 0; } } EditorGUI.EndDisabledGroup(); } // Capture { var contentSize = EditorStyles.label.CalcSize(Style.RecOnContents); if (GUILayout.Button(Style.CaptureContents, EditorStyles.toolbarButton, GUILayout.MaxWidth(contentSize.x + 10))) { System.DateTime dt = System.DateTime.Now; string result = dt.ToString("yyyyMMddHHmmss"); var path = EditorUtility.SaveFilePanel( "Save texture as PNG", "", result + ".png", "png"); if (path.Length != 0) { var pngData = playerViewTexture.EncodeToPNG(); if (pngData != null) { System.IO.File.WriteAllBytes(path, pngData); } } } } // Save Folder { if (GUILayout.Button(Style.FolderContents, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false))) { if (isRecord == false) { recordPath = EditorUtility.SaveFolderPanel("Save textures to folder", "", ""); } } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var playerCount = EditorConnection.instance.ConnectedPlayers.Count; System.Text.StringBuilder builder = new System.Text.StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); }
private void OnGUI() { var evt = Event.current; if (evt.type == EventType.ContextClick) { // MouseがWindow無いに入っていればMenuを表示する var window = (PlayerHierarchyWindow)EditorWindow.GetWindow(typeof(PlayerHierarchyWindow)); #if UNITY_2019_1_OR_NEWER if (window.rootVisualElement.localBound.Contains(evt.mousePosition)) #else if (this.GetRootVisualContainer().localBound.Contains(evt.mousePosition)) #endif { var menu = new GenericMenu(); menu.AddDisabledItem(Styles.Rename); menu.AddItem(Styles.Duplicate, false, DuplicateCB, lastClickedID); menu.AddItem(Styles.Delete, false, DeleteCB, lastClickedID); menu.AddItem(Styles.CreateEmpty, false, CreateEmptyCB, lastClickedID); menu.AddItem(new GUIContent("3D Object/Cube"), false, CreateCubeCB, lastClickedID); menu.AddItem(new GUIContent("3D Object/Sphere"), false, CreateSphereCB, lastClickedID); menu.AddItem(new GUIContent("3D Object/Capsule"), false, CreateCapsuleCB, lastClickedID); menu.AddItem(new GUIContent("3D Object/Clyinder"), false, CreateCylinderCB, lastClickedID); menu.AddItem(new GUIContent("3D Object/Plane"), false, CreatePlaneCB, lastClickedID); menu.AddDisabledItem(new GUIContent("3D Object/Quad")); menu.AddDisabledItem(new GUIContent("3D Object/Text-TextMeshPro")); menu.AddDisabledItem(new GUIContent("3D Object/Ragdoll")); menu.AddDisabledItem(new GUIContent("3D Object/Terrain")); menu.AddDisabledItem(new GUIContent("3D Object/Tree")); menu.AddDisabledItem(new GUIContent("3D Object/WindZone")); menu.AddItem(new GUIContent("2D Object/Sprite"), false, CreateSpriteCB, lastClickedID); menu.AddDisabledItem(new GUIContent("2D Object/Sprite Mask")); menu.AddDisabledItem(new GUIContent("2D Object/Tilemap")); menu.AddDisabledItem(new GUIContent("2D Object/Hexagonal Point Top Tilemap")); menu.AddDisabledItem(new GUIContent("2D Object/Hexagonal Flat Top Tilemap")); menu.AddDisabledItem(new GUIContent("2D Object/Isometric Tilemap")); menu.AddDisabledItem(new GUIContent("2D Object/Isometric Z As Y Tilemap")); menu.AddItem(new GUIContent("Effect/Particle System"), false, CreateParticleSystem, lastClickedID); menu.AddDisabledItem(new GUIContent("Effect/Particle System ForceField")); menu.AddDisabledItem(new GUIContent("Effect/Trail")); menu.AddDisabledItem(new GUIContent("Effect/Line")); menu.ShowAsContext(); evt.Use(); } } using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar)) { var contents = new GUIContent(Styles.NetworkMessages); var v2 = EditorStyles.label.CalcSize(contents); if (GUILayout.Button(contents, EditorStyles.toolbarButton, GUILayout.Width(v2.x + 8))) { // ChoseKunWindowを開く EditorWindow.GetWindow(typeof(UnityChoseKunEditorWindow)); UnityChoseKunEditor.SendMessage(UnityChoseKun.MessageID.GameObjectPull); } EditorGUILayout.Space(); #if ENABLE_PROFILER_STATES contents = new GUIContent("Connect To"); v2 = EditorStyles.label.CalcSize(contents); EditorGUILayout.LabelField(contents, GUILayout.Width(v2.x)); if (m_attachProfilerState != null) { ConnectionGUILayout.AttachToPlayerDropdown(m_attachProfilerState, EditorStyles.toolbarDropDown); switch (m_attachProfilerState.connectedToTarget) { case ConnectionTarget.None: //This case can never happen within the Editor, since the Editor will always fall back onto a connection to itself. break; case ConnectionTarget.Player: Profiler.enabled = GUILayout.Toggle(Profiler.enabled, string.Format("Profile the attached Player ({0})", m_attachProfilerState.connectionName), EditorStyles.toolbarButton); break; case ConnectionTarget.Editor: // The name of the Editor or the PlayMode Player would be "Editor" so adding the connectionName here would not add anything. Profiler.enabled = GUILayout.Toggle(Profiler.enabled, "Profile the Player in the Editor", EditorStyles.toolbarButton); break; default: break; } } #endif hierarchyTreeView.searchString = m_searchField.OnToolbarGUI(hierarchyTreeView.searchString); } #if ENABLE_PROFILER_STATES var playerCount = EditorConnection.instance.ConnectedPlayers.Count; StringBuilder builder = new StringBuilder(); builder.AppendLine(string.Format("{0} players connected.", playerCount)); int i = 0; foreach (var p in EditorConnection.instance.ConnectedPlayers) { builder.AppendLine(string.Format("[{0}] - {1} {2}", i++, p.name, p.playerId)); } EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info); #endif var rect = EditorGUILayout.GetControlRect(false, position.height - 16); hierarchyTreeView.OnGUI(rect); }