Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Assets/SplineMesh/Scripts/Editor/SplineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,19 @@ private void OnEnable() {
t.Apply();
upButtonStyle = new GUIStyle();
upButtonStyle.normal.background = t;
selection = null;
selection = getSelectedNode();

Undo.undoRedoPerformed -= spline.RefreshCurves;
Undo.undoRedoPerformed += spline.RefreshCurves;

// why? - see: https://answers.unity.com/questions/1418211/onscenegui-not-called.html
SceneView.onSceneGUIDelegate += this.OnSceneGUIDel;
}

private void OnDisable()
{
SceneView.onSceneGUIDelegate -= this.OnSceneGUIDel;
}

SplineNode AddClonedNode(SplineNode node) {
int index = spline.nodes.IndexOf(node);
Expand All @@ -65,6 +73,24 @@ SplineNode AddClonedNode(SplineNode node) {
}
return res;
}

protected SplineNode getSelectedNode()
{
if (spline != null && selection == null && Selection.activeGameObject == spline.gameObject)
{
if (selection == null && spline.nodes.Count > 0)
{
return spline.nodes[0];
}
}

return null;
}

void OnSceneGUIDel(SceneView sceneView)
{
OnSceneGUI();
}

void OnSceneGUI() {
Event e = Event.current;
Expand Down Expand Up @@ -210,7 +236,7 @@ public override void OnInspectorGUI() {
EditorGUILayout.HelpBox("Hold Alt and drag a node to create a new one.", MessageType.Info);

if(spline.nodes.IndexOf(selection) < 0) {
selection = null;
selection = getSelectedNode();
}

// add button
Expand Down