コード例 #1
0
        public void repaint(Rect r)
        {
            Vector2 newScreenPosition = GUIUtility.GUIToScreenPoint(r.position);

            if (bounds != r ||
                screenPosition != newScreenPosition)
            {
                screenPosition = newScreenPosition;
                bounds         = r;

                unitySetScreenBounds(instanceID, screenPosition.x, screenPosition.y, bounds.width, bounds.height);
                setupTexture();
            }

            GL.IssuePluginEvent(getRenderCallback(), instanceID);

            texture.SetPixels32(pixels);
            texture.Apply();

            EditorGUI.DrawPreviewTexture(bounds, texture);
        }
コード例 #2
0
        public void OnDropOutsidePort(Edge edge, Vector2 position)
        {
            var screenPosition = GUIUtility.GUIToScreenPoint(
                Event.current.mousePosition
                );

            if (edge.output != null)
            {
                m_Canvas.OpenSearch(
                    screenPosition,
                    edge.output.edgeConnector.edgeDragHelper.draggedPort as PortView
                    );
            }
            else if (edge.input != null)
            {
                m_Canvas.OpenSearch(
                    screenPosition,
                    edge.input.edgeConnector.edgeDragHelper.draggedPort as PortView
                    );
            }
        }
コード例 #3
0
        void UpdateValue()
        {
            Event evt = Event.current;

            if (updatingValue && evt != null)
            {
                switch (evt.rawType)
                {
                case EventType.MouseUp:
                    updatingValue = false;
                    break;
                }
            }

            float delta = GUIUtility.GUIToScreenPoint(Event.current.mousePosition).x - mouseStartPoint;
            float value = originalUpdatingValue + delta * updatingValueMultiplier;

            updatingParameter.UpdateValue(value);
            valueUpdated = true;
            Repaint();
        }
コード例 #4
0
        private void OnGUI()
        {
            if (needsRefresh)
            {
                Refresh();
            }

            SerializedSceneManager.SerializedManager.Update();
            SerializedSceneManager.SceneNodesObject.Update();

            Initialize();

            sceneFileDragReceiver.ReceiverBox = NodeEditor.NodeEditor.NodeEditorRect.
                                                WithPosition(GUIUtility.GUIToScreenPoint(NodeEditor.NodeEditor.NodeEditorRect.position));

            sceneFileDragReceiver.Update();

            RenderToolbar();

            if (isTabVisible)
            {
                splitView.BeginSplitView();

                RenderManagementWindow();

                splitView.Split();
            }

            NodeEditor.OnGUI();

            if (isTabVisible)
            {
                if (splitView.EndSplitView())
                {
                    Repaint();
                }
            }

            serializedSceneManager.SceneNodes.PanOffset = NodeEditor.NodeEditor.GetPanOffset();
        }
