using System; using System.Collections.Generic; namespace UnityEngine.Experimental.UIElements { // Token: 0x0200033D RID: 829 internal class UIElementsUtility { // Token: 0x06003377 RID: 13175 RVA: 0x0005085C File Offset: 0x0004EA5C static UIElementsUtility() { GUIUtility.takeCapture = (Action)Delegate.Combine(GUIUtility.takeCapture, new Action(UIElementsUtility.TakeCapture)); GUIUtility.releaseCapture = (Action)Delegate.Combine(GUIUtility.releaseCapture, new Action(UIElementsUtility.ReleaseCapture)); GUIUtility.processEvent = (Func)Delegate.Combine(GUIUtility.processEvent, new Func(UIElementsUtility.ProcessEvent)); GUIUtility.cleanupRoots = (Action)Delegate.Combine(GUIUtility.cleanupRoots, new Action(UIElementsUtility.CleanupRoots)); GUIUtility.endContainerGUIFromException = (Func)Delegate.Combine(GUIUtility.endContainerGUIFromException, new Func(UIElementsUtility.EndContainerGUIFromException)); } // Token: 0x17000BB3 RID: 2995 // (get) Token: 0x06003379 RID: 13177 RVA: 0x00050988 File Offset: 0x0004EB88 internal static IDispatcher eventDispatcher { get { if (UIElementsUtility.s_EventDispatcher == null) { UIElementsUtility.s_EventDispatcher = new EventDispatcher(); } return UIElementsUtility.s_EventDispatcher; } } // Token: 0x0600337A RID: 13178 RVA: 0x000509B8 File Offset: 0x0004EBB8 private static void TakeCapture() { if (UIElementsUtility.s_ContainerStack.Count > 0) { IMGUIContainer imguicontainer = UIElementsUtility.s_ContainerStack.Peek(); if (imguicontainer.GUIDepth == GUIUtility.Internal_GetGUIDepth()) { if (UIElementsUtility.eventDispatcher.capture != null && UIElementsUtility.eventDispatcher.capture != imguicontainer) { Debug.Log(string.Format("Should not grab hot control with an active capture (current={0} new={1}", UIElementsUtility.eventDispatcher.capture, imguicontainer)); } UIElementsUtility.eventDispatcher.TakeCapture(imguicontainer); } } } // Token: 0x0600337B RID: 13179 RVA: 0x00050A40 File Offset: 0x0004EC40 private static void ReleaseCapture() { UIElementsUtility.eventDispatcher.RemoveCapture(); } // Token: 0x0600337C RID: 13180 RVA: 0x00050A50 File Offset: 0x0004EC50 private static bool ProcessEvent(int instanceID, IntPtr nativeEventPtr) { Panel panel; bool flag; if (nativeEventPtr != IntPtr.Zero && UIElementsUtility.s_UIElementsCache.TryGetValue(instanceID, out panel)) { UIElementsUtility.s_EventInstance.CopyFromPtr(nativeEventPtr); flag = UIElementsUtility.DoDispatch(panel); } else { flag = false; } return flag; } // Token: 0x0600337D RID: 13181 RVA: 0x00050AA0 File Offset: 0x0004ECA0 private static void CleanupRoots() { UIElementsUtility.s_EventInstance = null; UIElementsUtility.s_EventDispatcher = null; UIElementsUtility.s_UIElementsCache = null; UIElementsUtility.s_ContainerStack = null; } // Token: 0x0600337E RID: 13182 RVA: 0x00050ABC File Offset: 0x0004ECBC private static bool EndContainerGUIFromException(Exception exception) { if (UIElementsUtility.s_ContainerStack.Count > 0) { GUIUtility.EndContainer(); UIElementsUtility.s_ContainerStack.Pop(); } return GUIUtility.ShouldRethrowException(exception); } // Token: 0x0600337F RID: 13183 RVA: 0x00050AFC File Offset: 0x0004ECFC internal static void BeginContainerGUI(GUILayoutUtility.LayoutCache cache, int instanceID, Event evt, IMGUIContainer container) { GUIUtility.BeginContainer(instanceID); UIElementsUtility.s_ContainerStack.Push(container); GUIUtility.s_SkinMode = (int)container.contextType; GUIUtility.s_OriginalID = instanceID; Event.current = evt; GUILayoutUtility.BeginContainer(cache); GUIUtility.ResetGlobalState(); Rect rect = container.lastWorldClip; if (rect.width == 0f || rect.height == 0f) { rect = container.globalBound; } Matrix4x4 matrix4x = Matrix4x4.TRS(new Vector3(container.position.x, container.position.y, 0f), Quaternion.identity, Vector3.one); GUIClip.SetTransform(container.globalTransform * matrix4x, rect); } // Token: 0x06003380 RID: 13184 RVA: 0x00050BB8 File Offset: 0x0004EDB8 internal static void EndContainerGUI() { if (Event.current.type == EventType.Layout && UIElementsUtility.s_ContainerStack.Count > 0) { Rect globalBound = UIElementsUtility.s_ContainerStack.Peek().globalBound; GUILayoutUtility.LayoutFromContainer(globalBound.width, globalBound.height); } GUILayoutUtility.SelectIDList(GUIUtility.s_OriginalID, false); GUIContent.ClearStaticCache(); if (UIElementsUtility.s_ContainerStack.Count > 0) { GUIUtility.EndContainer(); UIElementsUtility.s_ContainerStack.Pop(); } } // Token: 0x06003381 RID: 13185 RVA: 0x00050C40 File Offset: 0x0004EE40 internal static ContextType GetGUIContextType() { return (GUIUtility.s_SkinMode != 0) ? ContextType.Editor : ContextType.Player; } // Token: 0x06003382 RID: 13186 RVA: 0x00050C68 File Offset: 0x0004EE68 private static bool DoDispatch(BaseVisualElementPanel panel) { bool flag; if (UIElementsUtility.s_EventInstance.type == EventType.Repaint) { panel.Repaint(UIElementsUtility.s_EventInstance); flag = panel.IMGUIContainersCount > 0; } else { panel.ValidateLayout(); EventPropagation eventPropagation = UIElementsUtility.s_EventDispatcher.DispatchEvent(UIElementsUtility.s_EventInstance, panel); if (eventPropagation == EventPropagation.Stop) { panel.visualTree.Dirty(ChangeType.Repaint); } flag = eventPropagation == EventPropagation.Stop; } return flag; } // Token: 0x06003383 RID: 13187 RVA: 0x00050CE0 File Offset: 0x0004EEE0 internal static Dictionary.Enumerator GetPanelsIterator() { return UIElementsUtility.s_UIElementsCache.GetEnumerator(); } // Token: 0x06003384 RID: 13188 RVA: 0x00050D00 File Offset: 0x0004EF00 internal static Panel FindOrCreatePanel(int instanceId, ContextType contextType, IDataWatchService dataWatch = null, LoadResourceFunction loadResourceFunction = null) { Panel panel; if (!UIElementsUtility.s_UIElementsCache.TryGetValue(instanceId, out panel)) { panel = new Panel(instanceId, contextType, loadResourceFunction, dataWatch, UIElementsUtility.eventDispatcher); UIElementsUtility.s_UIElementsCache.Add(instanceId, panel); } else { Debug.Assert(contextType == panel.contextType, "Context type mismatch"); } return panel; } // Token: 0x06003385 RID: 13189 RVA: 0x00050D60 File Offset: 0x0004EF60 internal static Panel FindOrCreatePanel(int instanceId) { return UIElementsUtility.FindOrCreatePanel(instanceId, UIElementsUtility.GetGUIContextType(), null, null); } // Token: 0x06003386 RID: 13190 RVA: 0x00050D84 File Offset: 0x0004EF84 internal static void BeginBuilder(VisualContainer w) { } // Token: 0x04000A99 RID: 2713 private static Stack s_ContainerStack = new Stack(); // Token: 0x04000A9A RID: 2714 private static Dictionary s_UIElementsCache = new Dictionary(); // Token: 0x04000A9B RID: 2715 private static Event s_EventInstance = new Event(); // Token: 0x04000A9C RID: 2716 private static EventDispatcher s_EventDispatcher; } }