public static LevelSpline Create(string FilePath = "Assets/PathPoints.asset")
    {
        LevelSpline asset = ScriptableObject.CreateInstance <LevelSpline>();

        AssetDatabase.CreateAsset(asset, FilePath);
        AssetDatabase.SaveAssets();
        return(asset);
    }
 void OnEnable()
 {
     if (EditorPrefs.HasKey("LevelSplinePath"))
     {
         string objectPath = EditorPrefs.GetString("LevelSplinePath");
         splinePoints          = AssetDatabase.LoadAssetAtPath(objectPath, typeof(LevelSpline)) as LevelSpline;
         openedSplineAssetName = objectPath;
     }
     SceneView.onSceneGUIDelegate += OnSceneGUI;
 }
    void OpenItemList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Spline List", "", "");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            splinePoints = AssetDatabase.LoadAssetAtPath(relPath, typeof(LevelSpline)) as LevelSpline;
            if (splinePoints.pointsList == null)
            {
                splinePoints.pointsList = new List <LevelSplinePoint>();
            }
            if (splinePoints)
            {
                EditorPrefs.SetString("LevelSplinePath", relPath);
                openedSplineAssetName = relPath;
            }
        }
    }
    void CreateNewSpline()
    {
        // There is no overwrite protection here!
        // There is No "Are you sure you want to overwrite your existing object?" if it exists.
        // This should probably get a string from the user to create a new name and pass it ...
        string path = EditorUtility.SaveFilePanel("Select file for new spline", "", "LevelSpline", "asset");

        if (path.Length != 0)
        {
            string relPath = path.Substring(Application.dataPath.Length - "Assets".Length);
            viewIndex    = -1;
            splinePoints = LevelSplineCreator.Create(relPath);
            if (splinePoints)
            {
                splinePoints.pointsList = new List <LevelSplinePoint>();
                relPath = AssetDatabase.GetAssetPath(splinePoints);
                EditorPrefs.SetString("LevelSplinePath", relPath);
                openedSplineAssetName = relPath;
            }
        }
    }