コード例 #5
0
        protected override void OldOnGUI()
        {
            // Call reset GUI state as first thing so GUI.color is correct when drawing window decoration.
            EditorGUIUtility.ResetGUIState();

            Rect maximizedViewRect = Rect.zero;

            maximizedViewRect.size = position.size;
            maximizedViewRect      = Styles.background.margin.Remove(maximizedViewRect);

            Rect backRect = new Rect(maximizedViewRect.x + 1, maximizedViewRect.y, maximizedViewRect.width - 2, DockArea.kTabHeight);

            if (Event.current.type == EventType.Repaint)
            {
                Styles.background.Draw(maximizedViewRect, GUIContent.none, false, false, false, false);
                Styles.titleBackground.Draw(backRect, false, false, true, hasFocus);
                GUI.Label(backRect, actualView.titleContent, Styles.titleLabel);
            }

            if (Event.current.type == EventType.ContextClick && backRect.Contains(Event.current.mousePosition) && !ContainerWindow.s_Modal)
            {
                PopupGenericMenu(actualView, new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
            }

            // GetGenericMenuLeftOffset false because maximized window are not floating windows
            ShowGenericMenu(position.width - GetGenericMenuLeftOffset(false), backRect.yMin + Styles.genericMenuTopOffset);

            const float topBottomPadding = 0f;
            Rect        viewRect         = maximizedViewRect;

            viewRect.y      = backRect.yMax - topBottomPadding;
            viewRect.height = position.height - backRect.yMax + topBottomPadding;

            if (actualView)
            {
                actualView.m_Pos = new Rect(GUIUtility.GUIToScreenPoint(Vector2.zero), viewRect.size);
            }

            InvokeOnGUI(maximizedViewRect, viewRect);
        }
コード例 #6
0
        public Vector2 Drag(Rect rect, Vector2 position, Node node, out bool startDraging, float scale)
        {
            Event     currentEvent = Event.current;
            EventType eventType    = currentEvent.type;

            startDraging = false;
            Vector2 mousePosition       = currentEvent.mousePosition;
            Vector2 mouseScreenPosition = GUIUtility.GUIToScreenPoint(mousePosition / scale);

            if (_goingToDragNode == null && Node == null && eventType == EventType.MouseDown && currentEvent.button == 0 && rect.Contains(mousePosition))
            {
                Delta            = position - mouseScreenPosition;
                _startPosition   = mouseScreenPosition;
                _goingToDragNode = node;
                currentEvent.Use();
            }
            if (_goingToDragNode == node)
            {
                if ((mouseScreenPosition - _startPosition).magnitude > _threshold)
                {
                    Node             = node;
                    _goingToDragNode = null;
                    startDraging     = true;
                }
                if (eventType == EventType.MouseUp && currentEvent.button == 0 || eventType == EventType.MouseLeaveWindow)
                {
                    _goingToDragNode = null;
                }
            }
            if (Node == node)
            {
                if (eventType == EventType.MouseUp && currentEvent.button == 0 || eventType == EventType.MouseLeaveWindow)
                {
                    Node = null;
                    currentEvent.Use();
                }
                return(mouseScreenPosition + Delta);
            }
            return(position);
        }
コード例 #7
0
        public void Update(bool isLockedMaterial)
        {
            Event e = Event.current;

            _MouseClick      = !isLockedMaterial && e.type == EventType.MouseDown;
            _MouseLeftClick  = _MouseClick && e.button == 0;
            _MouseRightClick = _MouseClick && e.button == 1;
            if (_MouseClick)
            {
                HadMouseDown = _MouseClick;
            }
            if (HadMouseDown && e.type == EventType.Repaint)
            {
                HadMouseDownRepaint = true;
                HadMouseDown        = false;
            }
            is_alt_down           = e.alt;
            mouse_position        = e.mousePosition;
            screen_mouse_position = GUIUtility.GUIToScreenPoint(e.mousePosition);
            is_drop_event         = e.type == EventType.DragPerform;
            is_drag_drop_event    = is_drop_event || e.type == EventType.DragUpdated;
        }
コード例 #8
0
        private static void ShowPopupWindow(Rect rect, string path)
        {
            var window   = RainbowFoldersPopup.GetDraggableWindow();
            var position = GUIUtility.GUIToScreenPoint(rect.position + new Vector2(0, rect.height + 2));

            if (_multiSelection)
            {
                // ReSharper disable once RedundantTypeArgumentsOfMethod
                var paths = Selection.assetGUIDs
                            .Select <string, string>(AssetDatabase.GUIDToAssetPath)
                            .Where(AssetDatabase.IsValidFolder).ToList();

                var index = paths.IndexOf(path);
                window.ShowWithParams(position, paths, index);
            }
            else
            {
                window.ShowWithParams(position, new List <string> {
                    path
                }, 0);
            }
        }
コード例 #9
0
ファイル: EyeDropper.cs プロジェクト: yaoya/UnityDecompiled
 public static void DrawPreview(Rect position)
 {
     if (Event.current.type == EventType.Repaint)
     {
         Texture2D texture2D = EyeDropper.instance.m_Preview;
         int       num       = (int)Mathf.Ceil(position.width / 10f);
         int       num2      = (int)Mathf.Ceil(position.height / 10f);
         if (texture2D == null)
         {
             texture2D            = (EyeDropper.instance.m_Preview = ColorPicker.MakeTexture(num, num2));
             texture2D.filterMode = FilterMode.Point;
         }
         if (texture2D.width != num || texture2D.height != num2)
         {
             texture2D.Resize(num, num2);
         }
         Vector2 a        = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
         Vector2 pixelPos = a - new Vector2((float)(num / 2), (float)(num2 / 2));
         texture2D.SetPixels(InternalEditorUtility.ReadScreenPixel(pixelPos, num, num2), 0);
         texture2D.Apply(true);
         Graphics.DrawTexture(position, texture2D);
         float    num3     = position.width / (float)num;
         GUIStyle gUIStyle = EyeDropper.Styles.eyeDropperVerticalLine;
         for (float num4 = position.x; num4 < position.xMax; num4 += num3)
         {
             Rect position2 = new Rect(Mathf.Round(num4), position.y, num3, position.height);
             gUIStyle.Draw(position2, false, false, false, false);
         }
         float num5 = position.height / (float)num2;
         gUIStyle = EyeDropper.Styles.eyeDropperHorizontalLine;
         for (float num6 = position.y; num6 < position.yMax; num6 += num5)
         {
             Rect position3 = new Rect(position.x, Mathf.Floor(num6), position.width, num5);
             gUIStyle.Draw(position3, false, false, false, false);
         }
         Rect position4 = new Rect((a.x - pixelPos.x) * num3 + position.x, (a.y - pixelPos.y) * num5 + position.y, num3, num5);
         EyeDropper.Styles.eyeDropperPickedPixel.Draw(position4, false, false, false, false);
     }
 }
コード例 #10
0
ファイル: SequenceDrawer.cs プロジェクト: kirobame/Flux-2.0
        public override void OnGUI(Rect rect, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(rect, label, property);

            var header = rect.GetLayout();

            EditorGUI.LabelField(header.label, label);

            if (GUI.Button(header.value, new GUIContent("Edit")))
            {
                window = ScriptableObject.CreateInstance(typeof(SequenceGraph)) as SequenceGraph;
                window.titleContent = EditorGUIUtility.TrTextContentWithIcon("Sequence", "SceneViewFx");

                var position = GUIUtility.GUIToScreenPoint(UnityEngine.Event.current.mousePosition);
                var fullRect = EditorGUIUtility.GetMainWindowPosition();

                var width = fullRect.width - position.x - padding;
                if (width < minWidth)
                {
                    width      = minWidth;
                    position.x = fullRect.width - width - padding;
                }

                var height = fullRect.height - position.y - padding;
                if (height < minHeight)
                {
                    height     = minHeight;
                    position.y = fullRect.height - height - padding;
                }

                window.ShowUtility();
                window.position = new Rect(position, new Vector2(width, height));

                window.Initialize(property);
            }

            property.serializedObject.ApplyModifiedProperties();
            EditorGUI.EndProperty();
        }
コード例 #11
0
ファイル: RTEditorGUI.cs プロジェクト: hesch/terrain-viewer
        public static void EnumPopup <T>(GUIContent label, T selected, Action <T> callback) where T : System.Enum
        {
            label.text += ": " + selected.ToString();
            Rect buttonRect = GUILayoutUtility.GetRect(label, new GUIStyle(GUI.skin.button));

            if (GUI.Button(buttonRect, label))
            {
                PopupMenu menu   = new PopupMenu();
                T[]       values = (T[])Enum.GetValues(selected.GetType());
                Array.ForEach(values, e => { menu.AddItem(new GUIContent(Enum.GetName(selected.GetType(), e)), true, () => callback(e)); });

                Vector2 buttonPos = Event.current.mousePosition;           //new Vector2(buttonRect.x, buttonRect.y + buttonRect.height);
                buttonPos -= NodeEditor.curEditorState.zoomPanAdjust;
                buttonPos /= NodeEditor.curEditorState.zoom;
                buttonPos += NodeEditor.curEditorState.zoomPanAdjust;

                //buttonPos = GUIScaleUtility.ScaledToGUISpace(buttonPos);
                buttonPos = GUIUtility.GUIToScreenPoint(buttonPos);
                Debug.Log(buttonPos);
                menu.Show(new Vector2(buttonPos.x + 1, buttonPos.y + 1), buttonRect.width);
            }
        }
コード例 #12
0
        private void DrawAssemblyFilter()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(Styles.AssemblyFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth));

            var lastEnabled = GUI.enabled;

            GUI.enabled = m_AnalysisState == AnalysisState.Valid && !AssemblySelectionWindow.IsOpen() && m_ActiveAnalysisView.desc.showAssemblySelection;
            if (GUILayout.Button(Styles.AssemblyFilterSelect, EditorStyles.miniButton,
                                 GUILayout.Width(LayoutSize.FilterOptionsEnumWidth)))
            {
                if (m_AssemblyNames != null && m_AssemblyNames.Length > 0)
                {
                    // Note: Window auto closes as it loses focus so this isn't strictly required
                    if (AssemblySelectionWindow.IsOpen())
                    {
                        AssemblySelectionWindow.CloseAll();
                    }
                    else
                    {
                        var windowPosition =
                            new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth,
                                        Event.current.mousePosition.y + GUI.skin.label.lineHeight);
                        var screenPosition = GUIUtility.GUIToScreenPoint(windowPosition);

                        AssemblySelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AssemblySelection,
                                                     m_AssemblyNames);
                    }
                }
            }
            GUI.enabled = lastEnabled;

            m_AssemblySelectionSummary = GetSelectedAssembliesSummary();
            DrawSelectedText(m_AssemblySelectionSummary);

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndHorizontal();
        }
