internal static bool Show(Vector2 position, IBrowsePopupProvider provider)
        {
            // If the window is already open, close it instead.
            UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(typeof(BrowsePopup));
            if (wins.Length > 0)
            {
                try
                {
                    ((EditorWindow)wins[0]).Close();
                    return(false);
                }
                catch (Exception)
                {
                    s_FilterWindow = null;
                }
            }

            // We could not use realtimeSinceStartUp since it is set to 0 when entering/exitting playmode, we assume an increasing time when comparing time.
            long nowMilliSeconds = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
            bool justClosed      = nowMilliSeconds < s_LastClosedTime + 50;

            if (!justClosed)
            {
                Event.current.Use();
                if (s_FilterWindow == null)
                {
                    s_FilterWindow = ScriptableObject.CreateInstance <BrowsePopup>();
                }
                s_FilterWindow.Init(position, provider);
                return(true);
            }
            return(false);
        }
示例#2
0
        public void AddDropdown(Rect buttonRect, ReorderableList list)
        {
            var component    = list.serializedProperty.serializedObject.targetObject as Component;
            var gameObject   = component.gameObject;
            var propertyName = list.serializedProperty.name;

            var provider = new CallableProvider(
                gameObject,
                component,
                propertyName
                );;

            BrowsePopup.Show(buttonRect.position, provider);
        }
 public virtual bool OnGUI(BrowsePopup sFilterWindow)
 {
     return(false);
 }
 public virtual bool HandleKeyboard(Event evt, BrowsePopup w, Action goToParent)
 {
     return(false);
 }
 void OnDisable()
 {
     s_LastClosedTime = System.DateTime.Now.Ticks / System.TimeSpan.TicksPerMillisecond;
     s_FilterWindow   = null;
 }
 void OnEnable()
 {
     s_FilterWindow = this;
     m_Search       = "";
 }