- Home /
GridBackground not getting added to GraphView
I'm trying to create a basic class that derives from GraphView with some basic functionality to build a couple of other tools from, however the GridBackground isn't working. I'm trying to add the grid via code and I'm getting no errors. Annoying thing is, this has worked in the past...
public class rpg_GraphView : GraphView
{
VisualElement visualElement;
public rpg_GraphView ()
{
}
public void ConstructGraph(EditorWindow window)
{
visualElement = window.rootVisualElement;
visualElement.Add(this);
SetupZoom(ContentZoomer.DefaultMinScale, ContentZoomer.DefaultMaxScale);
this.AddManipulator(new ContentDragger());
GridBackground gridBackground = new GridBackground();
gridBackground.cullingEnabled = true;
this.Add(gridBackground);
gridBackground.SendToBack();
}
public void UpdateGraph(EditorGUILayout.HorizontalScope vis)
{
this.style.height = vis.rect.size.y - 2;
this.style.width = vis.rect.size.x - 2;
this.style.marginLeft = vis.rect.position.x + 1;
this.style.marginTop = vis.rect.position.y + 1;
}
}
Fixed the issue. In my prevous window I used a style sheet to set the colours for the grid. The USS file just has this...
--grid-background-color : #383838;
--line-color : rgba(17.6,17.6,17.6,0.1);
--spacing: 10;
Anyone know how to set this via code? I don't really want to have a separate USS file just for this. There isn't a property for grid-background-color or line-color in backgroundGrid.style.
Your answer
Follow this Question
Related Questions
Events for EditorGUILayout.Popup 1 Answer
Is there a way to avoid the Animation window drop-down menu with a selected Animator? 0 Answers
How to get Editor Window to update immediately in Editor Mode/Play Mode 1 Answer
Enum Value Changing At Runtime On A Prefab 1 Answer
Custom EditorWindow Scrollbars not working with GUILayout areas 1 Answer