public void OnStartDrag(SF_EditorNodeData nodeData) { //if( IsPlacing() ) // return; //Debug.Log( "DRAG BUTTON: " + nodeData.name ); dragNode = nodeData; }
public void ContextClick(object o) { // Add node SF_EditorNodeData nodeData = o as SF_EditorNodeData; editor.AddNode(nodeData, true); }
public SF_EditorNodeBrowser Initialize(SF_Editor editor) { this.editor = editor; unfiltered = editor.nodeTemplates; filtered = new List <SF_EditorNodeData>(); dragNode = null; return(this); }
public bool IsPlacing() { if (dragNode == null) { return(false); } if (string.IsNullOrEmpty(dragNode.nodeName)) { dragNode = null; return(false); } return(true); }
public SF_Node OnStopDrag() { if (!IsPlacing()) { return(null); } SF_Node newNode = null; if (editor.nodeView.rect.Contains(Event.current.mousePosition)) { newNode = editor.AddNode(dragNode, registerUndo: true); } dragNode = null; return(newNode); }
public void CancelDrag() { dragNode = null; }
public void ContextClick(object o) { SF_EditorNodeData entry = o as SF_EditorNodeData; SF_Web.OpenDocumentationForNode(entry); }
public void DrawButton(SF_EditorNodeData entry, ref Rect btnRect) { GUI.color = entry.isProperty ? SF_Node.colorExposed : Color.white; bool usable = !(!entry.availableInDeferredPrePass && editor.ps.catLighting.renderPath == SFPSC_Lighting.RenderPath.Deferred); if (!usable) { //GUI.color = Color.red; GUI.enabled = false; } bool mouseOver = btnRect.Contains(Event.current.mousePosition); if (usable) { if (dragNode == entry) { GUI.color = SF_GUI.selectionColorBright; } else if (mouseOver && dragNode == null) { GUI.color = SF_GUI.selectionColorBrighter; } } GUI.Label(btnRect, (usable ? string.Empty : " ") + entry.nodeName, styleButton); if (mouseOver && Event.current.type == EventType.MouseDown && Event.current.button == 0 && usable) { OnStartDrag(entry); } else if (Event.current.type == EventType.ContextClick) { Vector2 mousePos = Event.current.mousePosition; if (btnRect.Contains(mousePos)) { // Now create the menu, add items and show it GenericMenu menu = new GenericMenu(); editor.ResetRunningOutdatedTimer(); //menu.AddItem( new GUIContent("Edit Comment"), false, ContextClick, "cmt_edit" ); menu.AddItem(new GUIContent("What does " + entry.nodeName + " do?"), false, ContextClick, entry); menu.ShowAsContext(); Event.current.Use(); } } GUI.color = Color.white; if (entry.isNew || entry.isUnstable) { GUIStyle miniStyle = new GUIStyle(EditorStyles.miniBoldLabel); miniStyle.alignment = TextAnchor.UpperRight; miniStyle.normal.textColor = Color.red; GUI.Label(btnRect, entry.isNew ? "New" : "Unstable", miniStyle); } if (usable) { SF_GUI.AssignCursor(btnRect, MouseCursor.Pan); } else { if (Event.current.type == EventType.Repaint) { GUI.enabled = true; SF_GUI.DrawLock(btnRect.PadTop(4), "Forward rendering only", TextAlignment.Right); //Draw(btnRect.PadTop(4), false, true, true, false); // Draw lock GUI.enabled = false; } } GUI.enabled = true; btnRect.y += btnRect.height; }
public static void OpenDocumentationForNode(SF_EditorNodeData nodeData) { OpenDocumentationForString(nodeData.SearchName); }