コード例 #13
0
    void DrawBoxAroundPoints(Vector2 p0, Vector2 p1, float height = 6, float extraLength = 0)
    {
        // Draw a thin, rotated box around the line between the given points.
        // Our approach is to rotate the GUI transformation matrix around the center
        // of the line, and then draw an unrotated (horizontal) box at that point.
        float   width          = (p1 - p0).magnitude + extraLength;
        Vector2 center         = (p0 + p1) * 0.5f;
        Rect    horizontalRect = new Rect(center.x - width / 2, center.y - height / 2, width, height);
        float   angle          = Mathf.Atan2(p1.y - p0.y, p1.x - p0.x) * Mathf.Rad2Deg;

        Matrix4x4 savedMatrix  = GUI.matrix;
        Vector3   centerScreen = GUIUtility.GUIToScreenPoint(center);

        GUI.matrix =
            Matrix4x4.TRS(centerScreen, Quaternion.identity, Vector3.one)
            * Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(0, 0, angle), Vector3.one)
            * Matrix4x4.TRS(-centerScreen, Quaternion.identity, Vector3.one)
            * GUI.matrix;

        GUI.Box(horizontalRect, "");
        GUI.matrix = savedMatrix;
    }
コード例 #14
0
ファイル: Graph.cs プロジェクト: p-yboulerice/Assignment1
        protected void OnGUI()
        {
            if (this.GuiRect.width == 0)
            {
                const float DefaultHeight = 100f;
                this.GuiRect     = new Rect(0f, NextWindowStartY, Screen.width, DefaultHeight);
                NextWindowStartY = Mathf.Repeat(NextWindowStartY + DefaultHeight, Screen.height);
            }

            GUI.depth = (int)this.Z;

            this.GuiRect = GUI.Window(this.WindowId, this.GuiRect, DrawWindow, this.Format.Title, this.WindowStyle);

            // Convert Gui Window to screen space, with padding inside window
            RectOffset padding = new RectOffset(8, 8, 18, 8);
            Vector2    pos     = GUIUtility.GUIToScreenPoint(new Vector2(this.GuiRect.xMin + padding.left, this.GuiRect.yMax - padding.bottom));

            pos.y = Screen.height - pos.y;
            Vector2 dim = GUIUtility.GUIToScreenPoint(this.GuiRect.size - new Vector2(padding.horizontal, padding.vertical));

            this.GraphRect = new Rect(pos, dim);
        }
