public void OnGUI()
        {
            GUIContent content = EditorGUIUtility.TextContent(this.GetConnectedProfiler() + "|Specifies the target player for receiving profiler and log data.");
            Vector2    vector  = EditorStyles.toolbarDropDown.CalcSize(content);
            Rect       rect    = GUILayoutUtility.GetRect(vector.x, vector.y);

            if (EditorGUI.DropdownButton(rect, content, FocusType.Passive, EditorStyles.toolbarDropDown))
            {
                List <ProfilerChoise> list = new List <ProfilerChoise>();
                list.Clear();
                AttachProfilerUI.AddPlayerProfilers(list);
                AttachProfilerUI.AddDeviceProfilers(list);
                AttachProfilerUI.AddLastIPProfiler(list);
                if (!ProfilerDriver.IsConnectionEditor())
                {
                    if (!list.Any((ProfilerChoise p) => p.IsSelected()))
                    {
                        List <ProfilerChoise> arg_10B_0 = list;
                        ProfilerChoise        item      = default(ProfilerChoise);
                        item.Name       = "(Autoconnected Player)";
                        item.Enabled    = false;
                        item.IsSelected = (() => true);
                        item.ConnectTo  = delegate
                        {
                        };
                        arg_10B_0.Add(item);
                    }
                }
                this.AddEnterIPProfiler(list, GUIUtility.GUIToScreenRect(rect));
                this.OnGUIMenu(rect, list);
            }
        }
        private void AddEnterIPProfiler(List <ProfilerChoise> profilers, Rect buttonScreenRect)
        {
            ProfilerChoise item = default(ProfilerChoise);

            item.Name       = AttachProfilerUI.kEnterIPText;
            item.Enabled    = true;
            item.IsSelected = (() => false);
            item.ConnectTo  = delegate
            {
                ProfilerIPWindow.Show(buttonScreenRect);
            };
            profilers.Add(item);
        }
        private static void AddLastIPProfiler(List <ProfilerChoise> profilers)
        {
            string lastIP = ProfilerIPWindow.GetLastIPString();

            if (!string.IsNullOrEmpty(lastIP))
            {
                ProfilerChoise item = default(ProfilerChoise);
                item.Name       = lastIP;
                item.Enabled    = true;
                item.IsSelected = (() => ProfilerDriver.connectedProfiler == 65261);
                item.ConnectTo  = delegate
                {
                    AttachProfilerUI.DirectIPConnect(lastIP);
                };
                profilers.Add(item);
            }
        }
Exemple #4
0
 public void OnGUI(Rect connectRect, GUIContent profilerLabel)
 {
     if (EditorGUI.ButtonMouseDown(connectRect, profilerLabel, FocusType.Passive, EditorStyles.toolbarDropDown))
     {
         List <ProfilerChoise> list = new List <ProfilerChoise>();
         list.Clear();
         AttachProfilerUI.AddPlayerProfilers(list);
         AttachProfilerUI.AddDeviceProfilers(list);
         AttachProfilerUI.AddLastIPProfiler(list);
         if (!ProfilerDriver.IsConnectionEditor())
         {
             if (!list.Any((ProfilerChoise p) => p.IsSelected()))
             {
                 List <ProfilerChoise> arg_D2_0 = list;
                 ProfilerChoise        item     = default(ProfilerChoise);
                 item.Name       = "(Autoconnected Player)";
                 item.Enabled    = false;
                 item.IsSelected = (() => true);
                 item.ConnectTo  = delegate
                 {
                 };
                 arg_D2_0.Add(item);
             }
         }
         this.AddEnterIPProfiler(list, GUIUtility.GUIToScreenRect(connectRect));
         string[] options = (from p in list
                             select p.Name).ToArray <string>();
         bool[] enabled = (from p in list
                           select p.Enabled).ToArray <bool>();
         int   num = list.FindIndex((ProfilerChoise p) => p.IsSelected());
         int[] selected;
         if (num == -1)
         {
             selected = new int[0];
         }
         else
         {
             selected = new int[]
             {
                 num
             };
         }
         EditorUtility.DisplayCustomMenu(connectRect, options, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), list);
     }
 }