public LayoutDropdownWindow(EntityManager entityManager, IEnumerable <Entity> entities) { EntityManager = entityManager; Entities = entities.ToList(); Entity = Entities[0]; RectTransforms = new List <RectTransform>(Entities.Select(e => EntityManager.GetComponentData <RectTransform>(e)).ToList()); m_Main = RectTransforms[0]; m_InitValues = new Vector2[RectTransforms.Count, 4]; for (var i = 0; i < RectTransforms.Count; ++i) { var rt = RectTransforms[i]; m_InitValues[i, 0] = rt.anchorMin; m_InitValues[i, 1] = rt.anchorMax; m_InitValues[i, 2] = rt.anchoredPosition; m_InitValues[i, 3] = rt.sizeDelta; } }
public override void OnGUI(Rect rect) { if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return) { editorWindow.Close(); } RectTransforms.Clear(); RectTransforms.AddRange(Entities.Select(e => EntityManager.GetComponentData <RectTransform>(e))); m_Main = RectTransforms[0]; GUI.Label(new Rect(rect.x + 5, rect.y + 3, rect.width - 10, 16), EditorGUIUtility.TrTextContent("Anchor Presets"), EditorStyles.boldLabel); GUI.Label(new Rect(rect.x + 5, rect.y + 3 + 16, rect.width - 10, 16), EditorGUIUtility.TrTextContent("Shift: Also set pivot Alt: Also set position"), EditorStyles.label); var oldColor = GUI.color; GUI.color = Styles.tableLineColor * oldColor; GUI.DrawTexture(new Rect(0, k_TopPartHeight - 1, 400, 1), EditorGUIUtility.whiteTexture); GUI.color = oldColor; GUI.BeginGroup(new Rect(rect.x, rect.y + k_TopPartHeight, rect.width, rect.height - k_TopPartHeight)); TableGUI(rect); GUI.EndGroup(); }