コード例 #15
0
        public static void CreatePopup(Rect iconPosition)
        {
            float windowWidth  = 128f;
            float windowHeight = kLayerEntryHeight * (sLayerNames.Length);
            Rect  windowPos    = new Rect(iconPosition);

            windowPos.width  = windowWidth + sShadowOffset.x;
            windowPos.height = windowHeight + sShadowOffset.y;

            Vector2 windowCentre = new Vector2(windowPos.x, iconPosition.center.y);

            windowCentre.y = Mathf.Clamp(windowPos.center.y, 0f, (Screen.height - (windowHeight * 0.5f)) - (EditorGUIUtility.singleLineHeight * 2));

            windowPos.center = GUIUtility.GUIToScreenPoint(windowCentre);
            windowPos.x     -= windowWidth * 0.5f;

            sPopupWindow                = EditorWindow.CreateInstance <LayerSelectPopupWindow>();
            sPopupWindow.position       = windowPos;
            sPopupWindow.wantsMouseMove = true;
            sPopupWindow.ShowPopup();
            sPopupWindow.Focus();
        }
コード例 #16
0
        public void Draw(Vector2 position)
        {
            if (Event.current.type != EventType.Layout)
            {
                this.screenPos = GUIUtility.GUIToScreenPoint(position);
            }

            if (Event.current.type == EventType.Repaint)
            {
                if (this.material == null)
                {
                    this.material = new Material(Shader.Find("Unlit/Transparent"));
                }

                if (this.target != null)
                {
                    Graphics.Blit(this.target, RenderTexture.active, material);
                    RenderTexture.ReleaseTemporary(this.target);
                    this.target = null;
                }
            }
        }
