示例#1
0
        void Configure(Rect popoverPosition, OnSelectedItem selectedItemCallback, Styling style, BuildPlatform platform)
        {
            _xcodeFinder = new XcodeSDKFinder(platform);
            var minWidth = style.MaxLabelWidth(_xcodeFinder.FrameworkNames, popoverPosition.width) + 40;
            var width    = popoverPosition.width;

            _platform = platform;

            if (minWidth > popoverPosition.width)
            {
                width = Mathf.Max(minWidth, popoverPosition.width);
                float delta = (minWidth - popoverPosition.width) * 0.5f;
                popoverPosition.x -= delta;
            }

            var size = new Vector2(width, popoverPosition.height);

            popoverPosition.width = popoverPosition.height = 0;
            _onSelectedItem       = selectedItemCallback;
            _style = style;
            ShowAsDropDown(popoverPosition, size);
        }
示例#2
0
        void OnGUI()
        {
            if (Application.platform != RuntimePlatform.OSXEditor)
            {
                EditorGUILayout.LabelField("Can only browse frameworks on OS X.");
                EditorGUILayout.LabelField("Please enter framework names manually.");
                ManualEntry();
                return;
            }

            if (!_xcodeFinder.IsFound)
            {
                EditorGUILayout.LabelField("Xcode not found. Please set the Xcode location");

                if (GUILayout.Button("Find Xcode"))
                {
                    var xcodePath = EditorUtility.OpenFilePanel("Choose Xcode Location", "/Applications", "app");

                    if (!string.IsNullOrEmpty(xcodePath))
                    {
                        if (XcodeFinder.SetXcodeLocation(xcodePath))
                        {
                            _xcodeFinder = new XcodeSDKFinder(_platform);
                        }
                        else
                        {
                            EditorUtility.DisplayDialog("Invalid Xcode Location", xcodePath + " does not appear to be a valid Xcode install", "OK");
                        }
                    }
                }

                EditorGUILayout.HelpBox("You can change the location under settings", MessageType.Info);
                GUILayout.Space(20);
                EditorGUILayout.LabelField("Alternatively, add the framework names manually below.");
                ManualEntry();
                return;
            }

            if (_content == null)
            {
                _content = _xcodeFinder.FrameworkNames;
                _filteredList.Clear();
                _filteredList.AddRange(_content);
            }

            DrawSearchBox();
            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

            foreach (string framework in _filteredList)
            {
                if (GUILayout.Button(framework, EditorStyles.label))
                {
                    AddFramework(framework);
                }
            }

            EditorGUILayout.EndScrollView();

            if (Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == KeyCode.Escape)
                {
                    Close();
                }
            }
        }