OpenFilePanelWithFilters() private method

private OpenFilePanelWithFilters ( string title, string directory, string filters ) : string
title string
directory string
filters string
return string
Example #1
0
        //——————————————————特殊功能——————————————————


        private void LoadWaiTu(Image image)                      // 加载外部图片
        {
            string spr_path = EditorUtility.OpenFilePanelWithFilters("加载外部图片", @"E:\000资源\静态图\散图", tuFilters);

            if (!string.IsNullOrEmpty(spr_path))
            {
                Texture2D texture = LoadTextureInLocal(spr_path);
                //创建Sprite
                Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), HalfVec);
                image.sprite = sprite;
                image.SetNativeSize();
                pathK_ImageV.Add(spr_path, image);
            }
        }
        private void HandleDataSourceField()
        {
            m_DataSourceIsClip.target = m_DataSource.intValue == (int)VideoSource.VideoClip;
            m_DataSourceIsUrl.target  = m_DataSource.intValue == (int)VideoSource.Url;

            if (m_DataSource.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(s_Styles.selectUniformVideoSourceHelp, MessageType.Warning, false);
            }
            else
            {
                if (EditorGUILayout.BeginFadeGroup(m_DataSourceIsClip.faded))
                {
                    EditorGUILayout.PropertyField(m_VideoClip, s_Styles.videoClipContent);
                }
                EditorGUILayout.EndFadeGroup();

                if (EditorGUILayout.BeginFadeGroup(m_DataSourceIsUrl.faded))
                {
                    EditorGUILayout.PropertyField(m_Url, s_Styles.urlContent);
                    Rect browseRect = EditorGUILayout.GetControlRect(true, EditorGUI.kSingleLineHeight);
                    browseRect.xMin += EditorGUIUtility.labelWidth;
                    browseRect.xMax  = browseRect.xMin + GUI.skin.label.CalcSize(s_Styles.browseContent).x + 10;
                    if (EditorGUI.DropdownButton(
                            browseRect, s_Styles.browseContent, FocusType.Passive, GUISkin.current.button))
                    {
                        string path = EditorUtility.OpenFilePanelWithFilters(
                            s_Styles.selectMovieFile,
                            EditorPrefs.GetString(s_Styles.selectMovieFileRecentPath),
                            s_Styles.selectMovieFileFilter);
                        if (!string.IsNullOrEmpty(path))
                        {
                            m_Url.stringValue = "file://" + path;
                            serializedObject.ApplyModifiedProperties();
                            EditorPrefs.SetString(s_Styles.selectMovieFileRecentPath, path);
                        }
                        EditorGUIUtility.ExitGUI();
                    }
                }
                EditorGUILayout.EndFadeGroup();
            }
        }
        void LoadProfilingData(bool keepExistingData)
        {
            string recent   = EditorPrefs.GetString(kProfilerRecentSaveLoadProfilePath);
            string selected = EditorUtility.OpenFilePanelWithFilters(Styles.loadWindowTitle.text, recent, Styles.loadProfilingDataFileFilters);

            if (selected.Length != 0)
            {
                EditorPrefs.SetString(kProfilerRecentSaveLoadProfilePath, selected);
                if (ProfilerDriver.LoadProfile(selected, keepExistingData))
                {
                    // Stop current profiling if data was loaded successfully
                    ProfilerDriver.enabled = m_Recording = false;
                    SessionState.SetBool(kProfilerEnabledSessionKey, m_Recording);
#pragma warning disable CS0618
                    NetworkDetailStats.m_NetworkOperations.Clear();
#pragma warning restore
                }
            }

            // Opened a load pop-up, MacOS will redraw the window so bail out now
            EditorGUIUtility.ExitGUI();
        }
Example #4
0
        private void HandleDataSourceField()
        {
            m_DataSourceIsClip.target = m_DataSource.intValue == (int)VideoSource.VideoClip;
            if (m_DataSource.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox(s_Styles.selectUniformVideoSourceHelp, MessageType.Warning, false);
            }
            else if (EditorGUILayout.BeginFadeGroup(m_DataSourceIsClip.faded))
            {
                EditorGUILayout.PropertyField(m_VideoClip, s_Styles.videoClipContent);
            }
            else
            {
                EditorGUILayout.PropertyField(m_Url, s_Styles.urlContent);
                Rect browseRect = EditorGUILayout.GetControlRect(true, EditorGUI.kSingleLineHeight);
                browseRect.xMin += EditorGUIUtility.labelWidth;
                browseRect.xMax  = browseRect.xMin + GUI.skin.label.CalcSize(s_Styles.browseContent).x + 10;
                if (EditorGUI.DropdownButton(
                        browseRect, s_Styles.browseContent, FocusType.Passive, GUISkin.current.button))
                {
                    string[] filter =
                    {
                        // FIXME: Array should come from the player.
                        "Movie files", "dv,mp4,mpg,mpeg,m4v,ogv,vp8,webm",
                        "All files",   "*"
                    };

                    string path = EditorUtility.OpenFilePanelWithFilters(
                        s_Styles.selectMovieFile, "", filter);
                    if (!string.IsNullOrEmpty(path))
                    {
                        m_Url.stringValue = "file://" + path;
                    }
                }
            }

            EditorGUILayout.EndFadeGroup();
        }
Example #5
0
        /// <summary>
        /// Make a file field.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="filePath">The file path.</param>
        /// <param name="title">The title.</param>
        /// <param name="directory">The directory.</param>
        /// <param name="filters">The filters.</param>
        /// <param name="labelWidth">Width of the label.</param>
        /// <returns>The path of the file.</returns>
        public static string FileField(GUIContent label, string filePath, string title, string directory = "", string[] filters = null, float labelWidth = 0f)
        {
            var text = filePath;

            using (new EditorGUIFieldScope(labelWidth))
            {
                EditorGUILayout.LabelField(label, new GUIContent(text), Styles.PathFieldStyle);
                var buttonClicked = GUILayout.Button("Browse...", Styles.BrowseButtonStyle);

                if (!buttonClicked)
                {
                    return(text);
                }

                var newPath = UnityEditorUtility.OpenFilePanelWithFilters(title, directory, filters);
                if (!string.IsNullOrEmpty(newPath))
                {
                    text = newPath;
                }
            }

            return(text);
        }