コード例 #17
0
        private void DebugMouse()
        {
            var cam = Camera.current;

            if (cam == null || Event.current == null)
            {
                return;
            }

            Vector2 mouse, test;

            mouse = test = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            mouse.y = -mouse.y + Screen.height + 60;
            var gr = _self.Grid.GetMousePos(mouse, cam);

            if (_self.SelectedGrid != null)
            {
                DrawGrid(_self.SelectedGrid, Color.blue);
            }

            if (gr == null)
            {
                return;
            }

            if (Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                _self.SelectedGrid = gr;
                _mouseDown         = true;
            }
            else if (_mouseDown && Event.current.type == EventType.MouseUp && Event.current.button == 0)
            {
                _mouseDown = false;
            }

            DrawGrid(gr, Color.red);
        }
コード例 #18
0
        // Get mouse delta values in different situations when click-dragging
        public static bool DoDrag(int controlID, Rect dragRegion, bool activated, Rect startDragUserData)
        {
            Event evt = Event.current;

            switch (evt.GetTypeForControl(controlID))
            {
            case EventType.MouseDown:
                if (activated && GUIUtility.hotControl == 0 && dragRegion.Contains(evt.mousePosition) && evt.button == 0)
                {
                    GUIUtility.hotControl      = controlID;
                    GUIUtility.keyboardControl = 0;
                    s_StartDragPosition        = GUIUtility.GUIToScreenPoint(evt.mousePosition);                      // GUIToScreenPoint to prevent being affected by scrollviews
                    s_StartUserData            = startDragUserData;
                    evt.Use();
                }
                break;

            case EventType.MouseDrag:
                if (GUIUtility.hotControl == controlID)
                {
                    evt.Use();
                    Vector2 screenPos = GUIUtility.GUIToScreenPoint(evt.mousePosition);                             // GUIToScreenPoint to prevent being affected by scrollviews
                    s_DraggedVector = screenPos - s_StartDragPosition;
                    return(true);
                }
                break;

            case EventType.MouseUp:
                if (GUIUtility.hotControl == controlID && evt.button == 0)
                {
                    GUIUtility.hotControl = 0;
                    evt.Use();
                }
                break;
            }

            return(false);
        }
コード例 #19
0
        protected override void OldOnGUI()
        {
            ClearBackground();
            // Call reset GUI state as first thing so GUI.color is correct when drawing window decoration.
            EditorGUIUtility.ResetGUIState();

            Rect maximizedViewRect = new Rect(-2, 0, position.width + 4, position.height);

            maximizedViewRect = Styles.background.margin.Remove(maximizedViewRect);

            Rect backRect = new Rect(maximizedViewRect.x + 1, maximizedViewRect.y, maximizedViewRect.width - 2, DockArea.kTabHeight);

            if (Event.current.type == EventType.Repaint)
            {
                Styles.background.Draw(maximizedViewRect, GUIContent.none, false, false, false, false);
                Styles.dragTab.Draw(backRect, actualView.titleContent, false, false, true, hasFocus);
            }

            if (Event.current.type == EventType.ContextClick && backRect.Contains(Event.current.mousePosition))
            {
                PopupGenericMenu(actualView, new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0));
            }

            ShowGenericMenu(position.width - 20, backRect.yMin + 6f);

            const float topBottomPadding = 3f;
            Rect        viewRect         = maximizedViewRect;

            viewRect.y      = backRect.yMax - topBottomPadding;
            viewRect.height = position.height - backRect.yMax + topBottomPadding;

            if (actualView)
            {
                actualView.m_Pos = new Rect(GUIUtility.GUIToScreenPoint(Vector2.zero), viewRect.size);
            }

            InvokeOnGUI(maximizedViewRect, viewRect);
        }
