Skip to content

GoDummyPathEditor Enhancement #12

Open

Description

@RavenCastleSTU

Hi prime31, I created a small enhancement to the Editor class so we can move the nodes to start at the location of the GameObject where the GoDummyPath is.

I added this script just bellow this script block:

if( GUILayout.Button( "Shift Path to Start at Origin" ) ) { ... }

Here is the code:

// shift the start point to the GameObject where the GoDummyPath is
    if (GUILayout.Button("Shift Path to Start at Object"))
    {
        Undo.RegisterUndo(_target, "Path Vector Changed");

        var offset = Vector3.zero;

        // see what kind of path we are. the simplest case is just a straight line
        var path = new GoSpline(_target.nodes, _target.forceStraightLinePath);
        if (path.splineType == SplineType.StraightLine)
            offset = _target.transform.position - _target.nodes[0];
        else
            offset = _target.transform.position - _target.nodes[1];

        for (var i = 0; i < _target.nodes.Count; i++)
            _target.nodes[i] += offset;

        GUI.changed = true;
    }

I hope you add this to the branch. I found this very useful to observe the path when creating some spawn nodes in my game and reusing previously saved paths.

You may want to create a method that receives the start position Vector3 as an argument to avoid code duplication in both buttons (Shift Path to Start at Origin and this new one I created)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions