-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
15 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using UnityEngine; | ||
|
||
public class SaverLoader | ||
{ | ||
public void Save(string fileName, Rigidbody[] pieces) //Save pieces | ||
{ | ||
Piece[] newPieces = new Piece[pieces.Length]; | ||
string finalText; | ||
for (int i = 0; i < pieces.Length; i++) | ||
{ | ||
newPieces[i].pieceName = pieces[i].name;//Set name of piece | ||
if (pieces[i].GetComponent<FixedJoint>() != null)//Only for pieces who are not start piece | ||
{ | ||
newPieces[i].parentPiece = pieces[i].GetComponent<FixedJoint>().connectedBody;//Set parent piece | ||
} | ||
if (pieces[i].name == "StructuralPiece") | ||
{ | ||
newPieces[i].pieceType = PieceType.StructuralPiece; | ||
} | ||
if (pieces[i].name == "ControlUnit") | ||
{ | ||
newPieces[i].pieceType = PieceType.ControlUnit; | ||
} | ||
newPieces[i].position = pieces[i].transform.position;//Set position | ||
} | ||
string path = Application.dataPath + "/SavedMachines/" + fileName; | ||
if (!Directory.Exists(Application.dataPath + "/SavedMachines"))//Dirrectory handling | ||
{ | ||
Directory.CreateDirectory(Application.dataPath + "/SavedMachines"); | ||
} | ||
foreach (var newpiece in newPieces) | ||
{ | ||
//finalText.Insert(); | ||
} | ||
//File.WriteAllText(); | ||
} | ||
public void Load(string fileName) //Load pieces | ||
{ | ||
|
||
} | ||
private struct Piece | ||
{ | ||
public string pieceName; | ||
public Rigidbody parentPiece; | ||
public PieceType pieceType; | ||
public Vector3 position; | ||
} | ||
private enum PieceType | ||
{ | ||
StructuralPiece, ControlUnit | ||
} | ||
} |