コード例 #20
0
        public static T EnumPopup <T> (GUIContent label, T selected) where T : System.Enum
        {
            T oldSelected = selected;

                        #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return((T)UnityEditor.EditorGUILayout.EnumPopup(label, selected));
            }
                        #endif
            label.text += ": " + selected.ToString();
            GUILayout.Label(label);

            Rect buttonRect = GUILayoutUtility.GetRect(label, new GUIStyle(GUI.skin.button));
            if (GUI.Button(buttonRect, label))
            {
                PopupMenu menu   = new PopupMenu();
                T[]       values = (T[])Enum.GetValues(selected.GetType());
                Array.ForEach(values, e => { menu.AddItem(new GUIContent(Enum.GetName(selected.GetType(), e)), true, () => { Debug.Log("executing handler"); selected = e; }); });

                Vector2 mousePos = GUIUtility.GUIToScreenPoint(new Vector2(buttonRect.x, buttonRect.y + buttonRect.height));
                Debug.Log(mousePos);
                Debug.Log("showing Menu");
                menu.Show(new Vector2(mousePos.x + 1, mousePos.y + 1), buttonRect.width);
            }
            if (Event.current.type == EventType.MouseDown)
            {
                Debug.Log("MouseDown");
            }
            //buttonRect = GUILayoutUtility.GetLastRect();
            if (!Object.Equals(oldSelected, selected))
            {
                Debug.Log("changing selected");
                Debug.Log(oldSelected);
                Debug.Log(selected);
            }
            return(selected);
        }
コード例 #21
0
        //------------------------------------------------------
        // gui
        //------------------------------------------------------

        static void OnGUI(string guid, Rect selectionRect)
        {
            AssetMessageData msg;

            if (!m_dataMap.TryGetValue(guid, out msg))
            {
                return;
            }

            bool twoColumnLayout = (selectionRect.width / selectionRect.height) < 1f;
            var  itemPosition    = GetIconRect(selectionRect, twoColumnLayout);

            var e         = Event.current;
            var controlId = EditorGUIUtility.GetControlID(FocusType.Passive);

            switch (e.GetTypeForControl(controlId))
            {
            case EventType.Repaint:
                // ちょっと大きくしとこ
                if (!twoColumnLayout)
                {
                    itemPosition.x      -= 2;
                    itemPosition.width  += 4;
                    itemPosition.y      -= 2;
                    itemPosition.height += 4;
                }
                GUI.DrawTexture(itemPosition, m_icons[(int)msg.type]);
                break;

            case EventType.MouseDown:
                if (itemPosition.Contains(e.mousePosition) && e.button == 0)
                {
                    AssetMessageBoard.Open(guid, msg, GUIUtility.GUIToScreenPoint(e.mousePosition));
                    e.Use();
                }
                break;
            }
        }
コード例 #22
0
ファイル: EyeDropper.cs プロジェクト: yaoya/UnityDecompiled
        protected override void OldOnGUI()
        {
            EventType type = Event.current.type;

            if (type != EventType.MouseMove)
            {
                if (type != EventType.MouseDown)
                {
                    if (type == EventType.KeyDown)
                    {
                        if (Event.current.keyCode == KeyCode.Escape)
                        {
                            base.window.Close();
                            Event.current.Use();
                            this.SendEvent("EyeDropperCancelled", true, true);
                        }
                    }
                }
                else if (Event.current.button == 0)
                {
                    EyeDropper.s_PickCoordinates = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                    base.window.Close();
                    EyeDropper.s_LastPickedColor = EyeDropper.GetPickedColor();
                    Event.current.Use();
                    this.SendEvent("EyeDropperClicked", true, true);
                    if (this.m_ColorPickedCallback != null)
                    {
                        this.m_ColorPickedCallback(EyeDropper.s_LastPickedColor);
                    }
                }
            }
            else
            {
                EyeDropper.s_PickCoordinates = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
                base.StealMouseCapture();
                this.SendEvent("EyeDropperUpdate", true, false);
            }
        }
