Esempio n. 1
0
 private void SortMethodsDropDown()
 {
     if (this.hasSortMethods)
     {
         GUIContent gUIContent = this.m_SortingObjects[this.currentSortMethod].content;
         if (gUIContent == null)
         {
             gUIContent         = SceneHierarchyWindow.s_Styles.defaultSortingContent;
             gUIContent.tooltip = this.currentSortMethod;
         }
         Rect rect = GUILayoutUtility.GetRect(gUIContent, EditorStyles.toolbarButton);
         if (EditorGUI.ButtonMouseDown(rect, gUIContent, FocusType.Passive, EditorStyles.toolbarButton))
         {
             List <SceneHierarchySortingWindow.InputData> list = new List <SceneHierarchySortingWindow.InputData>();
             foreach (KeyValuePair <string, BaseHierarchySort> current in this.m_SortingObjects)
             {
                 list.Add(new SceneHierarchySortingWindow.InputData
                 {
                     m_TypeName = current.Key,
                     m_Name     = ObjectNames.NicifyVariableName(current.Key),
                     m_Selected = current.Key == this.m_CurrentSortMethod
                 });
             }
             if (SceneHierarchySortingWindow.ShowAtPosition(new Vector2(rect.x, rect.y + rect.height), list, new SceneHierarchySortingWindow.OnSelectCallback(this.SortFunctionCallback)))
             {
                 GUIUtility.ExitGUI();
             }
         }
     }
 }
 internal static bool ShowAtPosition(Vector2 pos, List<SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
 {
   if (DateTime.Now.Ticks / 10000L < SceneHierarchySortingWindow.s_LastClosedTime + 50L)
     return false;
   Event.current.Use();
   if ((UnityEngine.Object) SceneHierarchySortingWindow.s_SceneHierarchySortingWindow == (UnityEngine.Object) null)
     SceneHierarchySortingWindow.s_SceneHierarchySortingWindow = ScriptableObject.CreateInstance<SceneHierarchySortingWindow>();
   SceneHierarchySortingWindow.s_SceneHierarchySortingWindow.Init(pos, data, callback);
   return true;
 }
 private void Init(Vector2 pos, List<SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
 {
   Rect screenRect = GUIUtility.GUIToScreenRect(new Rect(pos.x, pos.y - 16f, 16f, 16f));
   data.Sort((Comparison<SceneHierarchySortingWindow.InputData>) ((lhs, rhs) => lhs.m_Name.CompareTo(rhs.m_Name)));
   this.m_Data = data;
   this.m_Callback = callback;
   if (SceneHierarchySortingWindow.s_Styles == null)
     SceneHierarchySortingWindow.s_Styles = new SceneHierarchySortingWindow.Styles();
   Vector2 windowSize = new Vector2(2f + this.GetWidth(), 2f + this.GetHeight());
   this.ShowAsDropDown(screenRect, windowSize);
 }
 internal static bool ShowAtPosition(Vector2 pos, List <SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
 {
     if (DateTime.Now.Ticks / 10000L < SceneHierarchySortingWindow.s_LastClosedTime + 50L)
     {
         return(false);
     }
     Event.current.Use();
     if ((UnityEngine.Object)SceneHierarchySortingWindow.s_SceneHierarchySortingWindow == (UnityEngine.Object)null)
     {
         SceneHierarchySortingWindow.s_SceneHierarchySortingWindow = ScriptableObject.CreateInstance <SceneHierarchySortingWindow>();
     }
     SceneHierarchySortingWindow.s_SceneHierarchySortingWindow.Init(pos, data, callback);
     return(true);
 }
		internal static bool ShowAtPosition(Vector2 pos, List<SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
		{
			long num = DateTime.Now.Ticks / 10000L;
			if (num >= SceneHierarchySortingWindow.s_LastClosedTime + 50L)
			{
				Event.current.Use();
				if (SceneHierarchySortingWindow.s_SceneHierarchySortingWindow == null)
				{
					SceneHierarchySortingWindow.s_SceneHierarchySortingWindow = ScriptableObject.CreateInstance<SceneHierarchySortingWindow>();
				}
				SceneHierarchySortingWindow.s_SceneHierarchySortingWindow.Init(pos, data, callback);
				return true;
			}
			return false;
		}
		private void Init(Vector2 pos, List<SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
		{
			Rect rect = new Rect(pos.x, pos.y - 16f, 16f, 16f);
			rect = GUIUtility.GUIToScreenRect(rect);
			data.Sort((SceneHierarchySortingWindow.InputData lhs, SceneHierarchySortingWindow.InputData rhs) => lhs.m_Name.CompareTo(rhs.m_Name));
			this.m_Data = data;
			this.m_Callback = callback;
			if (SceneHierarchySortingWindow.s_Styles == null)
			{
				SceneHierarchySortingWindow.s_Styles = new SceneHierarchySortingWindow.Styles();
			}
			float y = 2f + this.GetHeight();
			float x = 2f + this.GetWidth();
			Vector2 windowSize = new Vector2(x, y);
			base.ShowAsDropDown(rect, windowSize);
		}
Esempio n. 7
0
        internal static bool ShowAtPosition(Vector2 pos, List <InputData> data, OnSelectCallback callback)
        {
            // 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_SceneHierarchySortingWindow == null)
                {
                    s_SceneHierarchySortingWindow = CreateInstance <SceneHierarchySortingWindow>();
                }
                s_SceneHierarchySortingWindow.Init(pos, data, callback);
                return(true);
            }
            return(false);
        }
        internal static bool ShowAtPosition(Vector2 pos, List <SceneHierarchySortingWindow.InputData> data, SceneHierarchySortingWindow.OnSelectCallback callback)
        {
            long num = DateTime.Now.Ticks / 10000L;
            bool result;

            if (num >= SceneHierarchySortingWindow.s_LastClosedTime + 50L)
            {
                Event.current.Use();
                if (SceneHierarchySortingWindow.s_SceneHierarchySortingWindow == null)
                {
                    SceneHierarchySortingWindow.s_SceneHierarchySortingWindow = ScriptableObject.CreateInstance <SceneHierarchySortingWindow>();
                }
                SceneHierarchySortingWindow.s_SceneHierarchySortingWindow.Init(pos, data, callback);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
        private void SortMethodsDropDown()
        {
            if (!this.hasSortMethods)
            {
                return;
            }
            GUIContent content = this.m_SortingObjects[this.currentSortMethod].content;

            if (content == null)
            {
                content         = SceneHierarchyWindow.s_Styles.defaultSortingContent;
                content.tooltip = this.currentSortMethod;
            }
            Rect rect = GUILayoutUtility.GetRect(content, EditorStyles.toolbarButton);

            if (!EditorGUI.ButtonMouseDown(rect, content, FocusType.Passive, EditorStyles.toolbarButton))
            {
                return;
            }
            List <SceneHierarchySortingWindow.InputData> data = new List <SceneHierarchySortingWindow.InputData>();

            using (Dictionary <string, BaseHierarchySort> .Enumerator enumerator = this.m_SortingObjects.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, BaseHierarchySort> current = enumerator.Current;
                    data.Add(new SceneHierarchySortingWindow.InputData()
                    {
                        m_TypeName = current.Key,
                        m_Name     = ObjectNames.NicifyVariableName(current.Key),
                        m_Selected = current.Key == this.m_CurrentSortMethod
                    });
                }
            }
            if (!SceneHierarchySortingWindow.ShowAtPosition(new Vector2(rect.x, rect.y + rect.height), data, new SceneHierarchySortingWindow.OnSelectCallback(this.SortFunctionCallback)))
            {
                return;
            }
            GUIUtility.ExitGUI();
        }
 private void DrawListElement(Rect rect, SceneHierarchySortingWindow.InputData data)
 {
   EditorGUI.BeginChangeCheck();
   GUI.Toggle(rect, data.m_Selected, EditorGUIUtility.TempContent(data.m_Name), SceneHierarchySortingWindow.s_Styles.menuItem);
   if (!EditorGUI.EndChangeCheck())
     return;
   this.m_Callback(data);
   this.Close();
 }
		private void SortFunctionCallback(SceneHierarchySortingWindow.InputData data)
		{
			this.SetSortFunction(data.m_TypeName);
		}