public void UpdateDrag()
        {
            if (!IsPlacing())
            {
                return;
            }

            editor.Repaint();

            //Debug.Log( "Drag exists: " + ( dragNode != null ) + "\nDrag name: " + dragNode.name + "\nDrag type: " + dragNode.type.ToString() );

            //float preScale = (float)(editor.separatorRight.rect.x - Event.current.mousePosition.x);
            //preScale /= 48f; // Distance to animate in
            //preScale = Mathf.Clamp01(preScale);

            //Rect boxRect = new Rect( 0, 0, SF_Node.NODE_SIZE, SF_Node.NODE_SIZE ).ScaleSizeBy(preScale).ClampSize((int)styleCategory.fixedHeight,SF_Node.NODE_SIZE);
            Rect boxRect = new Rect(0, 0, SF_Node.NODE_SIZE, SF_Node.NODE_SIZE);

            boxRect.center = Event.current.mousePosition;

            GUI.Box(boxRect, dragNode.nodeName);
            //	Debug.Log( Event.current.type.ToString());
            if (Event.current.rawType == EventType.MouseUp)
            {
                OnStopDrag();
            }
        }
Exemplo n.º 2
0
        public void DrawMeshGUI(Rect previewRect)
        {
            if (previewRect == default(Rect))
            {
                previewRect = this.previewRect;
            }

            if (previewRect.width > 1)
            {
                this.previewRect = previewRect;
            }

            if (Event.current.rawType == EventType.MouseUp)
            {
                if (Event.current.button == 0)
                {
                    StopDragLMB();
                }
                else if (Event.current.button == 1)
                {
                    StopDragRMB();
                }
            }

            if (Event.current.type == EventType.MouseDown && MouseOverPreview())
            {
                if (Event.current.button == 0)
                {
                    StartDragLMB();
                }
                else if (Event.current.button == 1)
                {
                    StartDragRMB();
                }
            }

            if (isDraggingLMB)
            {
                UpdateDragLMB();
            }
            if (isDraggingRMB)
            {
                UpdateDragRMB();
            }


            if (mesh == null || InternalMaterial == null || Event.current.type != EventType.Repaint)
            {
                return;
            }

            if (previewStyle == null)
            {
                previewStyle = new GUIStyle(EditorStyles.textField);
            }
            previewStyle.normal.background = backgroundTexture;

            editor.Repaint();

            previewRenderUtility.BeginPreview(previewRect, GUIStyle.none);
            DrawMesh();
            previewRenderUtility.EndAndDrawPreview(previewRect);
        }