Exemple #1
0
        public virtual void Draw(int index, Rect contentRect, SDFEditor editor)
        {
            //rect.y = contentRect.y + (contentRect.height * 0.5f) - rect.height * 0.5f + rect.height * index;

            rect.y = contentRect.y + 5f + rect.height * index;

            switch (type)
            {
            case ConnectionPointType.In:
                rect.x = contentRect.x - rect.width;
                break;

            case ConnectionPointType.Out:
                rect.x = contentRect.x + contentRect.width;
                break;
            }

            if (GUI.Button(rect, ""))
            {
                OnClickConnectionPoint?.Invoke(this);
                if (type == ConnectionPointType.In)
                {
                    editor.OnClickInPoint(this);
                }
                else
                {
                    editor.OnClickOutPoint(this);
                }
            }
        }
Exemple #2
0
        private void ProcessContextMenu(SDFEditor editor)
        {
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent("Remove node"), false, () => OnClickRemoveNode(editor));
            AddOptionsToContextMenu(genericMenu);
            genericMenu.ShowAsContext();
        }
Exemple #3
0
        public override void Draw(SDFEditor editor)
        {
            base.Draw(editor);

            Vector2 previewSize = new Vector2(50, 20);

            Rect previewRect = new Rect(contentRect.center - previewSize / 2f, previewSize);

            Value = EditorGUI.IntField(previewRect, Value);
        }
Exemple #4
0
        public bool ProcessEvents(Event e, SDFEditor editor)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 0)
                {
                    if (rect.Contains(e.mousePosition))
                    //if (titleRect.Contains(e.mousePosition))
                    {
                        IsDragged   = true;
                        GUI.changed = true;
                        IsSelected  = true;
                    }
                    //else if(rect.Contains(e.mousePosition))
                    //{
                    //	GUI.changed = true;
                    //	IsSelected = true;
                    //}
                    else
                    {
                        GUI.changed = true;
                        IsSelected  = false;
                    }
                }
                else if (e.button == 1 && IsSelected && rect.Contains(e.mousePosition))
                {
                    ProcessContextMenu(editor);
                    e.Use();
                }
                break;

            case EventType.MouseUp:
                IsDragged = false;
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && IsDragged)
                {
                    Drag(e.delta);
                    e.Use();
                    return(true);
                }
                break;
            }

            return(false);
        }
        public override void Draw(SDFEditor editor)
        {
            base.Draw(editor);

            Vector2 previewSize = new Vector2(50, 20);

            //Rect previewRect = new Rect(contentRect.position + new Vector2(contentRect.width/2, 20f) - previewSize/2f, previewSize);
            //GUI.Box(previewRect, _currentVal.ToString());

            GUILayout.BeginArea(contentRect);

            EditorGUILayout.IntField(_currentVal);

            if (GUILayout.Button("Update"))
            {
                _currentVal = (int)inPoints[0].GetData() + (int)inPoints[1].GetData();
            }

            GUILayout.EndArea();
        }
Exemple #6
0
        public virtual void Draw(SDFEditor editor)
        {
            GUIStyle style = !IsSelected ? SDFEditor.NodeStyle : SDFEditor.SelectedNodeStyle;

            GUI.Box(rect, "", style);

            const int titelHeight = 20;

            titleRect = new Rect(rect.x, rect.y, rect.width, titelHeight);

            GUI.Box(titleRect, title);

            contentRect         = rect;
            contentRect.width  -= 12;
            contentRect.x      += 6;
            contentRect.height -= titelHeight;
            contentRect.y      += titelHeight;

            Rect inRect = rect;

            inRect.width = 20;

            Rect outRect = inRect;

            outRect.x = rect.x + rect.width - inRect.width;

            int i = 0;

            foreach (var point in inPoints)
            {
                point.Draw(i++, contentRect, editor);
            }

            int j = 0;

            foreach (var point in outPoints)
            {
                point.Draw(j++, contentRect, editor);
            }
        }
        public void Draw(SDFEditor editor)
        {
            Rect outRect = outPoint.GetRect();
            Rect inRect  = inPoint.GetRect();

            Handles.DrawBezier(
                outRect.center,
                inRect.center,
                outRect.center + Vector2.left * 50f,
                inRect.center - Vector2.left * 50f,
                Color.white,
                null,
                2f
                );

            if (Handles.Button((inRect.center + outRect.center) * 0.5f,
                               Quaternion.identity, 4, 8, Handles.RectangleHandleCap))
            {
                OnClickRemoveConnection?.Invoke(this);
                editor.OnClickRemoveConnection(this);
            }
        }
Exemple #8
0
 private void OnClickRemoveNode(SDFEditor editor)
 {
     OnRemoveNode?.Invoke(this);
     editor.OnClickRemoveNode(this);
 }
        private static void OpenWindow()
        {
            SDFEditor window = GetWindow <SDFEditor>();

            window.titleContent = new GUIContent("SDF Editor");
        }