Exemplo n.º 1
0
    public RawPathData createPath()
    {
        pathData = new RawPathData(transform.position);

        //points = pathData.GetPath();
        return(pathData);
    }
    void OnEnable()
    {
        Debug.Log("path editor enabled");
        creator = (PathCreator)target;

        if (creator.pathData == null || creator.pathData.NumOfPoints == 0)
        {
            creator.createPath();
        }
        instance  = creator.pathData;
        waypoints = new List <Vector2>();

        Debug.Log(instance.NumOfPoints);
    }
    void SavePath()
    {
        PathData  pathAsset = new PathData(waypoints);
        PathAsset SO        = CreateInstance <PathAsset>();

        SO.SetPath(pathAsset);
        SO.name = creator.bundle.name + "_" + PathID;


        AssetDatabase.CreateAsset(SO, "Assets/" + SO.name + ".asset");
        creator.createPath();
        instance  = creator.pathData;
        waypoints = new List <Vector2>();
        Debug.Log("AssetSaved");
    }
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        GUILayout.Label("PathID");
        PathID = EditorGUILayout.TextField(PathID);
        if (GUILayout.Button("createNew"))
        {
            creator.createPath();
            instance = creator.pathData;
            Debug.Log("created path");
            SceneView.RepaintAll();
        }
        if (GUILayout.Button("1. Generate waypoints"))
        {
            waypoints = getPointsInSegments();
        }
        if (GUILayout.Button("2. SaveToFile"))
        {
            SavePath();
        }
    }
Exemplo n.º 5
0
 public void DeletePath()
 {
     pathData = null;
 }