コード例 #23
0
        internal static string SetActiveToolTip(Rect control, string toolTip, ref bool toolTipActive, float xOffset)
        {
            // Note:  all values are screen point based.  (0,0 in lower left).  this removes confusion with the gui point of elements (o,o in upper left).
            if (!toolTipActive && control.Contains(Event.current.mousePosition))
            {
                toolTipActive = true;
                // Note at this time controlPosition is in Gui Point system and is local position.  convert to screenpoint.
                Rect newControl = new Rect
                {
                    position = GUIUtility.GUIToScreenPoint(control.position),
                    width    = control.width,
                    height   = control.height
                };

                // Event.current.mousePosition returns sceen mouseposition.  GuI elements return a value in gui position..
                // Add the height of parent GUI elements already drawn to y offset to get the correct screen position
                if (control.Contains(Event.current.mousePosition))
                {
                    // Let's use the rectangle as a solid anchor and a stable tooltip, forgiving of mouse movement within bounding box...
                    ToolTipPos = new Vector2(newControl.xMax + xOffset, newControl.y - 10);

                    ControlRect    = newControl;
                    XOffset        = xOffset;
                    ControlRect.x += xOffset;
                    ControlRect.y -= 10;
                }
                else
                {
                    toolTip = "";
                }
            }
            // We are in a loop so we don't need the return value from SetUpToolTip.  We will assign it instead.
            if (!toolTipActive)
            {
                toolTip = "";
            }
            return(toolTip);
        }
コード例 #24
0
 // ----------------------------------------------------------------------
 void ProcessEvents(Rect frameArea)
 {
     lastMousePosition = Event.current.mousePosition;
     switch (Event.current.type)
     {
     case EventType.MouseDown: {
         foreach (var keyValue in myRowInfo)
         {
             Rect area = keyValue.Value;
             if (area.y < lastMousePosition.y && area.yMax > lastMousePosition.y)
             {
                 var mouseInScreenPoint   = GUIUtility.GUIToScreenPoint(lastMousePosition);
                 var areaInScreenPoint    = GUIUtility.GUIToScreenPoint(new Vector2(area.x, area.y));
                 var areaInScreenPosition = new Rect(areaInScreenPoint.x, areaInScreenPoint.y, area.width, area.height);
                 myDataSource.MouseDownOn(keyValue.Key, mouseInScreenPoint, areaInScreenPosition);
                 //                        Event.current.Use();
                 return;
             }
         }
         break;
     }
     }
 }
コード例 #25
0
        //[MenuItem(u2dexMenu.Root + "Check for Updates", false, 20100)]
        public static void ShowUpdater(string UpdateFileURL, string AssetName, double AssetVersion)
        {
            var update_Window = EditorWindow.GetWindow <UnfinityUpdater>(true, AssetName + ": Updater");

            update_Window.minSize = new Vector2(350, 75);
            update_Window.maxSize = new Vector2(350, 75);

            var position = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);

            update_Window.position = new Rect(position.x - update_Window.minSize.x / 2,
                                              position.y - update_Window.minSize.y * 2,
                                              update_Window.minSize.x,
                                              update_Window.minSize.y);

            //Set our updateInfoURL to the URL we passed in.
            (update_Window as UnfinityUpdater).updateInfoUrl = UpdateFileURL;

            //Set our version to the version we passed in.
            (update_Window as UnfinityUpdater).assetVersion = AssetVersion;

            //Set our name to the name we passed in.
            (update_Window as UnfinityUpdater).assetName = AssetName;
        }
コード例 #26
0
        public static void Launch(VariablesEditor editor, ReorderableList list)
        {
            if (instance == null)
            {
                instance = CreateInstance <AddVariableWindow>();
            }
            instance.titleContent = new GUIContent("Add Variable");
            instance.list         = list;
            instance.editor       = editor;
            instance.ShowUtility();
            instance.Focus();

            var size = new Vector2(200, 110);

            instance.minSize = size;
            instance.maxSize = size;

            var rect = instance.position;

            rect.size         = size;
            rect.center       = GUIUtility.GUIToScreenPoint(XEvent.MousePos);
            instance.position = rect;
        }
コード例 #27
0
        // SteveM TODO - if AssemblySelectionWindow and AreaSelectionWindow end up sharing a common base class then
        // DrawAssemblyFilter() and DrawAreaFilter() can be made to call a common method and just pass the selection, names
        // and the type of window we want.
        private void DrawAreaFilter()
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(Styles.areaFilter, GUILayout.Width(LayoutSize.FilterOptionsLeftLabelWidth));

            if (m_AreaNames.Length > 0)
            {
                bool lastEnabled = GUI.enabled;
                // SteveM TODO - We don't currently have any sense of when the Auditor is busy and should disallow user input
                bool enabled = /*!IsAnalysisRunning() &&*/ !AreaSelectionWindow.IsOpen();
                GUI.enabled = enabled;
                if (GUILayout.Button(Styles.areaFilterSelect, EditorStyles.miniButton, GUILayout.Width(LayoutSize.FilterOptionsEnumWidth)))
                {
                    // Note: Window auto closes as it loses focus so this isn't strictly required
                    if (AreaSelectionWindow.IsOpen())
                    {
                        AreaSelectionWindow.CloseAll();
                    }
                    else
                    {
                        Vector2 windowPosition = new Vector2(Event.current.mousePosition.x + LayoutSize.FilterOptionsEnumWidth, Event.current.mousePosition.y + GUI.skin.label.lineHeight);
                        Vector2 screenPosition = GUIUtility.GUIToScreenPoint(windowPosition);

                        AreaSelectionWindow.Open(screenPosition.x, screenPosition.y, this, m_AreaSelection, m_AreaNames);
                    }
                }

                GUI.enabled = lastEnabled;

                m_AreaSelectionSummary = GetSelectedAreasSummary();
                DrawSelectedText(m_AreaSelectionSummary);

                GUILayout.FlexibleSpace();
            }

            EditorGUILayout.EndHorizontal();
        }
コード例 #28
0
        public void OnGUI()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("Filter: ");
            var filterCount = 0;

            for (var i = 0; i < selectedFilterTypes.Count; ++i)
            {
                if (selectedFilterTypes[i])
                {
                    ++filterCount;
                    var style = filterTypes[i].AccessModeType == ComponentType.AccessMode.Subtractive ? EntityDebuggerStyles.ComponentSubtractive : EntityDebuggerStyles.ComponentRequired;
                    GUILayout.Label(filterTypes[i].GetManagedType().Name, style);
                }
            }
            if (filterCount == 0)
            {
                GUILayout.Label("none");
            }
            if (GUILayout.Button("Edit"))
            {
                ComponentTypeChooser.Open(GUIUtility.GUIToScreenPoint(GUILayoutUtility.GetLastRect().position), filterTypes, selectedFilterTypes, ComponentFilterChanged);
            }
            if (filterCount > 0)
            {
                if (GUILayout.Button("Clear"))
                {
                    for (var i = 0; i < selectedFilterTypes.Count; ++i)
                    {
                        selectedFilterTypes[i] = false;
                    }
                    ComponentFilterChanged();
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
コード例 #29
0
ファイル: WindowHelper.cs プロジェクト: DGiroud/JavelinVR
                private static Vector2 GetFakeMousePosition(EditorWindow wnd, DockPosition position)
                {
                    Vector2 mousePosition = Vector2.zero:

                                            // The 20 is required to make the docking work.
                                            // Smaller values might not work when faking the mouse position.
                                            switch (position)
                    {
                    case DockPosition.Left:
                        mousePosition = new Vector2(20, wnd.position.size.y / 2) :
                                            break :
                                        case DockPosition.Top:
                                            mousePosition = new Vector2(wnd.position.size.x / 2, 20) :
                                                                break :
                                                            case DockPosition.Right:
                                                                mousePosition = new Vector2(wnd.position.size.x - 20, wnd.position.size.y / 2) :
                                                                                    break :
                                                                                case DockPosition.Bottom:
                                                                                    mousePosition = new Vector2(wnd.position.size.x / 2, wnd.position.size.y - 20) :
                                                                                                        break :
                    }

                    return GUIUtility.GUIToScreenPoint(mousePosition) :
                }
コード例 #30
0
        private void OnGUI()
        {
            if (descriptionStyle == null)
            {
                InitializeStyles();
            }

            folderDrag.ReceiverBox = position;
            Debug.Log(position);

            Debug.Log(GUIUtility.GUIToScreenPoint(Event.current.mousePosition));

            EditorGUILayout.LabelField(DescriptionText, descriptionStyle);

            EditorGUILayout.Space();

            selectedFolder = EditorGUILayout.TextField("Folder Path:", selectedFolder, folderTextboxStyle);

            folderDrag.Update();

            EditorGUILayout.BeginHorizontal();

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("OK", dialogButtonStyle))
            {
                Ok();
            }

            if (GUILayout.Button("Cancel", dialogButtonStyle))
            {
                Cancel(close: true);
            }

            EditorGUILayout.EndHorizontal();
        }